@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.
- package/Application/BottomSheet.hooks.ts +195 -0
- package/Application/BottomSheet.parts.tsx +147 -0
- package/Application/BottomSheet.styles.ts +43 -0
- package/Application/BottomSheet.tsx +76 -279
- package/Application/BottomTab/ActiveIndicator.tsx +90 -0
- package/Application/BottomTab/BottomTabBar.styles.ts +65 -0
- package/Application/BottomTab/BottomTabBar.tsx +229 -276
- package/Application/BottomTab/BottomTabInset.tsx +14 -0
- package/Application/BottomTab/CurvedContainer.tsx +153 -0
- package/Application/BottomTab/CustomBottomTabItem.tsx +132 -108
- package/Application/BottomTab/DuoBarCompression.tsx +4 -12
- package/Application/BottomTab/DuoRailTabBar.tsx +227 -0
- package/Application/BottomTab/DuoTabBar.styles.ts +81 -0
- package/Application/BottomTab/DuoTabBar.tsx +29 -495
- package/Application/BottomTab/TabBarIcon.tsx +160 -72
- package/Application/BottomTab/TabScreen.tsx +164 -0
- package/Application/BottomTab/index.tsx +84 -351
- package/Application/BottomTab/metrics.ts +164 -0
- package/Application/BottomTab/tabItems.ts +46 -0
- package/Application/BottomTab/usePressLift.ts +32 -0
- package/Application/Components/DuoGlassBackground.tsx +7 -9
- package/Application/Components/HeaderAnimated.tsx +1 -1
- package/Application/Components/HeaderBackground.tsx +1 -1
- package/Application/Components/HeaderExtendHeader.tsx +17 -11
- package/Application/Components/HeaderRight.styles.ts +144 -0
- package/Application/Components/HeaderRight.tsx +6 -528
- package/Application/Components/HeaderTitle.shared.ts +43 -0
- package/Application/Components/HeaderTitle.styles.ts +125 -0
- package/Application/Components/HeaderTitle.tsx +12 -576
- package/Application/Components/HeaderToolkitAction.tsx +208 -0
- package/Application/Components/NavigationButton.tsx +9 -6
- package/Application/Components/SearchHeader.tsx +1 -1
- package/Application/Components/SwipeBackHaptic.tsx +95 -0
- package/Application/Components/TitleJourney.tsx +110 -0
- package/Application/Components/TitleLocation.tsx +73 -0
- package/Application/Components/TitleUser.tsx +304 -0
- package/Application/Components/useToolkitActions.tsx +233 -0
- package/Application/ModalIconButton.tsx +66 -0
- package/Application/ModalScreen.tsx +39 -18
- package/Application/Navigation.ts +1 -1
- package/Application/NavigationContainer.tsx +7 -8
- package/Application/StackScreen.tracking.ts +158 -0
- package/Application/StackScreen.tsx +10 -137
- package/Application/WidgetContainer.tsx +10 -3
- package/Application/__tests__/modalLayout.test.ts +128 -0
- package/Application/hooks.ts +137 -0
- package/Application/index.ts +13 -1
- package/Application/modalLayout.ts +177 -0
- package/Application/navigationOptions.tsx +217 -0
- package/Application/types.header.ts +116 -0
- package/Application/types.tabs.ts +48 -0
- package/Application/types.theme.ts +87 -0
- package/Application/types.ts +12 -244
- package/Application/utils.ts +107 -0
- package/Badge/BadgeRibbon.tsx +3 -3
- package/Badge/styles.ts +2 -0
- package/Button/index.tsx +16 -136
- package/Button/styles.ts +1 -1
- package/Button/utils.ts +139 -0
- package/CheckBox/index.tsx +1 -6
- package/Divider/DashDivider.tsx +10 -11
- package/Divider/index.tsx +18 -8
- package/Image/index.tsx +1 -46
- package/Input/Input.tsx +7 -8
- package/Input/InputDropDown.tsx +3 -4
- package/Input/InputMoney.tsx +38 -164
- package/Input/InputMoneyView.tsx +187 -0
- package/Input/InputOTP.tsx +1 -1
- package/Input/InputPhoneNumber.tsx +5 -1
- package/Input/InputSearch.tsx +2 -108
- package/Input/InputTextArea.tsx +1 -5
- package/Input/SearchTextTyping.tsx +104 -0
- package/Input/common.tsx +4 -4
- package/Input/moneyUtils.ts +17 -0
- package/Input/styles.ts +26 -2
- package/Layout/FloatingButton.tsx +22 -21
- package/Layout/ReservedRegions.tsx +21 -4
- package/Layout/Screen.tsx +74 -670
- package/Layout/Section.tsx +1 -2
- package/Layout/index.ts +10 -4
- package/Layout/layoutMetrics.ts +58 -0
- package/Layout/layoutTypes.ts +86 -0
- package/Layout/screenContent.tsx +90 -0
- package/Layout/screenFooter.tsx +53 -0
- package/Layout/screenHeader.tsx +315 -0
- package/Layout/screenQuickReturn.tsx +67 -0
- package/Layout/screenScroll.ts +110 -0
- package/Layout/screenTypes.ts +134 -0
- package/Layout/styles.ts +2 -0
- package/Layout/utils.ts +10 -144
- package/Loader/DotLoader.tsx +7 -3
- package/Loader/ProgressBar.tsx +2 -6
- package/Loader/Spinner.tsx +7 -3
- package/Loader/styles.ts +4 -0
- package/Popup/PopupNotify.tsx +70 -64
- package/Popup/PopupPromotion.tsx +5 -4
- package/Popup/types.ts +7 -0
- package/Popup/utils.ts +46 -24
- package/Radio/index.tsx +2 -10
- package/Radio/styles.ts +6 -0
- package/Skeleton/index.tsx +1 -9
- package/Skeleton/styles.ts +1 -0
- package/Tag/index.tsx +3 -3
- package/Text/index.tsx +11 -2
- package/Title/index.tsx +2 -9
- package/Title/styles.ts +6 -0
- package/package.json +21 -22
- package/Application/device.ts +0 -29
- 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
|
|
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
|
-
|
|
29
|
-
|
|
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 '../
|
|
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 '../
|
|
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
|
|
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
|
|
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
|
|
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
|
+
});
|