Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F32197568
D13194.1765103792.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Size
4 KB
Referenced Files
None
Subscribers
None
D13194.1765103792.diff
View Options
diff --git a/native/components/nux-tips-context.react.js b/native/components/nux-tips-context.react.js
--- a/native/components/nux-tips-context.react.js
+++ b/native/components/nux-tips-context.react.js
@@ -25,45 +25,39 @@
type NUXTipParams = {
+nextTip: ?NUXTip,
+tooltipLocation: 'below' | 'above' | 'absolute',
- +nextRouteName: ?NUXTipRouteNames,
+ +routeName: NUXTipRouteNames,
+exitingCallback?: <Route: NUXTipRouteNames>(
navigation: AppNavigationProp<Route>,
) => void,
};
-const firstNUXTipKey = 'firstTip';
-type NUXTipParamsKeys = NUXTip | 'firstTip';
+const firstNUXTipKey = nuxTip.INTRO;
-const nuxTipParams: { +[NUXTipParamsKeys]: NUXTipParams } = {
- [firstNUXTipKey]: {
- nextTip: nuxTip.INTRO,
- tooltipLocation: 'absolute',
- nextRouteName: IntroTipRouteName,
- },
+const nuxTipParams: { +[NUXTip]: NUXTipParams } = {
[nuxTip.INTRO]: {
nextTip: nuxTip.COMMUNITY_DRAWER,
- tooltipLocation: 'below',
- nextRouteName: CommunityDrawerTipRouteName,
+ tooltipLocation: 'absolute',
+ routeName: IntroTipRouteName,
},
[nuxTip.COMMUNITY_DRAWER]: {
nextTip: nuxTip.HOME,
tooltipLocation: 'below',
- nextRouteName: HomeTabTipRouteName,
+ routeName: CommunityDrawerTipRouteName,
},
[nuxTip.HOME]: {
nextTip: nuxTip.MUTED,
tooltipLocation: 'below',
- nextRouteName: MutedTabTipRouteName,
+ routeName: HomeTabTipRouteName,
},
[nuxTip.MUTED]: {
nextTip: undefined,
- nextRouteName: undefined,
+ routeName: MutedTabTipRouteName,
tooltipLocation: 'below',
exitingCallback: navigation => navigation.goBack(),
},
};
-function getNUXTipParams(currentTipKey: NUXTipParamsKeys): NUXTipParams {
+function getNUXTipParams(currentTipKey: NUXTip): NUXTipParams {
return nuxTipParams[currentTipKey];
}
@@ -109,7 +103,7 @@
const tipsProps = React.useMemo(() => {
const result: { [tip: NUXTip]: TipProps } = {};
for (const type of values(nuxTip)) {
- if (type === nuxTip.INTRO) {
+ if (nuxTipParams[type].tooltipLocation === 'absolute') {
continue;
}
if (!tipsPropsState[type]) {
diff --git a/native/navigation/nux-tip-overlay-backdrop.react.js b/native/navigation/nux-tip-overlay-backdrop.react.js
--- a/native/navigation/nux-tip-overlay-backdrop.react.js
+++ b/native/navigation/nux-tip-overlay-backdrop.react.js
@@ -64,17 +64,14 @@
};
}, [onExitFinish]);
- const { nextTip, tooltipLocation, nextRouteName } =
- getNUXTipParams(firstNUXTipKey);
- invariant(nextRouteName && nextTip, 'first nux tip should be defined');
+ const { routeName } = getNUXTipParams(firstNUXTipKey);
React.useEffect(
() =>
props.navigation.navigate<NUXTipRouteNames>({
- name: nextRouteName,
+ name: routeName,
params: {
- tipKey: nextTip,
- tooltipLocation,
+ tipKey: firstNUXTipKey,
},
}),
// We want this effect to run exactly once, when this component is mounted
diff --git a/native/tooltip/nux-tips-overlay.react.js b/native/tooltip/nux-tips-overlay.react.js
--- a/native/tooltip/nux-tips-overlay.react.js
+++ b/native/tooltip/nux-tips-overlay.react.js
@@ -101,7 +101,6 @@
export type NUXTipsOverlayParams = {
+tipKey: NUXTip,
- +tooltipLocation: 'above' | 'below' | 'absolute',
};
export type NUXTipsOverlayProps<Route: NUXTipRouteNames> = {
@@ -198,7 +197,8 @@
[dimensions.width, initialCoordinates, tipHorizontalOffset],
);
- const { tooltipLocation } = route.params;
+ const tipParams = getNUXTipParams(route.params.tipKey);
+ const { tooltipLocation } = tipParams;
const baseTipContainerStyle = React.useMemo(() => {
const { y, x, height, width } = initialCoordinates;
@@ -380,31 +380,25 @@
}
const onPressOk = React.useCallback(() => {
- const callbackParams = getNUXTipParams(route.params.tipKey);
-
- const {
- nextTip,
- tooltipLocation: nextLocation,
- nextRouteName,
- exitingCallback,
- } = callbackParams;
+ const { nextTip, exitingCallback } = tipParams;
goBackOnce();
if (exitingCallback) {
exitingCallback?.(navigation);
}
- if (!nextTip || !nextRouteName) {
+ if (!nextTip) {
return;
}
+ const { routeName } = getNUXTipParams(nextTip);
+
navigation.navigate<NUXTipRouteNames>({
- name: nextRouteName,
+ name: routeName,
params: {
tipKey: nextTip,
- tooltipLocation: nextLocation,
},
});
- }, [goBackOnce, navigation, route.params.tipKey]);
+ }, [goBackOnce, navigation, tipParams]);
const button = React.useMemo(
() =>
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sun, Dec 7, 10:36 AM (17 h, 3 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
5843674
Default Alt Text
D13194.1765103792.diff (4 KB)
Attached To
Mode
D13194: [native] Simplify nux tips props design
Attached
Detach File
Event Timeline
Log In to Comment