@momo-kits/foundation 0.169.7-beta.3 → 0.169.7-beta.4

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 (141) 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 -16
  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 +4 -7
  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 +5 -8
  104. package/Layout/TrackingScope.tsx +0 -1
  105. package/Layout/screenContent.tsx +2 -4
  106. package/Layout/screenFooter.tsx +18 -28
  107. package/Layout/screenHeader.tsx +31 -34
  108. package/Layout/screenQuickReturn.tsx +20 -17
  109. package/Layout/screenScroll.ts +7 -4
  110. package/Layout/screenTypes.ts +2 -3
  111. package/Layout/types.ts +4 -2
  112. package/Layout/utils.ts +37 -31
  113. package/Loader/DotLoader.tsx +0 -4
  114. package/Loader/Loader.tsx +0 -4
  115. package/Loader/ProgressBar.tsx +0 -1
  116. package/Loader/Spinner.tsx +0 -4
  117. package/Loader/utils.ts +7 -11
  118. package/Pagination/Dot.tsx +0 -4
  119. package/Pagination/PaginationDot.tsx +0 -1
  120. package/Pagination/PaginationNumber.tsx +3 -5
  121. package/Pagination/PaginationScroll.tsx +0 -5
  122. package/Pagination/PaginationWhiteDot.tsx +0 -1
  123. package/Pagination/index.tsx +0 -4
  124. package/Pagination/types.ts +2 -2
  125. package/Popup/PopupNotify.tsx +49 -45
  126. package/Popup/PopupPromotion.tsx +7 -4
  127. package/Popup/types.ts +4 -4
  128. package/Popup/utils.ts +4 -11
  129. package/Radio/index.tsx +0 -4
  130. package/Skeleton/index.tsx +0 -8
  131. package/Switch/index.tsx +0 -1
  132. package/Tag/index.tsx +1 -5
  133. package/Tag/types.ts +3 -3
  134. package/Text/index.tsx +3 -14
  135. package/Text/styles.ts +1 -1
  136. package/Text/types.ts +6 -1
  137. package/Text/utils.ts +4 -20
  138. package/Title/index.tsx +32 -41
  139. package/ViewBoundary/index.tsx +2 -4
  140. package/index.ts +6 -0
  141. package/package.json +1 -1
