@momo-kits/foundation 0.168.1-beta.39 → 0.168.1-beta.40

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 (153) hide show
  1. package/Application/BottomSheet.tsx +398 -86
  2. package/Application/BottomTab/BottomTabBar.tsx +275 -215
  3. package/Application/BottomTab/CustomBottomTabItem.tsx +107 -131
  4. package/Application/BottomTab/DuoBarCompression.tsx +28 -14
  5. package/Application/BottomTab/DuoTabBar.tsx +540 -32
  6. package/Application/BottomTab/TabBarIcon.tsx +72 -146
  7. package/Application/BottomTab/index.tsx +353 -89
  8. package/Application/BottomTab/useLiquidSelection.ts +374 -0
  9. package/Application/Components/BackgroundImageView.tsx +0 -4
  10. package/Application/Components/DuoGlassBackground.tsx +5 -7
  11. package/Application/Components/HeaderAnimated.tsx +13 -41
  12. package/Application/Components/HeaderBackground.tsx +3 -20
  13. package/Application/Components/HeaderExtendHeader.tsx +46 -66
  14. package/Application/Components/HeaderLeft.tsx +18 -5
  15. package/Application/Components/HeaderRight.tsx +529 -8
  16. package/Application/Components/HeaderTitle.tsx +579 -16
  17. package/Application/Components/NavigationButton.tsx +11 -18
  18. package/Application/Components/SearchHeader.tsx +18 -38
  19. package/Application/Localize.ts +0 -7
  20. package/Application/ModalScreen.tsx +18 -41
  21. package/Application/Navigation.ts +17 -15
  22. package/Application/NavigationContainer.tsx +21 -23
  23. package/Application/Navigator.ts +48 -20
  24. package/Application/ScaleSizeProvider.tsx +6 -13
  25. package/Application/StackScreen.tsx +172 -27
  26. package/Application/TooltipPortal.tsx +5 -12
  27. package/Application/WidgetContainer.tsx +7 -20
  28. package/Application/device.ts +52 -0
  29. package/Application/index.ts +1 -23
  30. package/Application/types.ts +242 -17
  31. package/Application/utils.tsx +493 -0
  32. package/Badge/Badge.tsx +0 -5
  33. package/Badge/BadgeDot.tsx +0 -1
  34. package/Badge/BadgeDotAnimation.tsx +7 -15
  35. package/Badge/BadgeRibbon.tsx +39 -47
  36. package/Badge/Shape.tsx +0 -2
  37. package/Badge/styles.ts +0 -2
  38. package/Badge/types.ts +2 -2
  39. package/Button/index.tsx +152 -21
  40. package/Button/styles.ts +1 -1
  41. package/CheckBox/index.tsx +6 -5
  42. package/Consts/theme.ts +10 -10
  43. package/Context/index.ts +1 -5
  44. package/Divider/DashDivider.tsx +11 -11
  45. package/Divider/index.tsx +7 -21
  46. package/FoundationList/index.tsx +0 -4
  47. package/Icon/index.tsx +6 -6
  48. package/Icon/types.ts +1 -1
  49. package/IconButton/index.tsx +12 -4
  50. package/Image/index.tsx +7 -9
  51. package/Input/Input.tsx +12 -10
  52. package/Input/InputDropDown.tsx +13 -10
  53. package/Input/InputMoney.tsx +152 -45
  54. package/Input/InputOTP.tsx +34 -36
  55. package/Input/InputPhoneNumber.tsx +5 -8
  56. package/Input/InputSearch.tsx +111 -19
  57. package/Input/InputTextArea.tsx +5 -5
  58. package/Input/SystemTextInput.tsx +2 -7
  59. package/Input/TextTyping.tsx +0 -4
  60. package/Input/common.tsx +17 -31
  61. package/Input/index.tsx +21 -24
  62. package/Input/styles.ts +5 -25
  63. package/Input/utils.ts +12 -14
  64. package/Layout/Card.tsx +4 -7
  65. package/Layout/FloatingButton.tsx +21 -26
  66. package/Layout/Item.tsx +2 -6
  67. package/Layout/ItemList.tsx +7 -9
  68. package/Layout/ItemSectionList.tsx +1 -2
  69. package/Layout/ReservedRegions.tsx +17 -34
  70. package/Layout/Screen.tsx +696 -122
  71. package/Layout/Section.tsx +7 -9
  72. package/Layout/TrackingScope.tsx +0 -1
  73. package/Layout/index.ts +4 -10
  74. package/Layout/styles.ts +0 -2
  75. package/Layout/types.ts +4 -2
  76. package/Layout/utils.ts +181 -40
  77. package/Loader/DotLoader.tsx +3 -11
  78. package/Loader/Loader.tsx +0 -4
  79. package/Loader/ProgressBar.tsx +6 -3
  80. package/Loader/Spinner.tsx +3 -11
  81. package/Loader/styles.ts +0 -4
  82. package/Loader/utils.ts +7 -11
  83. package/Pagination/Dot.tsx +0 -4
  84. package/Pagination/PaginationDot.tsx +0 -1
  85. package/Pagination/PaginationNumber.tsx +3 -5
  86. package/Pagination/PaginationScroll.tsx +0 -5
  87. package/Pagination/PaginationWhiteDot.tsx +0 -1
  88. package/Pagination/index.tsx +0 -4
  89. package/Pagination/types.ts +2 -2
  90. package/Popup/PopupNotify.tsx +102 -94
  91. package/Popup/PopupPromotion.tsx +11 -9
  92. package/Popup/types.ts +4 -11
  93. package/Popup/utils.ts +18 -50
  94. package/Radio/index.tsx +10 -6
  95. package/Radio/styles.ts +0 -6
  96. package/Skeleton/index.tsx +9 -9
  97. package/Skeleton/styles.ts +0 -1
  98. package/Switch/index.tsx +0 -1
  99. package/Tag/index.tsx +4 -8
  100. package/Tag/types.ts +3 -3
  101. package/Text/index.tsx +5 -25
  102. package/Text/styles.ts +1 -1
  103. package/Text/types.ts +6 -1
  104. package/Text/utils.ts +4 -20
  105. package/Title/index.tsx +40 -42
  106. package/Title/styles.ts +0 -6
  107. package/ViewBoundary/index.tsx +2 -4
  108. package/index.ts +6 -0
  109. package/package.json +1 -2
  110. package/Application/BottomSheet.hooks.ts +0 -195
  111. package/Application/BottomSheet.parts.tsx +0 -157
  112. package/Application/BottomSheet.styles.ts +0 -43
  113. package/Application/BottomTab/ActiveIndicator.tsx +0 -91
  114. package/Application/BottomTab/BottomTabBar.styles.ts +0 -65
  115. package/Application/BottomTab/BottomTabInset.tsx +0 -18
  116. package/Application/BottomTab/CurvedContainer.tsx +0 -155
  117. package/Application/BottomTab/DuoRailTabBar.tsx +0 -223
  118. package/Application/BottomTab/DuoTabBar.styles.ts +0 -81
  119. package/Application/BottomTab/TabScreen.tsx +0 -160
  120. package/Application/BottomTab/metrics.ts +0 -164
  121. package/Application/BottomTab/tabItems.ts +0 -46
  122. package/Application/BottomTab/usePressLift.ts +0 -32
  123. package/Application/Components/HeaderRight.styles.ts +0 -146
  124. package/Application/Components/HeaderTitle.shared.ts +0 -44
  125. package/Application/Components/HeaderTitle.styles.ts +0 -125
  126. package/Application/Components/HeaderToolkitAction.tsx +0 -180
  127. package/Application/Components/SwipeBackHaptic.tsx +0 -95
  128. package/Application/Components/TitleJourney.tsx +0 -110
  129. package/Application/Components/TitleLocation.tsx +0 -73
  130. package/Application/Components/TitleUser.tsx +0 -304
  131. package/Application/Components/useToolkitActions.tsx +0 -218
  132. package/Application/ModalIconButton.tsx +0 -66
  133. package/Application/StackScreen.tracking.ts +0 -143
  134. package/Application/headerLayout.ts +0 -158
  135. package/Application/hooks.ts +0 -137
  136. package/Application/modalLayout.ts +0 -176
  137. package/Application/navigationOptions.tsx +0 -212
  138. package/Application/types.header.ts +0 -121
  139. package/Application/types.tabs.ts +0 -48
  140. package/Application/types.theme.ts +0 -87
  141. package/Application/utils.ts +0 -107
  142. package/Button/utils.ts +0 -133
  143. package/Input/InputMoneyView.tsx +0 -194
  144. package/Input/SearchTextTyping.tsx +0 -108
  145. package/Input/moneyUtils.ts +0 -23
  146. package/Layout/layoutMetrics.ts +0 -58
  147. package/Layout/layoutTypes.ts +0 -86
  148. package/Layout/screenContent.tsx +0 -92
  149. package/Layout/screenFooter.tsx +0 -63
  150. package/Layout/screenHeader.tsx +0 -321
  151. package/Layout/screenQuickReturn.tsx +0 -64
  152. package/Layout/screenScroll.ts +0 -107
  153. package/Layout/screenTypes.ts +0 -143
