@momo-kits/foundation 0.152.4 → 0.153.1-beta.1
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.
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import React, { useCallback, useContext, useEffect, useRef } from 'react';
|
|
2
2
|
import {
|
|
3
|
+
BackHandler,
|
|
3
4
|
Dimensions,
|
|
4
5
|
KeyboardAvoidingView,
|
|
5
6
|
Modal,
|
|
@@ -150,6 +151,17 @@ const BottomSheet: React.FC<BottomSheetParams> = props => {
|
|
|
150
151
|
[onDismiss],
|
|
151
152
|
);
|
|
152
153
|
|
|
154
|
+
useEffect(() => {
|
|
155
|
+
const backHandler = BackHandler.addEventListener(
|
|
156
|
+
'hardwareBackPress',
|
|
157
|
+
() => {
|
|
158
|
+
onDismiss();
|
|
159
|
+
return true;
|
|
160
|
+
},
|
|
161
|
+
);
|
|
162
|
+
return () => backHandler.remove();
|
|
163
|
+
}, [barrierDismissible, onDismiss]);
|
|
164
|
+
|
|
153
165
|
/**
|
|
154
166
|
* render header
|
|
155
167
|
*/
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React, { useContext, useEffect, useRef } from 'react';
|
|
1
|
+
import React, { useCallback, useContext, useEffect, useRef } from 'react';
|
|
2
2
|
import {
|
|
3
3
|
Animated,
|
|
4
4
|
Easing,
|
|
@@ -8,6 +8,7 @@ import {
|
|
|
8
8
|
StyleSheet,
|
|
9
9
|
View,
|
|
10
10
|
Modal as ModalRN,
|
|
11
|
+
BackHandler,
|
|
11
12
|
} from 'react-native';
|
|
12
13
|
|
|
13
14
|
import { ApplicationContext, MiniAppContext } from '../Context';
|
|
@@ -79,7 +80,7 @@ const Modal: React.FC<ModalParams> = props => {
|
|
|
79
80
|
};
|
|
80
81
|
}, [opacity, props.route.params, scale]);
|
|
81
82
|
|
|
82
|
-
const onDismiss = (callback = () => {}, preventClose = false) => {
|
|
83
|
+
const onDismiss = useCallback((callback = () => {}, preventClose = false) => {
|
|
83
84
|
if (preventClose) {
|
|
84
85
|
return;
|
|
85
86
|
}
|
|
@@ -99,7 +100,18 @@ const Modal: React.FC<ModalParams> = props => {
|
|
|
99
100
|
navigator?.pop();
|
|
100
101
|
runOnJS(callback)();
|
|
101
102
|
});
|
|
102
|
-
};
|
|
103
|
+
}, [navigator, opacity, scale]);
|
|
104
|
+
|
|
105
|
+
useEffect(() => {
|
|
106
|
+
const backHandler = BackHandler.addEventListener(
|
|
107
|
+
'hardwareBackPress',
|
|
108
|
+
() => {
|
|
109
|
+
onDismiss(undefined, barrierDismissible);
|
|
110
|
+
return true;
|
|
111
|
+
},
|
|
112
|
+
);
|
|
113
|
+
return () => backHandler.remove();
|
|
114
|
+
}, [barrierDismissible, onDismiss]);
|
|
103
115
|
|
|
104
116
|
return (
|
|
105
117
|
<Container
|
|
@@ -85,11 +85,20 @@ const StackScreen: React.FC<any> = props => {
|
|
|
85
85
|
});
|
|
86
86
|
}
|
|
87
87
|
|
|
88
|
+
const startTime = Date.now();
|
|
89
|
+
navigator?.maxApi?.setDataObserver?.('current_screen', {
|
|
90
|
+
screenName,
|
|
91
|
+
startTime,
|
|
92
|
+
});
|
|
93
|
+
|
|
88
94
|
if (!bottomTab) {
|
|
89
95
|
focusScreen = props.navigation.addListener('focus', () => {
|
|
90
96
|
navigator?.maxApi?.getDataObserver?.('current_screen', (item: any) => {
|
|
91
97
|
onScreenNavigated(item?.screenName, screenName);
|
|
92
|
-
navigator?.maxApi?.
|
|
98
|
+
navigator?.maxApi?.setDataObserver?.('current_screen', {
|
|
99
|
+
screenName,
|
|
100
|
+
startTime,
|
|
101
|
+
});
|
|
93
102
|
});
|
|
94
103
|
});
|
|
95
104
|
onFocusApp = navigator?.maxApi?.listen?.('onFocusApp', () => {
|
|
@@ -98,8 +107,9 @@ const StackScreen: React.FC<any> = props => {
|
|
|
98
107
|
'current_screen',
|
|
99
108
|
(item: any) => {
|
|
100
109
|
onScreenNavigated(item?.screenName, screenName);
|
|
101
|
-
navigator?.maxApi?.
|
|
110
|
+
navigator?.maxApi?.setDataObserver?.('current_screen', {
|
|
102
111
|
screenName,
|
|
112
|
+
startTime,
|
|
103
113
|
});
|
|
104
114
|
},
|
|
105
115
|
);
|