@momo-kits/foundation 0.111.1-beta.1 → 0.111.1-beta.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.tsx +2 -2
- package/Application/Components/HeaderBackground.tsx +12 -3
- package/Application/Components/HeaderExtendHeader.tsx +20 -1
- package/Application/Components/HeaderLeft.tsx +29 -29
- package/Application/ModalScreen.tsx +2 -6
- package/Application/utils.tsx +26 -0
- package/Input/InputTextArea.tsx +6 -1
- package/Popup/PopupPromotion.tsx +8 -2
- package/Text/index.tsx +7 -4
- package/package.json +1 -1
|
@@ -90,7 +90,7 @@ const BottomSheet: React.FC<BottomSheetParams> = props => {
|
|
|
90
90
|
toValue: {x: 0, y: 0},
|
|
91
91
|
useNativeDriver: false,
|
|
92
92
|
easing: customEasingOpen,
|
|
93
|
-
duration:
|
|
93
|
+
duration: 350,
|
|
94
94
|
}).start();
|
|
95
95
|
|
|
96
96
|
return () => {
|
|
@@ -112,7 +112,7 @@ const BottomSheet: React.FC<BottomSheetParams> = props => {
|
|
|
112
112
|
toValue: {x: 0, y: heightDevice},
|
|
113
113
|
useNativeDriver: false,
|
|
114
114
|
easing: customEasingClose,
|
|
115
|
-
duration:
|
|
115
|
+
duration: 200,
|
|
116
116
|
}).start(() => {
|
|
117
117
|
navigator?.pop();
|
|
118
118
|
});
|
|
@@ -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}
|
|
@@ -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,
|
|
@@ -136,7 +146,6 @@ const HeaderExtendHeader: React.FC<{
|
|
|
136
146
|
</LinearGradientAnimated>
|
|
137
147
|
)}
|
|
138
148
|
</Animated.View>
|
|
139
|
-
|
|
140
149
|
<Animated.View
|
|
141
150
|
style={{
|
|
142
151
|
justifyContent: 'flex-end',
|
|
@@ -185,6 +194,16 @@ const HeaderExtendHeader: React.FC<{
|
|
|
185
194
|
height: heightHeader,
|
|
186
195
|
backgroundColor: theme.colors.background.surface,
|
|
187
196
|
opacity: opacityBackground,
|
|
197
|
+
},
|
|
198
|
+
]}
|
|
199
|
+
/>
|
|
200
|
+
<Animated.View
|
|
201
|
+
style={[
|
|
202
|
+
{
|
|
203
|
+
position: 'absolute',
|
|
204
|
+
width: '100%',
|
|
205
|
+
zIndex: 1,
|
|
206
|
+
height: heightHeader,
|
|
188
207
|
overflow: 'hidden',
|
|
189
208
|
},
|
|
190
209
|
]}>
|
|
@@ -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}>
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import React, {useContext, useEffect, useRef} from 'react';
|
|
2
2
|
import {
|
|
3
3
|
Animated,
|
|
4
|
-
Dimensions,
|
|
5
4
|
KeyboardAvoidingView,
|
|
6
5
|
Platform,
|
|
7
6
|
Pressable,
|
|
@@ -13,7 +12,6 @@ import {Styles} from '../Consts';
|
|
|
13
12
|
import Navigation from './Navigation';
|
|
14
13
|
import {ModalParams} from './types';
|
|
15
14
|
import BottomSheet from './BottomSheet';
|
|
16
|
-
import {Spacing} from '@momo-kits/foundation';
|
|
17
15
|
|
|
18
16
|
const ModalScreen: React.FC<any> = props => {
|
|
19
17
|
if (props.route?.params?.isBottomSheet) {
|
|
@@ -28,7 +26,6 @@ const Modal: React.FC<ModalParams> = props => {
|
|
|
28
26
|
const Component = useRef(screen).current;
|
|
29
27
|
const opacity = useRef(new Animated.Value(0)).current;
|
|
30
28
|
const scale = useRef(new Animated.Value(0.8)).current;
|
|
31
|
-
const {width: widthDevice} = Dimensions.get('window');
|
|
32
29
|
|
|
33
30
|
const navigation = new Navigation(props.navigation);
|
|
34
31
|
const params = {
|
|
@@ -62,12 +59,12 @@ const Modal: React.FC<ModalParams> = props => {
|
|
|
62
59
|
Animated.parallel([
|
|
63
60
|
Animated.timing(opacity, {
|
|
64
61
|
toValue: 0,
|
|
65
|
-
duration:
|
|
62
|
+
duration: 200,
|
|
66
63
|
useNativeDriver: true,
|
|
67
64
|
}),
|
|
68
65
|
Animated.timing(scale, {
|
|
69
66
|
toValue: 0.8,
|
|
70
|
-
duration:
|
|
67
|
+
duration: 200,
|
|
71
68
|
useNativeDriver: true,
|
|
72
69
|
}),
|
|
73
70
|
]).start(() => {
|
|
@@ -87,7 +84,6 @@ const Modal: React.FC<ModalParams> = props => {
|
|
|
87
84
|
{
|
|
88
85
|
opacity,
|
|
89
86
|
transform: [{scale}],
|
|
90
|
-
maxWidth: widthDevice - Spacing.XL * 2,
|
|
91
87
|
},
|
|
92
88
|
modalStyle,
|
|
93
89
|
]}>
|
package/Application/utils.tsx
CHANGED
|
@@ -26,6 +26,32 @@ const getStackOptions = (): StackNavigationOptions => {
|
|
|
26
26
|
headerRight: (props: any) => <HeaderRight {...props} />,
|
|
27
27
|
headerTintColor: Colors.black_17,
|
|
28
28
|
gestureEnabled: false,
|
|
29
|
+
cardStyleInterpolator: ({current: {progress}, layouts}) => ({
|
|
30
|
+
cardStyle: {
|
|
31
|
+
transform: [
|
|
32
|
+
{
|
|
33
|
+
translateX: progress.interpolate({
|
|
34
|
+
inputRange: [0, 1],
|
|
35
|
+
outputRange: [layouts.screen.width, 0],
|
|
36
|
+
}),
|
|
37
|
+
},
|
|
38
|
+
],
|
|
39
|
+
},
|
|
40
|
+
}),
|
|
41
|
+
transitionSpec: {
|
|
42
|
+
open: {
|
|
43
|
+
animation: 'timing',
|
|
44
|
+
config: {
|
|
45
|
+
duration: 300,
|
|
46
|
+
},
|
|
47
|
+
},
|
|
48
|
+
close: {
|
|
49
|
+
animation: 'timing',
|
|
50
|
+
config: {
|
|
51
|
+
duration: 300,
|
|
52
|
+
},
|
|
53
|
+
},
|
|
54
|
+
},
|
|
29
55
|
};
|
|
30
56
|
};
|
|
31
57
|
|
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/Popup/PopupPromotion.tsx
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React, {useContext, useEffect, useRef} from 'react';
|
|
2
|
-
import {StyleSheet, TouchableOpacity, View} from 'react-native';
|
|
2
|
+
import {Dimensions, StyleSheet, TouchableOpacity, View} from 'react-native';
|
|
3
3
|
import {PopupPromotionProps} from './types';
|
|
4
4
|
import {ApplicationContext, MiniAppContext} from '../Application';
|
|
5
5
|
import {Image} from '../Image';
|
|
@@ -13,6 +13,7 @@ const PopupPromotion: React.FC<PopupPromotionProps> = ({
|
|
|
13
13
|
}) => {
|
|
14
14
|
const context = useContext<any>(MiniAppContext);
|
|
15
15
|
const {theme, navigator} = useContext(ApplicationContext);
|
|
16
|
+
const {width: widthDevice} = Dimensions.get('window');
|
|
16
17
|
const closeAction = useRef('touch_outside');
|
|
17
18
|
|
|
18
19
|
/**
|
|
@@ -83,7 +84,12 @@ const PopupPromotion: React.FC<PopupPromotionProps> = ({
|
|
|
83
84
|
source={{
|
|
84
85
|
uri: image,
|
|
85
86
|
}}
|
|
86
|
-
style={
|
|
87
|
+
style={[
|
|
88
|
+
styles.container,
|
|
89
|
+
{
|
|
90
|
+
width: widthDevice - Spacing.XL * 2,
|
|
91
|
+
},
|
|
92
|
+
]}
|
|
87
93
|
/>
|
|
88
94
|
{buildCloseIcon()}
|
|
89
95
|
</View>
|
package/Text/index.tsx
CHANGED
|
@@ -176,16 +176,19 @@ const exportFontFamily = (
|
|
|
176
176
|
let newFontFamily;
|
|
177
177
|
|
|
178
178
|
switch (fontWeight) {
|
|
179
|
-
case 'bold':
|
|
179
|
+
case 'bold':
|
|
180
|
+
case 'Bold':
|
|
180
181
|
typography = 'action_xs_bold';
|
|
181
182
|
break;
|
|
182
|
-
|
|
183
|
-
case 'regular':
|
|
183
|
+
|
|
184
|
+
case 'regular':
|
|
185
|
+
case 'Regular':
|
|
184
186
|
typography = 'body_default_regular';
|
|
185
187
|
break;
|
|
186
|
-
|
|
188
|
+
|
|
187
189
|
default: {
|
|
188
190
|
typography = 'body_default_regular';
|
|
191
|
+
break;
|
|
189
192
|
}
|
|
190
193
|
}
|
|
191
194
|
|