package/Layout/Screen.tsx CHANGED
@@ -1,46 +1,192 @@
1
+ import { StackNavigationOptions } from '@react-navigation/stack';
1
2
  import { useHeaderHeight } from '@react-navigation/elements';
2
3
  import React, {
3
4
  forwardRef,
5
+ Fragment,
6
+ ReactNode,
7
+ Ref,
8
+ useCallback,
4
9
  useContext,
5
10
  useEffect,
6
11
  useImperativeHandle,
7
- useLayoutEffect,
12
+ useMemo,
8
13
  useRef,
9
14
  } from 'react';
10
15
  import {
11
16
  Animated,
12
17
  KeyboardAvoidingView,
18
+ NativeScrollEvent,
19
+ NativeSyntheticEvent,
13
20
  Platform,
14
21
  ScrollView,
22
+ ScrollViewProps,
23
+ StatusBar,
24
+ StatusBarStyle,
15
25
  View,
26
+ ViewProps,
16
27
  } from 'react-native';
17
- import { useSharedValue } from 'react-native-reanimated';
28
+ import {
29
+ useAnimatedReaction,
30
+ useSharedValue,
31
+ withTiming,
32
+ } from 'react-native-reanimated';
18
33
  import {
19
34
  useSafeAreaFrame,
20
35
  useSafeAreaInsets,
21
36
  } from 'react-native-safe-area-context';
