@momo-kits/foundation 0.169.6 → 0.169.7-beta.10

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 (143) hide show
  1. package/Application/BottomSheet.hooks.ts +8 -8
  2. package/Application/BottomSheet.parts.tsx +34 -44
  3. package/Application/BottomSheet.tsx +37 -40
  4. package/Application/BottomTab/ActiveIndicator.tsx +14 -15
  5. package/Application/BottomTab/BottomTabBar.tsx +62 -49
  6. package/Application/BottomTab/BottomTabInset.tsx +4 -8
  7. package/Application/BottomTab/CurvedContainer.tsx +12 -14
  8. package/Application/BottomTab/CustomBottomTabItem.tsx +13 -13
  9. package/Application/BottomTab/DuoBarCompression.tsx +19 -13
  10. package/Application/BottomTab/DuoRailTabBar.tsx +24 -20
  11. package/Application/BottomTab/DuoTabBar.tsx +10 -8
  12. package/Application/BottomTab/TabBarIcon.tsx +29 -15
  13. package/Application/BottomTab/TabScreen.tsx +5 -1
  14. package/Application/BottomTab/index.tsx +30 -33
  15. package/Application/BottomTab/metrics.ts +23 -23
  16. package/Application/BottomTab/tabItems.ts +1 -1
  17. package/Application/BottomTab/usePressLift.ts +2 -2
  18. package/Application/Components/BackgroundImageView.tsx +0 -4
  19. package/Application/Components/DuoGlassBackground.tsx +4 -5
  20. package/Application/Components/HeaderAnimated.tsx +0 -4
  21. package/Application/Components/HeaderBackground.tsx +0 -4
  22. package/Application/Components/HeaderExtendHeader.tsx +10 -11
  23. package/Application/Components/HeaderLeft.tsx +1 -2
  24. package/Application/Components/HeaderRight.tsx +1 -2
  25. package/Application/Components/HeaderTitle.shared.ts +9 -11
  26. package/Application/Components/HeaderTitle.tsx +3 -4
  27. package/Application/Components/HeaderToolkitAction.tsx +20 -17
  28. package/Application/Components/NavigationButton.tsx +1 -2
  29. package/Application/Components/SearchHeader.tsx +10 -17
  30. package/Application/Components/TitleJourney.tsx +2 -2
  31. package/Application/Components/TitleLocation.tsx +2 -2
  32. package/Application/Components/TitleUser.tsx +2 -2
  33. package/Application/Components/useToolkitActions.tsx +32 -17
  34. package/Application/KitAdoption/AdoptionBadge.tsx +119 -0
  35. package/Application/KitAdoption/AdoptionProbe.tsx +166 -0
  36. package/Application/KitAdoption/AdoptionStore.ts +80 -0
  37. package/Application/KitAdoption/Authorship/utils.ts +137 -0
  38. package/Application/KitAdoption/Slots/utils.ts +68 -0
  39. package/Application/KitAdoption/constants.ts +120 -0
  40. package/Application/KitAdoption/index.ts +12 -0
  41. package/Application/KitAdoption/styles.ts +55 -0
  42. package/Application/KitAdoption/types.ts +61 -0
  43. package/Application/KitAdoption/utils.ts +376 -0
  44. package/Application/Localize.ts +0 -7
  45. package/Application/ModalScreen.tsx +10 -10
  46. package/Application/Navigation.ts +16 -14
  47. package/Application/NavigationContainer.tsx +18 -19
  48. package/Application/Navigator.ts +48 -20
  49. package/Application/ScaleSizeProvider.tsx +6 -13
  50. package/Application/StackScreen.tracking.ts +33 -11
  51. package/Application/StackScreen.tsx +54 -10
  52. package/Application/TooltipPortal.tsx +5 -12
  53. package/Application/WidgetContainer.tsx +4 -10
  54. package/Application/__tests__/KitAdoption.integration.test.tsx +253 -0
  55. package/Application/__tests__/KitAdoption.test.ts +283 -0
  56. package/Application/__tests__/KitAdoptionAuthorship.test.ts +132 -0
  57. package/Application/__tests__/KitAdoptionStore.test.ts +110 -0
  58. package/Application/__tests__/KitAdoptionStructural.test.ts +193 -0
  59. package/Application/__tests__/modalLayout.test.ts +128 -0
  60. package/Application/modalLayout.ts +14 -13
  61. package/Application/navigationOptions.tsx +17 -21
  62. package/Badge/Badge.tsx +0 -5
  63. package/Badge/BadgeDot.tsx +0 -1
  64. package/Badge/BadgeDotAnimation.tsx +7 -15
  65. package/Badge/BadgeRibbon.tsx +38 -46
  66. package/Badge/Shape.tsx +0 -2
  67. package/Badge/types.ts +2 -2
  68. package/Button/index.tsx +16 -5
  69. package/Button/utils.ts +15 -9
  70. package/CheckBox/index.tsx +0 -4
  71. package/Consts/theme.ts +10 -10
  72. package/Context/index.ts +1 -5
  73. package/Divider/DashDivider.tsx +0 -1
  74. package/Divider/index.tsx +0 -4
  75. package/FoundationList/index.tsx +0 -4
  76. package/Icon/index.tsx +6 -6
  77. package/Icon/types.ts +1 -1
  78. package/IconButton/index.tsx +12 -4
  79. package/Image/index.tsx +7 -9
  80. package/Input/Input.tsx +9 -8
  81. package/Input/InputDropDown.tsx +12 -10
  82. package/Input/InputMoney.tsx +8 -12
  83. package/Input/InputMoneyView.tsx +7 -14
  84. package/Input/InputOTP.tsx +33 -35
  85. package/Input/InputPhoneNumber.tsx +9 -8
  86. package/Input/InputSearch.tsx +6 -4
  87. package/Input/InputTextArea.tsx +0 -4
  88. package/Input/SearchTextTyping.tsx +0 -4
  89. package/Input/SystemTextInput.tsx +2 -7
  90. package/Input/TextTyping.tsx +0 -4
  91. package/Input/common.tsx +12 -26
  92. package/Input/index.tsx +20 -17
  93. package/Input/moneyUtils.ts +4 -10
  94. package/Input/styles.ts +5 -0
  95. package/Input/utils.ts +12 -14
  96. package/Layout/Card.tsx +13 -16
  97. package/Layout/FloatingButton.tsx +0 -4
  98. package/Layout/Item.tsx +2 -6
  99. package/Layout/ItemList.tsx +7 -9
  100. package/Layout/ItemSectionList.tsx +1 -2
  101. package/Layout/ReservedRegions.tsx +25 -25
  102. package/Layout/Screen.tsx +58 -56
  103. package/Layout/Section.tsx +13 -17
  104. package/Layout/TrackingScope.tsx +0 -1
  105. package/Layout/constants.ts +19 -0
  106. package/Layout/screenContent.tsx +2 -4
  107. package/Layout/screenFooter.tsx +18 -28
  108. package/Layout/screenHeader.tsx +31 -34
  109. package/Layout/screenQuickReturn.tsx +20 -17
  110. package/Layout/screenScroll.ts +7 -4
  111. package/Layout/screenTypes.ts +2 -3
  112. package/Layout/types.ts +41 -3
  113. package/Layout/useGridSystem.ts +49 -0
  114. package/Layout/utils.ts +37 -38
  115. package/Loader/DotLoader.tsx +0 -4
  116. package/Loader/Loader.tsx +0 -4
  117. package/Loader/ProgressBar.tsx +0 -1
  118. package/Loader/Spinner.tsx +0 -4
  119. package/Loader/utils.ts +7 -11
  120. package/Pagination/Dot.tsx +0 -4
  121. package/Pagination/PaginationDot.tsx +0 -1
  122. package/Pagination/PaginationNumber.tsx +3 -5
  123. package/Pagination/PaginationScroll.tsx +0 -5
  124. package/Pagination/PaginationWhiteDot.tsx +0 -1
  125. package/Pagination/index.tsx +0 -4
  126. package/Pagination/types.ts +2 -2
  127. package/Popup/PopupNotify.tsx +48 -44
  128. package/Popup/PopupPromotion.tsx +7 -4
  129. package/Popup/types.ts +4 -4
  130. package/Popup/utils.ts +0 -4
  131. package/Radio/index.tsx +0 -4
  132. package/Skeleton/index.tsx +0 -8
  133. package/Switch/index.tsx +0 -1
  134. package/Tag/index.tsx +1 -5
  135. package/Tag/types.ts +3 -3
  136. package/Text/index.tsx +3 -14
  137. package/Text/styles.ts +1 -1
  138. package/Text/types.ts +6 -1
  139. package/Text/utils.ts +4 -20
  140. package/Title/index.tsx +32 -41
  141. package/ViewBoundary/index.tsx +2 -4
  142. package/index.ts +6 -0
  143. package/package.json +1 -1
