@momo-kits/foundation 0.169.17-beta.8 → 0.169.17-beta.9

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.
@@ -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
  />
@@ -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,
@@ -78,6 +78,14 @@ const clamp = (value: number, min: number, max: number) => {
78
78
  return Math.min(Math.max(value, min), max);
79
79
  };
80
80
 
81
+ /**
82
+ * True when the window's short side reaches a foldable inner display (Galaxy Z Fold,
83
+ * Pixel Fold, iPhone Duo inner); short side, so a phone in landscape stays a phone.
84
+ */
85
+ const isFoldableWindow = (width: number, height: number) => {
86
+ return Math.min(width, height) >= FOLDABLE_MIN_WIDTH;
87
+ };
88
+
81
89
  /**
82
90
  * Modal geometry for a window, pure so it can be tested without a device.
83
91
  */
@@ -88,10 +96,9 @@ const getModalLayout = ({
88
96
  isDuo,
89
97
  hinge,
90
98
  }: ModalLayoutInput): ModalLayout => {
91
- const shortSide = Math.min(width, height);
92
- // short side, so a phone in landscape stays a phone
93
- const isFoldable = isDuo || shortSide >= FOLDABLE_MIN_WIDTH;
94
- const isDuoOuter = isDuo && shortSide < FOLDABLE_MIN_WIDTH;
99
+ const isWideWindow = isFoldableWindow(width, height);
100
+ const isFoldable = isDuo || isWideWindow;
101
+ const isDuoOuter = isDuo && !isWideWindow;
95
102
  const hingeRight = hinge ? hinge.x + hinge.width : 0;
96
103
  const hasHinge = !!hinge && hinge.x > 0;
97
104
  const isHingeInWindow = hingeRight < width - insets.right;
@@ -166,6 +173,7 @@ const useModalLayout = (): ModalLayout => {
166
173
 
167
174
  export {
168
175
  getModalLayout,
176
+ isFoldableWindow,
169
177
  useModalLayout,
170
178
  POPUP_MAX_WIDTH,
171
179
  POPUP_MIN_WIDTH,
@@ -99,16 +99,10 @@ export interface HeaderAnimatedProps extends ViewProps {
99
99
  useScale?: boolean;
100
100
  aspectRatio?: '16/9' | '3/2' | '1/1';
101
101
  /**
102
- * Optional. On wide windows the image is centered at phone width × 1.2; this
102
+ * Optional. On wide windows the image keeps its phone width, centered; this
103
103
  * color fills the sides and fades to transparent downward. No fill when unset.
104
- * `bannerGradientColors` wins when both are set.
105
104
  */
106
105
  bannerBackgroundColor?: string;
107
- /**
108
- * Optional. Side fill behind the centered banner on wide windows, from the top
109
- * color to the bottom one: `[start, end]`. A single color fills solid.
110
- */
111
- bannerGradientColors?: string[];
112
106
  }
113
107
 
114
108
  export type AnimatedHeader = {
@@ -0,0 +1,93 @@
1
+ import React from 'react';
2
+ import { StyleSheet, TouchableOpacity, View } from 'react-native';
3
+ import { Colors, Spacing, Styles } from '../Consts';
4
+ import { Image } from '../Image';
5
+ import { Text } from '../Text';
6
+ import { Typography } from '../Text/types';
7
+ import styles from './styles';
8
+
9
+ const FLAG_SIZE = 24;
10
+
11
+ type CountryCodeViewProps = {
12
+ countryCode: string;
13
+ countryFlag: string;
14
+ typography: Typography;
15
+ textColor: string;
16
+ dividerHeight: number;
17
+ componentId: string;
18
+ isDisabled: boolean;
19
+ onPress?: () => void;
20
+ };
21
+
22
+ /**
23
+ * Flag, dial code and divider ahead of a phone number. Only becomes a button
24
+ * when `onPress` is given, so the default render stays a plain view.
25
+ */
26
+ const CountryCodeView: React.FC<CountryCodeViewProps> = ({
27
+ countryCode,
28
+ countryFlag,
29
+ typography,
30
+ textColor,
31
+ dividerHeight,
32
+ componentId,
33
+ isDisabled,
34
+ onPress,
35
+ }) => {
36
+ const content = (
37
+ <>
38
+ <Image
39
+ source={{ uri: countryFlag }}
40
+ style={innerStyle.iconFlag}
41
+ resizeMode="contain"
42
+ accessibilityLabel={`${componentId}|leading-icon`}
43
+ />
44
+ <View style={{ width: Spacing.XS }} />
45
+ <Text typography={typography} color={textColor}>
46
+ {countryCode}
47
+ </Text>
48
+ </>
49
+ );
50
+
51
+ const renderContent = () => {
52
+ if (!onPress) {
53
+ return content;
54
+ }
55
+ return (
56
+ <TouchableOpacity
57
+ style={Styles.row}
58
+ onPress={onPress}
59
+ disabled={isDisabled}
60
+ accessibilityRole="button"
61
+ accessibilityLabel={`${componentId}|leading-icon-touch|${countryCode}`}
62
+ accessibilityState={{ disabled: isDisabled }}
63
+ >
64
+ {content}
65
+ </TouchableOpacity>
66
+ );
67
+ };
68
+
69
+ return (
70
+ <View style={[styles.leadingIconContainer, Styles.row]}>
71
+ {renderContent()}
72
+ <View
73
+ style={[
74
+ styles.phoneNumberDivider,
75
+ {
76
+ height: dividerHeight,
77
+ backgroundColor: Colors.black_04,
78
+ },
79
+ ]}
80
+ />
81
+ </View>
82
+ );
83
+ };
84
+
85
+ const innerStyle = StyleSheet.create({
86
+ iconFlag: {
87
+ width: FLAG_SIZE,
88
+ height: FLAG_SIZE,
89
+ marginHorizontal: Spacing.XXS,
90
+ },
91
+ });
92
+
93
+ export { CountryCodeView };