@momo-kits/foundation 0.169.17-beta.10 → 0.169.17-beta.13

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 (60) hide show
  1. package/Application/BottomSheet.tsx +2 -2
  2. package/Application/BottomTab/BottomTabBar.styles.ts +1 -1
  3. package/Application/BottomTab/DuoTabBar.styles.ts +1 -1
  4. package/Application/BottomTab/TabBarIcon.tsx +1 -1
  5. package/Application/BottomTab/index.tsx +1 -15
  6. package/Application/Components/HeaderExtendHeader.tsx +1 -3
  7. package/Application/Components/HeaderRight.tsx +3 -24
  8. package/Application/Components/SearchHeader.tsx +2 -3
  9. package/Application/ModalScreen.tsx +2 -2
  10. package/Application/StackScreen.tsx +6 -2
  11. package/Application/TooltipPortal.tsx +3 -3
  12. package/Application/headerLayout.ts +3 -7
  13. package/Application/hooks.ts +1 -1
  14. package/Application/modalLayout.ts +4 -12
  15. package/Application/types.tabs.ts +0 -8
  16. package/Button/index.tsx +2 -2
  17. package/Divider/DashDivider.tsx +2 -2
  18. package/Divider/index.tsx +3 -3
  19. package/FoundationList/index.tsx +1 -1
  20. package/Icon/types.ts +1 -2
  21. package/Image/index.tsx +70 -7
  22. package/Image/styles.ts +2 -0
  23. package/Image/types.ts +9 -1
  24. package/Input/Input.tsx +2 -2
  25. package/Input/InputMoney.tsx +7 -2
  26. package/Input/InputMoneyView.tsx +2 -2
  27. package/Input/InputOTP.tsx +2 -2
  28. package/Input/InputPhoneNumber.tsx +40 -22
  29. package/Input/InputSearch.tsx +2 -2
  30. package/Input/InputTextArea.tsx +2 -2
  31. package/Input/SearchTextTyping.tsx +2 -2
  32. package/Input/SystemTextInput.tsx +2 -1
  33. package/Input/TextTyping.tsx +7 -2
  34. package/Input/index.tsx +1 -14
  35. package/Layout/Screen.tsx +5 -11
  36. package/Layout/Section.tsx +3 -14
  37. package/Layout/screenFooter.tsx +21 -181
  38. package/Layout/screenHeader.tsx +41 -56
  39. package/Layout/screenTypes.ts +1 -16
  40. package/Layout/styles.ts +0 -10
  41. package/Layout/types.ts +0 -6
  42. package/Pagination/types.ts +6 -2
  43. package/package.json +28 -26
  44. package/Application/BottomTab/Legacy/BottomTabBar.styles.ts +0 -60
  45. package/Application/BottomTab/Legacy/BottomTabBar.tsx +0 -270
  46. package/Application/BottomTab/Legacy/CustomBottomTabItem.tsx +0 -153
  47. package/Application/BottomTab/Legacy/DuoBarCompression.tsx +0 -135
  48. package/Application/BottomTab/Legacy/DuoRailTabBar.tsx +0 -149
  49. package/Application/BottomTab/Legacy/DuoTabBar.parts.tsx +0 -202
  50. package/Application/BottomTab/Legacy/DuoTabBar.styles.ts +0 -123
  51. package/Application/BottomTab/Legacy/DuoTabBar.tsx +0 -151
  52. package/Application/BottomTab/Legacy/TabBarIcon.tsx +0 -113
  53. package/Application/BottomTab/Legacy/TabScreen.tsx +0 -177
  54. package/Application/BottomTab/Legacy/badge.ts +0 -41
  55. package/Application/BottomTab/Legacy/hooks.ts +0 -358
  56. package/Application/BottomTab/Legacy/index.styles.ts +0 -30
  57. package/Application/BottomTab/Legacy/index.tsx +0 -230
  58. package/Application/Components/useHeaderRightWidth.ts +0 -46
  59. package/Input/CountryCodeView.tsx +0 -93
  60. package/Layout/__tests__/screenFooter.test.ts +0 -56
@@ -6,10 +6,11 @@ import React, {
6
6
  useState,
7
7
  } from 'react';
