Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F2994948
D13697.id45092.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
4 KB
Referenced Files
None
Subscribers
None
D13697.id45092.diff
View Options
diff --git a/native/chat/chat-tab-bar.react.js b/native/chat/chat-tab-bar.react.js
--- a/native/chat/chat-tab-bar.react.js
+++ b/native/chat/chat-tab-bar.react.js
@@ -31,25 +31,11 @@
const viewRef = React.useRef<?React.ElementRef<typeof View>>();
const onLayout = React.useCallback(() => {
- const button = viewRef.current;
- if (!button) {
- return;
- }
-
const tipType = ButtonTitleToTip[props.route.name];
if (!tipType) {
return;
}
- button.measure((x, y, width, height, pageX, pageY) => {
- tipsContext.registerTipButton(tipType, {
- x,
- y,
- width,
- height,
- pageX,
- pageY,
- });
- });
+ tipsContext.registerTipButton(tipType, viewRef.current);
}, [props.route.name, tipsContext]);
return (
diff --git a/native/chat/chat.react.js b/native/chat/chat.react.js
--- a/native/chat/chat.react.js
+++ b/native/chat/chat.react.js
@@ -383,17 +383,9 @@
const { registerTipButton } = tipsContext;
const communityDrawerButtonOnLayout = React.useCallback(() => {
- communityDrawerButtonRef.current?.measure(
- (x, y, width, height, pageX, pageY) => {
- registerTipButton(nuxTip.COMMUNITY_DRAWER, {
- x,
- y,
- width,
- height,
- pageX,
- pageY,
- });
- },
+ registerTipButton(
+ nuxTip.COMMUNITY_DRAWER,
+ communityDrawerButtonRef.current,
);
}, [registerTipButton]);
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
@@ -1,6 +1,7 @@
// @flow
import * as React from 'react';
+import { View } from 'react-native';
import { values } from 'lib/utils/objects.js';
@@ -61,14 +62,7 @@
return nuxTipParams[currentTipKey];
}
-type TipProps = {
- +x: number,
- +y: number,
- +width: number,
- +height: number,
- +pageX: number,
- +pageY: number,
-};
+type TipProps = React.ElementRef<typeof View>;
export type NUXTipsContextType = {
+registerTipButton: (type: NUXTip, tipProps: ?TipProps) => void,
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
@@ -121,23 +121,36 @@
const dimensions = useSelector(state => state.dimensions);
- const { initialCoordinates, verticalBounds } = React.useMemo(() => {
+ const yInitial = (dimensions.height * 2) / 5;
+ const xInitial = dimensions.width / 2;
+
+ const [initialCoordinates, setInitialCoordinates] = React.useState<{
+ height: number,
+ width: number,
+ x: number,
+ y: number,
+ }>({ height: 0, width: 0, x: xInitial, y: yInitial });
+
+ const [verticalBounds, setVerticalBounds] = React.useState<{
+ height: number,
+ y: number,
+ }>({ height: 0, y: yInitial });
+
+ const [buttonMeasured, setButtonMeasured] =
+ React.useState<boolean>(!ButtonComponent);
+
+ React.useEffect(() => {
if (!ButtonComponent) {
- const y = (dimensions.height * 2) / 5;
- const x = dimensions.width / 2;
- return {
- initialCoordinates: { height: 0, width: 0, x, y },
- verticalBounds: { height: 0, y },
- };
+ return;
}
- const tipProps = nuxTipContext?.tipsProps?.[route.params.tipKey];
- invariant(tipProps, 'button should be registered with nuxTipContext');
- const { pageX, pageY, width, height } = tipProps;
+ const button = nuxTipContext?.tipsProps?.[route.params.tipKey];
+ invariant(button, 'button should be registered with nuxTipContext');
- return {
- initialCoordinates: { height, width, x: pageX, y: pageY },
- verticalBounds: { height, y: pageY },
- };
+ button?.measure((x, y, width, height, pageX, pageY) => {
+ setInitialCoordinates({ height, width, x: pageX, y: pageY });
+ setVerticalBounds({ height, y: pageY });
+ setButtonMeasured(true);
+ });
}, [dimensions, nuxTipContext?.tipsProps, route.params.tipKey]);
const overlayContext = React.useContext(OverlayContext);
@@ -420,6 +433,10 @@
[buttonStyle, contentContainerStyle, props.navigation, route],
);
+ if (!buttonMeasured) {
+ return null;
+ }
+
return (
<TouchableWithoutFeedback onPress={onPressOk}>
<View style={styles.container}>
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Fri, Oct 18, 8:27 AM (21 h, 48 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2316885
Default Alt Text
D13697.id45092.diff (4 KB)
Attached To
Mode
D13697: [native] Fix NUX Android problem
Attached
Detach File
Event Timeline
Log In to Comment