@momo-kits/foundation 0.168.1-rn862.1 → 0.169.2

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 (109) hide show
  1. package/Application/BottomSheet.hooks.ts +195 -0
  2. package/Application/BottomSheet.parts.tsx +147 -0
  3. package/Application/BottomSheet.styles.ts +43 -0
  4. package/Application/BottomSheet.tsx +76 -279
  5. package/Application/BottomTab/ActiveIndicator.tsx +90 -0
  6. package/Application/BottomTab/BottomTabBar.styles.ts +65 -0
  7. package/Application/BottomTab/BottomTabBar.tsx +229 -276
  8. package/Application/BottomTab/BottomTabInset.tsx +14 -0
  9. package/Application/BottomTab/CurvedContainer.tsx +153 -0
  10. package/Application/BottomTab/CustomBottomTabItem.tsx +132 -108
  11. package/Application/BottomTab/DuoBarCompression.tsx +4 -12
  12. package/Application/BottomTab/DuoRailTabBar.tsx +227 -0
  13. package/Application/BottomTab/DuoTabBar.styles.ts +81 -0
  14. package/Application/BottomTab/DuoTabBar.tsx +29 -495
  15. package/Application/BottomTab/TabBarIcon.tsx +160 -72
  16. package/Application/BottomTab/TabScreen.tsx +164 -0
  17. package/Application/BottomTab/index.tsx +84 -351
  18. package/Application/BottomTab/metrics.ts +164 -0
  19. package/Application/BottomTab/tabItems.ts +46 -0
  20. package/Application/BottomTab/usePressLift.ts +32 -0
  21. package/Application/Components/DuoGlassBackground.tsx +7 -9
  22. package/Application/Components/HeaderAnimated.tsx +1 -1
  23. package/Application/Components/HeaderBackground.tsx +1 -1
  24. package/Application/Components/HeaderExtendHeader.tsx +17 -11
  25. package/Application/Components/HeaderRight.styles.ts +144 -0
  26. package/Application/Components/HeaderRight.tsx +6 -528
  27. package/Application/Components/HeaderTitle.shared.ts +43 -0
  28. package/Application/Components/HeaderTitle.styles.ts +125 -0
  29. package/Application/Components/HeaderTitle.tsx +12 -576
  30. package/Application/Components/HeaderToolkitAction.tsx +208 -0
  31. package/Application/Components/NavigationButton.tsx +9 -6
  32. package/Application/Components/SearchHeader.tsx +1 -1
  33. package/Application/Components/SwipeBackHaptic.tsx +95 -0
  34. package/Application/Components/TitleJourney.tsx +110 -0
  35. package/Application/Components/TitleLocation.tsx +73 -0
  36. package/Application/Components/TitleUser.tsx +304 -0
  37. package/Application/Components/useToolkitActions.tsx +233 -0
  38. package/Application/ModalIconButton.tsx +66 -0
  39. package/Application/ModalScreen.tsx +39 -18
  40. package/Application/Navigation.ts +1 -1
  41. package/Application/NavigationContainer.tsx +7 -8
  42. package/Application/StackScreen.tracking.ts +158 -0
  43. package/Application/StackScreen.tsx +10 -137
  44. package/Application/WidgetContainer.tsx +10 -3
  45. package/Application/__tests__/modalLayout.test.ts +128 -0
  46. package/Application/hooks.ts +137 -0
  47. package/Application/index.ts +13 -1
  48. package/Application/modalLayout.ts +177 -0
  49. package/Application/navigationOptions.tsx +217 -0
  50. package/Application/types.header.ts +116 -0
  51. package/Application/types.tabs.ts +48 -0
  52. package/Application/types.theme.ts +87 -0
  53. package/Application/types.ts +12 -244
  54. package/Application/utils.ts +107 -0
  55. package/Badge/BadgeRibbon.tsx +3 -3
  56. package/Badge/styles.ts +2 -0
  57. package/Button/index.tsx +16 -136
  58. package/Button/styles.ts +1 -1
  59. package/Button/utils.ts +139 -0
  60. package/CheckBox/index.tsx +1 -6
  61. package/Divider/DashDivider.tsx +10 -11
  62. package/Divider/index.tsx +18 -8
  63. package/Image/index.tsx +1 -46
  64. package/Input/Input.tsx +7 -8
  65. package/Input/InputDropDown.tsx +3 -4
  66. package/Input/InputMoney.tsx +38 -164
  67. package/Input/InputMoneyView.tsx +187 -0
  68. package/Input/InputOTP.tsx +1 -1
  69. package/Input/InputPhoneNumber.tsx +5 -1
  70. package/Input/InputSearch.tsx +2 -108
  71. package/Input/InputTextArea.tsx +1 -5
  72. package/Input/SearchTextTyping.tsx +104 -0
  73. package/Input/common.tsx +4 -4
  74. package/Input/moneyUtils.ts +17 -0
  75. package/Input/styles.ts +26 -2
  76. package/Layout/FloatingButton.tsx +22 -21
  77. package/Layout/ReservedRegions.tsx +21 -4
  78. package/Layout/Screen.tsx +74 -670
  79. package/Layout/Section.tsx +1 -2
  80. package/Layout/index.ts +10 -4
  81. package/Layout/layoutMetrics.ts +58 -0
  82. package/Layout/layoutTypes.ts +86 -0
  83. package/Layout/screenContent.tsx +90 -0
  84. package/Layout/screenFooter.tsx +53 -0
  85. package/Layout/screenHeader.tsx +315 -0
  86. package/Layout/screenQuickReturn.tsx +67 -0
  87. package/Layout/screenScroll.ts +110 -0
  88. package/Layout/screenTypes.ts +134 -0
  89. package/Layout/styles.ts +2 -0
  90. package/Layout/utils.ts +10 -144
  91. package/Loader/DotLoader.tsx +7 -3
  92. package/Loader/ProgressBar.tsx +2 -6
  93. package/Loader/Spinner.tsx +7 -3
  94. package/Loader/styles.ts +4 -0
  95. package/Popup/PopupNotify.tsx +70 -64
  96. package/Popup/PopupPromotion.tsx +5 -4
  97. package/Popup/types.ts +7 -0
  98. package/Popup/utils.ts +46 -24
  99. package/Radio/index.tsx +2 -10
  100. package/Radio/styles.ts +6 -0
  101. package/Skeleton/index.tsx +1 -9
  102. package/Skeleton/styles.ts +1 -0
  103. package/Tag/index.tsx +3 -3
  104. package/Text/index.tsx +11 -2
  105. package/Title/index.tsx +2 -9
  106. package/Title/styles.ts +6 -0
  107. package/package.json +21 -22
  108. package/Application/device.ts +0 -29
  109. package/Application/utils.tsx +0 -497
