@momo-kits/foundation 0.169.19-beta.1 → 0.169.19-beta.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (44) hide show
  1. package/Application/BottomSheet.parts.tsx +4 -4
  2. package/Application/BottomSheet.tsx +18 -8
  3. package/Application/BottomTab/BottomTabBar.styles.ts +1 -1
  4. package/Application/BottomTab/DuoTabBar.styles.ts +1 -1
  5. package/Application/BottomTab/TabBarIcon.tsx +1 -1
  6. package/Application/Components/HeaderExtendHeader.tsx +2 -7
  7. package/Application/Components/HeaderLeft.tsx +5 -9
  8. package/Application/Components/HeaderRight.styles.ts +1 -5
  9. package/Application/Components/HeaderRight.tsx +21 -7
  10. package/Application/Components/SearchHeader.tsx +1 -5
  11. package/Application/Components/useHeaderRightWidth.ts +2 -2
  12. package/Application/ModalIconButton.tsx +15 -13
  13. package/Application/ModalScreen.tsx +6 -15
  14. package/Application/StackScreen.tsx +2 -6
  15. package/Application/TooltipPortal.tsx +3 -3
  16. package/Application/__tests__/headerLayout.test.ts +1 -2
  17. package/Application/headerLayout.ts +13 -10
  18. package/Application/hooks.ts +1 -1
  19. package/Application/modalLayout.ts +3 -43
  20. package/Application/navigationOptions.tsx +12 -5
  21. package/Button/index.tsx +2 -2
  22. package/Divider/DashDivider.tsx +2 -2
  23. package/Divider/index.tsx +3 -3
  24. package/FoundationList/index.tsx +1 -1
  25. package/Icon/types.ts +2 -1
  26. package/Image/index.tsx +7 -62
  27. package/Image/styles.ts +0 -2
  28. package/Image/types.ts +1 -9
  29. package/Input/ErrorView.tsx +1 -1
  30. package/Input/Input.tsx +2 -2
  31. package/Input/InputMoney.tsx +2 -7
  32. package/Input/InputMoneyView.tsx +16 -8
  33. package/Input/InputOTP.tsx +2 -2
  34. package/Input/InputPhoneNumber.tsx +40 -22
  35. package/Input/InputSearch.tsx +2 -2
  36. package/Input/InputTextArea.tsx +2 -2
  37. package/Input/SearchTextTyping.tsx +2 -2
  38. package/Input/SystemTextInput.tsx +1 -2
  39. package/Input/TextTyping.tsx +2 -7
  40. package/Input/index.tsx +1 -15
  41. package/Layout/screenHeader.tsx +20 -16
  42. package/Pagination/types.ts +2 -6
  43. package/package.json +26 -28
  44. package/Input/CountryCodeView.tsx +0 -109
@@ -120,9 +120,9 @@ type SheetStyleParams = {
120
120
  };
121
121
 
122
122
  /**
123
- * Sheet container style. On foldables the sheet sits at `sheet.x`: centered on
124
- * the window, clear of the iPhone Duo control column, and on the right half when
125
- * half folded; the keyboard lift comes off its max height.
123
+ * Sheet container style. On foldables the sheet is centered in the placement
124
+ * area, clear of the iPhone Duo control column and on the right half when half
125
+ * folded; the keyboard lift comes off its max height.
126
126
  */