package/Layout/Card.tsx CHANGED
@@ -1,12 +1,13 @@
1
1
  import React, { useContext } from 'react';
2
2
  import { View, ViewProps } from 'react-native';
3
- import { useGridSystem, useScreenLayout } from './utils';
3
+ import { GRID_GUTTER, GRID_MARGIN } from './constants';
4
+ import { useGridSystem } from './useGridSystem';
4
5
  import { GridContextProps } from './types';
5
6
  import { GridContext } from './index';
6
7
  import { Image } from '../Image';
7
8
  import { ApplicationContext } from '../Context';
8
9
  import styles from './styles';
9
- import { Radius, Shadow, Spacing } from '../Consts';
10
+ import { Radius, Shadow } from '../Consts';
10
11
 
11
12
  export interface CardProps extends ViewProps {
12
13
  /**
@@ -20,10 +21,6 @@ export interface CardProps extends ViewProps {
20
21
  useShadow?: boolean;
21
22
  }
22
23
 
23
- /**
24
- * Surface card across the content width minus 12pt margins, with its own grid for child
25
- * Items; optional background image and light shadow.
26
- */
27
24
  const Card: React.FC<CardProps> = ({
28
25
  children,
29
26
  style,
@@ -32,19 +29,19 @@ const Card: React.FC<CardProps> = ({
32
29
  ...props
33
30
  }) => {
34
31
  const { theme } = useContext(ApplicationContext);
35
- const { numberOfColumns } = useGridSystem();
36
- const { contentWidth } = useScreenLayout();
32
+ const { numberOfColumns, gridWidth, gridOffset } = useGridSystem();
37
33
 
38
- const gutterSize = 8;
39
- const margin = 12;
40
- const widthSection = contentWidth - margin * 2;
41
- const innerWidth = widthSection - margin * 2;
42
- const columnsWidth = innerWidth - gutterSize * (numberOfColumns - 1);
43
- const sizePerSpan = columnsWidth / numberOfColumns - 1 / numberOfColumns;
34
+ const gutterSize = GRID_GUTTER;
35
+ const margin = GRID_MARGIN;
36
+ const widthSection = gridWidth - margin * 2;
37
+ let sizePerSpan =
38
+ (widthSection - margin * 2 - gutterSize * (numberOfColumns - 1)) /
39
+ numberOfColumns -
40
+ 1 / numberOfColumns;
44
41
 
45
42
  const gridContext: GridContextProps = {
46
43
  numberOfColumns,
47
- gutterSize: Spacing.S,
44
+ gutterSize: GRID_GUTTER,
48
45
  sizePerSpan,
49
46
  getSizeSpan: span => {
50
47
  return sizePerSpan * span + gutterSize * (span - 1);
@@ -63,7 +60,7 @@ const Card: React.FC<CardProps> = ({
63
60
  styles.card,
64
61
  {
65
62
  width: widthSection,
66
- marginHorizontal: margin,
63
+ marginHorizontal: gridOffset + margin,
67
64
  gap: gutterSize,
68
65
  },
69
66
  !!backgroundImage && { backgroundColor: undefined },
@@ -31,10 +31,6 @@ export interface FloatingButtonProps {
31
31
  renderComponent?: () => React.ReactNode;
32
32
  }
33
33
 
34
- /**
35
- * Floating action button above the screen bottom. With a label and a scroll value it
36
- * shrinks to its icon while scrolling down and expands again on scroll up.
37
- */
38
34
  export const FloatingButton: React.FC<FloatingButtonProps> = ({
39
35
  renderComponent,
40
36
  label = '',
package/Layout/Item.tsx CHANGED
@@ -7,20 +7,16 @@ import { SpanNumber } from './types';
7
7
 
8
8
  export interface ItemProps extends ViewProps {
9
9
  /**
10
- * Width in grid columns (1-12). Defaults to the full row.
10
+ * Represents the width of the Card component in terms of span numbers (1-36, out of the grid's 12, 24 or 36 columns).
11
11
  */
12
12
  widthSpan?: SpanNumber;
13
13
 
14
14
  /**
15
- * Optional. Height in grid spans (1-12). Unset keeps the content height.
15
+ * Optional. Represents the height of the Card component in terms of span numbers (1-36, out of the grid's 12, 24 or 36 columns).
16
16
  */
17
17
  heightSpan?: SpanNumber;
18
18
  }
19
19
 
20
- /**
21
- * Grid cell sized from the enclosing GridContext; outlined when the mini app turns on
22
- * the baseline debug feature.
23
- */
24
20
  const Item: React.FC<ItemProps> = ({
25
21
  widthSpan,
26
22
  heightSpan,
@@ -7,16 +7,12 @@ import { SpanNumber } from './types';
7
7
 
8
8
  export interface ItemListProps extends FlatListProps<any> {
9
9
  /**
10
- * Width of each item in grid columns (1-12). Defaults to the full row.
10
+ * Represents the width of the Card component in terms of span numbers (1-12).
11
11
  */
12
12
  widthSpan?: SpanNumber;
13
13
  data: any[];
14
14
  }
15
15
 
16
- /**
17
- * FlatList on the grid: `widthSpan` sets how many items share a row, and every item but
18
- * the first of a row gets the gutter on its left.
19
- */
20
16
  const ItemList = forwardRef(
21
17
  (
22
18
  {
@@ -34,9 +30,6 @@ const ItemList = forwardRef(
34
30
  const indexBegin = props?.data?.map(
35
31
  (_i: any, index: number) => index * numColumns,
36
32
  );
37
- const defaultKeyExtractor = (item: any, index: number) => {
38
- return (item?.id ?? item?.key ?? index).toString();
39
- };
40
33
  const _renderItem = (item: any) => {
41
34
  if (indexBegin?.includes(item?.index)) {
42
35
  return <Item widthSpan={widthItem}>{renderItem?.(item)}</Item>;
@@ -53,7 +46,12 @@ const ItemList = forwardRef(
53
46
  ref={ref as React.RefObject<FlatList>}
54
47
  {...props}
55
48
  key={`ItemList-${numColumns}`}
56
- keyExtractor={(props as any)?.keyExtractor ?? defaultKeyExtractor}
49
+ keyExtractor={
50
+ // prefer caller's keyExtractor; fallback to common id/key/index
51
+ (props as any)?.keyExtractor ??
52
+ ((item: any, index: number) =>
53
+ (item?.id ?? item?.key ?? index).toString())
54
+ }
57
55
  numColumns={numColumns}
58
56
  renderItem={_renderItem}
59
57
  horizontal={false}
@@ -7,12 +7,11 @@ import { SpanNumber } from './types';
7
7
 
8
8
  export interface ItemSectionListProps extends SectionListProps<any> {
9
9
  /**
10
- * Width of each item in grid columns (1-12). Defaults to the full row.
10
+ * Represents the width of the Card component in terms of span numbers (1-12).
11
11
  */
12
12
  widthSpan?: SpanNumber;
13
13
  }
14
14
 
15
- /** SectionList whose items sit on the grid, `widthSpan` columns wide, a gutter apart. */
16
15
  const ItemSectionList: FC<ItemSectionListProps> = ({
17
16
  renderItem,
18
17
  widthSpan,
@@ -19,43 +19,43 @@ try {
19
19
  }
20
20
 
21
21
  /**
22
- * Screen regions the system currently occludes, relative to the provider, which fills
23
- * the root view so they line up with window coordinates.
22
+ * screen regions the system currently occludes, relative to the provider, which fills
23
+ * the root view so they line up with window coordinates
24
24
  */
25
25
  const ReservedRegionsContext = createContext<ReservedRegion[]>([]);
26
26
 
27
27
  /**
28
- * Vertical seam splitting the display into left and right halves, e.g. iPhone Duo
29
- * half folded. `undefined` while the display is flat or the system reports none.
28
+ * vertical seam splitting the display into left and right halves, e.g. iPhone Duo
29
+ * half folded. `undefined` while the display is flat or the system reports none
30
30
  */
31
31
  const HingeContext = createContext<ReservedRegion | undefined>(undefined);
32
32
 
33
- /** Frame of the vertical hinge (see HingeContext), `undefined` while the display is flat. */
34
33
  const useHinge = () => useContext(HingeContext);
35
34
 
36
35
  /**
37
- * Provides the occlusion regions and the vertical division (hinge) reported by the native
38
- * provider.
36
+ * keeps the occlusion regions and the vertical division reported by the native provider
39
37
  */
40
38
  const OcclusionRegions: React.FC<{
41
39
  useRegions: NativeReservedRegions['useReservedRegions'];
42
40
  children: ReactNode;
43
41
  }> = ({ useRegions, children }) => {
44
42
  const regions = useRegions();
45
- const occlusion = useMemo(() => {
46
- return regions
47
- .filter(region => region.kind === 'occlusion')
48
- .map(region => region.frame);
49
- }, [regions]);
50
- const hinge = useMemo(() => {
51
- const division = regions.find(region => {
52
- if (region.kind !== 'division') {
53
- return false;
54
- }
55
- return region.frame.height > region.frame.width;
56
- });
57
- return division?.frame;
58
- }, [regions]);
43
+ const occlusion = useMemo(
44
+ () =>
45
+ regions
46
+ .filter(region => region.kind === 'occlusion')
47
+ .map(region => region.frame),
48
+ [regions],
49
+ );
50
+ const hinge = useMemo(
51
+ () =>
52
+ regions.find(
53
+ region =>
54
+ region.kind === 'division' &&
55
+ region.frame.height > region.frame.width,
56
+ )?.frame,
57
+ [regions],
58
+ );
59
59
 
60
60
  return (
61
61
  <ReservedRegionsContext.Provider value={occlusion}>
@@ -65,8 +65,8 @@ const OcclusionRegions: React.FC<{
65
65
  };
66
66
 
67
67
  /**
68
- * Tracks the system occlusion regions (iOS 27.1+), e.g. the iPhone Duo status bar
69
- * cluster growing for a call or a Live Activity.
68
+ * tracks the system occlusion regions (iOS 27.1+), e.g. the iPhone Duo status bar
69
+ * cluster growing for a call or a Live Activity
70
70
  */
71
71
  const ReservedRegionsProvider: React.FC<{ children: ReactNode }> = ({
72
72
  children,
@@ -75,8 +75,8 @@ const ReservedRegionsProvider: React.FC<{ children: ReactNode }> = ({
75
75
  return <>{children}</>;
76
76
  }
77
77
 
78
- const NativeProvider = nativeLib.ReservedRegionsProvider;
79
- const { useReservedRegions } = nativeLib;
78
+ const { ReservedRegionsProvider: NativeProvider, useReservedRegions } =
79
+ nativeLib;
80
80
  return (
81
81
  <NativeProvider style={styles.container}>
82
82
  <OcclusionRegions useRegions={useReservedRegions}>
package/Layout/Screen.tsx CHANGED
@@ -37,10 +37,6 @@ import { useScreenQuickReturn } from './screenQuickReturn';
37
37
 
38
38
  export type { ScreenProps };
39
39
 
40
- /**
41
- * Screen container: sets the navigation header, lays children on the grid, and adds the
42
- * scroll view, floating button and footer, with iPhone Duo side bar and tab bar insets.
43
- */
44
40
  const Screen = forwardRef(
45
41
  (
46
42
  {
@@ -112,12 +108,14 @@ const Screen = forwardRef(
112
108
  const isIOS = Platform.OS === 'ios';
113
109
  const bottomInset = isIOS ? Math.min(insets.bottom, 21) : insets.bottom;
114
110
  const hasSideBar = !!layout.sideBar;
115
- const isPlainHeader = headerType === 'default' || headerType === 'extended';
116
- const hasCustomHeader = !!animatedHeader || !!inputSearchProps;
117
- const useDuoGlass = hasSideBar && isPlainHeader && !hasCustomHeader;
111
+ const useDuoGlass =
112
+ hasSideBar &&
113
+ (headerType === 'default' || headerType === 'extended') &&
114
+ !animatedHeader &&
115
+ !inputSearchProps;
118
116
 
119
- const hasOverlayHeader = useDuoGlass || !!animatedHeader;
120
- const useQuickReturn = hasSideBar && scrollable && hasOverlayHeader;
117
+ const useQuickReturn =
118
+ hasSideBar && scrollable && (useDuoGlass || !!animatedHeader);
121
119
  const { quickReturnOptions, snapQuickReturnHeader } = useScreenQuickReturn(
122
120
  sharedValue,
123
121
  useQuickReturn,
@@ -125,10 +123,18 @@ const Screen = forwardRef(
125
123
  );
126
124
 
127
125
  let keyboardOffset = heightHeader - bottomInset;
128
- if (headerType === 'extended' || hasCustomHeader || useDuoGlass) {
126
+ if (
127
+ headerType === 'extended' ||
128
+ animatedHeader ||
129
+ inputSearchProps ||
130
+ useDuoGlass
131
+ ) {
129
132
  keyboardOffset = -bottomInset;
130
133
  }
131
134
 
135
+ /**
136
+ * inject params for screen tracking
137
+ */
132
138
  screen?.onSetParams?.(trackingParams);
133
139
 
134
140
  const { setSearchHeader, currentTint } = useScreenHeader({
@@ -146,7 +152,9 @@ const Screen = forwardRef(
146
152
  layoutOffset,
147
153
  });
148
154
 
149
- // mutates the content node so callers keep its methods plus the header setters
155
+ /**
156
+ * expose ref for screen
157
+ */
150
158
  useImperativeHandle(ref, () => {
151
159
  return Object.assign(screenRef.current || {}, {
152
160
  setOptions: (params: NavigationOptions) => {
@@ -157,18 +165,19 @@ const Screen = forwardRef(
157
165
  });
158
166
  });
159
167
 
160
- const scrollHandlers = createScrollHandlers({
161
- scrollable,
162
- animatedValue: animatedValue.current,
163
- sharedValue,
164
- scrollViewProps,
165
- animatedHeader,
166
- inputSearchProps,
167
- currentTint,
168
- navigation,
169
- snapQuickReturnHeader,
170
- ref,
171
- });
168
+ const { handleScroll, handleScrollEnd, handleMomentumScrollEnd } =
169
+ createScrollHandlers({
170
+ scrollable,
171
+ animatedValue: animatedValue.current,
172
+ sharedValue,
173
+ scrollViewProps,
174
+ animatedHeader,
175
+ inputSearchProps,
176
+ currentTint,
177
+ navigation,
178
+ snapQuickReturnHeader,
179
+ ref,
180
+ });
172
181
  const Component: any = scrollable ? Animated.ScrollView : View;
173
182
 
174
183
  const getHeight = () => {
@@ -198,35 +207,6 @@ const Screen = forwardRef(
198
207
  floatingButtonBottom = 12 + duoTabInset;
199
208
  }
200
209
 
201
- const renderHeaderLayer = () => {
202
- if (useDuoGlass) {
203
- return (
204
- <DuoScrollGradient
205
- animatedValue={sharedValue}
206
- gradientColor={gradientColor}
207
- headerBackground={headerBackground}
208
- heightHeader={heightHeader}
209
- extended={headerType === 'extended'}
210
- followScroll={useQuickReturn}
211
- />
212
- );
213
- }
214
- return (
215
- <HeaderExtendHeader
216
- headerType={headerType}
217
- heightHeader={heightHeader}
218
- headerRightWidth={headerRightWidth}
219
- animatedValue={sharedValue}
220
- inputSearchProps={inputSearchProps}
221
- navigation={navigation}
222
- inputSearchRef={inputSearchRef}
223
- useShadowHeader={useShadowHeader}
224
- gradientColor={gradientColor}
225
- headerBackground={headerBackground}
226
- />
227
- );
228
- };
229
-
230
210
  return (
231
211
  <View
232
212
  style={[
@@ -237,7 +217,29 @@ const Screen = forwardRef(
237
217
  },
238
218
  ]}
239
219
  >
240
- {renderHeaderLayer()}
220
+ {useDuoGlass ? (
221
+ <DuoScrollGradient
222
+ animatedValue={sharedValue}
223
+ gradientColor={gradientColor}
224
+ headerBackground={headerBackground}
225
+ heightHeader={heightHeader}
226
+ extended={headerType === 'extended'}
227
+ followScroll={useQuickReturn}
228
+ />
229
+ ) : (
230
+ <HeaderExtendHeader
231
+ headerType={headerType}
232
+ heightHeader={heightHeader}
233
+ headerRightWidth={headerRightWidth}
234
+ animatedValue={sharedValue}
235
+ inputSearchProps={inputSearchProps}
236
+ navigation={navigation}
237
+ inputSearchRef={inputSearchRef}
238
+ useShadowHeader={useShadowHeader}
239
+ gradientColor={gradientColor}
240
+ headerBackground={headerBackground}
241
+ />
242
+ )}
241
243
 
242
244
  <KeyboardAvoidingView
243
245
  style={[
@@ -257,9 +259,9 @@ const Screen = forwardRef(
257
259
  {...scrollViewProps}
258
260
  ref={screenRef}
259
261
  showsVerticalScrollIndicator={false}
260
- onScroll={scrollHandlers.handleScroll}
261
- onScrollEndDrag={scrollHandlers.handleScrollEnd}
262
- onMomentumScrollEnd={scrollHandlers.handleMomentumScrollEnd}
262
+ onScroll={handleScroll}
263
+ onScrollEndDrag={handleScrollEnd}
264
+ onMomentumScrollEnd={handleMomentumScrollEnd}
263
265
  scrollEventThrottle={16}
264
266
  style={[
265
267
  Styles.flex,
@@ -1,11 +1,11 @@
1
1
  import React from 'react';
2
2
  import { View, ViewProps } from 'react-native';
3
- import { useGridSystem, useScreenLayout } from './utils';
3
+ import { GRID_GUTTER, GRID_MARGIN } from './constants';
4
+ import { useGridSystem } from './useGridSystem';
4
5
  import { GridContextProps } from './types';
5
6
  import { GridContext } from './index';
6
7
  import styles from './styles';
7
8
  import { Image } from '../Image';
8
- import { Spacing } from '../Consts';
9
9
 
10
10
  export interface SectionProps extends ViewProps {
11
11
  /**
@@ -15,8 +15,8 @@ export interface SectionProps extends ViewProps {
15
15
  expanded?: boolean;
16
16
 
17
17
  /**
18
- * Optional. If `true`, 12pt side margins are applied to the Section component.
19
- * Defaults to `true`.
18
+ * Optional. If `true`, margin will be applied to the Section component.
19
+ * Defaults to `false` if not provided.
20
20
  */
21
21
  useMargin?: boolean;
22
22
 
@@ -26,10 +26,6 @@ export interface SectionProps extends ViewProps {
26
26
  backgroundImage?: string;
27
27
  }
28
28
 
29
- /**
30
- * Content-wide grid row (12 or 24 columns) with optional side margins; child Items size
31
- * themselves from its GridContext.
32
- */
33
29
  const Section: React.FC<SectionProps> = ({
34
30
  children,
35
31
  useMargin = true,
@@ -37,22 +33,22 @@ const Section: React.FC<SectionProps> = ({
37
33
  style,
38
34
  ...props
39
35
  }) => {
40
- const { numberOfColumns } = useGridSystem();
41
- const { contentWidth } = useScreenLayout();
36
+ const { numberOfColumns, gridWidth, gridOffset } = useGridSystem();
42
37
 
43
- const gutterSize = 12;
38
+ const gutterSize = GRID_GUTTER;
44
39
  let margin = 0;
45
40
  if (useMargin) {
46
- margin = 12;
41
+ margin = GRID_MARGIN;
47
42
  }
48
- const widthSection = contentWidth - margin * 2;
43
+ const widthSection = gridWidth - margin * 2;
49
44
 
50
- const columnsWidth = widthSection - gutterSize * (numberOfColumns - 1);
51
- const sizePerSpan = columnsWidth / numberOfColumns - 1 / numberOfColumns;
45
+ const sizePerSpan =
46
+ (widthSection - gutterSize * (numberOfColumns - 1)) / numberOfColumns -
47
+ 1 / numberOfColumns;
52
48
 
53
49
  const gridContext: GridContextProps = {
54
50
  numberOfColumns,
55
- gutterSize: Spacing.M,
51
+ gutterSize: GRID_GUTTER,
56
52
  sizePerSpan,
57
53
  getSizeSpan: span => {
58
54
  return span * sizePerSpan + gutterSize * (span - 1);
@@ -70,7 +66,7 @@ const Section: React.FC<SectionProps> = ({
70
66
  styles.rowWrap,
71
67
  {
72
68
  width: widthSection,
73
- marginHorizontal: margin,
69
+ marginHorizontal: gridOffset + margin,
74
70
  gap: gutterSize,
75
71
  },
76
72
  ]}
@@ -1,7 +1,6 @@
1
1
  import React from 'react';
2
2
  import { TrackingScopeContext } from '../Context';
3
3
 
4
- /** Names a tracking scope; components inside prefix their component ids with it. */
5
4
  const TrackingScope = ({
6
5
  scopeName,
7
6
  children,
@@ -0,0 +1,19 @@
1
+ const GRID_MARGIN = 12;
2
+ const GRID_GUTTER = 12;
3
+ const GRID_PHONE_MAX_WIDTH = 600;
4
+ const GRID_TABLET_MIN_WIDTH = 800;
5
+ const GRID_DESKTOP_MIN_WIDTH = 1100;
6
+ const GRID_PHONE_COLUMNS = 12;
7
+ const GRID_TABLET_COLUMNS = 24;
8
+ const GRID_DESKTOP_COLUMNS = 36;
9
+
10
+ export {
11
+ GRID_DESKTOP_COLUMNS,
12
+ GRID_DESKTOP_MIN_WIDTH,
13
+ GRID_GUTTER,
14
+ GRID_MARGIN,
15
+ GRID_PHONE_COLUMNS,
16
+ GRID_PHONE_MAX_WIDTH,
17
+ GRID_TABLET_COLUMNS,
18
+ GRID_TABLET_MIN_WIDTH,
19
+ };
@@ -9,8 +9,7 @@ import { AnimatedHeader } from '../Application/types';
9
9
  type ContentInset = { insetLeft: number; insetRight: number };
10
10
 
11
11
  /**
12
- * Wraps each screen child (Fragments flattened) in a view with the screen's top spacing
13
- * and side insets; a child with `useMargin: false` gets no top spacing.
12
+ * build content for screen for grid rule
14
13
  */
15
14
  export const renderContent = (content: any, layout: ContentInset): any => {
16
15
  const results = validateChildren(content, [undefined]);
@@ -65,8 +64,7 @@ export const renderContent = (content: any, layout: ContentInset): any => {
65
64
  };
66
65
 
67
66
  /**
68
- * Animated banner from `animatedHeader.component`, clipped to the banner height plus
69
- * `layoutOffset`. Nothing without a component.
67
+ * render top navigation banner
70
68
  */
71
69
  export const renderAnimatedHeader = (
72
70
  animatedHeader: AnimatedHeader | undefined,
@@ -16,10 +16,6 @@ type ScreenFooterProps = {
16
16
  surfaceColor: string;
17
17
  };
18
18
 
19
- /**
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.
22
- */
23
19
  export const ScreenFooter = ({
24
20
  footer,
25
21
  marginFooter,
@@ -30,34 +26,28 @@ export const ScreenFooter = ({
30
26
  duoTabInset,
31
27
  bottomInset,
32
28
  surfaceColor,
33
- }: ScreenFooterProps) => {
34
- let bottomSpace = bottomInset;
35
- if (isTab && duoTabInset) {
36
- bottomSpace = duoTabInset;
37
- }
38
-
39
- return (
29
+ }: ScreenFooterProps) => (
30
+ <View
31
+ pointerEvents={'box-none'}
32
+ style={[
33
+ hasContentInset && styles.footerClip,
34
+ {
35
+ marginLeft: insetLeft,
36
+ marginRight: insetRight,
37
+ },
38
+ ]}
39
+ >
40
40
  <View
41
- pointerEvents={'box-none'}
42
41
  style={[
43
- hasContentInset && styles.footerClip,
42
+ styles.shadow,
44
43
  {
45
- marginLeft: insetLeft,
46
- marginRight: insetRight,
44
+ paddingBottom:
45
+ (isTab && duoTabInset ? duoTabInset : bottomInset) + Spacing.S,
46
+ backgroundColor: surfaceColor,
47
47
  },
48
48
  ]}
49
49
  >
50
- <View
51
- style={[
52
- styles.shadow,
53
- {
54
- paddingBottom: bottomSpace + Spacing.S,
55
- backgroundColor: surfaceColor,
56
- },
57
- ]}
58
- >
59
- <Section useMargin={marginFooter}>{footer}</Section>
60
- </View>
50
+ <Section useMargin={marginFooter}>{footer}</Section>
61
51
  </View>
62
- );
63
- };
52
+ </View>
53
+ );