22
37
  import { ApplicationContext, ScreenContext } from '../Context';
23
- import { NavigationOptions } from '../Application/types';
24
- import { Spacing, Styles } from '../Consts';
25
- import { FloatingButton } from './FloatingButton';
26
- import { getOptions } from '../Application/navigationOptions';
27
- import { useScreenLayout } from './utils';
28
- import { HeaderExtendHeader } from '../Application';
29
- import { DuoScrollGradient } from '../Application/Components/DuoGlassBackground';
30
- import { BottomTabInsetContext } from '../Application/BottomTab/BottomTabInset';
31
- import { ScreenProps } from './screenTypes';
32
- import { renderAnimatedHeader, renderContent } from './screenContent';
33
- import { createScrollHandlers } from './screenScroll';
34
- import { ScreenFooter } from './screenFooter';
35
- import { useScreenHeader } from './screenHeader';
36
- import { useScreenQuickReturn } from './screenQuickReturn';
37
-
38
- export type { ScreenProps };
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
- */
38
+ import Navigation from '../Application/Navigation';
39
+ import {
40
+ AnimatedHeader,
41
+ NavigationOptions,
42
+ ScreenTrackingParams,
43
+ SearchHeaderProps,
44
+ } from '../Application/types';
45
+ import { Colors, Spacing, Styles } from '../Consts';
46
+ import { FloatingButton, FloatingButtonProps } from './FloatingButton';
47
+ import styles from './styles';
48
+ import { HeaderType } from './types';
49
+ import { InputRef } from '../Input';
50
+ import { exportHeaderTitle, getOptions } from '../Application/utils';
51
+ import { getHeaderMargin, useScreenLayout, validateChildren } from './utils';
52
+ import Section from './Section';
53
+ import {
54
+ HeaderBackground,
55
+ HeaderExtendHeader,
56
+ HeaderLeft,
57
+ HeaderTitle,
58
+ SearchHeader,
59
+ } from '../Application';
60
+ import {
61
+ DuoGlassBackground,
62
+ DuoScrollGradient,
63
+ } from '../Application/Components/DuoGlassBackground';
64
+ import { DuoQuickReturnHeader } from '../Application/Components/DuoQuickReturnHeader';
65
+ import { useDuoTabBarInset } from '../Application/BottomTab/DuoTabBar';
66
+
67
+ const ANIMATED_BANNER_HEIGHT = 210;
68
+
69
+ export interface ScreenProps extends ViewProps {
70
+ /**
71
+ * ReactNode representing the content of the screen.
72
+ */
73
+ children: React.ReactNode;
74
+ /**
75
+ * Optional. Navigation object for handling navigation actions.
76
+ */
77
+ navigation?: Navigation;
78
+
79
+ /**
80
+ * Optional. If `true`, enable keyboard avoiding view for the screen.
81
+ */
82
+ enableKeyboardAvoidingView?: boolean;
83
+
84
+ /**
85
+ * Optional. If `true`, the screen content is scrollable.
86
+ */
87
+ scrollable?: boolean;
88
+
89
+ /**
90
+ * Optional. Set type of header.
91
+ */
92
+ headerType?: HeaderType;
93
+
94
+ /**
95
+ * Optional. Props for the animated component or bool used top navigation animated.
96
+ */
97
+ animatedHeader?: AnimatedHeader;
98
+
99
+ /**
100
+ * Optional. Props for the underlying ScrollView component when `scrollable` is `true`.
101
+ */
102
+ scrollViewProps?: ScrollViewProps;
103
+
104
+ /**
105
+ * Optional. ReactNode representing the header component of the screen.
106
+ */
107
+ headerComponent?: ReactNode;
108
+
109
+ /**
110
+ * Optional. ReactNode representing the footer component of the screen.
111
+ */
112
+ footerComponent?: ReactNode;
113
+
114
+ /**
115
+ * Optional. If `true`, the footer is inset by the standard horizontal margin
116
+ * (12pt each side). Set `false` for a footer that should span the full width —
117
+ * e.g. one that already carries its own horizontal padding.
118
+ * Defaults to `true`, on every platform.
119
+ */
120
+ marginFooter?: boolean;
121
+
122
+ /**
123
+ * Optional. Background color of the screen.
124
+ */
125
+ backgroundColor?: string;
126
+
127
+ /**
128
+ * Optional. layout card offset overlap header banner.
129
+ */
130
+ layoutOffset?: -8 | -24 | -56 | number;
131
+
132
+ /**
133
+ * Optional. Width of the right header. Defaults to the toolkit width (73), or 0 when
134
+ * iPhone Duo floats the toolkit into its side bar.
135
+ */
136
+ headerRightWidth?: 0 | 73 | 110 | number;
137
+
138
+ /**
139
+ * Optional. Props for the floating action button.
140
+ */
141
+ floatingButtonProps?: Omit<FloatingButtonProps, 'animatedValue' | 'bottom'>;
142
+
143
+ /**
144
+ * Optional. Keyboard vertical offset.
145
+ */
146
+ keyboardVerticalOffset?: number;
147
+
148
+ /**
149
+ * Optional. If `true`, the screen content is using grid layout by span.
150
+ */
151
+ useGridLayout?: boolean;
152
+
153
+ /**
154
+ * Optional. specs for input search.
155
+ */
156
+ inputSearchProps?: SearchHeaderProps;
157
+
158
+ /**
159
+ * Optional. Ref for input search.
160
+ */
161
+ inputSearchRef?: Ref<InputRef>;
162
+
163
+ /**
164
+ * Optional. React Native animated value for header.
165
+ * Internally, Screen mirrors it into a reanimated shared value.
166
+ */
167
+ animatedValue?: Animated.Value;
168
+
169
+ /**
170
+ * Optional. If `true`, use shadow header.
171
+ */
172
+ useShadowHeader?: boolean;
173
+
174
+ /**
175
+ * Optional. Custom header Gradient Color.
176
+ */
177
+ gradientColor?: string;
178
+
179
+ /**
180
+ * Optional. Custom headerBackground Image
181
+ */
182
+ headerBackground?: string;
183
+
184
+ /**
185
+ * Optional. Custom tracking params
186
+ */
187
+ trackingParams?: ScreenTrackingParams;
188
+ }
189
+
44
190
  const Screen = forwardRef(
45
191
  (
46
192
  {
@@ -67,7 +213,6 @@ const Screen = forwardRef(
67
213
  headerBackground,
68
214
  gradientColor,
69
215
  trackingParams,
70
- contentLayout,
71
216
  }: ScreenProps,
72
217
  ref: any,
73
218
  ) => {
@@ -99,56 +244,340 @@ const Screen = forwardRef(
99
244
  };
100
245
  }, [customAnimatedValue, internalShared]);
101
246
 
247
+ const currentTint = useRef<string | undefined>(undefined);
248
+
102
249
  const isTab = !!screen?.bottomTab;
103
- const tabBarInset = useContext(BottomTabInsetContext);
104
- const duoTabInset = isTab ? tabBarInset.inset : 0;
105
- const claimTabBarInset = tabBarInset.claim;
106
- // this screen keeps its content clear of the floating tab bar, so the tab stops padding it
107
- useLayoutEffect(() => {
108
- if (duoTabInset) {
109
- claimTabBarInset?.();
110
- }
111
- }, [duoTabInset, claimTabBarInset]);
250
+ const duoTabInset = useDuoTabBarInset();
251
+
252
+ let handleScroll;
253
+ let Component: any = View;
112
254
 
113
255
  const isIOS = Platform.OS === 'ios';
114
256
  const bottomInset = isIOS ? Math.min(insets.bottom, 21) : insets.bottom;
115
257
  const hasSideBar = !!layout.sideBar;
116
- const isPlainHeader = headerType === 'default' || headerType === 'extended';
117
- const hasCustomHeader = !!animatedHeader || !!inputSearchProps;
118
- const useDuoGlass = hasSideBar && isPlainHeader && !hasCustomHeader;
119
-
120
- const hasOverlayHeader = useDuoGlass || !!animatedHeader;
121
- const useQuickReturn = hasSideBar && scrollable && hasOverlayHeader;
122
- const { quickReturnOptions, snapQuickReturnHeader } = useScreenQuickReturn(
123
- sharedValue,
124
- useQuickReturn,
125
- heightHeader,
258
+ const useDuoGlass =
259
+ hasSideBar &&
260
+ (headerType === 'default' || headerType === 'extended') &&
261
+ !animatedHeader &&
262
+ !inputSearchProps;
263
+
264
+ const useQuickReturn =
265
+ hasSideBar && scrollable && (useDuoGlass || !!animatedHeader);
266
+ const headerHide = useSharedValue(0);
267
+ const lastScrollY = useSharedValue(0);
268
+
269
+ useAnimatedReaction(
270
+ () => sharedValue.value,
271
+ y => {
272
+ const delta = y - lastScrollY.value;
273
+ lastScrollY.value = y;
274
+ if (!useQuickReturn || y <= 0) {
275
+ headerHide.value = 0;
276
+ return;
277
+ }
278
+ headerHide.value = Math.min(
279
+ Math.max(headerHide.value + delta, 0),
280
+ heightHeader,
281
+ );
282
+ },
283
+ [useQuickReturn, heightHeader],
284
+ );
285
+
286
+ const quickReturnOptions: StackNavigationOptions = useMemo(
287
+ () =>
288
+ useQuickReturn
289
+ ? {
290
+ header: (props: any) => (
291
+ <DuoQuickReturnHeader {...props} offset={headerHide} />
292
+ ),
293
+ }
294
+ : { header: undefined },
295
+ [useQuickReturn, headerHide],
126
296
  );
127
297
 
128
298
  let keyboardOffset = heightHeader - bottomInset;
129
- if (headerType === 'extended' || hasCustomHeader || useDuoGlass) {
299
+ if (
300
+ headerType === 'extended' ||
301
+ animatedHeader ||
302
+ inputSearchProps ||
303
+ useDuoGlass
304
+ ) {
130
305
  keyboardOffset = -bottomInset;
131
306
  }
132
307
 
308
+ /**
309
+ * inject params for screen tracking
310
+ */
133
311
  screen?.onSetParams?.(trackingParams);
134
312
 
135
- const { setSearchHeader, currentTint } = useScreenHeader({
136
- navigation,
137
- layout,
138
- sharedValue,
139
- quickReturnOptions,
140
- hasSideBar,
313
+ const appliedHeaderMode = useRef<string | undefined>(undefined);
314
+
315
+ /**
316
+ * export options for screen
317
+ * @param headerType
318
+ */
319
+ const setHeaderType = useCallback(
320
+ (headerType: HeaderType, keepTitle = false) => {
321
+ let options: StackNavigationOptions;
322
+ switch (headerType) {
323
+ case 'none':
324
+ options = {
325
+ headerTransparent: true,
326
+ headerBackground: () => null,
327
+ headerShown: false,
328
+ };
329
+ break;
330
+
331
+ case 'extended':
332
+ options = {
333
+ ...quickReturnOptions,
334
+ headerShown: true,
335
+ headerTransparent: true,
336
+ headerBackground: () =>
337
+ hasSideBar ? (
338
+ <DuoGlassBackground animatedValue={sharedValue} />
339
+ ) : null,
340
+ headerTitle: (props: any) => <HeaderTitle {...props} />,
341
+ };
342
+ if (inputSearchProps) {
343
+ options = {
344
+ headerShown: true,
345
+ headerTransparent: true,
346
+ headerBackground: () => null,
347
+ headerTitle: (props: any) => (
348
+ <HeaderTitle
349
+ {...props}
350
+ interpolate={{
351
+ inputRange: [0, 50],
352
+ outputRange: [1, 0],
353
+ }}
354
+ animatedValue={sharedValue}
355
+ />
356
+ ),
357
+ };
358
+ }
359
+ break;
360
+
361
+ default:
362
+ if (hasSideBar && !inputSearchProps) {
363
+ options = {
364
+ ...quickReturnOptions,
365
+ headerTransparent: true,
366
+ headerTintColor: Colors.black_17,
367
+ headerShown: true,
368
+ headerBackground: () => (
369
+ <DuoGlassBackground animatedValue={sharedValue} />
370
+ ),
371
+ headerTitle: (props: any) => <HeaderTitle {...props} />,
372
+ };
373
+ break;
374
+ }
375
+ options = {
376
+ headerTransparent: false,
377
+ headerTintColor: Colors.black_17,
378
+ headerShown: true,
379
+ headerBackground: (props: any) => (
380
+ <HeaderBackground
381
+ {...props}
382
+ animatedValue={sharedValue}
383
+ useShadowHeader={useShadowHeader}
384
+ headerBackground={headerBackground}
385
+ gradientColor={gradientColor}
386
+ />
387
+ ),
388
+ headerTitle: (props: any) => <HeaderTitle {...props} />,
389
+ };
390
+ if (inputSearchProps) {
391
+ options = {
392
+ headerShown: true,
393
+ headerTransparent: true,
394
+ headerBackground: () => null,
395
+ headerTitle: (props: any) => (
396
+ <HeaderTitle
397
+ {...props}
398
+ interpolate={{
399
+ inputRange: [0, 50],
400
+ outputRange: [1, 0],
401
+ }}
402
+ animatedValue={sharedValue}
403
+ />
404
+ ),
405
+ };
406
+ }
407
+ }
408
+
409
+ if (keepTitle) {
410
+ delete options.headerTitle;
411
+ }
412
+
413
+ navigation?.instance?.setOptions({ header: undefined, ...options });
414
+ },
415
+ [
416
+ gradientColor,
417
+ headerBackground,
418
+ inputSearchProps,
419
+ navigation?.instance,
420
+ sharedValue,
421
+ useShadowHeader,
422
+ hasSideBar,
423
+ quickReturnOptions,
424
+ ],
425
+ );
426
+
427
+ /**
428
+ * export animatedHeader options for screen
429
+ * @param animatedHeader
430
+ */
431
+ const setAnimatedHeader = useCallback(
432
+ (animatedHeader: AnimatedHeader) => {
433
+ let options: StackNavigationOptions;
434
+ if (!currentTint.current) {
435
+ currentTint.current = animatedHeader?.headerTintColor;
436
+ }
437
+
438
+ options = {
439
+ ...quickReturnOptions,
440
+ headerTintColor: currentTint.current ?? Colors.black_17,
441
+ headerTransparent: true,
442
+ headerBackground: (props: any) =>
443
+ hasSideBar ? (
444
+ <DuoGlassBackground
445
+ animatedValue={sharedValue}
446
+ bannerBottom={ANIMATED_BANNER_HEIGHT + layoutOffset}
447
+ />
448
+ ) : (
449
+ <HeaderBackground
450
+ {...props}
451
+ animatedValue={sharedValue}
452
+ useGradient={false}
453
+ useShadowHeader={useShadowHeader}
454
+ headerBackground={headerBackground}
455
+ gradientColor={gradientColor}
456
+ />
457
+ ),
458
+ headerTitle: (props: any) => {
459
+ return <HeaderTitle {...props} />;
460
+ },
461
+ };
462
+
463
+ if (animatedHeader.headerTitle) {
464
+ options = {
465
+ ...options,
466
+ ...exportHeaderTitle(animatedHeader),
467
+ };
468
+ }
469
+
470
+ navigation?.instance?.setOptions(options);
471
+ },
472
+ [
473
+ gradientColor,
474
+ headerBackground,
475
+ navigation?.instance,
476
+ sharedValue,
477
+ useShadowHeader,
478
+ hasSideBar,
479
+ layoutOffset,
480
+ quickReturnOptions,
481
+ ],
482
+ );
483
+
484
+ /**
485
+ * export animatedHeader options for screen
486
+ */
487
+ const setAnimatedSearch = useCallback(() => {
488
+ const options: StackNavigationOptions = {
489
+ headerShown: true,
490
+ headerTransparent: true,
491
+ headerBackground: () => null,
492
+ headerTitle: (props: any) => (
493
+ <HeaderTitle
494
+ {...props}
495
+ interpolate={{
496
+ inputRange: [0, 50],
497
+ outputRange: [1, 0],
498
+ }}
499
+ animatedValue={sharedValue}
500
+ />
501
+ ),
502
+ };
503
+
504
+ navigation?.instance?.setOptions({ header: undefined, ...options });
505
+ }, [navigation?.instance, sharedValue]);
506
+
507
+ /**
508
+ * export search header
509
+ */
510
+ const setSearchHeader = (params: SearchHeaderProps) => {
511
+ let searchWidth = layout.width - 24;
512
+ let searchLeft = Spacing.M;
513
+ if (layout.sideBar) {
514
+ searchWidth = layout.contentWidth - Spacing.M * 2;
515
+ searchLeft = Spacing.M - getHeaderMargin(layout.width);
516
+ }
517
+ if (layout.statusBarClearance) {
518
+ searchWidth -=
519
+ layout.statusBarClearance.left + layout.statusBarClearance.right;
520
+ }
521
+ const options: StackNavigationOptions = {
522
+ headerRight: undefined,
523
+ headerTitleContainerStyle: {
524
+ width: searchWidth,
525
+ maxWidth: searchWidth,
526
+ marginLeft: 0,
527
+ marginEnd: 0,
528
+ marginStart: 0,
529
+ marginHorizontal: 0,
530
+ marginVertical: 0,
531
+ margin: 0,
532
+ left: searchLeft,
533
+ },
534
+ headerLeft: (props: any) =>
535
+ params?.hiddenBack ? null : <HeaderLeft {...props} floating />,
536
+ headerTitle: () => (
537
+ <SearchHeader {...params} animatedValue={sharedValue} />
538
+ ),
539
+ };
540
+
541
+ navigation?.instance?.setOptions(options);
542
+ };
543
+
544
+ useEffect(() => {
545
+ const focus = navigation?.instance?.addListener?.('focus', () => {
546
+ let barStyle: StatusBarStyle = 'dark-content';
547
+ if (currentTint.current === Colors.black_01) {
548
+ barStyle = 'light-content';
549
+ }
550
+ StatusBar.setBarStyle(barStyle, true);
551
+ });
552
+
553
+ if (animatedHeader) {
554
+ setAnimatedHeader(animatedHeader);
555
+ appliedHeaderMode.current = 'animated';
556
+ } else if (inputSearchProps) {
557
+ setAnimatedSearch();
558
+ appliedHeaderMode.current = 'search';
559
+ } else {
560
+ setHeaderType(headerType, appliedHeaderMode.current === headerType);
561
+ appliedHeaderMode.current = headerType;
562
+ }
563
+
564
+ return () => {
565
+ focus?.();
566
+ };
567
+ }, [
141
568
  headerType,
142
569
  animatedHeader,
143
570
  inputSearchProps,
144
571
  useShadowHeader,
145
- gradientColor,
146
- headerBackground,
147
- layoutOffset,
148
- contentLayout,
149
- });
572
+ navigation?.instance,
573
+ setAnimatedHeader,
574
+ setAnimatedSearch,
575
+ setHeaderType,
576
+ ]);
150
577
 
151
- // mutates the content node so callers keep its methods plus the header setters
578
+ /**
579
+ * expose ref for screen
580
+ */
152
581
  useImperativeHandle(ref, () => {
153
582
  return Object.assign(screenRef.current || {}, {
154
583
  setOptions: (params: NavigationOptions) => {
@@ -159,19 +588,164 @@ const Screen = forwardRef(
159
588
  });
160
589
  });
161
590
 
162
- const scrollHandlers = createScrollHandlers({
163
- scrollable,
164
- animatedValue: animatedValue.current,
165
- sharedValue,
166
- scrollViewProps,
167
- animatedHeader,
168
- inputSearchProps,
169
- currentTint,
170
- navigation,
171
- snapQuickReturnHeader,
172
- ref,
173
- });
174
- const Component: any = scrollable ? Animated.ScrollView : View;
591
+ /**
592
+ * animated when use scroll && animated value
593
+ */
594
+ if (scrollable) {
595
+ Component = Animated.ScrollView;
596
+ handleScroll = Animated.event(
597
+ [
598
+ {
599
+ nativeEvent: {
600
+ contentOffset: { y: animatedValue.current as Animated.Value },
601
+ },
602
+ },
603
+ ],
604
+ {
605
+ useNativeDriver: true,
606
+ listener: (e: NativeSyntheticEvent<NativeScrollEvent>) => {
607
+ const offsetY = e.nativeEvent.contentOffset.y;
608
+ sharedValue.value = offsetY;
609
+ scrollViewProps?.onScroll?.(e);
610
+ if (animatedHeader) {
611
+ let color = animatedHeader?.headerTintColor ?? Colors.black_17;
612
+ if (offsetY > 50) {
613
+ color = Colors.black_17;
614
+ }
615
+ if (color !== currentTint.current) {
616
+ currentTint.current = color;
617
+ navigation?.setOptions({
618
+ headerTintColor: color,
619
+ });
620
+
621
+ let barStyle: StatusBarStyle = 'dark-content';
622
+ if (currentTint.current === Colors.black_01) {
623
+ barStyle = 'light-content';
624
+ }
625
+ StatusBar.setBarStyle(barStyle, true);
626
+ }
627
+ }
628
+ },
629
+ },
630
+ );
631
+ }
632
+
633
+ /**
634
+ * handle scroll end
635
+ * @param e
636
+ */
637
+ /**
638
+ * a half-shown quick return header settles fully in or out
639
+ */
640
+ const snapQuickReturnHeader = (offsetY: number) => {
641
+ const hide = headerHide.value;
642
+ if (
643
+ !useQuickReturn ||
644
+ offsetY < heightHeader ||
645
+ hide <= 0 ||
646
+ hide >= heightHeader
647
+ ) {
648
+ return;
649
+ }
650
+ headerHide.value = withTiming(
651
+ hide > heightHeader / 2 ? heightHeader : 0,
652
+ { duration: 200 },
653
+ );
654
+ };
655
+
656
+ const handleMomentumScrollEnd = (
657
+ e: NativeSyntheticEvent<NativeScrollEvent>,
658
+ ) => {
659
+ snapQuickReturnHeader(e.nativeEvent.contentOffset.y);
660
+ scrollViewProps?.onMomentumScrollEnd?.(e);
661
+ };
662
+
663
+ const handleScrollEnd = (e: NativeSyntheticEvent<NativeScrollEvent>) => {
664
+ const offsetY = e.nativeEvent.contentOffset.y;
665
+ snapQuickReturnHeader(offsetY);
666
+ if (inputSearchProps && offsetY < 100 && offsetY > 0) {
667
+ Animated.timing(animatedValue.current, {
668
+ toValue: 0,
669
+ useNativeDriver: true,
670
+ duration: 300,
671
+ }).start();
672
+ sharedValue.value = withTiming(0, { duration: 300 });
673
+ ref?.scrollTo?.({ y: 0, animated: true });
674
+ }
675
+ scrollViewProps?.onScrollEndDrag?.(e);
676
+ };
677
+
678
+ /**
679
+ * render top navigation banner
680
+ */
681
+ const renderAnimatedHeader = () => {
682
+ if (typeof animatedHeader?.component === 'function') {
683
+ return (
684
+ <View
685
+ style={[
686
+ styles.screenBanner,
687
+ { maxHeight: ANIMATED_BANNER_HEIGHT + layoutOffset },
688
+ ]}
689
+ >
690
+ {animatedHeader?.component({
691
+ animatedValue: animatedValue.current,
692
+ sharedValue: sharedValue,
693
+ })}
694
+ </View>
695
+ );
696
+ }
697
+ };
698
+
699
+ /**
700
+ * build content for screen for grid rule
701
+ */
702
+ const renderContent = (children: any): any => {
703
+ const results = validateChildren(children, [undefined]);
704
+ if (Array.isArray(results)) {
705
+ return results.map((item, index) => {
706
+ const space = item?.props?.useMargin === false ? 0 : Spacing.M;
707
+ if (item?.type === Fragment) {
708
+ return renderContent(item?.props?.children);
709
+ }
710
+ if (item) {
711
+ return (
712
+ <View
713
+ key={`ScreenItem${index}`}
714
+ style={{
715
+ marginTop: space,
716
+ marginLeft: layout.insetLeft,
717
+ marginRight: layout.insetRight,
718
+ flex: item.props?.expanded ? 1 : undefined,
719
+ }}
720
+ onLayout={item.props?.onLayout}
721
+ >
722
+ {item}
723
+ </View>
724
+ );
725
+ }
726
+ });
727
+ } else {
728
+ const item: any = children;
729
+ const space = item?.props?.useMargin === false ? 0 : Spacing.M;
730
+ if (item?.type === Fragment) {
731
+ return renderContent(item?.props?.children);
732
+ }
733
+ return (
734
+ <View
735
+ key={`ScreenItem`}
736
+ style={{
737
+ marginTop: space,
738
+ marginLeft: layout.insetLeft,
739
+ marginRight: layout.insetRight,
740
+ flex: item?.props?.expanded ? 1 : undefined,
741
+ }}
742
+ onLayout={item?.props?.onLayout}
743
+ >
744
+ {children}
745
+ </View>
746
+ );
747
+ }
748
+ };
175
749
 
176
750
  const getHeight = () => {
177
751
  let newHeight = frame.height;
@@ -200,36 +774,6 @@ const Screen = forwardRef(
200
774
  floatingButtonBottom = 12 + duoTabInset;
201
775
  }
202
776
 
203
- const renderHeaderLayer = () => {
204
- if (useDuoGlass) {
205
- return (
206
- <DuoScrollGradient
207
- animatedValue={sharedValue}
208
- gradientColor={gradientColor}
209
- headerBackground={headerBackground}
210
- heightHeader={heightHeader}
211
- extended={headerType === 'extended'}
212
- followScroll={useQuickReturn}
213
- />
214
- );
215
- }
216
- return (
217
- <HeaderExtendHeader
218
- headerType={headerType}
219
- heightHeader={heightHeader}
220
- headerRightWidth={headerRightWidth}
221
- animatedValue={sharedValue}
222
- inputSearchProps={inputSearchProps}
223
- navigation={navigation}
224
- inputSearchRef={inputSearchRef}
225
- useShadowHeader={useShadowHeader}
226
- gradientColor={gradientColor}
227
- headerBackground={headerBackground}
228
- contentLayout={contentLayout}
229
- />
230
- );
231
- };
232
-
233
777
  return (
234
778
  <View
235
779
  style={[
@@ -240,7 +784,29 @@ const Screen = forwardRef(
240
784
  },
241
785
  ]}
242
786
  >
243
- {renderHeaderLayer()}
787
+ {useDuoGlass ? (
788
+ <DuoScrollGradient
789
+ animatedValue={sharedValue}
790
+ gradientColor={gradientColor}
791
+ headerBackground={headerBackground}
792
+ heightHeader={heightHeader}
793
+ extended={headerType === 'extended'}
794
+ followScroll={useQuickReturn}
795
+ />
796
+ ) : (
797
+ <HeaderExtendHeader
798
+ headerType={headerType}
799
+ heightHeader={heightHeader}
800
+ headerRightWidth={headerRightWidth}
801
+ animatedValue={sharedValue}
802
+ inputSearchProps={inputSearchProps}
803
+ navigation={navigation}
804
+ inputSearchRef={inputSearchRef}
805
+ useShadowHeader={useShadowHeader}
806
+ gradientColor={gradientColor}
807
+ headerBackground={headerBackground}
808
+ />
809
+ )}
244
810
 
245
811
  <KeyboardAvoidingView
246
812
  style={[
@@ -260,9 +826,9 @@ const Screen = forwardRef(
260
826
  {...scrollViewProps}
261
827
  ref={screenRef}
262
828
  showsVerticalScrollIndicator={false}
263
- onScroll={scrollHandlers.handleScroll}
264
- onScrollEndDrag={scrollHandlers.handleScrollEnd}
265
- onMomentumScrollEnd={scrollHandlers.handleMomentumScrollEnd}
829
+ onScroll={handleScroll}
830
+ onScrollEndDrag={handleScrollEnd}
831
+ onMomentumScrollEnd={handleMomentumScrollEnd}
266
832
  scrollEventThrottle={16}
267
833
  style={[
268
834
  Styles.flex,
@@ -277,14 +843,9 @@ const Screen = forwardRef(
277
843
  scrollViewProps?.contentContainerStyle,
278
844
  ]}
279
845
  >
280
- {renderAnimatedHeader(
281
- animatedHeader,
282
- layoutOffset,
283
- animatedValue.current,
284
- sharedValue,
285
- )}
286
-
287
- {useGridLayout ? renderContent(children, layout) : children}
846
+ {renderAnimatedHeader()}
847
+
848
+ {useGridLayout ? renderContent(children) : children}
288
849
  </Component>
289
850
 
290
851
  {floatingButtonProps && (
@@ -303,17 +864,30 @@ const Screen = forwardRef(
303
864
  )}
304
865
 
305
866
  {Footer && (
306
- <ScreenFooter
307
- footer={Footer}
308
- marginFooter={marginFooter}
309
- insetLeft={layout.insetLeft}
310
- insetRight={layout.insetRight}
311
- hasContentInset={hasContentInset}
312
- isTab={isTab}
313
- duoTabInset={duoTabInset}
314
- bottomInset={bottomInset}
315
- surfaceColor={theme.colors.background.surface}
316
- />
867
+ <View
868
+ pointerEvents={'box-none'}
869
+ style={[
870
+ hasContentInset && styles.footerClip,
871
+ {
872
+ marginLeft: layout.insetLeft,
873
+ marginRight: layout.insetRight,
874
+ },
875
+ ]}
876
+ >
877
+ <View
878
+ style={[
879
+ styles.shadow,
880
+ {
881
+ paddingBottom:
882
+ (isTab && duoTabInset ? duoTabInset : bottomInset) +
883
+ Spacing.S,
884
+ backgroundColor: theme.colors.background.surface,
885
+ },
886
+ ]}
887
+ >
888
+ <Section useMargin={marginFooter}>{Footer}</Section>
889
+ </View>
890
+ </View>
317
891
  )}
318
892
  </KeyboardAvoidingView>
319
893
  </View>