@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
@@ -1,321 +0,0 @@
1
- import { useCallback, useEffect, useRef } from 'react';
2
- import { StatusBar, StatusBarStyle } from 'react-native';
3
- import { StackNavigationOptions } from '@react-navigation/stack';
4
- import type { SharedValue } from 'react-native-reanimated';
5
- import Navigation from '../Application/Navigation';
6
- import { AnimatedHeader, SearchHeaderProps } from '../Application/types';
7
- import { exportHeaderTitle } from '../Application/navigationOptions';
8
- import { Colors, Spacing } from '../Consts';
9
- import {
10
- HeaderBackground,
11
- HeaderLeft,
12
- HeaderTitle,
13
- SearchHeader,
14
- } from '../Application';
15
- import { DuoGlassBackground } from '../Application/Components/DuoGlassBackground';
16
- import {
17
- type HeaderContentLayout,
18
- useHeaderFrameOptions,
19
- useHeaderLayout,
20
- } from '../Application/headerLayout';
21
- import { getHeaderMargin } from './utils';
22
- import { ANIMATED_BANNER_HEIGHT } from './screenTypes';
23
- import { HeaderType } from './types';
24
-
25
- type ScreenHeaderParams = {
26
- navigation?: Navigation;
27
- layout: any;
28
- sharedValue: any;
29
- quickReturnOptions: StackNavigationOptions;
30
- hasSideBar: boolean;
31
- headerType: HeaderType;
32
- animatedHeader?: AnimatedHeader;
33
- inputSearchProps?: SearchHeaderProps;
34
- useShadowHeader: boolean;
35
- gradientColor?: string;
36
- headerBackground?: string;
37
- layoutOffset: number;
38
- contentLayout?: HeaderContentLayout;
39
- };
40
-
41
- /**
42
- * Transparent header for an `inputSearchProps` Screen: its title fades out over the
43
- * first 50pt of scroll while the search collapses into the bar.
44
- */
45
- const getSearchTitleOptions = (
46
- sharedValue: SharedValue<number>,
47
- ): StackNavigationOptions => {
48
- return {
49
- headerShown: true,
50
- headerTransparent: true,
51
- headerBackground: () => null,
52
- headerTitle: (props: any) => (
53
- <HeaderTitle
54
- {...props}
55
- interpolate={{
56
- inputRange: [0, 50],
57
- outputRange: [1, 0],
58
- }}
59
- animatedValue={sharedValue}
60
- />
61
- ),
62
- };
63
- };
64
-
65
- /**
66
- * Applies the Screen's navigation header (plain, extended, animated banner or search) and
67
- * re-applies it when those props change. Returns the search header setter and the tint.
68
- */
69
- export const useScreenHeader = ({
70
- navigation,
71
- layout,
72
- sharedValue,
73
- quickReturnOptions,
74
- hasSideBar,
75
- headerType,
76
- animatedHeader,
77
- inputSearchProps,
78
- useShadowHeader,
79
- gradientColor,
80
- headerBackground,
81
- layoutOffset,
82
- contentLayout,
83
- }: ScreenHeaderParams) => {
84
- const currentTint = useRef<string | undefined>(undefined);
85
- const appliedHeaderMode = useRef<string | undefined>(undefined);
86
- const headerLayout = useHeaderLayout(contentLayout);
87
- const frameOptions = useHeaderFrameOptions(contentLayout);
88
-
89
- // keepTitle leaves a title the screen set itself when the same type is re-applied
90
- const setHeaderType = useCallback(
91
- (type: HeaderType, keepTitle = false) => {
92
- let options: StackNavigationOptions;
93
- switch (type) {
94
- case 'none':
95
- options = {
96
- headerTransparent: true,
97
- headerBackground: () => null,
98
- headerShown: false,
99
- };
100
- break;
101
-
102
- case 'extended':
103
- options = {
104
- ...quickReturnOptions,
105
- headerShown: true,
106
- headerTransparent: true,
107
- headerBackground: () => {
108
- if (!hasSideBar) {
109
- return null;
110
- }
111
- return <DuoGlassBackground animatedValue={sharedValue} />;
112
- },
113
- headerTitle: (props: any) => <HeaderTitle {...props} />,
114
- };
115
- if (inputSearchProps) {
116
- options = getSearchTitleOptions(sharedValue);
117
- }
118
- break;
119
-
120
- default:
121
- if (hasSideBar && !inputSearchProps) {
122
- options = {
123
- ...quickReturnOptions,
124
- headerTransparent: true,
125
- headerTintColor: Colors.black_17,
126
- headerShown: true,
127
- headerBackground: () => (
128
- <DuoGlassBackground animatedValue={sharedValue} />
129
- ),
130
- headerTitle: (props: any) => <HeaderTitle {...props} />,
131
- };
132
- break;
133
- }
134
- options = {
135
- headerTransparent: false,
136
- headerTintColor: Colors.black_17,
137
- headerShown: true,
138
- headerBackground: (props: any) => (
139
- <HeaderBackground
140
- {...props}
141
- animatedValue={sharedValue}
142
- useShadowHeader={useShadowHeader}
143
- headerBackground={headerBackground}
144
- gradientColor={gradientColor}
145
- />
146
- ),
147
- headerTitle: (props: any) => <HeaderTitle {...props} />,
148
- };
149
- if (inputSearchProps) {
150
- options = getSearchTitleOptions(sharedValue);
151
- }
152
- }
153
-
154
- if (keepTitle) {
155
- delete options.headerTitle;
156
- }
157
-
158
- navigation?.instance?.setOptions({
159
- header: undefined,
160
- ...frameOptions,
161
- ...options,
162
- });
163
- },
164
- [
165
- gradientColor,
166
- headerBackground,
167
- inputSearchProps,
168
- navigation?.instance,
169
- sharedValue,
170
- useShadowHeader,
171
- hasSideBar,
172
- quickReturnOptions,
173
- frameOptions,
174
- ],
175
- );
176
-
177
- // the first tint the animated header sets is kept for later scroll updates
178
- const setAnimatedHeader = useCallback(
179
- (nextAnimatedHeader: AnimatedHeader) => {
180
- let options: StackNavigationOptions;
181
- if (!currentTint.current) {
182
- currentTint.current = nextAnimatedHeader?.headerTintColor;
183
- }
184
-
185
- options = {
186
- ...quickReturnOptions,
187
- headerTintColor: currentTint.current ?? Colors.black_17,
188
- headerTransparent: true,
189
- headerBackground: (props: any) => {
190
- if (hasSideBar) {
191
- return (
192
- <DuoGlassBackground
193
- animatedValue={sharedValue}
194
- bannerBottom={ANIMATED_BANNER_HEIGHT + layoutOffset}
195
- />
196
- );
197
- }
198
- return (
199
- <HeaderBackground
200
- {...props}
201
- animatedValue={sharedValue}
202
- useGradient={false}
203
- useShadowHeader={useShadowHeader}
204
- headerBackground={headerBackground}
205
- gradientColor={gradientColor}
206
- />
207
- );
208
- },
209
- headerTitle: (props: any) => {
210
- return <HeaderTitle {...props} />;
211
- },
212
- };
213
-
214
- if (nextAnimatedHeader.headerTitle) {
215
- options = {
216
- ...options,
217
- ...exportHeaderTitle(nextAnimatedHeader),
218
- };
219
- }
220
-
221
- navigation?.instance?.setOptions({ ...frameOptions, ...options });
222
- },
223
- [
224
- gradientColor,
225
- headerBackground,
226
- navigation?.instance,
227
- sharedValue,
228
- useShadowHeader,
229
- hasSideBar,
230
- layoutOffset,
231
- quickReturnOptions,
232
- frameOptions,
233
- ],
234
- );
235
-
236
- const setAnimatedSearch = useCallback(() => {
237
- const options = getSearchTitleOptions(sharedValue);
238
- navigation?.instance?.setOptions({
239
- header: undefined,
240
- ...frameOptions,
241
- ...options,
242
- });
243
- }, [navigation?.instance, sharedValue, frameOptions]);
244
-
245
- // the search field spans the content (or the stretch frame), clear of the side bar
246
- // and status bar clusters
247
- const setSearchHeader = (params: SearchHeaderProps) => {
248
- let searchWidth = headerLayout.frameWidth;
249
- let searchLeft = Spacing.M;
250
- if (layout.sideBar) {
251
- searchWidth = layout.contentWidth - Spacing.M * 2;
252
- searchLeft = Spacing.M - getHeaderMargin(layout.width);
253
- }
254
- const clearance = layout.statusBarClearance;
255
- if (clearance) {
256
- searchWidth -= clearance.left + clearance.right;
257
- }
258
- const options: StackNavigationOptions = {
259
- ...frameOptions,
260
- headerRight: undefined,
261
- headerTitleContainerStyle: {
262
- width: searchWidth,
263
- maxWidth: searchWidth,
264
- marginLeft: 0,
265
- marginEnd: 0,
266
- marginStart: 0,
267
- marginHorizontal: 0,
268
- marginVertical: 0,
269
- margin: 0,
270
- left: searchLeft,
271
- },
272
- headerLeft: (props: any) => {
273
- if (params?.hiddenBack) {
274
- return null;
275
- }
276
- return <HeaderLeft {...props} floating />;
277
- },
278
- headerTitle: () => (
279
- <SearchHeader {...params} animatedValue={sharedValue} />
280
- ),
281
- };
282
-
283
- navigation?.instance?.setOptions(options);
284
- };
285
-
286
- useEffect(() => {
287
- const focus = navigation?.instance?.addListener?.('focus', () => {
288
- let barStyle: StatusBarStyle = 'dark-content';
289
- if (currentTint.current === Colors.black_01) {
290
- barStyle = 'light-content';
291
- }
292
- StatusBar.setBarStyle(barStyle, true);
293
- });
294
-
295
- if (animatedHeader) {
296
- setAnimatedHeader(animatedHeader);
297
- appliedHeaderMode.current = 'animated';
298
- } else if (inputSearchProps) {
299
- setAnimatedSearch();
300
- appliedHeaderMode.current = 'search';
301
- } else {
302
- setHeaderType(headerType, appliedHeaderMode.current === headerType);
303
- appliedHeaderMode.current = headerType;
304
- }
305
-
306
- return () => {
307
- focus?.();
308
- };
309
- }, [
310
- headerType,
311
- animatedHeader,
312
- inputSearchProps,
313
- useShadowHeader,
314
- navigation?.instance,
315
- setAnimatedHeader,
316
- setAnimatedSearch,
317
- setHeaderType,
318
- ]);
319
-
320
- return { setSearchHeader, currentTint };
321
- };
@@ -1,64 +0,0 @@
1
- import React, { useMemo } from 'react';
2
- import { StackNavigationOptions } from '@react-navigation/stack';
3
- import {
4
- SharedValue,
5
- useAnimatedReaction,
6
- useSharedValue,
7
- withTiming,
8
- } from 'react-native-reanimated';
9
- import { DuoQuickReturnHeader } from '../Application/Components/DuoQuickReturnHeader';
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
- export const useScreenQuickReturn = (
16
- sharedValue: SharedValue<number>,
17
- useQuickReturn: boolean,
18
- heightHeader: number,
19
- ) => {
20
- const headerHide = useSharedValue(0);
21
- const lastScrollY = useSharedValue(0);
22
-
23
- useAnimatedReaction(
24
- () => sharedValue.value,
25
- y => {
26
- const delta = y - lastScrollY.value;
27
- lastScrollY.value = y;
28
- if (!useQuickReturn || y <= 0) {
29
- headerHide.value = 0;
30
- return;
31
- }
32
- headerHide.value = Math.min(
33
- Math.max(headerHide.value + delta, 0),
34
- heightHeader,
35
- );
36
- },
37
- [useQuickReturn, heightHeader],
38
- );
39
-
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]);
50
-
51
- // a half-shown quick return header settles fully in or out
52
- const snapQuickReturnHeader = (offsetY: number) => {
53
- const hide = headerHide.value;
54
- const isSettled = hide <= 0 || hide >= heightHeader;
55
- if (!useQuickReturn || offsetY < heightHeader || isSettled) {
56
- return;
57
- }
58
- headerHide.value = withTiming(hide > heightHeader / 2 ? heightHeader : 0, {
59
- duration: 200,
60
- });
61
- };
62
-
63
- return { quickReturnOptions, snapQuickReturnHeader };
64
- };
@@ -1,107 +0,0 @@
1
- import { MutableRefObject } from 'react';
2
- import {
3
- Animated,
4
- NativeScrollEvent,
5
- NativeSyntheticEvent,
6
- ScrollViewProps,
7
- StatusBar,
8
- StatusBarStyle,
9
- } from 'react-native';
10
- import { withTiming } from 'react-native-reanimated';
11
- import Navigation from '../Application/Navigation';
12
- import { AnimatedHeader, SearchHeaderProps } from '../Application/types';
13
- import { Colors } from '../Consts';
14
-
15
- type ScrollHandlerParams = {
16
- scrollable: boolean;
17
- animatedValue: Animated.Value;
18
- sharedValue: any;
19
- scrollViewProps?: ScrollViewProps;
20
- animatedHeader?: AnimatedHeader;
21
- inputSearchProps?: SearchHeaderProps;
22
- currentTint: MutableRefObject<string | undefined>;
23
- navigation?: Navigation;
24
- snapQuickReturnHeader: (offsetY: number) => void;
25
- ref: any;
26
- };
27
-
28
- /**
29
- * Scroll handlers for Screen: feed the header animated values, retint an animated header
30
- * past 50pt, snap the quick return header and reset a search screen scrolled under 100pt.
31
- */
32
- export const createScrollHandlers = ({
33
- scrollable,
34
- animatedValue,
35
- sharedValue,
36
- scrollViewProps,
37
- animatedHeader,
38
- inputSearchProps,
39
- currentTint,
40
- navigation,
41
- snapQuickReturnHeader,
42
- ref,
43
- }: ScrollHandlerParams) => {
44
- let handleScroll;
45
-
46
- if (scrollable) {
47
- handleScroll = Animated.event(
48
- [
49
- {
50
- nativeEvent: {
51
- contentOffset: { y: animatedValue as Animated.Value },
52
- },
53
- },
54
- ],
55
- {
56
- useNativeDriver: true,
57
- listener: (e: NativeSyntheticEvent<NativeScrollEvent>) => {
58
- const offsetY = e.nativeEvent.contentOffset.y;
59
- sharedValue.value = offsetY;
60
- scrollViewProps?.onScroll?.(e);
61
- if (animatedHeader) {
62
- let color = animatedHeader?.headerTintColor ?? Colors.black_17;
63
- if (offsetY > 50) {
64
- color = Colors.black_17;
65
- }
66
- if (color !== currentTint.current) {
67
- currentTint.current = color;
68
- navigation?.setOptions({
69
- headerTintColor: color,
70
- });
71
-
72
- let barStyle: StatusBarStyle = 'dark-content';
73
- if (currentTint.current === Colors.black_01) {
74
- barStyle = 'light-content';
75
- }
76
- StatusBar.setBarStyle(barStyle, true);
77
- }
78
- }
79
- },
80
- },
81
- );
82
- }
83
-
84
- const handleMomentumScrollEnd = (
85
- e: NativeSyntheticEvent<NativeScrollEvent>,
86
- ) => {
87
- snapQuickReturnHeader(e.nativeEvent.contentOffset.y);
88
- scrollViewProps?.onMomentumScrollEnd?.(e);
89
- };
90
-
91
- const handleScrollEnd = (e: NativeSyntheticEvent<NativeScrollEvent>) => {
92
- const offsetY = e.nativeEvent.contentOffset.y;
93
- snapQuickReturnHeader(offsetY);
94
- if (inputSearchProps && offsetY < 100 && offsetY > 0) {
95
- Animated.timing(animatedValue, {
96
- toValue: 0,
97
- useNativeDriver: true,
98
- duration: 300,
99
- }).start();
100
- sharedValue.value = withTiming(0, { duration: 300 });
101
- ref?.scrollTo?.({ y: 0, animated: true });
102
- }
103
- scrollViewProps?.onScrollEndDrag?.(e);
104
- };
105
-
106
- return { handleScroll, handleScrollEnd, handleMomentumScrollEnd };
107
- };
@@ -1,143 +0,0 @@
1
- import React, { ReactNode, Ref } from 'react';
2
- import { Animated, ScrollViewProps, ViewProps } from 'react-native';
3
- import Navigation from '../Application/Navigation';
4
- import {
5
- AnimatedHeader,
6
- ScreenTrackingParams,
7
- SearchHeaderProps,
8
- } from '../Application/types';
9
- import { FloatingButtonProps } from './FloatingButton';
10
- import { HeaderType } from './types';
11
- import { InputRef } from '../Input';
12
- import type { HeaderContentLayout } from '../Application/headerLayout';
13
-
14
- export const ANIMATED_BANNER_HEIGHT = 210;
15
-
16
- export interface ScreenProps extends ViewProps {
17
- /**
18
- * ReactNode representing the content of the screen.
19
- */
20
- children: React.ReactNode;
21
- /**
22
- * Optional. Navigation object for handling navigation actions.
23
- */
24
- navigation?: Navigation;
25
-
26
- /**
27
- * Optional. If `true`, enable keyboard avoiding view for the screen.
28
- */
29
- enableKeyboardAvoidingView?: boolean;
30
-
31
- /**
32
- * Optional. If `true`, the screen content is scrollable.
33
- */
34
- scrollable?: boolean;
35
-
36
- /**
37
- * Optional. Set type of header.
38
- */
39
- headerType?: HeaderType;
40
-
41
- /**
42
- * Optional. Animated banner header: its component, tint and title.
43
- */
44
- animatedHeader?: AnimatedHeader;
45
-
46
- /**
47
- * Optional. Props for the underlying ScrollView component when `scrollable` is `true`.
48
- */
49
- scrollViewProps?: ScrollViewProps;
50
-
51
- /**
52
- * Optional. ReactNode representing the header component of the screen.
53
- */
54
- headerComponent?: ReactNode;
55
-
56
- /**
57
- * Optional. ReactNode representing the footer component of the screen.
58
- */
59
- footerComponent?: ReactNode;
60
-
61
- /**
62
- * Optional. If `true`, the footer is inset by the standard horizontal margin
63
- * (12pt each side). Set `false` for a footer that should span the full width —
64
- * e.g. one that already carries its own horizontal padding.
65
- * Defaults to `true`, on every platform.
66
- */
67
- marginFooter?: boolean;
68
-
69
- /**
70
- * Optional. Background color of the screen.
71
- */
72
- backgroundColor?: string;
73
-
74
- /**
75
- * Optional. Shift of the content against the animated header banner bottom; negative
76
- * values overlap the banner.
77
- */
78
- layoutOffset?: -8 | -24 | -56 | number;
79
-
80
- /**
81
- * Optional. Width of the right header. Defaults to the toolkit width (84), or 0 when
82
- * iPhone Duo floats the toolkit into its side bar.
83
- */
84
- headerRightWidth?: 0 | 84 | 124 | number;
85
-
86
- /**
87
- * Optional. `stretch` centers back, title or search and the right cluster of the
88
- * header in a 600pt frame on wide windows (foldable inner display, tablet); the
89
- * background and status bar stay full width. Defaults to `grid`.
90
- */
91
- contentLayout?: HeaderContentLayout;
92
-
93
- /**
94
- * Optional. Props for the floating action button.
95
- */
96
- floatingButtonProps?: Omit<FloatingButtonProps, 'animatedValue' | 'bottom'>;
97
-
98
- /**
99
- * Optional. Keyboard vertical offset.
100
- */
101
- keyboardVerticalOffset?: number;
102
-
103
- /**
104
- * Optional. If `true`, the screen content is using grid layout by span.
105
- */
106
- useGridLayout?: boolean;
107
-
108
- /**
109
- * Optional. specs for input search.
110
- */
111
- inputSearchProps?: SearchHeaderProps;
112
-
113
- /**
114
- * Optional. Ref for input search.
115
- */
116
- inputSearchRef?: Ref<InputRef>;
117
-
118
- /**
119
- * Optional. React Native animated value for header.
120
- * Internally, Screen mirrors it into a reanimated shared value.
121
- */
122
- animatedValue?: Animated.Value;
123
-
124
- /**
125
- * Optional. If `true`, use shadow header.
126
- */
127
- useShadowHeader?: boolean;
128
-
129
- /**
130
- * Optional. Custom header Gradient Color.
131
- */
132
- gradientColor?: string;
133
-
134
- /**
135
- * Optional. Custom headerBackground Image
136
- */
137
- headerBackground?: string;
138
-
139
- /**
140
- * Optional. Custom tracking params
141
- */
142
- trackingParams?: ScreenTrackingParams;
143
- }