@momo-kits/foundation 0.112.1-rn76.7 → 0.112.1-testing.20
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/BottomTab/index.tsx +34 -51
- package/Application/NavigationContainer.tsx +75 -110
- package/Application/StackScreen.tsx +6 -6
- package/Input/InputMoney.tsx +2 -197
- package/Layout/Screen.tsx +5 -6
- package/Layout/index.ts +0 -2
- package/index.ts +7 -0
- package/package.json +49 -34
- package/publish.sh +6 -6
|
@@ -16,7 +16,7 @@ import {BottomSheetParams} from './types';
|
|
|
16
16
|
import {Colors, Radius, Spacing, Styles} from '../Consts';
|
|
17
17
|
import {Text} from '../Text';
|
|
18
18
|
import {Icon} from '../Icon';
|
|
19
|
-
import {useHeaderHeight} from '@react-navigation/
|
|
19
|
+
import {useHeaderHeight} from '@react-navigation/stack';
|
|
20
20
|
import Animated, {Easing, Extrapolate} from 'react-native-reanimated';
|
|
21
21
|
|
|
22
22
|
const BottomSheet: React.FC<BottomSheetParams> = props => {
|
|
@@ -82,7 +82,7 @@ const BottomSheet: React.FC<BottomSheetParams> = props => {
|
|
|
82
82
|
}).start();
|
|
83
83
|
}
|
|
84
84
|
},
|
|
85
|
-
})
|
|
85
|
+
})
|
|
86
86
|
).current;
|
|
87
87
|
|
|
88
88
|
let Container: any = View;
|
|
@@ -1,11 +1,7 @@
|
|
|
1
1
|
import {createBottomTabNavigator} from '@react-navigation/bottom-tabs';
|
|
2
|
-
import {
|
|
3
|
-
NavigationContainer,
|
|
4
|
-
NavigationIndependentTree,
|
|
5
|
-
useFocusEffect,
|
|
6
|
-
} from '@react-navigation/native';
|
|
2
|
+
import {NavigationContainer, useFocusEffect} from '@react-navigation/native';
|
|
7
3
|
import {createStackNavigator} from '@react-navigation/stack';
|
|
8
|
-
import React, {useContext, useEffect
|
|
4
|
+
import React, {useContext, useEffect} from 'react';
|
|
9
5
|
import {Animated, Platform, StatusBar} from 'react-native';
|
|
10
6
|
import {useSafeAreaInsets} from 'react-native-safe-area-context';
|
|
11
7
|
import {Colors} from '../../Consts';
|
|
@@ -15,7 +11,7 @@ import {ApplicationContext} from '../index';
|
|
|
15
11
|
import StackScreen from '../StackScreen';
|
|
16
12
|
import {BottomTabProps} from '../types';
|
|
17
13
|
import {getOptions, getStackOptions} from '../utils';
|
|
18
|
-
|
|
14
|
+
import BottomTabBar from './BottomTabBar';
|
|
19
15
|
|
|
20
16
|
const Tab = createBottomTabNavigator();
|
|
21
17
|
const Stack = createStackNavigator();
|
|
@@ -25,19 +21,18 @@ const TabScreen: React.FC<any> = ({route, navigation}) => {
|
|
|
25
21
|
|
|
26
22
|
const opacityValue = 0.3;
|
|
27
23
|
const scaleValue = 0.97;
|
|
28
|
-
|
|
29
|
-
const
|
|
30
|
-
const scale = useRef(new Animated.Value(scaleValue));
|
|
24
|
+
const opacity = new Animated.Value(opacityValue);
|
|
25
|
+
const scale = new Animated.Value(scaleValue);
|
|
31
26
|
|
|
32
27
|
useFocusEffect(
|
|
33
28
|
React.useCallback(() => {
|
|
34
29
|
Animated.parallel([
|
|
35
|
-
Animated.timing(opacity
|
|
30
|
+
Animated.timing(opacity, {
|
|
36
31
|
toValue: 1,
|
|
37
32
|
duration: 200,
|
|
38
33
|
useNativeDriver: true,
|
|
39
34
|
}),
|
|
40
|
-
Animated.timing(scale
|
|
35
|
+
Animated.timing(scale, {
|
|
41
36
|
toValue: 1,
|
|
42
37
|
duration: 200,
|
|
43
38
|
useNativeDriver: true,
|
|
@@ -46,12 +41,12 @@ const TabScreen: React.FC<any> = ({route, navigation}) => {
|
|
|
46
41
|
return () => {
|
|
47
42
|
if (navigation.getState().index !== route?.params.index) {
|
|
48
43
|
Animated.parallel([
|
|
49
|
-
Animated.timing(opacity
|
|
44
|
+
Animated.timing(opacity, {
|
|
50
45
|
toValue: opacityValue,
|
|
51
46
|
duration: 200,
|
|
52
47
|
useNativeDriver: true,
|
|
53
48
|
}),
|
|
54
|
-
Animated.timing(scale
|
|
49
|
+
Animated.timing(scale, {
|
|
55
50
|
toValue: scaleValue,
|
|
56
51
|
duration: 200,
|
|
57
52
|
useNativeDriver: true,
|
|
@@ -59,7 +54,7 @@ const TabScreen: React.FC<any> = ({route, navigation}) => {
|
|
|
59
54
|
]).start();
|
|
60
55
|
}
|
|
61
56
|
};
|
|
62
|
-
}, [navigation
|
|
57
|
+
}, [navigation])
|
|
63
58
|
);
|
|
64
59
|
|
|
65
60
|
let stackOptions = {};
|
|
@@ -69,12 +64,7 @@ const TabScreen: React.FC<any> = ({route, navigation}) => {
|
|
|
69
64
|
|
|
70
65
|
if (nested) {
|
|
71
66
|
return (
|
|
72
|
-
<Animated.View
|
|
73
|
-
style={{
|
|
74
|
-
flex: 1,
|
|
75
|
-
opacity: opacity.current,
|
|
76
|
-
transform: [{scale: scale.current}],
|
|
77
|
-
}}>
|
|
67
|
+
<Animated.View style={{flex: 1, opacity, transform: [{scale}]}}>
|
|
78
68
|
<Stack.Navigator>
|
|
79
69
|
<Stack.Screen
|
|
80
70
|
name="Stack"
|
|
@@ -92,28 +82,21 @@ const TabScreen: React.FC<any> = ({route, navigation}) => {
|
|
|
92
82
|
}
|
|
93
83
|
|
|
94
84
|
return (
|
|
95
|
-
<Animated.View
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
initialParams,
|
|
111
|
-
}}
|
|
112
|
-
options={{...getStackOptions(), ...options}}
|
|
113
|
-
/>
|
|
114
|
-
</Stack.Navigator>
|
|
115
|
-
</NavigationContainer>
|
|
116
|
-
</NavigationIndependentTree>
|
|
85
|
+
<Animated.View style={{flex: 1, opacity, transform: [{scale}]}}>
|
|
86
|
+
<NavigationContainer independent={true}>
|
|
87
|
+
<Stack.Navigator>
|
|
88
|
+
<Stack.Screen
|
|
89
|
+
name="Stack"
|
|
90
|
+
component={StackScreen}
|
|
91
|
+
initialParams={{
|
|
92
|
+
screen,
|
|
93
|
+
options: stackOptions,
|
|
94
|
+
initialParams,
|
|
95
|
+
}}
|
|
96
|
+
options={{...getStackOptions(), ...options}}
|
|
97
|
+
/>
|
|
98
|
+
</Stack.Navigator>
|
|
99
|
+
</NavigationContainer>
|
|
117
100
|
</Animated.View>
|
|
118
101
|
);
|
|
119
102
|
};
|
|
@@ -135,7 +118,7 @@ const BottomTab: React.FC<BottomTabProps> = ({
|
|
|
135
118
|
headerTransparent: true,
|
|
136
119
|
headerBackground: undefined,
|
|
137
120
|
});
|
|
138
|
-
}, [
|
|
121
|
+
}, []);
|
|
139
122
|
|
|
140
123
|
const handler: {
|
|
141
124
|
tabPress?: (e: any) => void;
|
|
@@ -159,13 +142,13 @@ const BottomTab: React.FC<BottomTabProps> = ({
|
|
|
159
142
|
<Tab.Navigator
|
|
160
143
|
initialRouteName={initialRouteName}
|
|
161
144
|
backBehavior={'firstRoute'}
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
145
|
+
tabBar={props => (
|
|
146
|
+
<BottomTabBar
|
|
147
|
+
{...props}
|
|
148
|
+
floatingButton={floatingButton}
|
|
149
|
+
inactiveTintColor={theme.colors.text.hint}
|
|
150
|
+
/>
|
|
151
|
+
)}
|
|
169
152
|
tabBarOptions={{
|
|
170
153
|
style: {
|
|
171
154
|
height: 64 + Math.min(insets.bottom, 21),
|
|
@@ -1,10 +1,8 @@
|
|
|
1
1
|
import React, {useContext, useEffect, useRef, useState} from 'react';
|
|
2
|
-
import type {NavigationState} from '@react-navigation/routers';
|
|
3
2
|
import {SafeAreaProvider} from 'react-native-safe-area-context';
|
|
4
3
|
import {
|
|
5
4
|
NavigationContainer as ReactNavigationContainer,
|
|
6
5
|
NavigationContainerRef,
|
|
7
|
-
NavigationIndependentTree,
|
|
8
6
|
} from '@react-navigation/native';
|
|
9
7
|
import {
|
|
10
8
|
createStackNavigator,
|
|
@@ -18,7 +16,7 @@ import {getDialogOptions, getModalOptions, getStackOptions} from './utils';
|
|
|
18
16
|
import {NavigationContainerProps} from './types';
|
|
19
17
|
import {ApplicationContext, MiniAppContext} from './index';
|
|
20
18
|
import Localize from './Localize';
|
|
21
|
-
import {
|
|
19
|
+
import {defaultTheme, Configs} from '../Consts';
|
|
22
20
|
|
|
23
21
|
const Stack = createStackNavigator();
|
|
24
22
|
|
|
@@ -31,7 +29,7 @@ const NavigationContainer: React.FC<NavigationContainerProps> = ({
|
|
|
31
29
|
localize = new Localize({vi: {}, en: {}}),
|
|
32
30
|
}) => {
|
|
33
31
|
const context = useContext<any>(MiniAppContext);
|
|
34
|
-
const navigationRef = useRef<NavigationContainerRef
|
|
32
|
+
const navigationRef = useRef<NavigationContainerRef>(null);
|
|
35
33
|
const routes = useRef<any>();
|
|
36
34
|
const isReady = useRef(false);
|
|
37
35
|
const navigator = useRef(new Navigator(navigationRef, isReady));
|
|
@@ -52,7 +50,7 @@ const NavigationContainer: React.FC<NavigationContainerProps> = ({
|
|
|
52
50
|
'onChangeGrid',
|
|
53
51
|
enable => {
|
|
54
52
|
setShowGrid(!!enable);
|
|
55
|
-
}
|
|
53
|
+
}
|
|
56
54
|
);
|
|
57
55
|
|
|
58
56
|
return () => {
|
|
@@ -60,10 +58,6 @@ const NavigationContainer: React.FC<NavigationContainerProps> = ({
|
|
|
60
58
|
};
|
|
61
59
|
}, []);
|
|
62
60
|
|
|
63
|
-
/**
|
|
64
|
-
* translate context method
|
|
65
|
-
* @param data
|
|
66
|
-
*/
|
|
67
61
|
const translate = (data?: string | {vi: string; en: string}) => {
|
|
68
62
|
if (data && typeof data !== 'string') {
|
|
69
63
|
return localize?.translateData(data);
|
|
@@ -80,7 +74,7 @@ const NavigationContainer: React.FC<NavigationContainerProps> = ({
|
|
|
80
74
|
const onScreenNavigated = (
|
|
81
75
|
preScreenName: string,
|
|
82
76
|
screenName: string,
|
|
83
|
-
action: string
|
|
77
|
+
action: string
|
|
84
78
|
) => {
|
|
85
79
|
console.log(preScreenName, screenName, action);
|
|
86
80
|
context?.autoTracking?.({
|
|
@@ -92,6 +86,9 @@ const NavigationContainer: React.FC<NavigationContainerProps> = ({
|
|
|
92
86
|
action,
|
|
93
87
|
});
|
|
94
88
|
|
|
89
|
+
/**
|
|
90
|
+
* debug toast
|
|
91
|
+
*/
|
|
95
92
|
maxApi?.showToastDebug?.({
|
|
96
93
|
appId: context.appId,
|
|
97
94
|
message: `${screenName} screen_navigated`,
|
|
@@ -99,46 +96,11 @@ const NavigationContainer: React.FC<NavigationContainerProps> = ({
|
|
|
99
96
|
});
|
|
100
97
|
};
|
|
101
98
|
|
|
102
|
-
/**
|
|
103
|
-
* onStateChange
|
|
104
|
-
* @param state
|
|
105
|
-
*/
|
|
106
|
-
const onStateChange = (state: Readonly<NavigationState> | undefined) => {
|
|
107
|
-
const lastedRoute: any = state?.routes?.[state?.routes?.length - 1];
|
|
108
|
-
const oldRoute: any = routes.current?.[routes.current?.length - 1];
|
|
109
|
-
const lasted = lastedRoute?.params?.screen;
|
|
110
|
-
const previous = oldRoute?.params?.screen;
|
|
111
|
-
const preScreenName = previous?.name ?? previous?.type?.name;
|
|
112
|
-
const screenName = lasted?.name ?? lasted?.type?.name;
|
|
113
|
-
|
|
114
|
-
let action = 'push';
|
|
115
|
-
if (routes.current?.length > (state?.routes?.length ?? 0)) {
|
|
116
|
-
action = 'back';
|
|
117
|
-
}
|
|
118
|
-
onScreenNavigated(preScreenName, screenName, action);
|
|
119
|
-
maxApi?.setObserver('CURRENT_SCREEN', {screenName});
|
|
120
|
-
routes.current = state?.routes;
|
|
121
|
-
};
|
|
122
|
-
|
|
123
|
-
/**
|
|
124
|
-
* onReady
|
|
125
|
-
*/
|
|
126
|
-
const onReady = () => {
|
|
127
|
-
isReady.current = true;
|
|
128
|
-
routes.current = navigationRef.current?.getRootState?.()?.routes;
|
|
129
|
-
maxApi?.getDataObserver('CURRENT_SCREEN', (data: any) => {
|
|
130
|
-
onScreenNavigated(data?.screenName, screen?.name, 'push');
|
|
131
|
-
maxApi?.setObserver('CURRENT_SCREEN', {
|
|
132
|
-
screenName: screen?.name,
|
|
133
|
-
});
|
|
134
|
-
});
|
|
135
|
-
};
|
|
136
|
-
|
|
137
|
-
navigator.current.setCurrentContext = setCurrentContext;
|
|
138
|
-
|
|
139
99
|
const headerBackground = theme.assets?.headerBackground || Configs.headerBar;
|
|
140
100
|
const headerGradient = Configs?.headerGradient || theme.colors?.gradient;
|
|
141
101
|
|
|
102
|
+
navigator.current.setCurrentContext = setCurrentContext;
|
|
103
|
+
|
|
142
104
|
return (
|
|
143
105
|
<SafeAreaProvider>
|
|
144
106
|
<MiniAppContext.Provider
|
|
@@ -163,69 +125,72 @@ const NavigationContainer: React.FC<NavigationContainerProps> = ({
|
|
|
163
125
|
showGrid,
|
|
164
126
|
translate,
|
|
165
127
|
}}>
|
|
166
|
-
<
|
|
167
|
-
|
|
168
|
-
theme
|
|
169
|
-
|
|
170
|
-
colors
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
128
|
+
<ReactNavigationContainer
|
|
129
|
+
theme={{
|
|
130
|
+
...theme,
|
|
131
|
+
colors: {
|
|
132
|
+
...theme.colors,
|
|
133
|
+
background: theme.colors.background.default,
|
|
134
|
+
card: theme.colors.background.surface,
|
|
135
|
+
text: theme.colors.text.default,
|
|
136
|
+
border: theme.colors.border.default,
|
|
137
|
+
notification: theme.colors.error.primary,
|
|
138
|
+
},
|
|
139
|
+
}}
|
|
140
|
+
ref={navigationRef}
|
|
141
|
+
onReady={() => {
|
|
142
|
+
isReady.current = true;
|
|
143
|
+
routes.current = navigationRef.current?.getRootState?.()?.routes;
|
|
144
|
+
maxApi?.getDataObserver('CURRENT_SCREEN', (data: any) => {
|
|
145
|
+
onScreenNavigated(data?.screenName, screen?.name, 'push');
|
|
146
|
+
maxApi?.setObserver('CURRENT_SCREEN', {
|
|
147
|
+
screenName: screen?.name,
|
|
148
|
+
});
|
|
149
|
+
});
|
|
150
|
+
}}
|
|
151
|
+
onStateChange={state => {
|
|
152
|
+
const lastedRoute: any =
|
|
153
|
+
state?.routes?.[state?.routes?.length - 1];
|
|
154
|
+
const oldRoute: any =
|
|
155
|
+
routes.current?.[routes.current?.length - 1];
|
|
156
|
+
const lasted = lastedRoute?.params?.screen;
|
|
157
|
+
const previous = oldRoute?.params?.screen;
|
|
158
|
+
const preScreenName = previous?.name ?? previous?.type?.name;
|
|
159
|
+
const screenName = lasted?.name ?? lasted?.type?.name;
|
|
160
|
+
|
|
161
|
+
let action = 'push';
|
|
162
|
+
if (routes.current?.length > (state?.routes?.length ?? 0)) {
|
|
163
|
+
action = 'back';
|
|
164
|
+
}
|
|
165
|
+
onScreenNavigated(preScreenName, screenName, action);
|
|
166
|
+
maxApi?.setObserver('CURRENT_SCREEN', {screenName});
|
|
167
|
+
routes.current = state?.routes;
|
|
168
|
+
}}
|
|
169
|
+
independent={true}>
|
|
170
|
+
<Stack.Navigator initialRouteName="Stack" headerMode="screen">
|
|
171
|
+
<Stack.Screen
|
|
172
|
+
name="Stack"
|
|
173
|
+
component={StackScreen}
|
|
174
|
+
initialParams={{screen, initialParams}}
|
|
175
|
+
options={{
|
|
176
|
+
...getStackOptions(),
|
|
177
|
+
...(options as StackNavigationOptions),
|
|
178
|
+
}}
|
|
179
|
+
/>
|
|
180
|
+
<Stack.Screen
|
|
181
|
+
name="Dialog"
|
|
182
|
+
component={StackScreen}
|
|
183
|
+
options={getDialogOptions()}
|
|
184
|
+
initialParams={{screen}}
|
|
185
|
+
/>
|
|
186
|
+
<Stack.Screen
|
|
187
|
+
name="Modal"
|
|
188
|
+
component={ModalScreen}
|
|
189
|
+
options={getModalOptions()}
|
|
190
|
+
initialParams={{screen}}
|
|
191
|
+
/>
|
|
192
|
+
</Stack.Navigator>
|
|
193
|
+
</ReactNavigationContainer>
|
|
229
194
|
</ApplicationContext.Provider>
|
|
230
195
|
</MiniAppContext.Provider>
|
|
231
196
|
</SafeAreaProvider>
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React, {useContext, useEffect, useLayoutEffect, useRef} from 'react';
|
|
2
|
+
import {useHeaderHeight} from '@react-navigation/stack';
|
|
2
3
|
import {Alert, InteractionManager} from 'react-native';
|
|
3
|
-
import {useHeaderHeight} from '@react-navigation/elements';
|
|
4
4
|
import {ScreenParams} from './types';
|
|
5
5
|
import Navigation from './Navigation';
|
|
6
6
|
import {ApplicationContext, MiniAppContext, ScreenContext} from './index';
|
|
@@ -77,14 +77,14 @@ const StackScreen: React.FC<ScreenParams> = props => {
|
|
|
77
77
|
context,
|
|
78
78
|
(data: any) => {
|
|
79
79
|
tracking.current.traceIdLoad = data?.traceId;
|
|
80
|
-
}
|
|
80
|
+
}
|
|
81
81
|
);
|
|
82
82
|
navigator?.maxApi?.startTraceScreenInteraction?.(
|
|
83
83
|
screenName,
|
|
84
84
|
context,
|
|
85
85
|
(data: any) => {
|
|
86
86
|
tracking.current.traceIdInteraction = data?.traceId;
|
|
87
|
-
}
|
|
87
|
+
}
|
|
88
88
|
);
|
|
89
89
|
|
|
90
90
|
tracking.current.timeoutTracking = setTimeout(() => {
|
|
@@ -121,7 +121,7 @@ const StackScreen: React.FC<ScreenParams> = props => {
|
|
|
121
121
|
navigator?.maxApi?.stopTrace?.(
|
|
122
122
|
tracking.current.traceIdLoad,
|
|
123
123
|
{value: timeLoad / 1000},
|
|
124
|
-
null
|
|
124
|
+
null
|
|
125
125
|
);
|
|
126
126
|
tracking.current.releaseLoad = true;
|
|
127
127
|
|
|
@@ -139,7 +139,7 @@ const StackScreen: React.FC<ScreenParams> = props => {
|
|
|
139
139
|
) {
|
|
140
140
|
Alert.alert(
|
|
141
141
|
`${screenName}- load ${timeLoad}ms`,
|
|
142
|
-
JSON.stringify(lastElement.current?.children?.current)
|
|
142
|
+
JSON.stringify(lastElement.current?.children?.current)
|
|
143
143
|
);
|
|
144
144
|
}
|
|
145
145
|
}
|
|
@@ -169,7 +169,7 @@ const StackScreen: React.FC<ScreenParams> = props => {
|
|
|
169
169
|
navigator?.maxApi?.stopTrace?.(
|
|
170
170
|
tracking.current.traceIdInteraction,
|
|
171
171
|
{value: tracking.current.timeInteraction / 1000},
|
|
172
|
-
null
|
|
172
|
+
null
|
|
173
173
|
);
|
|
174
174
|
tracking.current.releaseInteraction = true;
|
|
175
175
|
|
package/Input/InputMoney.tsx
CHANGED
|
@@ -25,203 +25,8 @@ import {
|
|
|
25
25
|
import {InputMoneyProps} from './index';
|
|
26
26
|
import styles from './styles';
|
|
27
27
|
import {formatMoneyToNumber, formatNumberToMoney} from './utils';
|
|
28
|
+
import {Input} from '@momo-kits/foundation';
|
|
28
29
|
|
|
29
|
-
const InputMoney =
|
|
30
|
-
(
|
|
31
|
-
{
|
|
32
|
-
onChangeText,
|
|
33
|
-
floatingValue,
|
|
34
|
-
floatingIcon,
|
|
35
|
-
size = 'small',
|
|
36
|
-
loading,
|
|
37
|
-
onBlur,
|
|
38
|
-
onFocus,
|
|
39
|
-
errorMessage,
|
|
40
|
-
icon,
|
|
41
|
-
iconColor,
|
|
42
|
-
onPressIcon,
|
|
43
|
-
trailing,
|
|
44
|
-
trailingColor,
|
|
45
|
-
onPressTrailing,
|
|
46
|
-
disabled = false,
|
|
47
|
-
floatingIconColor,
|
|
48
|
-
required = false,
|
|
49
|
-
errorSpacing,
|
|
50
|
-
style,
|
|
51
|
-
params,
|
|
52
|
-
defaultValue = '',
|
|
53
|
-
accessibilityLabel,
|
|
54
|
-
hintText,
|
|
55
|
-
value: _value,
|
|
56
|
-
onPressFloatingIcon,
|
|
57
|
-
placeholder = '0đ',
|
|
58
|
-
currency = 'đ',
|
|
59
|
-
showClearIcon = true,
|
|
60
|
-
...props
|
|
61
|
-
}: InputMoneyProps,
|
|
62
|
-
ref
|
|
63
|
-
) => {
|
|
64
|
-
const {theme} = useContext(ApplicationContext);
|
|
65
|
-
|
|
66
|
-
const [focused, setFocused] = useState(false);
|
|
67
|
-
const inputRef = useRef<TextInput>(null);
|
|
68
|
-
|
|
69
|
-
useEffect(() => {
|
|
70
|
-
if (_value) {
|
|
71
|
-
setValue(validateText(_value));
|
|
72
|
-
onChangeText?.(formatMoneyToNumber(_value, currency).toString());
|
|
73
|
-
}
|
|
74
|
-
}, [_value]);
|
|
75
|
-
|
|
76
|
-
const validateText = (text: string) => {
|
|
77
|
-
const valueFormat = formatMoneyToNumber(text, currency);
|
|
78
|
-
return formatNumberToMoney(valueFormat, currency);
|
|
79
|
-
};
|
|
80
|
-
|
|
81
|
-
const [value, setValue] = useState(
|
|
82
|
-
defaultValue ? validateText(defaultValue) : ''
|
|
83
|
-
);
|
|
84
|
-
|
|
85
|
-
const onClearText = () => {
|
|
86
|
-
inputRef?.current?.clear();
|
|
87
|
-
setValue('');
|
|
88
|
-
onChangeText?.('');
|
|
89
|
-
};
|
|
90
|
-
|
|
91
|
-
const _onChangeText = (text: string) => {
|
|
92
|
-
if (text.length < value.length && value.indexOf(text) === 0) {
|
|
93
|
-
text = value.slice(0, -2) + currency;
|
|
94
|
-
}
|
|
95
|
-
setValue(validateText(text));
|
|
96
|
-
onChangeText?.(formatMoneyToNumber(text, currency).toString());
|
|
97
|
-
};
|
|
98
|
-
|
|
99
|
-
useImperativeHandle(ref, () => {
|
|
100
|
-
return {
|
|
101
|
-
clear: onClearText,
|
|
102
|
-
focus: () => inputRef.current?.focus(),
|
|
103
|
-
blur: () => inputRef.current?.blur(),
|
|
104
|
-
setText: _onChangeText,
|
|
105
|
-
};
|
|
106
|
-
});
|
|
107
|
-
|
|
108
|
-
const _onFocus = (e: NativeSyntheticEvent<TextInputFocusEventData>) => {
|
|
109
|
-
setFocused(true);
|
|
110
|
-
onFocus?.(e);
|
|
111
|
-
};
|
|
112
|
-
|
|
113
|
-
const _onBlur = (e: NativeSyntheticEvent<TextInputFocusEventData>) => {
|
|
114
|
-
setFocused(false);
|
|
115
|
-
onBlur?.(e);
|
|
116
|
-
};
|
|
117
|
-
|
|
118
|
-
const renderInputView = () => {
|
|
119
|
-
const disabledColor = theme.colors.text.disable;
|
|
120
|
-
let textColor = theme.colors.text.default;
|
|
121
|
-
let placeholderColor = theme.colors.text.hint;
|
|
122
|
-
let iconTintColor = trailingColor ?? iconColor;
|
|
123
|
-
|
|
124
|
-
if (disabled) {
|
|
125
|
-
textColor = disabledColor;
|
|
126
|
-
placeholderColor = disabledColor;
|
|
127
|
-
iconTintColor = disabledColor;
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
return (
|
|
131
|
-
<View
|
|
132
|
-
style={[
|
|
133
|
-
styles.inputWrapper,
|
|
134
|
-
{backgroundColor: theme.colors.background.surface},
|
|
135
|
-
getSizeStyle(size),
|
|
136
|
-
getBorderColor(theme, focused, errorMessage, disabled),
|
|
137
|
-
]}>
|
|
138
|
-
<FloatingView
|
|
139
|
-
floatingValue={floatingValue}
|
|
140
|
-
floatingIconColor={floatingIconColor}
|
|
141
|
-
disabled={disabled}
|
|
142
|
-
required={required}
|
|
143
|
-
floatingIcon={floatingIcon}
|
|
144
|
-
onPress={onPressFloatingIcon}
|
|
145
|
-
/>
|
|
146
|
-
<View style={styles.inputView}>
|
|
147
|
-
<TextInput
|
|
148
|
-
{...props}
|
|
149
|
-
accessibilityLabel={accessibilityLabel}
|
|
150
|
-
editable={!disabled}
|
|
151
|
-
ref={inputRef}
|
|
152
|
-
keyboardType={'number-pad'}
|
|
153
|
-
allowFontScaling={false}
|
|
154
|
-
style={[
|
|
155
|
-
styles.moneyInput,
|
|
156
|
-
{
|
|
157
|
-
color: textColor,
|
|
158
|
-
},
|
|
159
|
-
]}
|
|
160
|
-
value={value}
|
|
161
|
-
onChangeText={_onChangeText}
|
|
162
|
-
onFocus={_onFocus}
|
|
163
|
-
onBlur={_onBlur}
|
|
164
|
-
selectionColor={theme.colors.primary}
|
|
165
|
-
placeholderTextColor={placeholderColor}
|
|
166
|
-
placeholder={placeholder}
|
|
167
|
-
/>
|
|
168
|
-
</View>
|
|
169
|
-
<View style={styles.iconView}>
|
|
170
|
-
{showClearIcon && focused && (
|
|
171
|
-
<TouchableOpacity
|
|
172
|
-
style={styles.iconWrapper}
|
|
173
|
-
onPress={onClearText}>
|
|
174
|
-
<Icon
|
|
175
|
-
source="24_navigation_close_circle_full"
|
|
176
|
-
size={16}
|
|
177
|
-
color={theme.colors.text.hint}
|
|
178
|
-
/>
|
|
179
|
-
</TouchableOpacity>
|
|
180
|
-
)}
|
|
181
|
-
<RenderTrailing
|
|
182
|
-
color={iconTintColor}
|
|
183
|
-
icon={icon}
|
|
184
|
-
trailing={trailing}
|
|
185
|
-
onPressTrailing={onPressTrailing}
|
|
186
|
-
onPressIcon={onPressIcon}
|
|
187
|
-
loading={loading}
|
|
188
|
-
/>
|
|
189
|
-
</View>
|
|
190
|
-
</View>
|
|
191
|
-
);
|
|
192
|
-
};
|
|
193
|
-
|
|
194
|
-
let inputState = 'active';
|
|
195
|
-
|
|
196
|
-
if (value && value?.length > 0) {
|
|
197
|
-
inputState = 'filled';
|
|
198
|
-
}
|
|
199
|
-
if (errorMessage && errorMessage?.length > 0) {
|
|
200
|
-
inputState = 'error';
|
|
201
|
-
}
|
|
202
|
-
|
|
203
|
-
if (disabled) {
|
|
204
|
-
inputState = 'disabled';
|
|
205
|
-
}
|
|
206
|
-
|
|
207
|
-
return (
|
|
208
|
-
<ComponentContext.Provider
|
|
209
|
-
value={{
|
|
210
|
-
componentName: 'InputMoney',
|
|
211
|
-
params,
|
|
212
|
-
state: inputState,
|
|
213
|
-
}}>
|
|
214
|
-
<View style={[style, styles.wrapper]}>
|
|
215
|
-
{renderInputView()}
|
|
216
|
-
<ErrorView
|
|
217
|
-
errorMessage={errorMessage}
|
|
218
|
-
errorSpacing={errorSpacing}
|
|
219
|
-
hintText={hintText}
|
|
220
|
-
/>
|
|
221
|
-
</View>
|
|
222
|
-
</ComponentContext.Provider>
|
|
223
|
-
);
|
|
224
|
-
}
|
|
225
|
-
);
|
|
30
|
+
const InputMoney = Input;
|
|
226
31
|
|
|
227
32
|
export default InputMoney;
|
package/Layout/Screen.tsx
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import {StackNavigationOptions} from '@react-navigation/stack';
|
|
2
|
-
import {useHeaderHeight} from '@react-navigation/elements';
|
|
1
|
+
import {StackNavigationOptions, useHeaderHeight} from '@react-navigation/stack';
|
|
3
2
|
import React, {
|
|
4
3
|
forwardRef,
|
|
5
4
|
Fragment,
|
|
@@ -176,14 +175,14 @@ const Screen = forwardRef(
|
|
|
176
175
|
headerBackground,
|
|
177
176
|
gradientColor,
|
|
178
177
|
}: ScreenProps,
|
|
179
|
-
ref: any
|
|
178
|
+
ref: any
|
|
180
179
|
) => {
|
|
181
180
|
const screenRef = useRef<View | ScrollView>();
|
|
182
181
|
const {theme} = useContext(ApplicationContext);
|
|
183
182
|
const insets = useSafeAreaInsets();
|
|
184
183
|
const heightHeader = useHeaderHeight();
|
|
185
184
|
const animatedValue = useRef<Animated.Value>(
|
|
186
|
-
customAnimatedValue || new Animated.Value(0)
|
|
185
|
+
customAnimatedValue || new Animated.Value(0)
|
|
187
186
|
);
|
|
188
187
|
const currentTint = useRef<string | undefined>(undefined);
|
|
189
188
|
const isTab = navigation?.instance?.getState?.()?.type === 'tab';
|
|
@@ -424,7 +423,7 @@ const Screen = forwardRef(
|
|
|
424
423
|
}
|
|
425
424
|
}
|
|
426
425
|
},
|
|
427
|
-
}
|
|
426
|
+
}
|
|
428
427
|
);
|
|
429
428
|
}
|
|
430
429
|
|
|
@@ -574,7 +573,7 @@ const Screen = forwardRef(
|
|
|
574
573
|
</KeyboardAvoidingView>
|
|
575
574
|
</View>
|
|
576
575
|
);
|
|
577
|
-
}
|
|
576
|
+
}
|
|
578
577
|
);
|
|
579
578
|
|
|
580
579
|
export default Screen;
|
package/Layout/index.ts
CHANGED
|
@@ -7,7 +7,6 @@ import {GridContextProps} from './types';
|
|
|
7
7
|
import Item from './Item';
|
|
8
8
|
import ItemList from './ItemList';
|
|
9
9
|
import ItemSectionList from './ItemSectionList';
|
|
10
|
-
import Screen from './Screen';
|
|
11
10
|
|
|
12
11
|
const GridContext = createContext<GridContextProps>({
|
|
13
12
|
numberOfColumns: 12,
|
|
@@ -25,5 +24,4 @@ export {
|
|
|
25
24
|
Item,
|
|
26
25
|
ItemList,
|
|
27
26
|
ItemSectionList,
|
|
28
|
-
Screen,
|
|
29
27
|
};
|
package/index.ts
CHANGED
|
@@ -49,3 +49,10 @@ export * from './Title';
|
|
|
49
49
|
export * from './Title/types';
|
|
50
50
|
export * from './Badge';
|
|
51
51
|
export * from './Badge/types';
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* export trick for keep old mini app working
|
|
55
|
+
* @deprecated
|
|
56
|
+
*/
|
|
57
|
+
export * from 'react-native-modalize';
|
|
58
|
+
export * from '@gorhom/bottom-sheet';
|
package/package.json
CHANGED
|
@@ -1,35 +1,50 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
"
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
"
|
|
35
|
-
|
|
2
|
+
"name": "@momo-kits/foundation",
|
|
3
|
+
"version": "0.112.1-testing.20",
|
|
4
|
+
"description": "React Native Component Kits",
|
|
5
|
+
"main": "index.ts",
|
|
6
|
+
"scripts": {},
|
|
7
|
+
"keywords": [
|
|
8
|
+
"@momo-kits/foundation"
|
|
9
|
+
],
|
|
10
|
+
"dependencies": {
|
|
11
|
+
"@gorhom/bottom-sheet": "2.4.1",
|
|
12
|
+
"react-native-modalize": "2.1.1",
|
|
13
|
+
"react-native-safe-area-context": "3.1.4",
|
|
14
|
+
"react-native-linear-gradient": "2.8.3",
|
|
15
|
+
"react-native-gesture-handler": "1.10.3",
|
|
16
|
+
"react-native-fast-image": "8.1.5",
|
|
17
|
+
"@react-navigation/bottom-tabs": "https://gitlab.mservice.com.vn/momo-platform/react-native-bottom-tabs.git",
|
|
18
|
+
"@react-navigation/core": "5.16.1",
|
|
19
|
+
"@react-navigation/native": "5.9.8",
|
|
20
|
+
"@react-navigation/routers": "5.7.4",
|
|
21
|
+
"react-native-reanimated": "git+https://gitlab.mservice.com.vn/momo-platform/react-native-reanimated.git#v1.13.4_gradle_7",
|
|
22
|
+
"lottie-react-native": "git+https://gitlab.mservice.com.vn/momo-platform/momo-lottie-react-native.git",
|
|
23
|
+
"@react-navigation/stack": "https://gitlab.mservice.com.vn/momo-platform/react-navigation-stack.git"
|
|
24
|
+
},
|
|
25
|
+
"peerDependencies": {
|
|
26
|
+
"react-native": "*"
|
|
27
|
+
},
|
|
28
|
+
"devDependencies": {
|
|
29
|
+
"@babel/core": "^7.12.9",
|
|
30
|
+
"@babel/runtime": "^7.12.5",
|
|
31
|
+
"@react-native-community/eslint-config": "^2.0.0",
|
|
32
|
+
"@types/jest": "26.0.23",
|
|
33
|
+
"@types/react-native": "0.64.4",
|
|
34
|
+
"@types/react-test-renderer": "16.9.2",
|
|
35
|
+
"@types/d3-shape": "1.3.7",
|
|
36
|
+
"babel-jest": "^26.6.3",
|
|
37
|
+
"eslint": "^7.14.0",
|
|
38
|
+
"jest": "^26.6.3",
|
|
39
|
+
"metro-react-native-babel-preset": "^0.64.0",
|
|
40
|
+
"react-test-renderer": "17.0.1",
|
|
41
|
+
"typescript": "^4.0.3",
|
|
42
|
+
"@momo-platform/versions": "4.1.11",
|
|
43
|
+
"react-scanner": "^1.1.0",
|
|
44
|
+
"@types/color": "3.0.6"
|
|
45
|
+
},
|
|
46
|
+
"publishConfig": {
|
|
47
|
+
"registry": "https://registry.npmjs.org/"
|
|
48
|
+
},
|
|
49
|
+
"license": "MoMo"
|
|
50
|
+
}
|
package/publish.sh
CHANGED
|
@@ -2,16 +2,16 @@
|
|
|
2
2
|
|
|
3
3
|
|
|
4
4
|
if [ "$1" == "stable" ]; then
|
|
5
|
-
|
|
6
|
-
|
|
5
|
+
npm version $(npm view @momo-kits/foundation@stable version)
|
|
6
|
+
npm version patch
|
|
7
7
|
npm publish --tag stable --access=public
|
|
8
8
|
elif [ "$1" == "latest" ]; then
|
|
9
|
-
|
|
10
|
-
|
|
9
|
+
npm version $(npm view @momo-kits/foundation@latest version)
|
|
10
|
+
npm version prerelease --preid=rc
|
|
11
11
|
npm publish --tag latest --access=public
|
|
12
12
|
else
|
|
13
|
-
|
|
14
|
-
|
|
13
|
+
npm version $(npm view @momo-kits/foundation@beta version)
|
|
14
|
+
npm version prerelease --preid=beta
|
|
15
15
|
npm publish --tag beta --access=public
|
|
16
16
|
fi
|
|
17
17
|
PACKAGE_NAME=$(npm pkg get name)
|