8
8
  import {
9
- TextInput,
9
+ StyleSheet,
10
10
  TextInputFocusEvent,
11
11
  TouchableOpacity,
12
12
  View,
13
+ type TextInputInstance,
13
14
  } from 'react-native';
14
15
  import { useComponentId } from '../Application';
15
16
  import {
@@ -17,11 +18,12 @@ import {
17
18
  ComponentContext,
18
19
  MiniAppContext,
19
20
  } from '../Context';
21
+ import { Colors, Spacing, Styles } from '../Consts';
20
22
  import { Icon } from '../Icon';
21
- import { useScaleSize, exportFontFamily } from '../Text';
23
+ import { Image } from '../Image';
24
+ import { useScaleSize, Text, exportFontFamily } from '../Text';
22
25
  import { Typography } from '../Text/types';
23
26
  import { CLEAR_ICON_SIZE } from './constants';
24
- import { CountryCodeView } from './CountryCodeView';
25
27
  import { ErrorView } from './ErrorView';
26
28
  import { InputPhoneNumberProps } from './index';
27
29
  import { RenderTrailing } from './RenderTrailing';
@@ -34,13 +36,11 @@ const LARGE_FONT_SIZE = 18;
34
36
  const SMALL_DIVIDER_HEIGHT = 24;
35
37
  const LARGE_DIVIDER_HEIGHT = 32;
36
38
  const FOCUSED_BORDER_WIDTH = 1.5;
37
- const DEFAULT_COUNTRY_CODE = '+84';
38
- const DEFAULT_COUNTRY_FLAG =
39
- 'https://static.momocdn.net/app/img/icon/ic-qrcode-package/ic_vn_flag.png';
39
+ const FLAG_SIZE = 24;
40
40
 
41
41
  /**
42
- * Phone number input behind a country flag and dial code (Vietnam `+84` by
43
- * default), number pad by default, plus clear and trailing icons.
42
+ * Vietnamese phone number input with a fixed flag and `+84` prefix, number pad
43
+ * by default, plus clear and trailing icons.
44
44
  */
45
45
  const InputPhoneNumber = forwardRef(
46
46
  (
@@ -66,9 +66,6 @@ const InputPhoneNumber = forwardRef(
66
66
  editable = true,
67
67
  showClearIcon = true,
68
68
  defaultValue,
69
- countryCode = DEFAULT_COUNTRY_CODE,
70
- countryFlag = DEFAULT_COUNTRY_FLAG,
71
- onPressLeadingIcon,
72
69
  ...props
73
70
  }: InputPhoneNumberProps,
74
71
  ref,
@@ -79,7 +76,7 @@ const InputPhoneNumber = forwardRef(
79
76
  const [isFocused, setIsFocused] = useState(false);
80
77
  const [internalText, setInternalText] = useState(defaultValue || '');
81
78
  const hasValue = value !== undefined ? !!value : !!internalText;
82
- const inputRef = useRef<TextInput | null>(null);
79
+ const inputRef = useRef<TextInputInstance | null>(null);
83
80
  const componentName = 'InputPhoneNumber';
84
81
 
85
82
  const showBaseLineDebug = context?.features?.showBaseLineDebug ?? false;
@@ -185,16 +182,29 @@ const InputPhoneNumber = forwardRef(
185
182
  ]}
186
183
  >
187
184
  <View style={styles.inputView}>
188
- <CountryCodeView
189
- countryCode={countryCode}
190
- countryFlag={countryFlag}
191
- typography={typography}
192
- textColor={textColor}
193
- dividerHeight={dividerHeight}
194
- componentId={componentId}
195
- isDisabled={disabled || !editable}
196
- onPress={onPressLeadingIcon}
197
- />
185
+ <View style={[styles.leadingIconContainer, Styles.row]}>
186
+ <Image
187
+ source={{
188
+ uri: 'https://static.momocdn.net/app/img/icon/ic-qrcode-package/ic_vn_flag.png',
189
+ }}
190
+ style={innerStyle.iconFlag}
191
+ resizeMode="contain"
192
+ accessibilityLabel={`${componentId}|leading-icon`}
193
+ />
194
+ <View style={{ width: Spacing.XS }} />
195
+ <Text typography={typography} color={textColor}>
196
+ {'+84'}
197
+ </Text>
198
+ <View
199
+ style={[
200
+ styles.phoneNumberDivider,
201
+ {
202
+ height: dividerHeight,
203
+ backgroundColor: Colors.black_04,
204
+ },
205
+ ]}
206
+ />
207
+ </View>
198
208
  <SystemTextInput
199
209
  {...props}
200
210
  accessibilityLabel={`${componentId}`}
@@ -292,4 +302,12 @@ const InputPhoneNumber = forwardRef(
292
302
  },
293
303
  );
294
304
 
305
+ const innerStyle = StyleSheet.create({
306
+ iconFlag: {
307
+ width: FLAG_SIZE,
308
+ height: FLAG_SIZE,
309
+ marginHorizontal: Spacing.XXS,
310
+ },
311
+ });
312
+
295
313
  export default InputPhoneNumber;
@@ -7,10 +7,10 @@ import React, {
7
7
  useState,
8
8
  } from 'react';
9
9
  import {
10
- TextInput,
11
10
  TextInputFocusEvent,
12
11
  TouchableOpacity,
13
12
  View,
13
+ type TextInputInstance,
14
14
  } from 'react-native';
15
15
  import { useComponentId } from '../Application';
16
16
  import { HeaderBarMetrics } from '../Application/headerLayout';
@@ -76,7 +76,7 @@ const InputSearch: ForwardRefRenderFunction<InputRef, InputSearchProps> = (
76
76
  const [internalText, setInternalText] = useState(defaultValue || '');
77
77
  const currentValue = value !== undefined ? value : internalText;
78
78
  const hasValue = !!currentValue;
79
- const inputRef = useRef<TextInput | null>(null);
79
+ const inputRef = useRef<TextInputInstance | null>(null);
80
80
 
81
81
  const componentName = 'InputSearch';
82
82
 
@@ -7,10 +7,10 @@ import React, {
7
7
  useState,
8
8
  } from 'react';
9
9
  import {
10
- TextInput,
11
10
  TextInputFocusEvent,
12
11
  TouchableOpacity,
13
12
  View,
13
+ type TextInputInstance,
14
14
  } from 'react-native';
15
15
  import { setAutomationID, useComponentId } from '../Application';
16
16
  import { ApplicationContext, MiniAppContext } from '../Context';
@@ -70,7 +70,7 @@ const InputTextArea = forwardRef(
70
70
  const inputFontFamily = exportFontFamily('regular');
71
71
  const [isFocused, setIsFocused] = useState(false);
72
72
  const [inputValue, setInputValue] = useState(defaultValue ?? '');
73
- const inputRef = useRef<TextInput | null>(null);
73
+ const inputRef = useRef<TextInputInstance | null>(null);
74
74
 
75
75
  useEffect(() => {
76
76
  setInputValue(value ?? '');
@@ -1,6 +1,6 @@
1
1
  /* eslint-disable react-hooks/exhaustive-deps */
2
2
  import React, { FC, useEffect, useRef } from 'react';
3
- import { TextInput } from 'react-native';
3
+ import { TextInput, type TextInputInstance } from 'react-native';
4
4
  import { useScaleSize, exportFontFamily } from '../Text';
5
5
  import styles from './styles';
6
6
 
@@ -13,7 +13,7 @@ export const TextTyping: FC<any> = ({
13
13
  timeDelayEnd = 2000,
14
14
  timeDelayNextChar = 20,
15
15
  }) => {
16
- const textRef = useRef<TextInput>(null);
16
+ const textRef = useRef<TextInputInstance>(null);
17
17
  const scaledFontSize = useScaleSize(12);
18
18
  const typingFontFamily = exportFontFamily('regular');
19
19
 
@@ -4,11 +4,12 @@ import {
4
4
  TextInput,
5
5
  TextInputProps,
6
6
  TouchableOpacity,
7
+ type TextInputInstance,
7
8
  } from 'react-native';
8
9
  import { Styles } from '../Consts';
9
10
 
10
11
  interface SystemTextInputProps extends TextInputProps {
11
- ref?: React.RefObject<TextInput | null>;
12
+ ref?: React.RefObject<TextInputInstance | null>;
12
13
  }
13
14
 
14
15
  /**
@@ -1,6 +1,11 @@
1
1
  /* eslint-disable react-hooks/exhaustive-deps */
2
2
  import React, { FC, memo, useEffect, useRef } from 'react';
3
- import { Platform, TextInput, TextStyle } from 'react-native';
3
+ import {
4
+ Platform,
5
+ TextInput,
6
+ TextStyle,
7
+ type TextInputInstance,
8
+ } from 'react-native';
4
9
  import { Colors } from '../Consts';
5
10
  import { useScaleSize, exportFontFamily } from '../Text';
6
11
 
@@ -21,7 +26,7 @@ const TextTyping: FC<TextTypingProps> = ({
21
26
  timeDelayNextChar = 20,
22
27
  inputStyle = {},
23
28
  }) => {
24
- const textRef = useRef<TextInput>(null);
29
+ const textRef = useRef<TextInputInstance>(null);
25
30
  const scaledFontSize = useScaleSize(12);
26
31
  const inputFontFamily = exportFontFamily('regular');
27
32
 
package/Input/index.tsx CHANGED
@@ -351,22 +351,9 @@ export interface InputDropDownProps extends TouchableOpacityProps {
351
351
 
352
352
  export interface InputPhoneNumberProps extends InputProps {
353
353
  /**
354
- * Optional. Dial code shown verbatim before the number.
355
- * Defaults to `+84` if not provided.
354
+ * Optional. Currently unused: the displayed prefix is always `+84`.
356
355
  */
357
356
  countryCode?: string;
358
-
359
- /**
360
- * Optional. URL of the flag image shown before the dial code.
361
- * Defaults to the Vietnam flag if not provided.
362
- */
363
- countryFlag?: string;
364
-
365
- /**
366
- * Optional. Called when the flag or dial code is pressed (e.g. to pick a country),
367
- * which then reads as a button. Ignored while `disabled` or `editable={false}`.
368
- */
369
- onPressLeadingIcon?: () => void;
370
357
  }
371
358
 
372
359
  export type InputRef = {
package/Layout/Screen.tsx CHANGED
@@ -31,11 +31,7 @@ import { BottomTabInsetContext } from '../Application/BottomTab/BottomTabInset';
31
31
  import { ScreenProps } from './screenTypes';
32
32
  import { renderAnimatedHeader, renderContent } from './screenContent';
33
33
  import { createScrollHandlers } from './screenScroll';
34
- import {
35
- renderFooterSpacer,
36
- ScreenFooter,
37
- useFooterLayout,
38
- } from './screenFooter';
34
+ import { ScreenFooter } from './screenFooter';
39
35
  import { useScreenHeader } from './screenHeader';
40
36
  import { useScreenQuickReturn } from './screenQuickReturn';
41
37
 
@@ -57,8 +53,6 @@ const Screen = forwardRef(
57
53
  headerComponent: Header,
58
54
  footerComponent: Footer,
59
55
  marginFooter = true,
60
- footerStyle,
61
- footerHasImageBackground: hasImageFooter,
62
56
  layoutOffset = -56,
63
57
  headerRightWidth,
64
58
  backgroundColor,
@@ -84,7 +78,6 @@ const Screen = forwardRef(
84
78
  const insets = useSafeAreaInsets();
85
79
  const frame = useSafeAreaFrame();
86
80
  const heightHeader = useHeaderHeight();
87
- const footerLayout = useFooterLayout(layout, footerStyle, hasImageFooter);
88
81
 
89
82
  const animatedValue = useRef<Animated.Value>(
90
83
  customAnimatedValue ?? new Animated.Value(0),
@@ -202,7 +195,7 @@ const Screen = forwardRef(
202
195
 
203
196
  let floatingButtonBottom = bottomInset + Spacing.S;
204
197
  if (Footer) {
205
- floatingButtonBottom = 12 + footerLayout.overlap;
198
+ floatingButtonBottom = 12;
206
199
  } else if (isTab) {
207
200
  floatingButtonBottom = 12 + duoTabInset;
208
201
  }
@@ -292,7 +285,6 @@ const Screen = forwardRef(
292
285
  )}
293
286
 
294
287
  {useGridLayout ? renderContent(children, layout) : children}
295
- {renderFooterSpacer(footerLayout.overlap)}
296
288
  </Component>
297
289
 
298
290
  {floatingButtonProps && (
@@ -314,7 +306,9 @@ const Screen = forwardRef(
314
306
  <ScreenFooter
315
307
  footer={Footer}
316
308
  marginFooter={marginFooter}
317
- layout={footerLayout}
309
+ insetLeft={layout.insetLeft}
310
+ insetRight={layout.insetRight}
311
+ hasContentInset={hasContentInset}
318
312
  isTab={isTab}
319
313
  duoTabInset={duoTabInset}
320
314
  bottomInset={bottomInset}
@@ -24,22 +24,16 @@ export interface SectionProps extends ViewProps {
24
24
  * Optional. Background image for the Section component.
25
25
  */
26
26
  backgroundImage?: string;
27
-
28
- /**
29
- * Optional. Caps the row width, side margins excluded; a capped row is centered.
30
- */
31
- maxWidth?: number;
32
27
  }
33
28
 
34
29
  /**
35
- * Content-wide grid row (12 or 24 columns) with optional side margins, capped by
36
- * `maxWidth`; child Items size themselves from its GridContext.
30
+ * Content-wide grid row (12 or 24 columns) with optional side margins; child Items size
31
+ * themselves from its GridContext.
37
32
  */
38
33
  const Section: React.FC<SectionProps> = ({
39
34
  children,
40
35
  useMargin = true,
41
36
  backgroundImage,
42
- maxWidth,
43
37
  style,
44
38
  ...props
45
39
  }) => {
@@ -51,11 +45,7 @@ const Section: React.FC<SectionProps> = ({
51
45
  if (useMargin) {
52
46
  margin = 12;
53
47
  }
54
- const isCapped = maxWidth !== undefined;
55
- let widthSection = contentWidth - margin * 2;
56
- if (isCapped) {
57
- widthSection = Math.min(widthSection, maxWidth);
58
- }
48
+ const widthSection = contentWidth - margin * 2;
59
49
 
60
50
  const columnsWidth = widthSection - gutterSize * (numberOfColumns - 1);
61
51
  const sizePerSpan = columnsWidth / numberOfColumns - 1 / numberOfColumns;
@@ -78,7 +68,6 @@ const Section: React.FC<SectionProps> = ({
78
68
  style,
79
69
  styles.protectedStyle,
80
70
  styles.rowWrap,
81
- isCapped && styles.centered,
82
71
  {
83
72
  width: widthSection,
84
73
  marginHorizontal: margin,
@@ -1,54 +1,15 @@
1
- import React, { ReactNode, useCallback, useContext, useState } from 'react';
2
- import { LayoutChangeEvent, StyleProp, View, ViewStyle } from 'react-native';
3
- import { isFoldableWindow } from '../Application/modalLayout';
4
- import { ApplicationContext, MiniAppContext } from '../Context';
1
+ import React, { ReactNode } from 'react';
2
+ import { View } from 'react-native';
5
3
  import { Spacing } from '../Consts';
6
- import { ScreenLayout } from './layoutTypes';
7
- import { ScreenFooterStyle } from './types';
8
4
  import Section from './Section';
9
5
  import styles from './styles';
10
6
 
11
- // Foldable footer spec, shared with the Compose / SwiftUI kits
12
- const FOOTER_MAX_WIDTH = 600;
13
- const FOOTER_WIDE_MAX_WIDTH = 800;
14
- const FOOTER_WIDE_WINDOW_MIN_WIDTH = 800;
15
- const FOOTER_BORDER_WIDTH = 1;
16
-
17
- type FooterKind = 'phone' | 'anchored' | 'sheet';
18
-
19
- type FooterGeometry = { kind: FooterKind; width: number };
20
-
21
- type DesignSystemContext = {
22
- designSystemConfig?: { config?: { footerStyle?: unknown } };
23
- };
24
-
25
- type FooterGeometryInput = {
26
- width: number;
27
- height: number;
28
- contentWidth: number;
29
- footerStyle: ScreenFooterStyle;
30
- hasImageBackground: boolean;
31
- };
32
-
33
- type FooterLayout = FooterGeometry & {
34
- hasBorder: boolean;
35
- /**
36
- * `false` on a foldable with an image background, so the screen's image shows through.
37
- */
38
- hasSurface: boolean;
39
- insetLeft: number;
40
- insetRight: number;
41
- /**
42
- * Height the sheet overlaps the body by; 0 while the footer sits below the body.
43
- */
44
- overlap: number;
45
- handleLayout: (event: LayoutChangeEvent) => void;
46
- };
47
-
48
7
  type ScreenFooterProps = {
49
8
  footer: ReactNode;
50
9
  marginFooter: boolean;
51
- layout: FooterLayout;
10
+ insetLeft: number;
11
+ insetRight: number;
12
+ hasContentInset: boolean;
52
13
  isTab: boolean;
53
14
  duoTabInset: number;
54
15
  bottomInset: number;
@@ -56,168 +17,47 @@ type ScreenFooterProps = {
56
17
  };
57
18
 
58
19
  /**
59
- * The screen prop wins over the host's design system config; anything else is `anchored`.
60
- */
61
- const getFooterStyle = (
62
- footerStyle?: ScreenFooterStyle,
63
- configured?: unknown,
64
- ): ScreenFooterStyle => {
65
- if ((footerStyle ?? configured) === 'sheet') {
66
- return 'sheet';
67
- }
68
- return 'anchored';
69
- };
70
-
71
- /**
72
- * Footer kind and width (anchored content or sheet) for a window, pure so it can be
73
- * tested without a device. Phones, iPhone Duo outer included, keep the shadowed bar.
74
- */
75
- const getFooterGeometry = ({
76
- width,
77
- height,
78
- contentWidth,
79
- footerStyle,
80
- hasImageBackground,
81
- }: FooterGeometryInput): FooterGeometry => {
82
- if (!isFoldableWindow(width, height)) {
83
- return { kind: 'phone', width: contentWidth };
84
- }
85
-
86
- let maxWidth = FOOTER_MAX_WIDTH;
87
- if (width >= FOOTER_WIDE_WINDOW_MIN_WIDTH) {
88
- maxWidth = FOOTER_WIDE_MAX_WIDTH;
89
- }
90
- const footerWidth = Math.min(contentWidth - Spacing.M * 2, maxWidth);
91
- // an image background spans the window, so it never sits in a sheet
92
- const isSheet = footerStyle === 'sheet' && !hasImageBackground;
93
- return { kind: isSheet ? 'sheet' : 'anchored', width: footerWidth };
94
- };
95
-
96
- /**
97
- * Footer layout for the screen layout. A sheet overlaps the body, so its measured
98
- * height comes back as `overlap` for the body to pad its end by.
99
- */
100
- const useFooterLayout = (
101
- layout: ScreenLayout,
102
- footerStyle?: ScreenFooterStyle,
103
- hasImageBackground = false,
104
- ): FooterLayout => {
105
- const context: DesignSystemContext | undefined = useContext(MiniAppContext);
106
- const [height, setHeight] = useState(0);
107
- const handleLayout = useCallback((event: LayoutChangeEvent) => {
108
- setHeight(event.nativeEvent.layout.height);
109
- }, []);
110
-
111
- const configured = context?.designSystemConfig?.config?.footerStyle;
112
- const geometry = getFooterGeometry({
113
- width: layout.width,
114
- height: layout.height,
115
- contentWidth: layout.contentWidth,
116
- footerStyle: getFooterStyle(footerStyle, configured),
117
- hasImageBackground,
118
- });
119
-
120
- let overlap = 0;
121
- if (geometry.kind === 'sheet') {
122
- overlap = height;
123
- }
124
- return {
125
- ...geometry,
126
- hasBorder: geometry.kind === 'anchored' && !hasImageBackground,
127
- hasSurface: geometry.kind === 'phone' || !hasImageBackground,
128
- insetLeft: layout.insetLeft,
129
- insetRight: layout.insetRight,
130
- overlap,
131
- handleLayout,
132
- };
133
- };
134
-
135
- /**
136
- * Spacer at the end of the body so a sheet footer does not cover its last element.
137
- */
138
- const renderFooterSpacer = (overlap: number) => {
139
- if (!overlap) {
140
- return null;
141
- }
142
- return <View style={{ height: overlap }} />;
143
- };
144
-
145
- /**
146
- * Screen footer on the surface color above the home indicator or the floating tab bar.
147
- * Phones keep the top shadow; foldables cap the content under a full-width bar with a
148
- * top border (`anchored`) or in a centered sheet over the body (`sheet`).
20
+ * Screen footer on the surface color with a top shadow, padded above the home indicator,
21
+ * or above the floating tab bar on a tab screen.
149
22
  */
150
- const ScreenFooter = ({
23
+ export const ScreenFooter = ({
151
24
  footer,
152
25
  marginFooter,
153
- layout,
26
+ insetLeft,
27
+ insetRight,
28
+ hasContentInset,
154
29
  isTab,
155
30
  duoTabInset,
156
31
  bottomInset,
157
32
  surfaceColor,
158
33
  }: ScreenFooterProps) => {
159
- const { theme } = useContext(ApplicationContext);
160
34
  let bottomSpace = bottomInset;
161
35
  if (isTab && duoTabInset) {
162
36
  bottomSpace = duoTabInset;
163
37
  }
164
38
 
165
- const { kind, insetLeft, insetRight } = layout;
166
- const hasContentInset = insetLeft > 0 || insetRight > 0;
167
- const margin = marginFooter ? Spacing.M : 0;
168
-
169
- // one view tree for every kind, so folding keeps the footer content's state
170
- let containerStyle: StyleProp<ViewStyle> = [
171
- kind === 'phone' && hasContentInset && styles.footerClip,
172
- { marginLeft: insetLeft, marginRight: insetRight },
173
- ];
174
- let surfaceStyle: StyleProp<ViewStyle> = styles.shadow;
175
- let sectionMaxWidth: number | undefined;
176
- if (kind === 'anchored') {
177
- surfaceStyle = [
178
- styles.footerBar,
179
- layout.hasBorder && {
180
- borderTopWidth: FOOTER_BORDER_WIDTH,
181
- borderTopColor: theme.colors.border.default,
182
- },
183
- ];
184
- sectionMaxWidth = layout.width;
185
- }
186
- if (kind === 'sheet') {
187
- containerStyle = [containerStyle, { marginTop: -layout.overlap }];
188
- surfaceStyle = [styles.footerSheet, { width: layout.width }];
189
- sectionMaxWidth = layout.width - margin * 2;
190
- }
191
-
192
39
  return (
193
40
  <View
194
41
  pointerEvents={'box-none'}
195
- onLayout={layout.handleLayout}
196
- style={containerStyle}
42
+ style={[
43
+ hasContentInset && styles.footerClip,
44
+ {
45
+ marginLeft: insetLeft,
46
+ marginRight: insetRight,
47
+ },
48
+ ]}
197
49
  >
198
50
  <View
199
51
  style={[
200
- surfaceStyle,
52
+ styles.shadow,
201
53
  {
202
54
  paddingBottom: bottomSpace + Spacing.S,
203
- backgroundColor: layout.hasSurface ? surfaceColor : undefined,
55
+ backgroundColor: surfaceColor,
204
56
  },
205
57
  ]}
206
58
  >
207
- <Section useMargin={marginFooter} maxWidth={sectionMaxWidth}>
208
- {footer}
209
- </Section>
59
+ <Section useMargin={marginFooter}>{footer}</Section>
210
60
  </View>
211
61
  </View>
212
62
  );
213
63
  };
214
-
215
- export type { FooterLayout };
216
-
217
- export {
218
- ScreenFooter,
219
- getFooterGeometry,
220
- getFooterStyle,
221
- renderFooterSpacer,
222
- useFooterLayout,
223
- };