@@ -0,0 +1,46 @@
1
+ import { BottomTabBarProps } from '@react-navigation/bottom-tabs';
2
+ import { CommonActions, Route } from '@react-navigation/native';
3
+
4
+ /**
5
+ * navigation items of the tab bar, with the press handlers of the system tab bar
6
+ */
7
+ const getTabItems = ({ state, descriptors, navigation }: BottomTabBarProps) => {
8
+ return state.routes.map((route: Route<string>, index: number) => {
9
+ const { options } = descriptors[route.key];
10
+ const focused = index === state.index;
11
+ const label = `${options.title ?? route.name}`;
12
+
13
+ const onPress = () => {
14
+ const event = navigation.emit({
15
+ type: 'tabPress',
16
+ target: route.key,
17
+ canPreventDefault: true,
18
+ });
19
+ if (!focused && !event.defaultPrevented) {
20
+ navigation.dispatch({
21
+ ...CommonActions.navigate(route.name),
22
+ target: state.key,
23
+ });
24
+ }
25
+ };
26
+
27
+ const onLongPress = () => {
28
+ navigation.emit({ type: 'tabLongPress', target: route.key });
29
+ };
30
+
31
+ return {
32
+ route,
33
+ focused,
34
+ label,
35
+ icon: options.tabBarIcon as any,
36
+ badge: options.tabBarBadge,
37
+ onPress,
38
+ onLongPress,
39
+ };
40
+ });
41
+ };
42
+
43
+ type TabItem = ReturnType<typeof getTabItems>[number];
44
+
45
+ export { getTabItems };
46
+ export type { TabItem };
@@ -0,0 +1,32 @@
1
+ import {
2
+ useAnimatedStyle,
3
+ useReducedMotion,
4
+ useSharedValue,
5
+ withSpring,
6
+ } from 'react-native-reanimated';
7
+
8
+ const SPRING = { damping: 18, stiffness: 220, mass: 0.8 };
9
+ // the button grows by a tenth while held
10
+ const PRESSED_SCALE = 1.1;
11
+
12
+ /**
13
+ * lift for a single button, e.g. the compressed rail
14
+ */
15
+ const usePressLift = () => {
16
+ const reduceMotion = useReducedMotion();
17
+ const lift = useSharedValue(0);
18
+ const style = useAnimatedStyle(() => ({
19
+ transform: [{ scale: 1 + lift.value * (PRESSED_SCALE - 1) }],
20
+ }));
21
+ const onPressIn = () => {
22
+ if (!reduceMotion) {
23
+ lift.value = withSpring(1, SPRING);
24
+ }
25
+ };
26
+ const onPressOut = () => {
27
+ lift.value = withSpring(0, SPRING);
28
+ };
29
+ return { style, onPressIn, onPressOut };
30
+ };
31
+
32
+ export { usePressLift };
@@ -9,13 +9,12 @@ import Animated, {
9
9
  import { ApplicationContext } from '../../Context';
10
10
  import { Shadow } from '../../Consts';
11
11
  import { Image } from '../../Image';
12
- import { AnimatedCompatValue, useNormalizedSharedValue } from '../utils';
12
+ import { type AnimatedCompatValue } from '../utils';
13
+ import { useNormalizedSharedValue } from '../hooks';
14
+ import { useScreenLayout } from '../../Layout';
13
15
 
14
- // extended headers run their gradient this far below the header, as off Duo
15
16
  const EXTENDED_GRADIENT_EXTRA = 52;
16
- // scroll distance over which the extended gradient collapses to the header
17
17
  const EXTENDED_COLLAPSE_DISTANCE = 100;
18
- // scroll distance over which the bar material fades in
19
18
  const FADE_DISTANCE = 16;
20
19
  const TRANSLUCENT_ALPHA = 'CC';
21
20
 
@@ -25,11 +24,12 @@ const TRANSLUCENT_ALPHA = 'CC';
25
24
  */
26
25
  const DuoGlassBackground: React.FC<{
27
26
  animatedValue?: AnimatedCompatValue;
28
- // scroll offset where the bar starts to show, e.g. below an animated banner
29
- fadeStart?: number;
30
- }> = ({ animatedValue, fadeStart = 0 }) => {
27
+ bannerBottom?: number;
28
+ }> = ({ animatedValue, bannerBottom = 0 }) => {
31
29
  const { theme } = useContext(ApplicationContext);
30
+ const { headerHeight } = useScreenLayout();
32
31
  const sharedValue = useNormalizedSharedValue(animatedValue);
32
+ const fadeStart = Math.max(bannerBottom - headerHeight, 0);
33
33
 
34
34
  const fadeStyle = useAnimatedStyle(() => ({
35
35
  opacity: interpolate(
@@ -68,7 +68,6 @@ const DuoScrollGradient: React.FC<{
68
68
  headerBackground?: string;
69
69
  heightHeader: number;
70
70
  extended?: boolean;
71
- // quick return header: the gradient leaves with the content instead of fading
72
71
  followScroll?: boolean;
73
72
  }> = ({
74
73
  animatedValue,
@@ -147,7 +146,6 @@ const styles = StyleSheet.create({
147
146
  right: 0,
148
147
  overflow: 'hidden',
149
148
  },
150
- // banner image keeps its 375:154 shape, the gradient box clips it
151
149
  gradientFill: {
152
150
  width: '100%',
153
151
  position: 'absolute',
@@ -8,7 +8,7 @@ import { type HeaderAnimatedProps } from '../types';
8
8
  import React from 'react';
9
9
  import { Image } from '../../Image';
10
10
  import { Colors } from '../../Consts';
11
- import { useNormalizedSharedValue } from '../utils';
11
+ import { useNormalizedSharedValue } from '../hooks';
12
12
 
13
13
  const ASPECT_RATIOS: Record<
14
14
  NonNullable<HeaderAnimatedProps['aspectRatio']>,
@@ -7,7 +7,7 @@ import { ApplicationContext, MiniAppContext } from '../../Context';
7
7
  import { Colors, Styles } from '../../Consts';
8
8
  import { Image } from '../../Image';
9
9
  import BackgroundImageView from './BackgroundImageView';
10
- import { useNormalizedSharedValue } from '../utils';
10
+ import { useNormalizedSharedValue } from '../hooks';
11
11
 
12
12
  const HeaderBackground: React.FC<HeaderBackgroundProps> = ({
13
13
  animatedValue,
@@ -14,7 +14,8 @@ import { Colors, Radius, Spacing } from '../../Consts';
14
14
  import { Image } from '../../Image';
15
15
  import { SearchHeaderProps } from '../types';
16
16
  import BackgroundImageView from './BackgroundImageView';
17
- import { AnimatedCompatValue, useNormalizedSharedValue } from '../utils';
17
+ import { type AnimatedCompatValue } from '../utils';
18
+ import { useNormalizedSharedValue } from '../hooks';
18
19
  import { useScreenLayout } from '../../Layout';
19
20
  import { DuoMetrics, HeaderMetrics } from '../../Layout/utils';
20
21
 
@@ -147,7 +148,9 @@ const HeaderExtendHeader: React.FC<{
147
148
 
148
149
  if (inputSearchProps) {
149
150
  return (
150
- <View style={[{ zIndex: 0 }, showBaseLineDebug && styles.debugBaseLine]}>
151
+ <View
152
+ style={[styles.container, showBaseLineDebug && styles.debugBaseLine]}
153
+ >
151
154
  <Animated.View style={heightStyle} />
152
155
  <BackgroundImageView
153
156
  useShadowHeader={useShadowHeader}
@@ -186,14 +189,7 @@ const HeaderExtendHeader: React.FC<{
186
189
  )}
187
190
  </Animated.View>
188
191
  <Animated.View
189
- style={[
190
- {
191
- justifyContent: 'flex-end',
192
- position: 'absolute',
193
- zIndex: 2,
194
- },
195
- heightStyle,
196
- ]}
192
+ style={[styles.searchContainer, heightStyle]}
197
193
  >
198
194
  <Animated.View
199
195
  style={[{ marginVertical: Spacing.S }, searchTranslateStyle]}
@@ -216,7 +212,9 @@ const HeaderExtendHeader: React.FC<{
216
212
 
217
213
  if (headerType === 'extended') {
218
214
  return (
219
- <View style={[{ zIndex: 0 }, showBaseLineDebug && styles.debugBaseLine]}>
215
+ <View
216
+ style={[styles.container, showBaseLineDebug && styles.debugBaseLine]}
217
+ >
220
218
  <BackgroundImageView
221
219
  useShadowHeader={useShadowHeader}
222
220
  heightHeader={heightHeader}
@@ -283,6 +281,14 @@ const styles = StyleSheet.create({
283
281
  alignSelf: 'center',
284
282
  },
285
283
  debugBaseLine: { borderWidth: 1, borderColor: Colors.green_06 },
284
+ container: {
285
+ zIndex: 0,
286
+ },
287
+ searchContainer: {
288
+ justifyContent: 'flex-end',
289
+ position: 'absolute',
290
+ zIndex: 2,
291
+ },
286
292
  });
287
293
 
288
294
  export { HeaderExtendHeader };
@@ -0,0 +1,144 @@
1
+ import { Platform, StyleSheet } from 'react-native';
2
+ import { Colors, Spacing } from '../../Consts';
3
+
4
+ export const styles = StyleSheet.create({
5
+ navigationButton: {
6
+ height: 28,
7
+ width: 28,
8
+ borderRadius: 14,
9
+ justifyContent: 'center',
10
+ alignItems: 'center',
11
+ backgroundColor: Colors.black_01 + '99',
12
+ borderColor: Colors.black_20 + '33',
13
+ borderWidth: 0.2,
14
+ },
15
+ headerBackground: {
16
+ width: '100%',
17
+ height: undefined,
18
+ position: 'absolute',
19
+ aspectRatio: 375 / 154,
20
+ },
21
+ headerTitleContainer: {
22
+ alignItems: 'center',
23
+ justifyContent: 'center',
24
+ width: '70%',
25
+ },
26
+ circle: {
27
+ width: 32,
28
+ height: 32,
29
+ borderRadius: 16,
30
+ borderWidth: 0.5,
31
+ borderColor: Colors.black_04,
32
+ },
33
+ dotAvatar: {
34
+ position: 'absolute',
35
+ width: 12,
36
+ height: 12,
37
+ borderRadius: 6,
38
+ bottom: -2,
39
+ right: -2,
40
+ borderWidth: 2,
41
+ borderColor: Colors.black_01,
42
+ },
43
+ headerButton: { paddingHorizontal: 4 },
44
+ headerRightButton: {
45
+ flexDirection: 'row',
46
+ justifyContent: 'center',
47
+ alignItems: 'center',
48
+ paddingRight: Spacing.M,
49
+ },
50
+ toolkitContainer: {
51
+ height: 28,
52
+ borderRadius: 14,
53
+ justifyContent: 'center',
54
+ alignItems: 'center',
55
+ flexDirection: 'row',
56
+ backgroundColor: Colors.black_01 + '99',
57
+ borderColor: Colors.black_20 + '33',
58
+ borderWidth: 0.2,
59
+ marginLeft: Spacing.S,
60
+ },
61
+ toolkitButton: {
62
+ padding: 4,
63
+ },
64
+ divider: {
65
+ width: 0.5,
66
+ height: 12,
67
+ },
68
+ sideBarColumn: {
69
+ gap: Spacing.M,
70
+ },
71
+ sideBarRow: {
72
+ flexDirection: 'row',
73
+ gap: Spacing.M,
74
+ },
75
+ headerLeft: {
76
+ marginLeft: 12,
77
+ },
78
+ badge: {
79
+ position: 'absolute',
80
+ top: -Spacing.S,
81
+ right: -6,
82
+ },
83
+ badgeDot: {
84
+ position: 'absolute',
85
+ top: -Spacing.XXS,
86
+ right: -Spacing.XXS,
87
+ },
88
+ badgeDotAnimation: {
89
+ position: 'absolute',
90
+ top: -Spacing.XS,
91
+ right: -Spacing.XS,
92
+ },
93
+ gradientContainer: {
94
+ width: '100%',
95
+ height: '100%',
96
+ position: 'absolute',
97
+ overflow: 'hidden',
98
+ },
99
+ extendedHeader: {
100
+ aspectRatio: 2.43,
101
+ position: 'absolute',
102
+ width: '100%',
103
+ },
104
+ verifiedDot: {
105
+ width: 4,
106
+ height: 4,
107
+ borderRadius: 2,
108
+ backgroundColor: Colors.green_03,
109
+ position: 'absolute',
110
+ alignSelf: 'center',
111
+ },
112
+ shadowHeader: {
113
+ ...Platform.select({
114
+ ios: {
115
+ shadowColor: Colors.black_20,
116
+ shadowOffset: {
117
+ width: 3,
118
+ height: 3,
119
+ },
120
+ shadowOpacity: 0.12,
121
+ shadowRadius: 10,
122
+ },
123
+ android: {
124
+ shadowColor: Colors.black_17,
125
+ shadowOffset: {
126
+ width: 3,
127
+ height: 3,
128
+ },
129
+ shadowOpacity: 0.12,
130
+ shadowRadius: 10,
131
+ elevation: 10,
132
+ },
133
+ }),
134
+ },
135
+ onBoarding: {
136
+ marginRight: Spacing.M,
137
+ },
138
+ toolkitWide: {
139
+ width: 65,
140
+ },
141
+ toolkitNarrow: {
142
+ width: 28,
143
+ },
144
+ });