@momo-kits/foundation 0.151.1-beta.4-sp.5 → 0.151.1-beta.6
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 +0 -1
- package/Application/BottomTab/Badge.tsx +2 -15
- package/Application/BottomTab/index.tsx +13 -7
- package/Application/ModalScreen.tsx +0 -1
- package/Application/NavigationContainer.tsx +14 -1
- package/Application/StackScreen.tsx +22 -26
- package/Application/WidgetContainer.tsx +16 -1
- package/Application/utils.tsx +2 -33
- package/Input/Input.tsx +0 -1
- package/Input/InputMoney.tsx +0 -1
- package/Input/InputSearch.tsx +0 -1
- package/Input/InputTextArea.tsx +0 -1
- package/package.json +34 -34
|
@@ -77,18 +77,6 @@ export function Badge({
|
|
|
77
77
|
const borderRadius = size / 2;
|
|
78
78
|
const fontSize = Math.floor((size * 3) / 4);
|
|
79
79
|
|
|
80
|
-
const isNumber = () => {
|
|
81
|
-
const numberRegex = /^\d+$/;
|
|
82
|
-
return numberRegex.test(String(children));
|
|
83
|
-
};
|
|
84
|
-
|
|
85
|
-
const formatTitle = () => {
|
|
86
|
-
if (isNumber() && Number(children) > 99) {
|
|
87
|
-
return '99+';
|
|
88
|
-
}
|
|
89
|
-
return children;
|
|
90
|
-
};
|
|
91
|
-
|
|
92
80
|
return (
|
|
93
81
|
<Animated.Text
|
|
94
82
|
numberOfLines={1}
|
|
@@ -115,9 +103,8 @@ export function Badge({
|
|
|
115
103
|
styles.container,
|
|
116
104
|
restStyle,
|
|
117
105
|
]}
|
|
118
|
-
{...rest}
|
|
119
|
-
|
|
120
|
-
{formatTitle()}
|
|
106
|
+
{...rest}>
|
|
107
|
+
{children}
|
|
121
108
|
</Animated.Text>
|
|
122
109
|
);
|
|
123
110
|
}
|
|
@@ -5,7 +5,13 @@ import {
|
|
|
5
5
|
useFocusEffect,
|
|
6
6
|
} from '@react-navigation/native';
|
|
7
7
|
import { createStackNavigator } from '@react-navigation/stack';
|
|
8
|
-
import React, {
|
|
8
|
+
import React, {
|
|
9
|
+
useCallback,
|
|
10
|
+
useContext,
|
|
11
|
+
useEffect,
|
|
12
|
+
useLayoutEffect,
|
|
13
|
+
useRef,
|
|
14
|
+
} from 'react';
|
|
9
15
|
import { useSafeAreaInsets } from 'react-native-safe-area-context';
|
|
10
16
|
import {
|
|
11
17
|
Animated,
|
|
@@ -21,7 +27,7 @@ import { exportFontFamily, Text } from '../../Text';
|
|
|
21
27
|
import { ApplicationContext, MiniAppContext } from '../index';
|
|
22
28
|
import StackScreen from '../StackScreen';
|
|
23
29
|
import { BottomTabProps } from '../types';
|
|
24
|
-
import { getOptions, getStackOptions
|
|
30
|
+
import { getOptions, getStackOptions } from '../utils';
|
|
25
31
|
import BottomTabBar from './BottomTabBar';
|
|
26
32
|
|
|
27
33
|
const Tab = createBottomTabNavigator();
|
|
@@ -38,10 +44,9 @@ const TabScreen: React.FC<any> = ({ route, navigation }) => {
|
|
|
38
44
|
const opacity = useRef(new Animated.Value(opacityValue)).current;
|
|
39
45
|
const scale = useRef(new Animated.Value(scaleValue)).current;
|
|
40
46
|
const screenName = screen?.name || screen?.type?.name || 'Invalid';
|
|
41
|
-
const { isBackgroundToForeground } = useAppState();
|
|
42
47
|
|
|
43
|
-
const onScreenNavigated = (
|
|
44
|
-
|
|
48
|
+
const onScreenNavigated = useCallback(
|
|
49
|
+
(pre: string, current: string) => {
|
|
45
50
|
const data: any = {
|
|
46
51
|
preScreenName: pre,
|
|
47
52
|
screenName: current,
|
|
@@ -63,8 +68,9 @@ const TabScreen: React.FC<any> = ({ route, navigation }) => {
|
|
|
63
68
|
message: `${screenName} screen_navigated`,
|
|
64
69
|
type: 'ERROR',
|
|
65
70
|
});
|
|
66
|
-
}
|
|
67
|
-
|
|
71
|
+
},
|
|
72
|
+
[context, navigator?.maxApi, screenName],
|
|
73
|
+
);
|
|
68
74
|
|
|
69
75
|
useFocusEffect(
|
|
70
76
|
React.useCallback(
|
|
@@ -47,7 +47,20 @@ const NavigationContainer: React.FC<NavigationContainerProps> = ({
|
|
|
47
47
|
const context = useContext<any>(MiniAppContext);
|
|
48
48
|
const [currentContext, setCurrentContext] = useState({});
|
|
49
49
|
return (
|
|
50
|
-
<SafeAreaProvider
|
|
50
|
+
<SafeAreaProvider initialMetrics={{
|
|
51
|
+
insets: {
|
|
52
|
+
top: 0,
|
|
53
|
+
bottom: 0,
|
|
54
|
+
left:0,
|
|
55
|
+
right: 0,
|
|
56
|
+
},
|
|
57
|
+
frame: {
|
|
58
|
+
width: 0,
|
|
59
|
+
height: 0,
|
|
60
|
+
x: 0,
|
|
61
|
+
y: 0,
|
|
62
|
+
}
|
|
63
|
+
}}>
|
|
51
64
|
<MiniAppContext.Provider
|
|
52
65
|
value={{
|
|
53
66
|
...context,
|
|
@@ -6,7 +6,6 @@ import Navigation from './Navigation';
|
|
|
6
6
|
import { ApplicationContext, MiniAppContext, ScreenContext } from './index';
|
|
7
7
|
import { GridSystem } from '../Layout';
|
|
8
8
|
import { version } from '../package.json';
|
|
9
|
-
import { useAppState } from './utils';
|
|
10
9
|
|
|
11
10
|
const runAfterInteractions = InteractionManager.runAfterInteractions;
|
|
12
11
|
|
|
@@ -49,7 +48,6 @@ const StackScreen: React.FC<any> = props => {
|
|
|
49
48
|
} = props.route.params;
|
|
50
49
|
const navigation = useRef(new Navigation(props.navigation, context)).current;
|
|
51
50
|
const heightHeader = useHeaderHeight();
|
|
52
|
-
const { isBackgroundToForeground } = useAppState();
|
|
53
51
|
|
|
54
52
|
const data = {
|
|
55
53
|
...initialParams,
|
|
@@ -142,31 +140,29 @@ const StackScreen: React.FC<any> = props => {
|
|
|
142
140
|
}, []);
|
|
143
141
|
|
|
144
142
|
const onScreenNavigated = (pre: string, current: string) => {
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
};
|
|
153
|
-
|
|
154
|
-
context?.autoTracking?.({
|
|
155
|
-
...context,
|
|
156
|
-
...item,
|
|
157
|
-
});
|
|
158
|
-
|
|
159
|
-
tracking.current.mounted = true;
|
|
143
|
+
const item: any = {
|
|
144
|
+
preScreenName: pre,
|
|
145
|
+
screenName: current,
|
|
146
|
+
componentName: 'Screen',
|
|
147
|
+
state: 'navigated',
|
|
148
|
+
action: tracking.current?.mounted ? 'back' : 'push',
|
|
149
|
+
};
|
|
160
150
|
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
151
|
+
context?.autoTracking?.({
|
|
152
|
+
...context,
|
|
153
|
+
...item,
|
|
154
|
+
});
|
|
155
|
+
|
|
156
|
+
tracking.current.mounted = true;
|
|
157
|
+
|
|
158
|
+
/**
|
|
159
|
+
* debug toast
|
|
160
|
+
*/
|
|
161
|
+
navigator?.maxApi?.showToastDebug?.({
|
|
162
|
+
appId: context.appId,
|
|
163
|
+
message: `${screenName} screen_navigated`,
|
|
164
|
+
type: 'ERROR',
|
|
165
|
+
});
|
|
170
166
|
};
|
|
171
167
|
|
|
172
168
|
/**
|
|
@@ -69,7 +69,22 @@ const WidgetContainer: React.FC<WidgetContainerProps> = ({
|
|
|
69
69
|
|
|
70
70
|
return (
|
|
71
71
|
<View style={{ height: height ?? '100%' }}>
|
|
72
|
-
<SafeAreaProvider
|
|
72
|
+
<SafeAreaProvider
|
|
73
|
+
initialMetrics={{
|
|
74
|
+
insets: {
|
|
75
|
+
top: 0,
|
|
76
|
+
bottom: 0,
|
|
77
|
+
left: 0,
|
|
78
|
+
right: 0,
|
|
79
|
+
},
|
|
80
|
+
frame: {
|
|
81
|
+
width: 0,
|
|
82
|
+
height: 0,
|
|
83
|
+
x: 0,
|
|
84
|
+
y: 0,
|
|
85
|
+
},
|
|
86
|
+
}}
|
|
87
|
+
>
|
|
73
88
|
<MiniAppContext.Provider
|
|
74
89
|
value={{
|
|
75
90
|
...context,
|
package/Application/utils.tsx
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React, { useContext,
|
|
1
|
+
import React, { useContext, useMemo } from 'react';
|
|
2
2
|
import {
|
|
3
3
|
StackNavigationOptions,
|
|
4
4
|
TransitionPresets,
|
|
@@ -12,7 +12,7 @@ import {
|
|
|
12
12
|
} from './Components';
|
|
13
13
|
import { HeaderTitleProps, NavigationOptions } from './types';
|
|
14
14
|
import { Colors, Spacing } from '../Consts';
|
|
15
|
-
import { Animated,
|
|
15
|
+
import { Animated, Platform } from 'react-native';
|
|
16
16
|
import { MiniAppContext, ScreenContext, TrackingScopeContext } from './index';
|
|
17
17
|
|
|
18
18
|
/**
|
|
@@ -205,36 +205,6 @@ export const getImageName = (source: any): string => {
|
|
|
205
205
|
return '';
|
|
206
206
|
};
|
|
207
207
|
|
|
208
|
-
const useAppState = () => {
|
|
209
|
-
const isBackgroundToForeground = useRef(false);
|
|
210
|
-
const appState = useRef(AppState.currentState);
|
|
211
|
-
|
|
212
|
-
useEffect(() => {
|
|
213
|
-
const subscription = AppState.addEventListener('change', nextAppState => {
|
|
214
|
-
isBackgroundToForeground.current = !!(
|
|
215
|
-
appState.current.match(/inactive|background/) &&
|
|
216
|
-
nextAppState === 'active'
|
|
217
|
-
);
|
|
218
|
-
appState.current = nextAppState;
|
|
219
|
-
|
|
220
|
-
if (isBackgroundToForeground.current) {
|
|
221
|
-
setTimeout(() => {
|
|
222
|
-
isBackgroundToForeground.current = false;
|
|
223
|
-
}, 100);
|
|
224
|
-
}
|
|
225
|
-
});
|
|
226
|
-
|
|
227
|
-
return () => {
|
|
228
|
-
subscription.remove();
|
|
229
|
-
};
|
|
230
|
-
}, []);
|
|
231
|
-
|
|
232
|
-
return {
|
|
233
|
-
isBackgroundToForeground: isBackgroundToForeground.current,
|
|
234
|
-
appState: appState.current,
|
|
235
|
-
};
|
|
236
|
-
};
|
|
237
|
-
|
|
238
208
|
export {
|
|
239
209
|
getStackOptions,
|
|
240
210
|
getModalOptions,
|
|
@@ -242,5 +212,4 @@ export {
|
|
|
242
212
|
exportHeaderTitle,
|
|
243
213
|
setAutomationID,
|
|
244
214
|
useComponentId,
|
|
245
|
-
useAppState,
|
|
246
215
|
};
|
package/Input/Input.tsx
CHANGED
package/Input/InputMoney.tsx
CHANGED
package/Input/InputSearch.tsx
CHANGED
package/Input/InputTextArea.tsx
CHANGED
package/package.json
CHANGED
|
@@ -1,35 +1,35 @@
|
|
|
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.151.1-beta.6",
|
|
4
|
+
"description": "React Native Component Kits",
|
|
5
|
+
"main": "index.ts",
|
|
6
|
+
"scripts": {},
|
|
7
|
+
"keywords": [
|
|
8
|
+
"@momo-kits/foundation"
|
|
9
|
+
],
|
|
10
|
+
"dependencies": {
|
|
11
|
+
"react-native-fast-image": "git+https://oauth2:TGi6oBj-LdzsKpLXQSoH@gitlab.mservice.com.vn/momo-platform/public/react-native-fast-image.git#v8.11.0",
|
|
12
|
+
"@react-navigation/bottom-tabs": "7.4.2",
|
|
13
|
+
"@react-navigation/core": "7.12.1",
|
|
14
|
+
"@react-navigation/elements": "2.5.2",
|
|
15
|
+
"@react-navigation/native": "7.1.14",
|
|
16
|
+
"@react-navigation/routers": "7.4.1",
|
|
17
|
+
"@react-navigation/stack": "7.4.2",
|
|
18
|
+
"react-native-gesture-handler": "2.27.1",
|
|
19
|
+
"react-native-linear-gradient": "git+https://oauth2:TGi6oBj-LdzsKpLXQSoH@gitlab.mservice.com.vn/momo-platform/public/react-native-linear-gradient#v3.0.0",
|
|
20
|
+
"react-native-reanimated": "4.1.0",
|
|
21
|
+
"react-native-safe-area-context": "5.5.2",
|
|
22
|
+
"@shopify/flash-list": "2.1.0"
|
|
23
|
+
},
|
|
24
|
+
"peerDependencies": {
|
|
25
|
+
"react-native": "*"
|
|
26
|
+
},
|
|
27
|
+
"devDependencies": {
|
|
28
|
+
"@momo-platform/versions": "4.1.11",
|
|
29
|
+
"@types/color": "3.0.6"
|
|
30
|
+
},
|
|
31
|
+
"publishConfig": {
|
|
32
|
+
"registry": "https://registry.npmjs.org/"
|
|
33
|
+
},
|
|
34
|
+
"license": "MoMo"
|
|
35
|
+
}
|