@@ -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-12).
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-12).
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,
@@ -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,
@@ -47,8 +43,9 @@ const Section: React.FC<SectionProps> = ({
47
43
  }
48
44
  const widthSection = contentWidth - margin * 2;
49
45
 
50
- const columnsWidth = widthSection - gutterSize * (numberOfColumns - 1);
51
- const sizePerSpan = columnsWidth / numberOfColumns - 1 / numberOfColumns;
46
+ const sizePerSpan =
47
+ (widthSection - gutterSize * (numberOfColumns - 1)) / numberOfColumns -
48
+ 1 / numberOfColumns;
52
49
 
53
50
  const gridContext: GridContextProps = {
54
51
  numberOfColumns,
@@ -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,
@@ -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
+ );
@@ -31,10 +31,6 @@ type ScreenHeaderParams = {
31
31
  layoutOffset: number;
32
32
  };
33
33
 
34
- /**
35
- * Applies the Screen's navigation header (plain, extended, animated banner or search) and
36
- * re-applies it when those props change. Returns the search header setter and the tint.
37
- */
38
34
  export const useScreenHeader = ({
39
35
  navigation,
40
36
  layout,
@@ -52,7 +48,10 @@ export const useScreenHeader = ({
52
48
  const currentTint = useRef<string | undefined>(undefined);
53
49
  const appliedHeaderMode = useRef<string | undefined>(undefined);
54
50
 
55
- // keepTitle leaves a title the screen set itself when the same type is re-applied
51
+ /**
52
+ * export options for screen
53
+ * @param type
54
+ */
56
55
  const setHeaderType = useCallback(
57
56
  (type: HeaderType, keepTitle = false) => {
58
57
  let options: StackNavigationOptions;
@@ -70,12 +69,10 @@ export const useScreenHeader = ({
70
69
  ...quickReturnOptions,
71
70
  headerShown: true,
72
71
  headerTransparent: true,
73
- headerBackground: () => {
74
- if (!hasSideBar) {
75
- return null;
76
- }
77
- return <DuoGlassBackground animatedValue={sharedValue} />;
78
- },
72
+ headerBackground: () =>
73
+ hasSideBar ? (
74
+ <DuoGlassBackground animatedValue={sharedValue} />
75
+ ) : null,
79
76
  headerTitle: (props: any) => <HeaderTitle {...props} />,
80
77
  };
81
78
  if (inputSearchProps) {
@@ -163,7 +160,10 @@ export const useScreenHeader = ({
163
160
  ],
164
161
  );
165
162
 
166
- // the first tint the animated header sets is kept for later scroll updates
163
+ /**
164
+ * export animatedHeader options for screen
165
+ * @param nextAnimatedHeader
166
+ */
167
167
  const setAnimatedHeader = useCallback(
168
168
  (nextAnimatedHeader: AnimatedHeader) => {
169
169
  let options: StackNavigationOptions;
@@ -175,16 +175,13 @@ export const useScreenHeader = ({
175
175
  ...quickReturnOptions,
176
176
  headerTintColor: currentTint.current ?? Colors.black_17,
177
177
  headerTransparent: true,
178
- headerBackground: (props: any) => {
179
- if (hasSideBar) {
180
- return (
181
- <DuoGlassBackground
182
- animatedValue={sharedValue}
183
- bannerBottom={ANIMATED_BANNER_HEIGHT + layoutOffset}
184
- />
185
- );
186
- }
187
- return (
178
+ headerBackground: (props: any) =>
179
+ hasSideBar ? (
180
+ <DuoGlassBackground
181
+ animatedValue={sharedValue}
182
+ bannerBottom={ANIMATED_BANNER_HEIGHT + layoutOffset}
183
+ />
184
+ ) : (
188
185
  <HeaderBackground
189
186
  {...props}
190
187
  animatedValue={sharedValue}
@@ -193,8 +190,7 @@ export const useScreenHeader = ({
193
190
  headerBackground={headerBackground}
194
191
  gradientColor={gradientColor}
195
192
  />
196
- );
197
- },
193
+ ),
198
194
  headerTitle: (props: any) => {
199
195
  return <HeaderTitle {...props} />;
200
196
  },
@@ -221,6 +217,9 @@ export const useScreenHeader = ({
221
217
  ],
222
218
  );
223
219
 
220
+ /**
221
+ * export animatedHeader options for screen
222
+ */
224
223
  const setAnimatedSearch = useCallback(() => {
225
224
  const options: StackNavigationOptions = {
226
225
  headerShown: true,
@@ -241,7 +240,9 @@ export const useScreenHeader = ({
241
240
  navigation?.instance?.setOptions({ header: undefined, ...options });
242
241
  }, [navigation?.instance, sharedValue]);
243
242
 
244
- // the search field spans the content, clear of the side bar and status bar clusters
243
+ /**
244
+ * export search header
245
+ */
245
246
  const setSearchHeader = (params: SearchHeaderProps) => {
246
247
  let searchWidth = layout.width - 24;
247
248
  let searchLeft = Spacing.M;
@@ -249,9 +250,9 @@ export const useScreenHeader = ({
249
250
  searchWidth = layout.contentWidth - Spacing.M * 2;
250
251
  searchLeft = Spacing.M - getHeaderMargin(layout.width);
251
252
  }
252
- const clearance = layout.statusBarClearance;
253
- if (clearance) {
254
- searchWidth -= clearance.left + clearance.right;
253
+ if (layout.statusBarClearance) {
254
+ searchWidth -=
255
+ layout.statusBarClearance.left + layout.statusBarClearance.right;
255
256
  }
256
257
  const options: StackNavigationOptions = {
257
258
  headerRight: undefined,
@@ -266,12 +267,8 @@ export const useScreenHeader = ({
266
267
  margin: 0,
267
268
  left: searchLeft,
268
269
  },
269
- headerLeft: (props: any) => {
270
- if (params?.hiddenBack) {
271
- return null;
272
- }
273
- return <HeaderLeft {...props} floating />;
274
- },
270
+ headerLeft: (props: any) =>
271
+ params?.hiddenBack ? null : <HeaderLeft {...props} floating />,
275
272
  headerTitle: () => (
276
273
  <SearchHeader {...params} animatedValue={sharedValue} />
277
274
  ),
@@ -8,10 +8,6 @@ import {
8
8
  } from 'react-native-reanimated';
9
9
  import { DuoQuickReturnHeader } from '../Application/Components/DuoQuickReturnHeader';
10
10
 
11
- /**
12
- * iPhone Duo quick return header: it slides out while the content scrolls down and back
13
- * on scroll up. Returns the header options and a snap to call when scrolling ends.
14
- */
15
11
  export const useScreenQuickReturn = (
16
12
  sharedValue: SharedValue<number>,
17
13
  useQuickReturn: boolean,
@@ -37,22 +33,29 @@ export const useScreenQuickReturn = (
37
33
  [useQuickReturn, heightHeader],
38
34
  );
39
35
 
40
- const quickReturnOptions: StackNavigationOptions = useMemo(() => {
41
- if (!useQuickReturn) {
42
- return { header: undefined };
43
- }
44
- return {
45
- header: (props: any) => (
46
- <DuoQuickReturnHeader {...props} offset={headerHide} />
47
- ),
48
- };
49
- }, [useQuickReturn, headerHide]);
36
+ const quickReturnOptions: StackNavigationOptions = useMemo(
37
+ () =>
38
+ useQuickReturn
39
+ ? {
40
+ header: (props: any) => (
41
+ <DuoQuickReturnHeader {...props} offset={headerHide} />
42
+ ),
43
+ }
44
+ : { header: undefined },
45
+ [useQuickReturn, headerHide],
46
+ );
50
47
 
51
- // a half-shown quick return header settles fully in or out
48
+ /**
49
+ * a half-shown quick return header settles fully in or out
50
+ */
52
51
  const snapQuickReturnHeader = (offsetY: number) => {
53
52
  const hide = headerHide.value;
54
- const isSettled = hide <= 0 || hide >= heightHeader;
55
- if (!useQuickReturn || offsetY < heightHeader || isSettled) {
53
+ if (
54
+ !useQuickReturn ||
55
+ offsetY < heightHeader ||
56
+ hide <= 0 ||
57
+ hide >= heightHeader
58
+ ) {
56
59
  return;
57
60
  }
58
61
  headerHide.value = withTiming(hide > heightHeader / 2 ? heightHeader : 0, {