@momo-kits/foundation 0.169.17 → 0.169.18-beta.1

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.
@@ -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 (
@@ -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
@@ -12,8 +12,6 @@ import { Colors } from '../../Consts';
12
12
  import { useNormalizedSharedValue } from '../hooks';
13
13
  import { HeaderBarMetrics, useHeaderLayout } from '../headerLayout';
14
14
 
15
- const TRANSPARENT_ALPHA = '00';
16
-
17
15
  const ASPECT_RATIOS: Record<
18
16
  NonNullable<HeaderAnimatedProps['aspectRatio']>,
19
17
  number
@@ -23,30 +21,10 @@ const ASPECT_RATIOS: Record<
23
21
  '1/1': 1 / 1,
24
22
  };
25
23
 
26
- /**
27
- * Side fill colors behind the centered banner: `gradientColors` (one color fills
28
- * solid, as LinearGradient needs two), else `backgroundColor` fading to transparent.
29
- */
30
- const getBannerGradientColors = (
31
- gradientColors?: string[],
32
- backgroundColor?: string,
33
- ) => {
34
- if (gradientColors?.length === 1) {
35
- return [gradientColors[0], gradientColors[0]];
36
- }
37
- if (gradientColors?.length) {
38
- return gradientColors;
39
- }
40
- if (backgroundColor) {
41
- return [backgroundColor, backgroundColor + TRANSPARENT_ALPHA];
42
- }
43
- return undefined;
44
- };
45
-
46
24
  /**
47
25
  * Parallax header image (or `children`): stretches when pulled down and fades out
48
- * as the content scrolls up. Wide windows and the iPhone Duo inner display center
49
- * it at phone size × 1.2 over the side gradient.
26
+ * as the content scrolls up. Wide windows and the iPhone Duo inner display keep
27
+ * it at phone size, centered.
50
28
  */
