@momo-kits/foundation 0.152.4-beta.1 → 0.152.4-beta.3

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,20 +85,11 @@ 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
-
94
88
  if (!bottomTab) {
95
89
  focusScreen = props.navigation.addListener('focus', () => {
96
90
  navigator?.maxApi?.getDataObserver?.('current_screen', (item: any) => {
97
91
  onScreenNavigated(item?.screenName, screenName);
98
- navigator?.maxApi?.setDataObserver?.('current_screen', {
99
- screenName,
100
- startTime,
101
- });
92
+ navigator?.maxApi?.setObserver?.('current_screen', { screenName });
102
93
  });
103
94
  });
104
95
  onFocusApp = navigator?.maxApi?.listen?.('onFocusApp', () => {
@@ -107,9 +98,8 @@ const StackScreen: React.FC<any> = props => {
107
98
  'current_screen',
108
99
  (item: any) => {
109
100
  onScreenNavigated(item?.screenName, screenName);
110
- navigator?.maxApi?.setDataObserver?.('current_screen', {
101
+ navigator?.maxApi?.setObserver?.('current_screen', {
111
102
  screenName,
112
- startTime,
113
103
  });
114
104
  },
115
105
  );
package/package.json CHANGED
@@ -1,36 +1,36 @@
1
1
  {
2
- "name": "@momo-kits/foundation",
3
- "version": "0.152.4-beta.1",
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
- "lottie-react-native": "7.2.4"
24
- },
25
- "peerDependencies": {
26
- "react-native": "*"
27
- },
28
- "devDependencies": {
29
- "@momo-platform/versions": "4.1.11",
30
- "@types/color": "3.0.6"
31
- },
32
- "publishConfig": {
33
- "registry": "https://registry.npmjs.org/"
34
- },
35
- "license": "MoMo"
36
- }
2
+ "name": "@momo-kits/foundation",
3
+ "version": "0.152.4-beta.3",
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
+ "lottie-react-native": "7.2.4"
24
+ },
25
+ "peerDependencies": {
26
+ "react-native": "*"
27
+ },
28
+ "devDependencies": {
29
+ "@momo-platform/versions": "4.1.11",
30
+ "@types/color": "3.0.6"
31
+ },
32
+ "publishConfig": {
33
+ "registry": "https://registry.npmjs.org/"
34
+ },
35
+ "license": "MoMo"
36
+ }