@momo-kits/foundation 0.151.1-tracking.3 → 0.151.1-tracking.5
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.
|
@@ -15,6 +15,7 @@ import React, {
|
|
|
15
15
|
import { useSafeAreaInsets } from 'react-native-safe-area-context';
|
|
16
16
|
import {
|
|
17
17
|
Animated,
|
|
18
|
+
AppState,
|
|
18
19
|
Platform,
|
|
19
20
|
StatusBar,
|
|
20
21
|
StyleSheet,
|
|
@@ -44,34 +45,57 @@ const TabScreen: React.FC<any> = ({ route, navigation }) => {
|
|
|
44
45
|
const opacity = useRef(new Animated.Value(opacityValue)).current;
|
|
45
46
|
const scale = useRef(new Animated.Value(scaleValue)).current;
|
|
46
47
|
const screenName = screen?.name || screen?.type?.name || 'Invalid';
|
|
48
|
+
const appState = useRef(AppState.currentState);
|
|
49
|
+
let isBackgroundToForeground = useRef(false);
|
|
47
50
|
|
|
48
51
|
const onScreenNavigated = useCallback(
|
|
49
52
|
(pre: string, current: string) => {
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
53
|
+
if (!isBackgroundToForeground.current) {
|
|
54
|
+
const data: any = {
|
|
55
|
+
preScreenName: pre,
|
|
56
|
+
screenName: current,
|
|
57
|
+
componentName: 'Screen',
|
|
58
|
+
state: 'navigated',
|
|
59
|
+
action: 'push',
|
|
60
|
+
};
|
|
57
61
|
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
+
context?.autoTracking?.({
|
|
63
|
+
...context,
|
|
64
|
+
...data,
|
|
65
|
+
});
|
|
62
66
|
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
67
|
+
/**
|
|
68
|
+
* debug toast
|
|
69
|
+
*/
|
|
70
|
+
navigator?.maxApi?.showToastDebug?.({
|
|
71
|
+
appId: context.appId,
|
|
72
|
+
message: `${screenName} screen_navigated`,
|
|
73
|
+
type: 'ERROR',
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
if (isBackgroundToForeground.current)
|
|
78
|
+
isBackgroundToForeground.current = false;
|
|
71
79
|
},
|
|
72
80
|
[context, navigator?.maxApi, screenName],
|
|
73
81
|
);
|
|
74
82
|
|
|
83
|
+
useEffect(() => {
|
|
84
|
+
const subscription = AppState.addEventListener('change', nextAppState => {
|
|
85
|
+
if (
|
|
86
|
+
appState.current.match(/inactive|background/) &&
|
|
87
|
+
nextAppState === 'active'
|
|
88
|
+
) {
|
|
89
|
+
isBackgroundToForeground.current = true;
|
|
90
|
+
}
|
|
91
|
+
appState.current = nextAppState;
|
|
92
|
+
});
|
|
93
|
+
|
|
94
|
+
return () => {
|
|
95
|
+
subscription.remove();
|
|
96
|
+
};
|
|
97
|
+
}, []);
|
|
98
|
+
|
|
75
99
|
useFocusEffect(
|
|
76
100
|
React.useCallback(
|
|
77
101
|
() => {
|
|
@@ -158,7 +158,7 @@ const StackScreen: React.FC<any> = props => {
|
|
|
158
158
|
}, []);
|
|
159
159
|
|
|
160
160
|
const onScreenNavigated = (pre: string, current: string) => {
|
|
161
|
-
if (!isBackgroundToForeground) {
|
|
161
|
+
if (!isBackgroundToForeground.current) {
|
|
162
162
|
const item: any = {
|
|
163
163
|
preScreenName: pre,
|
|
164
164
|
screenName: current,
|
|
@@ -184,7 +184,8 @@ const StackScreen: React.FC<any> = props => {
|
|
|
184
184
|
});
|
|
185
185
|
}
|
|
186
186
|
|
|
187
|
-
if (isBackgroundToForeground
|
|
187
|
+
if (isBackgroundToForeground.current)
|
|
188
|
+
isBackgroundToForeground.current = false;
|
|
188
189
|
};
|
|
189
190
|
|
|
190
191
|
/**
|