51
29
  const HeaderAnimated: React.FC<HeaderAnimatedProps> = ({
52
30
  animatedValue,
@@ -54,16 +32,11 @@ const HeaderAnimated: React.FC<HeaderAnimatedProps> = ({
54
32
  useScale = true,
55
33
  aspectRatio = '16/9',
56
34
  bannerBackgroundColor,
57
- bannerGradientColors,
58
35
  children,
59
36
  }) => {
60
37
  const sharedValue = useNormalizedSharedValue(animatedValue);
61
38
  const { isBannerCentered, bannerWidth } = useHeaderLayout();
62
39
  const ratio = ASPECT_RATIOS[aspectRatio];
63
- const sideColors = getBannerGradientColors(
64
- bannerGradientColors,
65
- bannerBackgroundColor,
66
- );
67
40
  const animatedStyle = useAnimatedStyle(() => {
68
41
  let scale = 1;
69
42
  if (useScale) {
@@ -115,10 +88,13 @@ const HeaderAnimated: React.FC<HeaderAnimatedProps> = ({
115
88
  <Animated.View
116
89
  style={[styles.container, { height: bannerWidth / ratio }, animatedStyle]}
117
90
  >
118
- {sideColors && (
119
- <LinearGradient colors={sideColors} style={StyleSheet.absoluteFill} />
91
+ {!!bannerBackgroundColor && (
92
+ <LinearGradient
93
+ colors={[bannerBackgroundColor, bannerBackgroundColor + '00']}
94
+ style={StyleSheet.absoluteFill}
95
+ />
120
96
  )}
121
- <View style={styles.centeredBanner}>{content}</View>
97
+ <View style={styles.phoneBanner}>{content}</View>
122
98
  </Animated.View>
123
99
  );
124
100
  };
@@ -134,7 +110,7 @@ const styles = StyleSheet.create({
134
110
  alignSelf: 'center',
135
111
  },
136
112
  full: { width: '100%', height: '100%' },
137
- centeredBanner: {
113
+ phoneBanner: {
138
114
  width: HeaderBarMetrics.bannerWidth,
139
115
  height: '100%',
140
116
  alignSelf: 'center',
@@ -17,7 +17,7 @@ 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';
20
+ import { HeaderMetrics } from '../../Layout/utils';
21
21
  import {
22
22
  HeaderBarMetrics,
23
23
  type HeaderContentLayout,
@@ -28,12 +28,10 @@ import { useHeaderRightWidth } from './useHeaderRightWidth';
28
28
  const { buttonSize, pillWidth, sidePadding, titleGap } = HeaderBarMetrics;
29
29
  const SCREEN_PADDING = sidePadding;
30
30
  const TOOLKIT_WIDTH = pillWidth + sidePadding;
31
- // the extended header without search grows this much past the bar until scrolled
32
- const EXTENDED_HEIGHT_EXTRA = 52;
33
31
 
34
32
  /**
35
33
  * Extended header background: a gradient that collapses on scroll and, with
36
- * `inputSearchProps`, a window-wide search that slides into the bar beside back/toolkit.
34
+ * `inputSearchProps`, a full-width search that slides into the bar beside back/toolkit.
37
35
  */
38
36
  const HeaderExtendHeader: React.FC<{
39
37
  headerType?: HeaderType;
@@ -46,10 +44,6 @@ const HeaderExtendHeader: React.FC<{
46
44
  useShadowHeader?: boolean;
47
45
  gradientColor?: string;
48
46
  headerBackground?: string;
49
- /**
50
- * `stretch` keeps the collapsed search beside back and the right cluster in the
51
- * 600pt frame; the expanded search row spans the window with either layout.
52
- */
53
47
  contentLayout?: HeaderContentLayout;
54
48
  }> = ({
55
49
  headerType = 'default',
@@ -70,12 +64,8 @@ const HeaderExtendHeader: React.FC<{
70
64
  const headerBackground = customBackground ?? theme.assets?.headerBackground;
71
65
  const layout = useScreenLayout();
72
66
  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
- }
67
+ // the stretch frame pulls the search in from both bar edges
68
+ const frameShift = headerLayout.frameInset - sidePadding;
79
69
 
80
70
  const backLeft = buttonSize + sidePadding + titleGap;
81
71
  const defaultLeft = layout.sideBar ? SCREEN_PADDING : backLeft;
@@ -83,22 +73,22 @@ const HeaderExtendHeader: React.FC<{
83
73
  const measuredRightWidth = useHeaderRightWidth() ?? TOOLKIT_WIDTH;
84
74
  const defaultRightWidth = layout.sideBar ? 0 : measuredRightWidth;
85
75
  const headerRightWidth = customHeaderRightWidth ?? defaultRightWidth;
86
- const contentLeft = layout.insetLeft + SCREEN_PADDING;
87
- const contentRight = layout.insetLeft + layout.contentWidth;
76
+ const contentLeft = layout.insetLeft + SCREEN_PADDING + frameShift;
77
+ const contentRight = layout.insetLeft + layout.contentWidth - frameShift;
88
78
  // collapsed on the status bar row, the search stays between its clusters
89
79
  const clearanceLeft = layout.statusBarClearance?.left ?? 0;
90
80
  const clearanceRight = layout.statusBarClearance?.right ?? 0;
91
- const searchLeft = leftPosition + clearanceLeft;
92
- const collapsedLeft = layout.insetLeft + searchLeft + frameShift;
93
- const barRight = contentRight - clearanceRight - frameShift;
94
- const collapsedRight = barRight - headerRightWidth;
81
+ const searchLeft = leftPosition + clearanceLeft + frameShift;
82
+ const collapsedLeft = layout.insetLeft + searchLeft;
83
+ const collapsedRight = contentRight - clearanceRight - headerRightWidth;
95
84
  const searchWidth = contentRight - contentLeft - SCREEN_PADDING;
96
85
  const collapsedSearchWidth = collapsedRight - collapsedLeft - SCREEN_PADDING;
97
- // expanded search row under the bar: the search plus its vertical margins
98
- const searchRowHeight = HeaderBarMetrics.searchBarHeight;
99
- // a row taller than the search row (iPhone Duo) centers the collapsed search on the title
100
- const titleRowHeight = heightHeader - layout.headerStatusBarHeight;
101
- const collapsedRaise = (titleRowHeight - searchRowHeight) / 2;
86
+ // a row taller than barHeight (iPhone Duo) centers the collapsed search on the title
87
+ const titleRowHeight = layout.headerHeight - layout.headerStatusBarHeight;
88
+ const collapsedRaise = (titleRowHeight - HeaderMetrics.barHeight) / 2;
89
+
90
+ // the iPhone Duo side bar keeps the content search size
91
+ const searchSize = layout.sideBar ? 'default' : 'header';
102
92
 
103
93
  let useShadowHeader = useShadowHeaderProp;
104
94
  if (inputSearchProps && Platform.OS === 'android') {
@@ -111,7 +101,7 @@ const HeaderExtendHeader: React.FC<{
111
101
  height: interpolate(
112
102
  sharedValue.value,
113
103
  [0, 100],
114
- [heightHeader + searchRowHeight, heightHeader],
104
+ [heightHeader + 52, heightHeader],
115
105
  Extrapolation.CLAMP,
116
106
  ),
117
107
  }));
@@ -164,7 +154,7 @@ const HeaderExtendHeader: React.FC<{
164
154
  height: interpolate(
165
155
  sharedValue.value,
166
156
  [0, 100],
167
- [heightHeader + EXTENDED_HEIGHT_EXTRA, heightHeader],
157
+ [heightHeader + 52, heightHeader],
168
158
  Extrapolation.CLAMP,
169
159
  ),
170
160
  }));
@@ -225,7 +215,7 @@ const HeaderExtendHeader: React.FC<{
225
215
  <InputSearch
226
216
  {...inputSearchProps}
227
217
  ref={inputSearchRef}
228
- size={'header'}
218
+ size={searchSize}
229
219
  backgroundColor={'transparent'}
230
220
  showButtonText={false}
231
221
  />
@@ -1,5 +1,5 @@
1
1
  import { Colors, Radius, Spacing, Styles } from '../../Consts';
2
- import { InputRef, InputSearch } from '../../Input';
2
+ import { InputRef, InputSearch, type InputSearchProps } from '../../Input';
3
3
  import { StyleSheet, TouchableOpacity, View } from 'react-native';
4
4
  import Animated, { useAnimatedStyle } from 'react-native-reanimated';
5
5
  import React, { useContext } from 'react';
@@ -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
 
@@ -37,8 +36,10 @@ const SearchHeader = React.forwardRef<InputRef, SearchHeaderProps>(
37
36
  const context = useContext<any>(MiniAppContext);
38
37
  const layout = useScreenLayout();
39
38
  let defaultRightWidth = useHeaderRightWidth() ?? TOOLKIT_WIDTH;
39
+ let searchSize: InputSearchProps['size'] = 'header';
40
40
  if (layout.sideBar) {
41
41
  defaultRightWidth = DUO_TOOLKIT_WIDTH;
42
+ searchSize = 'default';
42
43
  }
43
44
 
44
45
  const sharedValue = useNormalizedSharedValue(animatedValue);
@@ -47,10 +48,7 @@ const SearchHeader = React.forwardRef<InputRef, SearchHeaderProps>(
47
48
  const headerRightWidth = props?.headerRightWidth ?? defaultRightWidth;
48
49
 
49
50
  // 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;
51
+ const rowWidth = layout.width - leftPosition - sidePadding;
54
52
  let searchMaxWidth = rowWidth - headerRightWidth;
55
53
  if (layout.sideBar) {
56
54
  searchMaxWidth = layout.contentWidth - Spacing.M * 2 - headerRightWidth;
@@ -120,7 +118,7 @@ const SearchHeader = React.forwardRef<InputRef, SearchHeaderProps>(
120
118
  <InputSearch
121
119
  ref={ref}
122
120
  {...props}
123
- size={'header'}
121
+ size={searchSize}
124
122
  backgroundColor={'transparent'}
125
123
  showButtonText={false}
126
124
  />
@@ -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,14 +156,6 @@ 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
@@ -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
  },
@@ -2,18 +2,14 @@ import { useMemo } from 'react';
2
2
  import { useWindowDimensions, type ViewStyle } from 'react-native';
3
3
  import type { StackNavigationOptions } from '@react-navigation/stack';
4
4
  import { Spacing } from '../Consts';
5
- import {
6
- getHeaderMargin,
7
- getHeaderRowOptions,
8
- useScreenLayout,
9
- } from '../Layout/utils';
5
+ import { getHeaderMargin } from '../Layout/utils';
10
6
  import { FOLDABLE_MIN_WIDTH } from './modalLayout';
11
7
  import { isIPhoneDuo } from './utils';
12
8
 
13
9
  // Top navigation spec, shared with the Compose / SwiftUI kits
14
10
  const HEADER_FRAME_MAX_WIDTH = 600;
15
- // banner image on wide windows and the iPhone Duo inner display: phone (375) × 1.2
16
- const WIDE_BANNER_SCALE = 1.2;
11
+ // stretch frame on hold until design confirms it: `stretch` lays out like `grid`
12
+ const IS_STRETCH_FRAME_ENABLED = false;
17
13
 
18
14
  /**
19
15
  * Top navigation geometry on every device
@@ -21,11 +17,10 @@ const WIDE_BANNER_SCALE = 1.2;
21
17
  * - pillWidth / pillHeight: help center | home capsule
22
18
  * - clusterWidth: shortcut, gap and pill on the right of the bar
23
19
  * - searchHeight: search field inside the header
24
- * - searchBarHeight: header row holding the search, taller than the plain bar
25
20
  * - titleGap: space between back and the title, and the title and the right cluster
26
21
  * - sidePadding: bar edge to back and to the right cluster
27
22
  * - gradientHeight: header gradient, kept at the phone height on wide windows
28
- * - bannerWidth: animated banner image on wide windows, centered (phone × 1.2)
23
+ * - bannerWidth: animated banner image, kept at the phone width on wide windows
29
24
  */
30
25
  const HeaderBarMetrics = {
31
26
  buttonSize: 32,
@@ -33,17 +28,17 @@ const HeaderBarMetrics = {
33
28
  pillWidth: 72,
34
29
  pillHeight: 32,
35
30
  clusterWidth: 112,
36
- searchHeight: 40,
37
- searchBarHeight: 56,
31
+ searchHeight: 32,
38
32
  titleGap: Spacing.S,
39
33
  sidePadding: Spacing.M,
40
34
  gradientHeight: 154,
41
- bannerWidth: 450,
35
+ bannerWidth: 375,
42
36
  };
43
37
 
44
38
  /**
45
39
  * `grid` keeps the header row at the bar edges, `stretch` centers it in a 600pt
46
- * frame on wide windows. Background, status bar and the search always span the window.
40
+ * frame on wide windows (on hold: same as `grid` for now). Background and status
41
+ * bar always span the window.
47
42
  */
48
43
  type HeaderContentLayout = 'grid' | 'stretch';
49
44
 
@@ -58,10 +53,6 @@ type HeaderLayout = typeof HeaderBarMetrics & {
58
53
  * inner display, portrait and landscape.
59
54
  */
60
55
  isBannerCentered: boolean;
61
- /**
62
- * Banner size against the phone banner: `WIDE_BANNER_SCALE` when centered, else 1.
63
- */
64
- bannerScale: number;
65
56
  /**
66
57
  * Window edge to back and to the right cluster: `sidePadding`, or centering the
67
58
  * row in the 600pt frame with `stretch` on a wide window.
@@ -80,18 +71,6 @@ type HeaderLayoutInput = {
80
71
  contentLayout?: HeaderContentLayout;
81
72
  };
82
73
 
83
- type EdgePadding = { left: number; right: number };
84
-
85
- type HeaderFrameInput = {
86
- layout: HeaderLayout;
87
- isDuo: boolean;
88
- // side margin @react-navigation/elements already adds to the row
89
- headerMargin: number;
90
- // padding of the plain row containers: the iPhone Duo status bar clearance, else 0
91
- edgePadding: EdgePadding;
92
- contentLayout?: HeaderContentLayout;
93
- };
94
-
95
74
  /**
96
75
  * Header geometry for a window, pure so it can be tested without a device.
97
76
  */
@@ -105,19 +84,15 @@ const getHeaderLayout = ({
105
84
  const isLargeWindow = Math.min(width, height) >= FOLDABLE_MIN_WIDTH;
106
85
  const isWide = !isDuo && isLargeWindow;
107
86
  let frameInset = sidePadding;
108
- if (isWide && contentLayout === 'stretch') {
87
+ const isStretch = IS_STRETCH_FRAME_ENABLED && contentLayout === 'stretch';
88
+ if (isWide && isStretch) {
109
89
  const centered = (width - HEADER_FRAME_MAX_WIDTH) / 2;
110
90
  frameInset = Math.max(sidePadding, centered);
111
91
  }
112
- let bannerScale = 1;
113
- if (isLargeWindow) {
114
- bannerScale = WIDE_BANNER_SCALE;
115
- }
116
92
  return {
117
93
  ...HeaderBarMetrics,
118
94
  isWide,
119
95
  isBannerCentered: isLargeWindow,
120
- bannerScale,
121
96
  frameInset,
122
97
  frameWidth: width - frameInset * 2,
123
98
  };
@@ -142,19 +117,6 @@ const useHeaderLayout = (contentLayout?: HeaderContentLayout): HeaderLayout => {
142
117
  }, [width, height, isDuo, contentLayout]);
143
118
  };
144
119
 
145
- /**
146
- * Header height once the search sits in its row: the row grows to `searchBarHeight`,
147
- * a taller row (iPhone landscape, iPhone Duo) keeps its height.
148
- */
149
- const getSearchHeaderHeight = (
150
- headerHeight: number,
151
- statusBarHeight: number,
152
- ) => {
153
- const rowHeight = headerHeight - statusBarHeight;
154
- const { searchBarHeight } = HeaderBarMetrics;
155
- return statusBarHeight + Math.max(rowHeight, searchBarHeight);
156
- };
157
-
158
120
  const TITLE_CONTAINER_RESET: ViewStyle = {
159
121
  marginLeft: 0,
160
122
  marginEnd: 0,
@@ -165,77 +127,33 @@ const TITLE_CONTAINER_RESET: ViewStyle = {
165
127
  };
166
128
 
167
129
  /**
168
- * Container styles of the bar-edge row, set explicitly: options are merged, so a
169
- * former `stretch` frame would otherwise stay after a layout switch or a fold.
170
- */
171
- const getEdgeFrameOptions = (
172
- edgePadding: EdgePadding,
173
- ): StackNavigationOptions => {
174
- return {
175
- headerLeftContainerStyle: { paddingLeft: edgePadding.left },
176
- headerRightContainerStyle: { paddingRight: edgePadding.right },
177
- headerTitleContainerStyle: {
178
- ...TITLE_CONTAINER_RESET,
179
- left: HeaderBarMetrics.titleGap,
180
- },
181
- };
182
- };
183
-
184
- /**
185
- * React Navigation container styles placing back, title and the right cluster for
186
- * `contentLayout`: the 600pt frame with `stretch`, else the bar edges (also iPhone
187
- * Duo). `undefined` when the screen leaves `contentLayout` unset.
188
- */
189
- const getHeaderFrameOptions = ({
190
- layout,
191
- isDuo,
192
- headerMargin,
193
- edgePadding,
194
- contentLayout,
195
- }: HeaderFrameInput): StackNavigationOptions | undefined => {
196
- if (!contentLayout) {
197
- return undefined;
198
- }
199
- if (contentLayout !== 'stretch' || isDuo) {
200
- return getEdgeFrameOptions(edgePadding);
201
- }
202
- // the header content row already sits this far in on large iOS windows
203
- const shift = layout.frameInset - layout.sidePadding;
204
- const containerShift = Math.max(0, shift - headerMargin);
205
- return {
206
- headerLeftContainerStyle: { paddingLeft: containerShift },
207
- headerRightContainerStyle: { paddingRight: containerShift },
208
- headerTitleContainerStyle: {
209
- ...TITLE_CONTAINER_RESET,
210
- left: layout.titleGap,
211
- maxWidth: getTitleBudget(layout),
212
- },
213
- };
214
- };
215
-
216
- /**
217
- * Container styles for `contentLayout` on the current window, re-computed on fold,
218
- * unfold and rotation; see `getHeaderFrameOptions`.
130
+ * React Navigation container styles that keep back, title and the right cluster
131
+ * in the `stretch` frame. `undefined` for `grid`, and on iPhone Duo, which keeps
132
+ * its own header row.
219
133
  */
220
134
  const useHeaderFrameOptions = (
221
135
  contentLayout?: HeaderContentLayout,
222
136
  ): StackNavigationOptions | undefined => {
223
137
  const layout = useHeaderLayout(contentLayout);
224
- const screenLayout = useScreenLayout();
225
- const rowOptions = getHeaderRowOptions(screenLayout);
226
- const edgeLeft = rowOptions.headerLeftContainerStyle?.paddingLeft ?? 0;
227
- const edgeRight = rowOptions.headerRightContainerStyle?.paddingRight ?? 0;
228
- const headerMargin = getHeaderMargin(screenLayout.width);
138
+ const { width } = useWindowDimensions();
229
139
  const isDuo = isIPhoneDuo();
230
140
  return useMemo(() => {
231
- return getHeaderFrameOptions({
232
- layout,
233
- isDuo,
234
- headerMargin,
235
- edgePadding: { left: edgeLeft, right: edgeRight },
236
- contentLayout,
237
- });
238
- }, [contentLayout, isDuo, layout, headerMargin, edgeLeft, edgeRight]);
141
+ if (!IS_STRETCH_FRAME_ENABLED || contentLayout !== 'stretch' || isDuo) {
142
+ return undefined;
143
+ }
144
+ // the header content row already sits this far in on large iOS windows
145
+ const shift = layout.frameInset - layout.sidePadding;
146
+ const containerShift = Math.max(0, shift - getHeaderMargin(width));
147
+ return {
148
+ headerLeftContainerStyle: { paddingLeft: containerShift },
149
+ headerRightContainerStyle: { paddingRight: containerShift },
150
+ headerTitleContainerStyle: {
151
+ ...TITLE_CONTAINER_RESET,
152
+ left: layout.titleGap,
153
+ maxWidth: getTitleBudget(layout),
154
+ },
155
+ };
156
+ }, [contentLayout, isDuo, layout, width]);
239
157
  };
240
158
 
241
159
  export type { HeaderContentLayout, HeaderLayout };
@@ -244,9 +162,7 @@ export {
244
162
  HeaderBarMetrics,
245
163
  HEADER_FRAME_MAX_WIDTH,
246
164
  TITLE_CONTAINER_RESET,
247
- getHeaderFrameOptions,
248
165
  getHeaderLayout,
249
- getSearchHeaderHeight,
250
166
  getTitleBudget,
251
167
  useHeaderLayout,
252
168
  useHeaderFrameOptions,