Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F32181829
D12963.1765077963.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Size
2 KB
Referenced Files
None
Subscribers
None
D12963.1765077963.diff
View Options
diff --git a/native/components/nux-tips-context.react.js b/native/components/nux-tips-context.react.js
new file mode 100644
--- /dev/null
+++ b/native/components/nux-tips-context.react.js
@@ -0,0 +1,72 @@
+// @flow
+
+import * as React from 'react';
+
+import { values } from 'lib/utils/objects.js';
+
+const nuxTip = Object.freeze({
+ MUTED: 'muted',
+ COMMUNITY_DRAWER: 'community_drawer',
+});
+
+type NUXTip = $Values<typeof nuxTip>;
+
+type TipProps = {
+ +x: ?number,
+ +y: ?number,
+ +width: ?number,
+ +height: ?number,
+ +pageX: ?number,
+ +pageY: ?number,
+};
+
+export type NUXTipsContextType = {
+ +registerTipButton: (type: NUXTip, tipProps: TipProps) => void,
+ +getTipsProps: () => ?{ [type: NUXTip]: TipProps },
+};
+
+const NUXTipsContext: React.Context<?NUXTipsContextType> =
+ React.createContext<?NUXTipsContextType>();
+
+type Props = {
+ +children: React.Node,
+};
+
+function NUXTipsContextProvider(props: Props): React.Node {
+ const { children } = props;
+
+ const tipsProps = React.useRef<{ [tip: NUXTip]: TipProps }>({});
+
+ const registerTipButton = React.useCallback(
+ (type: NUXTip, tipProps: TipProps) => {
+ tipsProps.current[type] = {
+ ...tipsProps.current[type],
+ ...tipProps,
+ };
+ },
+ [],
+ );
+
+ const getTipsProps = React.useCallback(() => {
+ for (const type of values(nuxTip)) {
+ if (!tipsProps.current[type]) {
+ return null;
+ }
+ }
+ return tipsProps.current;
+ }, []);
+
+ const value = React.useMemo(
+ () => ({
+ registerTipButton,
+ getTipsProps,
+ }),
+ [getTipsProps, registerTipButton],
+ );
+
+ return (
+ <NUXTipsContext.Provider value={value}>{children}</NUXTipsContext.Provider>
+ );
+}
+
+export { NUXTipsContext, NUXTipsContextProvider, nuxTip };
diff --git a/native/root.react.js b/native/root.react.js
--- a/native/root.react.js
+++ b/native/root.react.js
@@ -54,6 +54,7 @@
import BackgroundIdentityLoginHandler from './components/background-identity-login-handler.react.js';
import ConnectFarcasterAlertHandler from './components/connect-farcaster-alert-handler.react.js';
import { FeatureFlagsProvider } from './components/feature-flags-provider.react.js';
+import { NUXTipsContextProvider } from './components/nux-tips-context.react.js';
import PersistedStateGate from './components/persisted-state-gate.js';
import ReportHandler from './components/report-handler.react.js';
import VersionSupportedChecker from './components/version-supported.react.js';
@@ -303,7 +304,9 @@
<ChatContextProvider>
<DeepLinksContextProvider>
<ChatMentionContextProvider>
- <RootNavigator />
+ <NUXTipsContextProvider>
+ <RootNavigator />
+ </NUXTipsContextProvider>
</ChatMentionContextProvider>
</DeepLinksContextProvider>
</ChatContextProvider>
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sun, Dec 7, 3:26 AM (13 h, 36 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
5842273
Default Alt Text
D12963.1765077963.diff (2 KB)
Attached To
Mode
D12963: [native] Add nux context
Attached
Detach File
Event Timeline
Log In to Comment