127
127
  export const getSheetStyle = ({
128
128
  backgroundColor,
@@ -138,7 +138,7 @@ export const getSheetStyle = ({
138
138
  if (isFoldable && width !== undefined && maxHeight !== undefined) {
139
139
  foldableStyle = {
140
140
  width,
141
- marginLeft: sheet.x ?? placement.x + (placement.width - width) / 2,
141
+ marginLeft: placement.x + (placement.width - width) / 2,
142
142
  maxHeight: maxHeight - keyboardLift,
143
143
  minHeight: sheet.minHeight,
144
144
  };
@@ -7,7 +7,6 @@ import {
7
7
  Pressable,
8
8
  StyleSheet,
9
9
  View,
10
- ViewStyle,
11
10
  } from 'react-native';
12
11
  import { ApplicationContext, MiniAppContext } from '../Context';
13
12
  import { BottomSheetParams } from './types';
@@ -191,10 +190,22 @@ const BottomSheet: React.FC<BottomSheetParams> = props => {
191
190
  />
192
191
  );
193
192
 
194
- // same tree on every layout so fold / unfold keeps the screen mounted (state, scroll)
195
- let contentStyle: ViewStyle | undefined;
193
+ let content: React.ReactNode;
196
194
  if (isFoldable) {
197
- contentStyle = styles.shrink;
195
+ // Content shrinks so a tall sheet keeps its header and footer.
196
+ content = (
197
+ <View style={styles.shrink}>
198
+ {renderSheetHeader(headerParams)}
199
+ <View style={styles.shrink}>{screen}</View>
200
+ </View>
201
+ );
202
+ } else {
203
+ content = (
204
+ <>
205
+ {renderSheetHeader(headerParams)}
206
+ {screen}
207
+ </>
208
+ );
198
209
  }
199
210
 
200
211
  return (
@@ -204,7 +215,7 @@ const BottomSheet: React.FC<BottomSheetParams> = props => {
204
215
  onRequestClose={() => {
205
216
  handleDismiss();
206
217
  }}
207
- style={StyleSheet.absoluteFill}
218
+ style={StyleSheet.absoluteFillObject}
208
219
  isModalKit={true}
209
220
  supportedOrientations={isDuo ? DUO_ORIENTATIONS : undefined}
210
221
  >
@@ -219,7 +230,7 @@ const BottomSheet: React.FC<BottomSheetParams> = props => {
219
230
  style={styles.container}
220
231
  >
221
232
  <Pressable
222
- style={StyleSheet.absoluteFill}
233
+ style={StyleSheet.absoluteFillObject}
223
234
  onPress={() => {
224
235
  action.current = 'touch';
225
236
  handleDismiss();
@@ -242,8 +253,7 @@ const BottomSheet: React.FC<BottomSheetParams> = props => {
242
253
  }),
243
254
  ]}
244
255
  >
245
- {renderSheetHeader(headerParams)}
246
- <View style={contentStyle}>{screen}</View>
256
+ {content}
247
257
  {renderSheetFooter({ footerComponent, theme })}
248
258
  {useBottomInset && (
249
259
  <View
@@ -68,7 +68,7 @@ export const styles = StyleSheet.create({
68
68
  },
69
69
  // custom label content over the label text, centered and unclipped
70
70
  ctaLabelOverlay: {
71
- ...{position: 'absolute', top: 0, bottom: 0, left: 0, right: 0},
71
+ ...StyleSheet.absoluteFillObject,
72
72
  alignItems: 'center',
73
73
  justifyContent: 'center',
74
74
  },
@@ -57,7 +57,7 @@ export const styles = StyleSheet.create({
57
57
  },
58
58
  // custom label content over the label text, centered and unclipped
59
59
  railCtaLabelOverlay: {
60
- ...{position: 'absolute', top: 0, bottom: 0, left: 0, right: 0},
60
+ ...StyleSheet.absoluteFillObject,
61
61
  alignItems: 'center',
62
62
  justifyContent: 'center',
63
63
  },
@@ -150,7 +150,7 @@ const styles = StyleSheet.create({
150
150
  height: TabBarMetrics.iconSize,
151
151
  },
152
152
  layer: {
153
- ...{position: 'absolute', top: 0, bottom: 0, left: 0, right: 0},
153
+ ...StyleSheet.absoluteFillObject,
154
154
  alignItems: 'center',
155
155
  justifyContent: 'center',
156
156
  },
@@ -17,7 +17,6 @@ import BackgroundImageView from './BackgroundImageView';
17
17
  import { type AnimatedCompatValue } from '../utils';
18
18
  import { useNormalizedSharedValue } from '../hooks';
19
19
  import { useScreenLayout } from '../../Layout';
20
- import { getHeaderMargin } from '../../Layout/utils';
21
20
  import {
22
21
  HeaderBarMetrics,
23
22
  type HeaderContentLayout,
@@ -70,12 +69,8 @@ const HeaderExtendHeader: React.FC<{
70
69
  const headerBackground = customBackground ?? theme.assets?.headerBackground;
71
70
  const layout = useScreenLayout();
72
71
  const headerLayout = useHeaderLayout(contentLayout);
73
- // collapsed into the bar, the search follows back and the right cluster into the
74
- // frame, or the side margin React Navigation adds on large iOS windows (the larger)
75
- let frameShift = headerLayout.frameInset - sidePadding;
76
- if (!layout.sideBar) {
77
- frameShift = Math.max(frameShift, getHeaderMargin(layout.width));
78
- }
72
+ // collapsed into the bar, the search follows back and the right cluster into the frame
73
+ const frameShift = headerLayout.frameInset - sidePadding;
79
74
 
80
75
  const backLeft = buttonSize + sidePadding + titleGap;
81
76
  const defaultLeft = layout.sideBar ? SCREEN_PADDING : backLeft;
@@ -1,4 +1,4 @@
1
- import { BackHandler, StyleSheet, View } from 'react-native';
1
+ import { BackHandler, useWindowDimensions, View } from 'react-native';
2
2
  import type { HeaderBackProps } from '../types';
3
3
  import React, { useCallback, useContext, useEffect } from 'react';
4
4
  import { ApplicationContext, MiniAppContext } from '../../Context';
@@ -8,11 +8,12 @@ import { SideBarButton } from './SideBarButton';
8
8
  import Animated from 'react-native-reanimated';
9
9
  import { useSideBarItemStyle } from '../../Layout/utils';
10
10
  import { useSideBarCounterStyle } from './DuoQuickReturnHeader';
11
- import { HeaderBarMetrics } from '../headerLayout';
11
+ import { getHeaderRowInset } from '../headerLayout';
12
12
 
13
13
  /**
14
14
  * Header back button, also bound to the Android hardware back. `preventBack`
15
15
  * confirms in a popup first; the iPhone Duo side bar uses the 48pt side bar button.
16
+ * In the bar it sits `sidePadding` from the window edge on every iPhone width.
16
17
  */
17
18
  const HeaderLeft: React.FC<HeaderBackProps> = ({
18
19
  tintColor,
@@ -25,6 +26,7 @@ const HeaderLeft: React.FC<HeaderBackProps> = ({
25
26
  const { navigator } = useContext(ApplicationContext);
26
27
  const sideBarStyle = useSideBarItemStyle('left', 0);
27
28
  const counterStyle = useSideBarCounterStyle();
29
+ const { width } = useWindowDimensions();
28
30
 
29
31
  const goBack = useCallback(() => {
30
32
  const canGoBack = navigator?.ref?.current?.canGoBack?.();
@@ -98,7 +100,7 @@ const HeaderLeft: React.FC<HeaderBackProps> = ({
98
100
  }
99
101
 
100
102
  return (
101
- <View style={styles.headerLeft}>
103
+ <View style={{ marginLeft: getHeaderRowInset(width) }}>
102
104
  <NavigationButton
103
105
  accessibilityLabel="btn_navigation_back"
104
106
  icon="arrow-back"
@@ -109,10 +111,4 @@ const HeaderLeft: React.FC<HeaderBackProps> = ({
109
111
  );
110
112
  };
111
113
 
112
- const styles = StyleSheet.create({
113
- headerLeft: {
114
- marginLeft: HeaderBarMetrics.sidePadding,
115
- },
116
- });
117
-
118
114
  export { HeaderLeft };
@@ -2,7 +2,7 @@ import { Platform, StyleSheet } from 'react-native';
2
2
  import { Colors, Spacing } from '../../Consts';
3
3
  import { HeaderBarMetrics } from '../headerLayout';
4
4
 
5
- const { buttonSize, pillWidth, pillHeight, sidePadding } = HeaderBarMetrics;
5
+ const { buttonSize, pillWidth, pillHeight } = HeaderBarMetrics;
6
6
 
7
7
  export const styles = StyleSheet.create({
8
8
  navigationButton: {
@@ -48,7 +48,6 @@ export const styles = StyleSheet.create({
48
48
  flexDirection: 'row',
49
49
  justifyContent: 'center',
50
50
  alignItems: 'center',
51
- paddingRight: sidePadding,
52
51
  },
53
52
  toolkitContainer: {
54
53
  height: pillHeight,
@@ -134,9 +133,6 @@ export const styles = StyleSheet.create({
134
133
  },
135
134
  }),
136
135
  },
137
- onBoarding: {
138
- marginRight: Spacing.M,
139
- },
140
136
  toolkitWide: {
141
137
  width: pillWidth,
142
138
  },
@@ -1,10 +1,16 @@
1
1
  import React, { useCallback, useContext, useEffect } from 'react';
2
- import { type LayoutChangeEvent, TouchableOpacity, View } from 'react-native';
2
+ import {
3
+ type LayoutChangeEvent,
4
+ TouchableOpacity,
5
+ useWindowDimensions,
6
+ View,
7
+ } from 'react-native';
3
8
  import { NavigationRouteContext } from '@react-navigation/native';
4
9
  import { ApplicationContext } from '../../Context';
5
10
  import { Text } from '../../Text';
6
11
  import Animated from 'react-native-reanimated';
7
- import { useSideBarItemStyle } from '../../Layout/utils';
12
+ import { getHeaderMargin, useSideBarItemStyle } from '../../Layout/utils';
13
+ import { getHeaderRowInset } from '../headerLayout';
8
14
  import { useSideBarCounterStyle } from './DuoQuickReturnHeader';
9
15
  import { HeaderToolkitAction } from './HeaderToolkitAction';
10
16
  import { styles } from './HeaderRight.styles';
@@ -13,7 +19,8 @@ import { setHeaderRightWidth } from './useHeaderRightWidth';
13
19
  /**
14
20
  * Header right slot: a custom `headerRight` render function, the onboarding skip
15
21
  * button, or the toolkit (stacked vertically in the floating iPhone Duo side bar).
16
- * The bar toolkit reports its width so header searches stop short of it.
22
+ * The bar toolkit sits `sidePadding` from the window edge and reports its width
23
+ * from that edge so header searches stop short of it.
17
24
  */
18
25
  const HeaderRight: React.FC<any> = props => {
19
26
  const { translate } = useContext(ApplicationContext);
@@ -22,14 +29,18 @@ const HeaderRight: React.FC<any> = props => {
22
29
  const sideBarStyle = useSideBarItemStyle('right', 1);
23
30
  const counterStyle = useSideBarCounterStyle();
24
31
  const routeKey = useContext(NavigationRouteContext)?.key;
32
+ const { width } = useWindowDimensions();
33
+ const rowMargin = getHeaderMargin(width);
34
+ const rowInset = getHeaderRowInset(width);
25
35
 
26
36
  const handleToolkitLayout = useCallback(
27
37
  (event: LayoutChangeEvent) => {
28
38
  if (routeKey) {
29
- setHeaderRightWidth(routeKey, event.nativeEvent.layout.width);
39
+ const toolkitWidth = event.nativeEvent.layout.width + rowMargin;
40
+ setHeaderRightWidth(routeKey, toolkitWidth);
30
41
  }
31
42
  },
32
- [routeKey],
43
+ [routeKey, rowMargin],
33
44
  );
34
45
 
35
46
  useEffect(() => {
@@ -46,7 +57,7 @@ const HeaderRight: React.FC<any> = props => {
46
57
 
47
58
  if (useOnBoarding && onPress) {
48
59
  return (
49
- <TouchableOpacity onPress={onPress} style={styles.onBoarding}>
60
+ <TouchableOpacity onPress={onPress} style={{ marginRight: rowInset }}>
50
61
  <Text typography={'action_s_bold'}>
51
62
  {buttonOnBoarding || translate?.('skip')}
52
63
  </Text>
@@ -70,7 +81,10 @@ const HeaderRight: React.FC<any> = props => {
70
81
  }
71
82
 
72
83
  return (
73
- <View style={styles.headerRightButton} onLayout={handleToolkitLayout}>
84
+ <View
85
+ style={[styles.headerRightButton, { paddingRight: rowInset }]}
86
+ onLayout={handleToolkitLayout}
87
+ >
74
88
  <HeaderToolkitAction {...props.headerRight} tintColor={props.tintColor} />
75
89
  </View>
76
90
  );
@@ -8,7 +8,6 @@ import { ApplicationContext, MiniAppContext } from '../../Context';
8
8
  import { Text } from '../../Text';
9
9
  import { useNormalizedSharedValue } from '../hooks';
10
10
  import { useScreenLayout } from '../../Layout';
11
- import { getHeaderMargin } from '../../Layout/utils';
12
11
  import { HeaderBarMetrics } from '../headerLayout';
13
12
  import { useHeaderRightWidth } from './useHeaderRightWidth';
14
13
 
@@ -47,10 +46,7 @@ const SearchHeader = React.forwardRef<InputRef, SearchHeaderProps>(
47
46
  const headerRightWidth = props?.headerRightWidth ?? defaultRightWidth;
48
47
 
49
48
  // iPhone Duo side bar holds back: the search shares the content width with the buttons only
50
- // large iOS windows: React Navigation narrows the header row by a margin each side
51
- const headerMargin = getHeaderMargin(layout.width);
52
- const rowWidth =
53
- layout.width - leftPosition - sidePadding - headerMargin * 2;
49
+ const rowWidth = layout.width - leftPosition - sidePadding;
54
50
  let searchMaxWidth = rowWidth - headerRightWidth;
55
51
  if (layout.sideBar) {
56
52
  searchMaxWidth = layout.contentWidth - Spacing.M * 2 - headerRightWidth;
@@ -16,8 +16,8 @@ const subscribe = (listener: () => void) => {
16
16
  };
17
17
 
18
18
  /**
19
- * Records the laid out width of a route's header right, side padding included;
20
- * `undefined` clears it when the header right unmounts.
19
+ * Records how far a route's header right reaches in from the window edge, side
20
+ * padding included; `undefined` clears it when the header right unmounts.
21
21
  */
22
22
  const setHeaderRightWidth = (routeKey: string, width?: number) => {
23
23
  if (widths.get(routeKey) === width) {
@@ -6,14 +6,12 @@ import {
6
6
  ViewStyle,
7
7
  } from 'react-native';
8
8
  import { ApplicationContext } from '../Context';
9
- import { Colors } from '../Consts';
9
+ import { Radius, Spacing } from '../Consts';
10
10
  import { Icon } from '../Icon';
11
- import { HeaderBarMetrics } from './headerLayout';
12
11
 
13
- // same round button as the Top nav (NavigationButton), shared with the Compose / SwiftUI kits
14
- const MODAL_ICON_BUTTON_SIZE = HeaderBarMetrics.buttonSize;
15
- const MODAL_ICON_SIZE = HeaderBarMetrics.iconSize;
16
- const MODAL_ICON_BUTTON_BORDER_WIDTH = 0.2;
12
+ // modal spec: icon button 32, icon 20, shared with the Compose / SwiftUI kits
13
+ const MODAL_ICON_BUTTON_SIZE = Spacing.XXL;
14
+ const MODAL_ICON_SIZE = 20;
17
15
 
18
16
  type ModalIconButtonProps = {
19
17
  icon: string;
@@ -23,8 +21,7 @@ type ModalIconButtonProps = {
23
21
  };
24
22
 
25
23
  /**
26
- * Close / back button of popups and bottom sheet headers, drawn like the round
27
- * Top nav icon button so modals and headers share one look.
24
+ * Close / back button of popups and bottom sheet headers
28
25
  */
29
26
  const ModalIconButton: React.FC<ModalIconButtonProps> = ({
30
27
  icon,
@@ -37,7 +34,14 @@ const ModalIconButton: React.FC<ModalIconButtonProps> = ({
37
34
  <TouchableOpacity
38
35
  accessibilityLabel={accessibilityLabel}
39
36
  onPress={onPress}
40
- style={[styles.button, style]}
37
+ style={[
38
+ styles.button,
39
+ {
40
+ backgroundColor: theme.colors.background.surface,
41
+ borderColor: theme.colors.border.default,
42
+ },
43
+ style,
44
+ ]}
41
45
  >
42
46
  <Icon
43
47
  source={icon}
@@ -52,12 +56,10 @@ const styles = StyleSheet.create({
52
56
  button: {
53
57
  width: MODAL_ICON_BUTTON_SIZE,
54
58
  height: MODAL_ICON_BUTTON_SIZE,
55
- borderRadius: MODAL_ICON_BUTTON_SIZE / 2,
56
- borderWidth: MODAL_ICON_BUTTON_BORDER_WIDTH,
59
+ borderRadius: Radius.L,
60
+ borderWidth: 1,
57
61
  alignItems: 'center',
58
62
  justifyContent: 'center',
59
- backgroundColor: Colors.black_01 + '99',
60
- borderColor: Colors.black_20 + '33',
61
63
  },
62
64
  });
63
65
 
@@ -46,8 +46,7 @@ const ModalScreen: React.FC<any> = props => {
46
46
 
47
47
  /**
48
48
  * Centered popup that fades and scales in over a scrim. On foldables it is
49
- * centered on the window (`popup.x`), clear of the iPhone Duo control column,
50
- * at most a popup wide.
49
+ * centered in the modal placement area, at most a popup wide.
51
50
  */
52
51
  const Modal: React.FC<ModalParams> = props => {
53
52
  const { navigator } = useContext(ApplicationContext);
@@ -157,20 +156,12 @@ const Modal: React.FC<ModalParams> = props => {
157
156
  return () => backHandler.remove();
158
157
  }, [barrierDismissible, handleDismiss]);
159
158
 
160
- // popup.x centers it on the window; without it, centered in the placement
161
- let popupLeft = placement.x;
162
- let popupRight = width - placement.x - placement.width;
163
- if (popup.x !== undefined) {
164
- popupLeft = popup.x;
165
- popupRight = Math.max(width - popup.x - popup.width, 0);
166
- }
167
-
168
159
  return (
169
160
  <Container
170
161
  transparent
171
162
  visible={true}
172
163
  onRequestClose={handleDismiss}
173
- style={StyleSheet.absoluteFill}
164
+ style={StyleSheet.absoluteFillObject}
174
165
  isModalKit={true}
175
166
  supportedOrientations={isDuo ? DUO_ORIENTATIONS : undefined}
176
167
  >
@@ -179,7 +170,7 @@ const Modal: React.FC<ModalParams> = props => {
179
170
  behavior={Platform.OS === 'ios' ? 'padding' : undefined}
180
171
  >
181
172
  <Pressable
182
- style={StyleSheet.absoluteFill}
173
+ style={StyleSheet.absoluteFillObject}
183
174
  onPress={() => handleDismiss(undefined, barrierDismissible)}
184
175
  >
185
176
  <Animated.View style={[styles.overlayContent, scrimStyle]} />
@@ -190,13 +181,13 @@ const Modal: React.FC<ModalParams> = props => {
190
181
  opacity,
191
182
  transform: [{ scale }],
192
183
  },
193
- // centered on the window at popup.x, clear of the control column, at most a popup wide
184
+ // centered in the placement area, at most a popup wide
194
185
  isFoldable && styles.shrink,
195
186
  isFoldable && {
196
187
  marginTop: placement.y,
197
188
  marginBottom: height - placement.y - placement.height,
198
- marginLeft: popupLeft,
199
- marginRight: popupRight,
189
+ marginLeft: placement.x,
190
+ marginRight: width - placement.x - placement.width,
200
191
  maxWidth: popup.width,
201
192
  maxHeight: popup.maxHeight,
202
193
  },
@@ -1,4 +1,5 @@
1
1
  import React, { useContext, useEffect, useLayoutEffect, useRef } from 'react';
2
+ import { InteractionManager } from 'react-native';
2
3
  import { useHeaderHeight } from '@react-navigation/elements';
3
4
  import { ScreenTrackingParams } from './types';
4
5
  import Navigation from './Navigation';
@@ -13,12 +14,7 @@ const TRACKING_TIMEOUT = 5000;
13
14
  const ELEMENT_IDLE_TIMEOUT = 2000;
14
15
  const LOADING_IDLE_TIMEOUT = 2000;
15
16
 
16
- // RN 0.87+: InteractionManager đã bị xoá khỏi react-native → thay bằng requestIdleCallback.
17
- // Giữ nguyên shape trả về { cancel } để code bên dưới (timeoutInteraction?.cancel?.()) không đổi.
18
- const runAfterInteractions = (task: () => void) => {
19
- const handle = requestIdleCallback(() => task());
20
- return { cancel: () => cancelIdleCallback(handle) };
21
- };
17
+ const runAfterInteractions = InteractionManager.runAfterInteractions;
22
18
 
23
19
  /**
24
20
  * Hosts a feature screen in the stack: applies its header options, provides
@@ -8,13 +8,13 @@ import React, {
8
8
  useReducer,
9
9
  useRef,
10
10
  } from 'react';
11
- import { StyleSheet, View, type ViewInstance } from 'react-native';
11
+ import { StyleSheet, View } from 'react-native';
12
12
 
13
13
  interface TooltipPortalContextValue {
14
14
  register: (id: string, content: ReactNode) => void;
15
15
  unregister: (id: string, immediate?: boolean) => void;
16
16
  portals: Map<string, ReactNode>;
17
- hostRef: RefObject<ViewInstance | null>;
17
+ hostRef: RefObject<View | null>;
18
18
  }
19
19
 
20
20
  const TooltipPortalContext = createContext<TooltipPortalContextValue | null>(
@@ -30,7 +30,7 @@ export const TooltipPortalProvider: React.FC<{ children: ReactNode }> = ({
30
30
  }) => {
31
31
  // The ref map updates synchronously; the reducer only triggers re-renders.
32
32
  const portalsRef = useRef<Map<string, ReactNode>>(new Map());
33
- const hostRef = useRef<ViewInstance>(null);
33
+ const hostRef = useRef<View>(null);
34
34
  const [updateCounter, forceUpdate] = useReducer((x: number) => x + 1, 0);
35
35
  const pendingUpdateRef = useRef<any>(null);
36
36
 
@@ -69,7 +69,7 @@ describe('getHeaderFrameOptions', () => {
69
69
  isDuo: false,
70
70
  contentLayout,
71
71
  });
72
- return { layout, isDuo: false, headerMargin: 0, edgePadding: NO_EDGE };
72
+ return { layout, isDuo: false, edgePadding: NO_EDGE };
73
73
  };
74
74
 
75
75
  it('leaves the options alone when contentLayout is unset', () => {
@@ -103,7 +103,6 @@ describe('getHeaderFrameOptions', () => {
103
103
  const options = getHeaderFrameOptions({
104
104
  layout,
105
105
  isDuo: true,
106
- headerMargin: 0,
107
106
  edgePadding: DUO_EDGE,
108
107
  contentLayout: 'stretch',
109
108
  });
@@ -85,8 +85,6 @@ type EdgePadding = { left: number; right: number };
85
85
  type HeaderFrameInput = {
86
86
  layout: HeaderLayout;
87
87
  isDuo: boolean;
88
- // side margin @react-navigation/elements already adds to the row
89
- headerMargin: number;
90
88
  // padding of the plain row containers: the iPhone Duo status bar clearance, else 0
91
89
  edgePadding: EdgePadding;
92
90
  contentLayout?: HeaderContentLayout;
@@ -123,6 +121,14 @@ const getHeaderLayout = ({
123
121
  };
124
122
  };
125
123
 
124
+ /**
125
+ * Inset from the React Navigation header row that puts an item `sidePadding` from
126
+ * the window edge: large iOS windows already inset that row by `getHeaderMargin`.
127
+ */
128
+ const getHeaderRowInset = (width: number) => {
129
+ return HeaderBarMetrics.sidePadding - getHeaderMargin(width);
130
+ };
131
+
126
132
  /**
127
133
  * Widest a title can be between back and the right cluster of the header row.
128
134
  */
@@ -189,7 +195,6 @@ const getEdgeFrameOptions = (
189
195
  const getHeaderFrameOptions = ({
190
196
  layout,
191
197
  isDuo,
192
- headerMargin,
193
198
  edgePadding,
194
199
  contentLayout,
195
200
  }: HeaderFrameInput): StackNavigationOptions | undefined => {
@@ -199,12 +204,11 @@ const getHeaderFrameOptions = ({
199
204
  if (contentLayout !== 'stretch' || isDuo) {
200
205
  return getEdgeFrameOptions(edgePadding);
201
206
  }
202
- // the header content row already sits this far in on large iOS windows
207
+ // back and toolkit already net out the header row margin of large iOS windows
203
208
  const shift = layout.frameInset - layout.sidePadding;
204
- const containerShift = Math.max(0, shift - headerMargin);
205
209
  return {
206
- headerLeftContainerStyle: { paddingLeft: containerShift },
207
- headerRightContainerStyle: { paddingRight: containerShift },
210
+ headerLeftContainerStyle: { paddingLeft: shift },
211
+ headerRightContainerStyle: { paddingRight: shift },
208
212
  headerTitleContainerStyle: {
209
213
  ...TITLE_CONTAINER_RESET,
210
214
  left: layout.titleGap,
@@ -225,17 +229,15 @@ const useHeaderFrameOptions = (
225
229
  const rowOptions = getHeaderRowOptions(screenLayout);
226
230
  const edgeLeft = rowOptions.headerLeftContainerStyle?.paddingLeft ?? 0;
227
231
  const edgeRight = rowOptions.headerRightContainerStyle?.paddingRight ?? 0;
228
- const headerMargin = getHeaderMargin(screenLayout.width);
229
232
  const isDuo = isIPhoneDuo();
230
233
  return useMemo(() => {
231
234
  return getHeaderFrameOptions({
232
235
  layout,
233
236
  isDuo,
234
- headerMargin,
235
237
  edgePadding: { left: edgeLeft, right: edgeRight },
236
238
  contentLayout,
237
239
  });
238
- }, [contentLayout, isDuo, layout, headerMargin, edgeLeft, edgeRight]);
240
+ }, [contentLayout, isDuo, layout, edgeLeft, edgeRight]);
239
241
  };
240
242
 
241
243
  export type { HeaderContentLayout, HeaderLayout };
@@ -247,6 +249,7 @@ export {
247
249
  getHeaderFrameOptions,
248
250
  getHeaderLayout,
249
251
  getSearchHeaderHeight,
252
+ getHeaderRowInset,
250
253
  getTitleBudget,
251
254
  useHeaderLayout,
252
255
  useHeaderFrameOptions,
@@ -54,7 +54,7 @@ const useAppState = () => {
54
54
 
55
55
  useEffect(() => {
56
56
  const subscription = AppState.addEventListener('change', nextAppState => {
57
- const wasInBackground = /inactive|background/.test(appState.current ?? '');
57
+ const wasInBackground = /inactive|background/.test(appState.current);
58
58
  const isReturning = wasInBackground && nextAppState === 'active';
59
59
  isBackgroundToForeground.current = isReturning;
60
60
  appState.current = nextAppState;