@momo-kits/foundation 0.151.1-test.5 → 0.151.1-test.7
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.
|
@@ -77,6 +77,18 @@ 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
|
+
|
|
80
92
|
return (
|
|
81
93
|
<Animated.Text
|
|
82
94
|
numberOfLines={1}
|
|
@@ -103,8 +115,9 @@ export function Badge({
|
|
|
103
115
|
styles.container,
|
|
104
116
|
restStyle,
|
|
105
117
|
]}
|
|
106
|
-
{...rest}
|
|
107
|
-
|
|
118
|
+
{...rest}
|
|
119
|
+
>
|
|
120
|
+
{formatTitle()}
|
|
108
121
|
</Animated.Text>
|
|
109
122
|
);
|
|
110
123
|
}
|
|
@@ -5,13 +5,7 @@ import {
|
|
|
5
5
|
useFocusEffect,
|
|
6
6
|
} from '@react-navigation/native';
|
|
7
7
|
import { createStackNavigator } from '@react-navigation/stack';
|
|
8
|
-
import React, {
|
|
9
|
-
useCallback,
|
|
10
|
-
useContext,
|
|
11
|
-
useEffect,
|
|
12
|
-
useLayoutEffect,
|
|
13
|
-
useRef,
|
|
14
|
-
} from 'react';
|
|
8
|
+
import React, { useContext, useEffect, useLayoutEffect, useRef } from 'react';
|
|
15
9
|
import { useSafeAreaInsets } from 'react-native-safe-area-context';
|
|
16
10
|
import {
|
|
17
11
|
Animated,
|
|
@@ -27,7 +21,7 @@ import { exportFontFamily, Text } from '../../Text';
|
|
|
27
21
|
import { ApplicationContext, MiniAppContext } from '../index';
|
|
28
22
|
import StackScreen from '../StackScreen';
|
|
29
23
|
import { BottomTabProps } from '../types';
|
|
30
|
-
import { getOptions, getStackOptions } from '../utils';
|
|
24
|
+
import { getOptions, getStackOptions, useAppState } from '../utils';
|
|
31
25
|
import BottomTabBar from './BottomTabBar';
|
|
32
26
|
|
|
33
27
|
const Tab = createBottomTabNavigator();
|
|
@@ -44,9 +38,10 @@ const TabScreen: React.FC<any> = ({ route, navigation }) => {
|
|
|
44
38
|
const opacity = useRef(new Animated.Value(opacityValue)).current;
|
|
45
39
|
const scale = useRef(new Animated.Value(scaleValue)).current;
|
|
46
40
|
const screenName = screen?.name || screen?.type?.name || 'Invalid';
|
|
41
|
+
const { isBackgroundToForeground } = useAppState();
|
|
47
42
|
|
|
48
|
-
const onScreenNavigated =
|
|
49
|
-
(
|
|
43
|
+
const onScreenNavigated = (pre: string, current: string) => {
|
|
44
|
+
if (!isBackgroundToForeground) {
|
|
50
45
|
const data: any = {
|
|
51
46
|
preScreenName: pre,
|
|
52
47
|
screenName: current,
|
|
@@ -68,9 +63,8 @@ const TabScreen: React.FC<any> = ({ route, navigation }) => {
|
|
|
68
63
|
message: `${screenName} screen_navigated`,
|
|
69
64
|
type: 'ERROR',
|
|
70
65
|
});
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
);
|
|
66
|
+
}
|
|
67
|
+
};
|
|
74
68
|
|
|
75
69
|
useFocusEffect(
|
|
76
70
|
React.useCallback(
|
|
@@ -6,6 +6,7 @@ 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';
|
|
9
10
|
|
|
10
11
|
const runAfterInteractions = InteractionManager.runAfterInteractions;
|
|
11
12
|
|
|
@@ -48,6 +49,7 @@ const StackScreen: React.FC<any> = props => {
|
|
|
48
49
|
} = props.route.params;
|
|
49
50
|
const navigation = useRef(new Navigation(props.navigation, context)).current;
|
|
50
51
|
const heightHeader = useHeaderHeight();
|
|
52
|
+
const { isBackgroundToForeground } = useAppState();
|
|
51
53
|
|
|
52
54
|
const data = {
|
|
53
55
|
...initialParams,
|
|
@@ -140,29 +142,31 @@ const StackScreen: React.FC<any> = props => {
|
|
|
140
142
|
}, []);
|
|
141
143
|
|
|
142
144
|
const onScreenNavigated = (pre: string, current: string) => {
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
145
|
+
if (!isBackgroundToForeground) {
|
|
146
|
+
const item: any = {
|
|
147
|
+
preScreenName: pre,
|
|
148
|
+
screenName: current,
|
|
149
|
+
componentName: 'Screen',
|
|
150
|
+
state: 'navigated',
|
|
151
|
+
action: tracking.current?.mounted ? 'back' : 'push',
|
|
152
|
+
};
|
|
153
|
+
|
|
154
|
+
context?.autoTracking?.({
|
|
155
|
+
...context,
|
|
156
|
+
...item,
|
|
157
|
+
});
|
|
150
158
|
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
appId: context.appId,
|
|
163
|
-
message: `${screenName} screen_navigated`,
|
|
164
|
-
type: 'ERROR',
|
|
165
|
-
});
|
|
159
|
+
tracking.current.mounted = true;
|
|
160
|
+
|
|
161
|
+
/**
|
|
162
|
+
* debug toast
|
|
163
|
+
*/
|
|
164
|
+
navigator?.maxApi?.showToastDebug?.({
|
|
165
|
+
appId: context.appId,
|
|
166
|
+
message: `${screenName} screen_navigated`,
|
|
167
|
+
type: 'ERROR',
|
|
168
|
+
});
|
|
169
|
+
}
|
|
166
170
|
};
|
|
167
171
|
|
|
168
172
|
/**
|
package/Application/utils.tsx
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React, { useContext, useMemo } from 'react';
|
|
1
|
+
import React, { useContext, useEffect, useMemo, useRef } 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, Platform } from 'react-native';
|
|
15
|
+
import { Animated, AppState, Platform } from 'react-native';
|
|
16
16
|
import { MiniAppContext, ScreenContext, TrackingScopeContext } from './index';
|
|
17
17
|
|
|
18
18
|
/**
|
|
@@ -205,6 +205,36 @@ 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
|
+
|
|
208
238
|
export {
|
|
209
239
|
getStackOptions,
|
|
210
240
|
getModalOptions,
|
|
@@ -212,4 +242,5 @@ export {
|
|
|
212
242
|
exportHeaderTitle,
|
|
213
243
|
setAutomationID,
|
|
214
244
|
useComponentId,
|
|
245
|
+
useAppState,
|
|
215
246
|
};
|
package/Button/index.tsx
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React, {FC, useContext} from 'react';
|
|
1
|
+
import React, { FC, useContext, useRef } from 'react';
|
|
2
2
|
import {
|
|
3
3
|
Animated,
|
|
4
4
|
StyleSheet,
|
|
@@ -18,8 +18,8 @@ import {Typography} from '../Text/types';
|
|
|
18
18
|
import {Colors, Spacing} from '../Consts';
|
|
19
19
|
import styles from './styles';
|
|
20
20
|
import {Icon} from '../Icon';
|
|
21
|
-
import {Loader} from '../Loader';
|
|
22
21
|
import {Skeleton} from '../Skeleton';
|
|
22
|
+
import LottieView from 'lottie-react-native';
|
|
23
23
|
|
|
24
24
|
const AnimationLinear = Animated.createAnimatedComponent(LinearGradient);
|
|
25
25
|
|
|
@@ -98,6 +98,7 @@ const Button: FC<ButtonProps> = ({
|
|
|
98
98
|
const {theme, config} = useContext(ApplicationContext);
|
|
99
99
|
const skeleton = useContext(SkeletonContext);
|
|
100
100
|
const componentName = 'Button';
|
|
101
|
+
const animationRef = useRef<LottieView>(null);
|
|
101
102
|
|
|
102
103
|
const {componentId} = useComponentId(
|
|
103
104
|
`${componentName}/${title}`,
|
|
@@ -105,6 +106,7 @@ const Button: FC<ButtonProps> = ({
|
|
|
105
106
|
);
|
|
106
107
|
const {gradient, color} = config?.navigationBar?.buttonColors ?? {};
|
|
107
108
|
let gradientPros;
|
|
109
|
+
const isDisabled = type === 'disabled' || loading;
|
|
108
110
|
|
|
109
111
|
if (gradient?.length > 0 && type === 'primary') {
|
|
110
112
|
gradientPros = {
|
|
@@ -247,7 +249,16 @@ const Button: FC<ButtonProps> = ({
|
|
|
247
249
|
|
|
248
250
|
if (loading) {
|
|
249
251
|
return (
|
|
250
|
-
<
|
|
252
|
+
<LottieView
|
|
253
|
+
ref={animationRef}
|
|
254
|
+
source={require('./lottie_circle_loader.json')}
|
|
255
|
+
autoPlay
|
|
256
|
+
loop
|
|
257
|
+
colorFilters={[
|
|
258
|
+
{ keypath: 'loading 2.Ellipse 1.Stroke 1', color: textColor },
|
|
259
|
+
{ keypath: 'loading 3.Ellipse 1.Stroke 1', color: textColor },
|
|
260
|
+
{ keypath: 'base pink 2.Ellipse 1.Stroke 1', color: textColor },
|
|
261
|
+
]}
|
|
251
262
|
style={[
|
|
252
263
|
styles.trailing,
|
|
253
264
|
{
|
|
@@ -256,9 +267,8 @@ const Button: FC<ButtonProps> = ({
|
|
|
256
267
|
marginRight,
|
|
257
268
|
borderRadius: Spacing.M,
|
|
258
269
|
},
|
|
259
|
-
]}
|
|
260
|
-
|
|
261
|
-
</View>
|
|
270
|
+
]}
|
|
271
|
+
/>
|
|
262
272
|
);
|
|
263
273
|
}
|
|
264
274
|
if (iconLeft) {
|
|
@@ -299,6 +309,7 @@ const Button: FC<ButtonProps> = ({
|
|
|
299
309
|
getSizeStyle(),
|
|
300
310
|
getTypeStyle(),
|
|
301
311
|
full && {width: '100%'},
|
|
312
|
+
loading && {opacity: 0.75}
|
|
302
313
|
]);
|
|
303
314
|
|
|
304
315
|
if (skeleton?.loading) {
|
|
@@ -318,11 +329,11 @@ const Button: FC<ButtonProps> = ({
|
|
|
318
329
|
accessibilityLabel={componentId}
|
|
319
330
|
accessibilityRole="button"
|
|
320
331
|
accessibilityState={{
|
|
321
|
-
disabled:
|
|
332
|
+
disabled: isDisabled,
|
|
322
333
|
busy: loading,
|
|
323
334
|
...accessibilityState,
|
|
324
335
|
}}
|
|
325
|
-
disabled={
|
|
336
|
+
disabled={isDisabled}
|
|
326
337
|
activeOpacity={0.5}
|
|
327
338
|
style={buttonStyle}>
|
|
328
339
|
{renderLeading()}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"v":"5.10.2","fr":30,"ip":0,"op":20,"w":100,"h":100,"nm":"Spinner3.1_Refine","ddd":0,"assets":[],"layers":[{"ddd":0,"ind":12,"ty":4,"nm":"loading 2","sr":1,"ks":{"o":{"a":0,"k":100,"ix":11},"r":{"a":1,"k":[{"i":{"x":[0.833],"y":[0.833]},"o":{"x":[0.167],"y":[0.167]},"t":0,"s":[0],"e":[360]},{"t":20}],"ix":10},"p":{"a":0,"k":[50,50,0],"ix":2,"l":2},"a":{"a":0,"k":[44.124,44.124,0],"ix":1,"l":2},"s":{"a":0,"k":[100,100,100],"ix":6,"l":2}},"ao":0,"shapes":[{"ty":"gr","it":[{"d":1,"ty":"el","s":{"a":0,"k":[90,90],"ix":2},"p":{"a":0,"k":[0,0],"ix":3},"nm":"Ellipse Path 1","mn":"ADBE Vector Shape - Ellipse","hd":false},{"ty":"st","c":{"a":0,"k":[0.996078431373,0.956862745098,0.980392156863,1],"ix":3},"o":{"a":0,"k":100,"ix":4},"w":{"a":0,"k":9,"ix":5},"lc":2,"lj":1,"ml":4,"bm":0,"nm":"Stroke 1","mn":"ADBE Vector Graphic - Stroke","hd":false},{"ty":"tr","p":{"a":0,"k":[44.124,44.124],"ix":2},"a":{"a":0,"k":[0,0],"ix":1},"s":{"a":0,"k":[100,100],"ix":3},"r":{"a":0,"k":0,"ix":6},"o":{"a":0,"k":100,"ix":7},"sk":{"a":0,"k":0,"ix":4},"sa":{"a":0,"k":0,"ix":5},"nm":"Transform"}],"nm":"Ellipse 1","np":3,"cix":2,"bm":0,"ix":1,"mn":"ADBE Vector Group","hd":false},{"ty":"tm","s":{"a":1,"k":[{"i":{"x":[0.667],"y":[1]},"o":{"x":[0.167],"y":[0.167]},"t":0,"s":[0],"e":[20]},{"i":{"x":[0.833],"y":[0.833]},"o":{"x":[0.333],"y":[0]},"t":10,"s":[20],"e":[0]},{"t":20}],"ix":1},"e":{"a":1,"k":[{"i":{"x":[0.667],"y":[1]},"o":{"x":[0.167],"y":[0.167]},"t":0,"s":[35],"e":[50]},{"i":{"x":[0.833],"y":[0.833]},"o":{"x":[0.333],"y":[0]},"t":10,"s":[50],"e":[35]},{"t":20}],"ix":2},"o":{"a":0,"k":0,"ix":3},"m":1,"ix":2,"nm":"Trim Paths 1","mn":"ADBE Vector Filter - Trim","hd":false}],"ip":0,"op":20,"st":0,"ct":1,"bm":0},{"ddd":0,"ind":13,"ty":4,"nm":"loading 3","sr":1,"ks":{"o":{"a":0,"k":100,"ix":11},"r":{"a":1,"k":[{"i":{"x":[0.833],"y":[0.833]},"o":{"x":[0.167],"y":[0.167]},"t":2,"s":[0],"e":[360]},{"t":20}],"ix":10},"p":{"a":0,"k":[50,50,0],"ix":2,"l":2},"a":{"a":0,"k":[44.124,44.124,0],"ix":1,"l":2},"s":{"a":0,"k":[100,100,100],"ix":6,"l":2}},"ao":0,"shapes":[{"ty":"gr","it":[{"d":1,"ty":"el","s":{"a":0,"k":[90,90],"ix":2},"p":{"a":0,"k":[0,0],"ix":3},"nm":"Ellipse Path 1","mn":"ADBE Vector Shape - Ellipse","hd":false},{"ty":"st","c":{"a":0,"k":[0.98431372549,0.835294117647,0.917647058824,1],"ix":3},"o":{"a":0,"k":100,"ix":4},"w":{"a":0,"k":9,"ix":5},"lc":2,"lj":1,"ml":4,"bm":0,"nm":"Stroke 1","mn":"ADBE Vector Graphic - Stroke","hd":false},{"ty":"tr","p":{"a":0,"k":[44.124,44.124],"ix":2},"a":{"a":0,"k":[0,0],"ix":1},"s":{"a":0,"k":[100,100],"ix":3},"r":{"a":0,"k":0,"ix":6},"o":{"a":0,"k":100,"ix":7},"sk":{"a":0,"k":0,"ix":4},"sa":{"a":0,"k":0,"ix":5},"nm":"Transform"}],"nm":"Ellipse 1","np":3,"cix":2,"bm":0,"ix":1,"mn":"ADBE Vector Group","hd":false},{"ty":"tm","s":{"a":1,"k":[{"i":{"x":[0.667],"y":[1]},"o":{"x":[0.167],"y":[0.167]},"t":2,"s":[0],"e":[20]},{"i":{"x":[0.833],"y":[0.833]},"o":{"x":[0.333],"y":[0]},"t":12,"s":[20],"e":[0]},{"t":20}],"ix":1},"e":{"a":1,"k":[{"i":{"x":[0.667],"y":[1]},"o":{"x":[0.167],"y":[0.167]},"t":2,"s":[35],"e":[50]},{"i":{"x":[0.833],"y":[0.833]},"o":{"x":[0.333],"y":[0]},"t":12,"s":[50],"e":[35]},{"t":20}],"ix":2},"o":{"a":0,"k":0,"ix":3},"m":1,"ix":2,"nm":"Trim Paths 1","mn":"ADBE Vector Filter - Trim","hd":false}],"ip":0,"op":20,"st":0,"ct":1,"bm":0},{"ddd":0,"ind":14,"ty":4,"nm":"base pink 2","sr":1,"ks":{"o":{"a":0,"k":40,"ix":11},"r":{"a":0,"k":0,"ix":10},"p":{"a":0,"k":[50,50,0],"ix":2,"l":2},"a":{"a":0,"k":[44.124,44.124,0],"ix":1,"l":2},"s":{"a":0,"k":[100,100,100],"ix":6,"l":2}},"ao":0,"shapes":[{"ty":"gr","it":[{"d":1,"ty":"el","s":{"a":0,"k":[90,90],"ix":2},"p":{"a":0,"k":[0,0],"ix":3},"nm":"Ellipse Path 1","mn":"ADBE Vector Shape - Ellipse","hd":false},{"ty":"st","c":{"a":0,"k":[0.996078431373,0.972549019608,0.988235294118,1],"ix":3},"o":{"a":0,"k":100,"ix":4},"w":{"a":0,"k":9,"ix":5},"lc":1,"lj":1,"ml":4,"bm":0,"nm":"Stroke 1","mn":"ADBE Vector Graphic - Stroke","hd":false},{"ty":"tr","p":{"a":0,"k":[44.124,44.124],"ix":2},"a":{"a":0,"k":[0,0],"ix":1},"s":{"a":0,"k":[100,100],"ix":3},"r":{"a":0,"k":0,"ix":6},"o":{"a":0,"k":100,"ix":7},"sk":{"a":0,"k":0,"ix":4},"sa":{"a":0,"k":0,"ix":5},"nm":"Transform"}],"nm":"Ellipse 1","np":3,"cix":2,"bm":0,"ix":1,"mn":"ADBE Vector Group","hd":false}],"ip":0,"op":20,"st":0,"ct":1,"bm":0}],"markers":[]}
|