@momo-kits/foundation 0.110.1-optimize.1 → 0.110.1-optimize.10
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.tsx +6 -1
- package/Application/Components/HeaderBackground.tsx +16 -7
- package/Application/Components/HeaderExtendHeader.tsx +46 -23
- package/Application/Components/HeaderLeft.tsx +29 -29
- package/Application/Components/HeaderTitle.tsx +1 -1
- package/Application/NavigationContainer.tsx +30 -15
- package/Application/StackScreen.tsx +7 -2
- package/Application/types.ts +1 -0
- package/Input/InputTextArea.tsx +6 -1
- package/Input/styles.ts +1 -0
- package/Text/index.tsx +10 -4
- package/package.json +1 -1
|
@@ -30,6 +30,7 @@ const BottomSheet: React.FC<BottomSheetParams> = props => {
|
|
|
30
30
|
barrierDismissible = false,
|
|
31
31
|
draggable = true,
|
|
32
32
|
useBottomInset = true,
|
|
33
|
+
useKeyboardAvoidingView = true,
|
|
33
34
|
keyboardVerticalOffset,
|
|
34
35
|
}: BottomSheetParams = props.route.params;
|
|
35
36
|
const pan = useRef(
|
|
@@ -172,8 +173,12 @@ const BottomSheet: React.FC<BottomSheetParams> = props => {
|
|
|
172
173
|
}}
|
|
173
174
|
style={styles.overlay}>
|
|
174
175
|
<KeyboardAvoidingView
|
|
175
|
-
behavior={Platform.
|
|
176
|
+
behavior={Platform.select({
|
|
177
|
+
ios: 'padding',
|
|
178
|
+
android: undefined,
|
|
179
|
+
})}
|
|
176
180
|
keyboardVerticalOffset={keyboardVerticalOffset ?? -20}
|
|
181
|
+
enabled={useKeyboardAvoidingView}
|
|
177
182
|
style={[Styles.flex, {justifyContent: 'flex-end'}]}>
|
|
178
183
|
<TouchableOpacity
|
|
179
184
|
style={Styles.flex}
|
|
@@ -16,12 +16,12 @@ const HeaderBackground: React.FC<HeaderBackgroundProps> = ({
|
|
|
16
16
|
animatedValue = new Animated.Value(0),
|
|
17
17
|
useGradient = true,
|
|
18
18
|
useShadowHeader = true,
|
|
19
|
-
gradientColor,
|
|
19
|
+
gradientColor: customGradientColor,
|
|
20
20
|
headerBackground,
|
|
21
21
|
}) => {
|
|
22
22
|
const {theme} = useContext(ApplicationContext);
|
|
23
23
|
|
|
24
|
-
const
|
|
24
|
+
const gradientColor = customGradientColor ?? theme.colors.gradient;
|
|
25
25
|
|
|
26
26
|
let headerImage = headerBackground ?? theme.assets?.headerBackground;
|
|
27
27
|
if (image === null) {
|
|
@@ -43,14 +43,23 @@ const HeaderBackground: React.FC<HeaderBackgroundProps> = ({
|
|
|
43
43
|
<View style={Styles.flex}>
|
|
44
44
|
<Animated.View
|
|
45
45
|
style={[
|
|
46
|
-
Styles.flex,
|
|
47
46
|
useShadowHeader ? styles.shadowHeader : styles.dividerHeader,
|
|
48
47
|
{
|
|
49
48
|
backgroundColor: theme.colors.background.surface,
|
|
50
49
|
opacity: opacityBackground,
|
|
51
|
-
|
|
50
|
+
height: '100%',
|
|
51
|
+
width: '100%',
|
|
52
52
|
},
|
|
53
|
-
]}
|
|
53
|
+
]}
|
|
54
|
+
/>
|
|
55
|
+
<Animated.View
|
|
56
|
+
style={{
|
|
57
|
+
position: 'absolute',
|
|
58
|
+
zIndex: 1,
|
|
59
|
+
height: '100%',
|
|
60
|
+
width: '100%',
|
|
61
|
+
overflow: 'hidden',
|
|
62
|
+
}}>
|
|
54
63
|
{theme?.assets?.headerBackground && (
|
|
55
64
|
<Image
|
|
56
65
|
style={styles.headerBackground}
|
|
@@ -60,9 +69,9 @@ const HeaderBackground: React.FC<HeaderBackgroundProps> = ({
|
|
|
60
69
|
)}
|
|
61
70
|
</Animated.View>
|
|
62
71
|
<View style={styles.gradientContainer}>
|
|
63
|
-
{useGradient && (
|
|
72
|
+
{useGradient && !!gradientColor && (
|
|
64
73
|
<LinearGradientAnimated
|
|
65
|
-
colors={[
|
|
74
|
+
colors={[gradientColor, gradientColor + '00']}
|
|
66
75
|
style={[styles.extendedHeader, {opacity: opacityGradient}]}>
|
|
67
76
|
{!!headerImage && (
|
|
68
77
|
<Image
|
|
@@ -99,8 +99,18 @@ const HeaderExtendHeader: React.FC<{
|
|
|
99
99
|
? styles.shadowHeader
|
|
100
100
|
: styles.dividerHeader,
|
|
101
101
|
{
|
|
102
|
+
position: 'absolute',
|
|
103
|
+
width: '100%',
|
|
104
|
+
zIndex: 1,
|
|
105
|
+
height: heightHeader,
|
|
102
106
|
backgroundColor: theme.colors.background.surface,
|
|
103
107
|
opacity: opacityBackground,
|
|
108
|
+
},
|
|
109
|
+
]}
|
|
110
|
+
/>
|
|
111
|
+
<Animated.View
|
|
112
|
+
style={[
|
|
113
|
+
{
|
|
104
114
|
position: 'absolute',
|
|
105
115
|
width: '100%',
|
|
106
116
|
height: heightHeader,
|
|
@@ -122,19 +132,20 @@ const HeaderExtendHeader: React.FC<{
|
|
|
122
132
|
styles.headerBox,
|
|
123
133
|
{height: headerType === 'extended' ? height : heightHeader},
|
|
124
134
|
]}>
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
135
|
+
{!!gradientColor && (
|
|
136
|
+
<LinearGradientAnimated
|
|
137
|
+
colors={[gradientColor, gradientColor + '00']}
|
|
138
|
+
style={[styles.extendedHeader, {opacity: opacityGradient}]}>
|
|
139
|
+
{!!theme.assets?.headerBackground && (
|
|
140
|
+
<Image
|
|
141
|
+
style={styles.headerBackground}
|
|
142
|
+
source={{uri: theme.assets?.headerBackground}}
|
|
143
|
+
loading={false}
|
|
144
|
+
/>
|
|
145
|
+
)}
|
|
146
|
+
</LinearGradientAnimated>
|
|
147
|
+
)}
|
|
136
148
|
</Animated.View>
|
|
137
|
-
|
|
138
149
|
<Animated.View
|
|
139
150
|
style={{
|
|
140
151
|
justifyContent: 'flex-end',
|
|
@@ -183,6 +194,16 @@ const HeaderExtendHeader: React.FC<{
|
|
|
183
194
|
height: heightHeader,
|
|
184
195
|
backgroundColor: theme.colors.background.surface,
|
|
185
196
|
opacity: opacityBackground,
|
|
197
|
+
},
|
|
198
|
+
]}
|
|
199
|
+
/>
|
|
200
|
+
<Animated.View
|
|
201
|
+
style={[
|
|
202
|
+
{
|
|
203
|
+
position: 'absolute',
|
|
204
|
+
width: '100%',
|
|
205
|
+
zIndex: 1,
|
|
206
|
+
height: heightHeader,
|
|
186
207
|
overflow: 'hidden',
|
|
187
208
|
},
|
|
188
209
|
]}>
|
|
@@ -194,17 +215,19 @@ const HeaderExtendHeader: React.FC<{
|
|
|
194
215
|
/>
|
|
195
216
|
)}
|
|
196
217
|
</Animated.View>
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
218
|
+
{!!gradientColor && (
|
|
219
|
+
<LinearGradientAnimated
|
|
220
|
+
colors={[gradientColor, gradientColor + '00']}
|
|
221
|
+
style={[styles.extendedHeader, {opacity: opacityGradient}]}>
|
|
222
|
+
{!!headerBackground && (
|
|
223
|
+
<Image
|
|
224
|
+
style={styles.headerBackground}
|
|
225
|
+
source={{uri: headerBackground}}
|
|
226
|
+
loading={false}
|
|
227
|
+
/>
|
|
228
|
+
)}
|
|
229
|
+
</LinearGradientAnimated>
|
|
230
|
+
)}
|
|
208
231
|
<View style={{height: heightHeader}} />
|
|
209
232
|
<Verified />
|
|
210
233
|
</>
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {BackHandler, StyleSheet, View} from 'react-native';
|
|
2
2
|
import {HeaderBackProps} from '../types';
|
|
3
|
-
import React, {useContext, useEffect} from 'react';
|
|
3
|
+
import React, {useCallback, useContext, useEffect} from 'react';
|
|
4
4
|
import {ApplicationContext, MiniAppContext} from '../index';
|
|
5
5
|
import {PopupNotify} from '../../Popup';
|
|
6
6
|
import {NavigationButton} from './NavigationButton';
|
|
@@ -17,35 +17,26 @@ const HeaderLeft: React.FC<HeaderBackProps> = ({
|
|
|
17
17
|
const context = useContext<any>(MiniAppContext);
|
|
18
18
|
const {navigator} = useContext(ApplicationContext);
|
|
19
19
|
|
|
20
|
-
|
|
21
|
-
const
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
20
|
+
const goBack = useCallback(() => {
|
|
21
|
+
const canGoBack = navigator?.ref?.current?.canGoBack?.();
|
|
22
|
+
const currentRoute = navigator?.ref?.current?.getCurrentRoute?.();
|
|
23
|
+
context?.autoTracking?.({
|
|
24
|
+
...context,
|
|
25
|
+
componentName: 'IconButton',
|
|
26
|
+
componentId: 'navigation_back',
|
|
27
|
+
screenName: currentRoute?.params?.screen?.name ?? currentRoute?.name,
|
|
28
|
+
});
|
|
25
29
|
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
...context,
|
|
35
|
-
componentName: 'IconButton',
|
|
36
|
-
componentId: 'navigation_back',
|
|
37
|
-
screenName: currentRoute?.params?.screen?.name ?? currentRoute?.name,
|
|
38
|
-
});
|
|
39
|
-
|
|
40
|
-
if (canGoBack) {
|
|
41
|
-
navigator?.ref?.current?.goBack?.();
|
|
42
|
-
} else if (navigator?.maxApi) {
|
|
43
|
-
navigator?.maxApi?.dismiss?.(navigator?.dismissData);
|
|
44
|
-
} else {
|
|
45
|
-
(global as any)?.miniAppApi?.dispatch?.('dismiss', context);
|
|
46
|
-
}
|
|
47
|
-
};
|
|
30
|
+
if (canGoBack) {
|
|
31
|
+
navigator?.ref?.current?.goBack?.();
|
|
32
|
+
} else if (navigator?.maxApi) {
|
|
33
|
+
navigator?.maxApi?.dismiss?.(navigator?.dismissData);
|
|
34
|
+
} else {
|
|
35
|
+
(global as any)?.miniAppApi?.dispatch?.('dismiss', context);
|
|
36
|
+
}
|
|
37
|
+
}, [navigator, context]);
|
|
48
38
|
|
|
39
|
+
const goBackSafe = useCallback(() => {
|
|
49
40
|
if (preventBack) {
|
|
50
41
|
navigator?.showModal({
|
|
51
42
|
screen: () => (
|
|
@@ -70,7 +61,16 @@ const HeaderLeft: React.FC<HeaderBackProps> = ({
|
|
|
70
61
|
}
|
|
71
62
|
}
|
|
72
63
|
return true;
|
|
73
|
-
};
|
|
64
|
+
}, [preventBack, onPressLeftHeader, onBackHandler, goBack]);
|
|
65
|
+
|
|
66
|
+
useEffect(() => {
|
|
67
|
+
const backHandler = BackHandler.addEventListener(
|
|
68
|
+
'hardwareBackPress',
|
|
69
|
+
goBackSafe
|
|
70
|
+
);
|
|
71
|
+
|
|
72
|
+
return () => backHandler.remove();
|
|
73
|
+
}, [goBackSafe]);
|
|
74
74
|
|
|
75
75
|
return (
|
|
76
76
|
<View style={styles.headerLeft}>
|
|
@@ -34,7 +34,8 @@ const NavigationContainer: React.FC<NavigationContainerProps> = ({
|
|
|
34
34
|
const isReady = useRef(false);
|
|
35
35
|
const navigator = useRef(new Navigator(navigationRef, isReady));
|
|
36
36
|
const [showGrid, setShowGrid] = useState(false);
|
|
37
|
-
|
|
37
|
+
|
|
38
|
+
let config: any = null;
|
|
38
39
|
try {
|
|
39
40
|
config = JSON.parse(
|
|
40
41
|
NativeModules?.ConfigsModule?.getConfigSync?.('DESIGN_SYSTEM') || ''
|
|
@@ -72,11 +73,18 @@ const NavigationContainer: React.FC<NavigationContainerProps> = ({
|
|
|
72
73
|
return localize?.translate(data as string);
|
|
73
74
|
};
|
|
74
75
|
|
|
76
|
+
/**
|
|
77
|
+
* navigation state route change handle
|
|
78
|
+
* @param preScreenName
|
|
79
|
+
* @param screenName
|
|
80
|
+
* @param action
|
|
81
|
+
*/
|
|
75
82
|
const onScreenNavigated = (
|
|
76
83
|
preScreenName: string,
|
|
77
84
|
screenName: string,
|
|
78
85
|
action: string
|
|
79
86
|
) => {
|
|
87
|
+
console.log(preScreenName, screenName, action);
|
|
80
88
|
context?.autoTracking?.({
|
|
81
89
|
...context,
|
|
82
90
|
preScreenName,
|
|
@@ -96,6 +104,9 @@ const NavigationContainer: React.FC<NavigationContainerProps> = ({
|
|
|
96
104
|
});
|
|
97
105
|
};
|
|
98
106
|
|
|
107
|
+
const headerBackground = config?.headerBar || theme.assets?.headerBackground;
|
|
108
|
+
const headerGradient = config?.headerGradient || theme.colors?.gradient;
|
|
109
|
+
|
|
99
110
|
return (
|
|
100
111
|
<SafeAreaProvider>
|
|
101
112
|
<ApplicationContext.Provider
|
|
@@ -103,9 +114,13 @@ const NavigationContainer: React.FC<NavigationContainerProps> = ({
|
|
|
103
114
|
navigator: navigator.current,
|
|
104
115
|
theme: {
|
|
105
116
|
...theme,
|
|
117
|
+
colors: {
|
|
118
|
+
...theme.colors,
|
|
119
|
+
gradient: headerGradient,
|
|
120
|
+
},
|
|
106
121
|
assets: {
|
|
107
|
-
|
|
108
|
-
|
|
122
|
+
...theme.assets,
|
|
123
|
+
headerBackground,
|
|
109
124
|
},
|
|
110
125
|
},
|
|
111
126
|
showGrid,
|
|
@@ -127,25 +142,25 @@ const NavigationContainer: React.FC<NavigationContainerProps> = ({
|
|
|
127
142
|
onReady={() => {
|
|
128
143
|
isReady.current = true;
|
|
129
144
|
routes.current = navigationRef.current?.getRootState?.()?.routes;
|
|
145
|
+
maxApi?.getDataObserver('CURRENT_SCREEN', (data: any) => {
|
|
146
|
+
onScreenNavigated(data?.screenName, screen?.name, 'push');
|
|
147
|
+
maxApi?.setObserver('CURRENT_SCREEN', {screenName: screen?.name});
|
|
148
|
+
});
|
|
130
149
|
}}
|
|
131
150
|
onStateChange={state => {
|
|
132
151
|
const lastedRoute: any = state?.routes?.[state?.routes?.length - 1];
|
|
133
152
|
const oldRoute: any = routes.current?.[routes.current?.length - 1];
|
|
134
153
|
const lasted = lastedRoute?.params?.screen;
|
|
135
154
|
const previous = oldRoute?.params?.screen;
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
} else if (routes.current?.length > (state?.routes?.length ?? 0)) {
|
|
143
|
-
onScreenNavigated(
|
|
144
|
-
previous?.name ?? previous?.type?.name,
|
|
145
|
-
lasted?.name ?? lasted?.type?.name,
|
|
146
|
-
'back'
|
|
147
|
-
);
|
|
155
|
+
const preScreenName = previous?.name ?? previous?.type?.name;
|
|
156
|
+
const screenName = lasted?.name ?? lasted?.type?.name;
|
|
157
|
+
|
|
158
|
+
let action = 'push';
|
|
159
|
+
if (routes.current?.length > (state?.routes?.length ?? 0)) {
|
|
160
|
+
action = 'back';
|
|
148
161
|
}
|
|
162
|
+
onScreenNavigated(preScreenName, screenName, action);
|
|
163
|
+
maxApi?.setObserver('CURRENT_SCREEN', {screenName});
|
|
149
164
|
routes.current = state?.routes;
|
|
150
165
|
}}
|
|
151
166
|
independent={true}>
|
|
@@ -207,7 +207,7 @@ const StackScreen: React.FC<ScreenParams> = props => {
|
|
|
207
207
|
/**
|
|
208
208
|
* for stop tracking when user interaction
|
|
209
209
|
*/
|
|
210
|
-
if (data
|
|
210
|
+
if (data?.interaction) {
|
|
211
211
|
onScreenLoad();
|
|
212
212
|
onScreenInteraction();
|
|
213
213
|
}
|
|
@@ -225,7 +225,12 @@ const StackScreen: React.FC<ScreenParams> = props => {
|
|
|
225
225
|
}, 2000);
|
|
226
226
|
},
|
|
227
227
|
}}>
|
|
228
|
-
<Component
|
|
228
|
+
<Component
|
|
229
|
+
heightHeader={heightHeader}
|
|
230
|
+
{...data}
|
|
231
|
+
onScreenLoad={onScreenLoad}
|
|
232
|
+
onScreenInteraction={onScreenInteraction}
|
|
233
|
+
/>
|
|
229
234
|
{showGrid && <GridSystem />}
|
|
230
235
|
</ScreenContext.Provider>
|
|
231
236
|
);
|
package/Application/types.ts
CHANGED
package/Input/InputTextArea.tsx
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import React, {
|
|
2
2
|
forwardRef,
|
|
3
3
|
useContext,
|
|
4
|
+
useEffect,
|
|
4
5
|
useImperativeHandle,
|
|
5
6
|
useRef,
|
|
6
7
|
useState,
|
|
@@ -54,6 +55,10 @@ const InputTextArea = forwardRef(
|
|
|
54
55
|
const [inputValue, setInputValue] = useState(defaultValue ?? '');
|
|
55
56
|
const inputRef = useRef<TextInput | null>(null);
|
|
56
57
|
|
|
58
|
+
useEffect(() => {
|
|
59
|
+
setInputValue(value ?? '');
|
|
60
|
+
}, [value]);
|
|
61
|
+
|
|
57
62
|
const onClearText = () => {
|
|
58
63
|
inputRef?.current?.clear();
|
|
59
64
|
_onChangeText('');
|
|
@@ -137,7 +142,7 @@ const InputTextArea = forwardRef(
|
|
|
137
142
|
maxLength={maxLength}
|
|
138
143
|
textBreakStrategy="highQuality"
|
|
139
144
|
multiline={true}
|
|
140
|
-
value={
|
|
145
|
+
value={inputValue}
|
|
141
146
|
onChangeText={_onChangeText}
|
|
142
147
|
onFocus={_onFocus}
|
|
143
148
|
onBlur={_onBlur}
|
package/Input/styles.ts
CHANGED
package/Text/index.tsx
CHANGED
|
@@ -111,6 +111,9 @@ const getTypoStyle = (typo: Typography, newFontFamily?: string) => {
|
|
|
111
111
|
fontFamily = `${font}-${MomoTrustSans[fontWeight]}${style}`;
|
|
112
112
|
break;
|
|
113
113
|
}
|
|
114
|
+
case 'Montserrat-Bold':
|
|
115
|
+
case 'iCielPanton-Black':
|
|
116
|
+
case 'iCielBCCubano-Normal':
|
|
114
117
|
case 'MomoTrustDisplay':
|
|
115
118
|
case 'MomoSignature': {
|
|
116
119
|
fontFamily = font;
|
|
@@ -173,16 +176,19 @@ const exportFontFamily = (
|
|
|
173
176
|
let newFontFamily;
|
|
174
177
|
|
|
175
178
|
switch (fontWeight) {
|
|
176
|
-
case 'bold':
|
|
179
|
+
case 'bold':
|
|
180
|
+
case 'Bold':
|
|
177
181
|
typography = 'action_xs_bold';
|
|
178
182
|
break;
|
|
179
|
-
|
|
180
|
-
case 'regular':
|
|
183
|
+
|
|
184
|
+
case 'regular':
|
|
185
|
+
case 'Regular':
|
|
181
186
|
typography = 'body_default_regular';
|
|
182
187
|
break;
|
|
183
|
-
|
|
188
|
+
|
|
184
189
|
default: {
|
|
185
190
|
typography = 'body_default_regular';
|
|
191
|
+
break;
|
|
186
192
|
}
|
|
187
193
|
}
|
|
188
194
|
|