@momo-kits/foundation 0.121.0-beta.1 → 0.121.0-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.
@@ -62,8 +62,22 @@ const NavigationContainer: React.FC<NavigationContainerProps> = ({
62
62
  }
63
63
  );
64
64
 
65
+ const onFocusApp = maxApi?.listen?.('onFocusApp', () => {
66
+ const routes = navigationRef.current?.getRootState?.()?.routes;
67
+ const currentRoute: any = routes?.[routes?.length - 1];
68
+ const previousRoute: any = routes?.[routes?.length - 2];
69
+ const current = currentRoute?.params?.screen;
70
+ const previous = previousRoute?.params?.screen;
71
+ const screenName = current?.name ?? current?.type?.name;
72
+ const preScreenName = previous?.name ?? previous?.type?.name;
73
+
74
+ onScreenNavigated(preScreenName, screenName, 'back', 'Screen');
75
+ maxApi?.setObserver('CURRENT_SCREEN', {screenName});
76
+ });
77
+
65
78
  return () => {
66
79
  subscription?.remove?.();
80
+ onFocusApp?.remove?.();
67
81
  };
68
82
  }, []);
69
83
 
@@ -159,16 +173,15 @@ const NavigationContainer: React.FC<NavigationContainerProps> = ({
159
173
  onReady={() => {
160
174
  isReady.current = true;
161
175
  routes.current = navigationRef.current?.getRootState?.()?.routes;
176
+ const screenName = screen?.name ?? (screen as any)?.type?.name;
162
177
  maxApi?.getDataObserver('CURRENT_SCREEN', (data: any) => {
163
178
  onScreenNavigated(
164
179
  data?.screenName,
165
- screen?.name,
180
+ screenName,
166
181
  'push',
167
182
  'Screen'
168
183
  );
169
- maxApi?.setObserver('CURRENT_SCREEN', {
170
- screenName: screen?.name,
171
- });
184
+ maxApi?.setObserver('CURRENT_SCREEN', {screenName});
172
185
  });
173
186
  }}
174
187
  onStateChange={state => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@momo-kits/foundation",
3
- "version": "0.121.0-beta.1",
3
+ "version": "0.121.0-beta.3",
4
4
  "minimumDeployTarget": 32,
5
5
  "deploymentTarget": 120,
6
6
  "description": "React Native Component Kits",
package/publish.sh CHANGED
@@ -9,10 +9,13 @@ elif [ "$1" == "latest" ]; then
9
9
  npm version $(npm view @momo-kits/foundation@latest version)
10
10
  npm version prerelease --preid=rc
11
11
  npm publish --tag latest --access=public
12
- else
12
+ elif [ "$1" == "beta" ]; then
13
13
  npm version $(npm view @momo-kits/foundation@beta version)
14
14
  npm version prerelease --preid=beta
15
15
  npm publish --tag beta --access=public
16
+ else
17
+ npm publish --tag alpha --access=public
16
18
  fi
19
+
17
20
  PACKAGE_NAME=$(npm pkg get name)
18
21
  NEW_PACKAGE_VERSION=$(npm pkg get version)
@@ -1,192 +0,0 @@
1
- import React, {useContext} from 'react';
2
- import {StyleSheet, TouchableOpacity, View} from 'react-native';
3
- import {ApplicationContext, MiniAppContext} from '../index';
4
- import {Colors, Radius, Spacing, Styles} from '../../Consts';
5
- import {Text} from '../../Text';
6
- import {Icon} from '../../Icon';
7
-
8
- const ServiceItem: React.FC<any> = ({service}) => {
9
- const {theme, translate} = useContext(ApplicationContext);
10
- const {title, description, icon, onPress} = service;
11
- const serviceTitle = translate?.(title);
12
- const serviceDescription = translate?.(description);
13
-
14
- return (
15
- <TouchableOpacity onPress={onPress} style={Styles.row}>
16
- <View style={styles.iconWrapper}>
17
- <Icon color={theme.colors.text.hint} source={icon} size={28} />
18
- </View>
19
- <View>
20
- <View style={Styles.row}>
21
- <Text typography={'action_xs_bold'}>{serviceTitle}</Text>
22
- <Icon source={'arrow_chevron_right_small'} size={16} />
23
- </View>
24
- <Text
25
- typography={'description_xs_regular'}
26
- color={theme.colors.text.hint}>
27
- {serviceDescription}
28
- </Text>
29
- </View>
30
- </TouchableOpacity>
31
- );
32
- };
33
-
34
- const BottomSheetHelpCenter: React.FC<any> = ({onRequestClose}) => {
35
- const {theme, navigator} = useContext(ApplicationContext);
36
- const context = useContext<any>(MiniAppContext);
37
-
38
- const onPressFaq = () => {
39
- const routes = navigator?.ref.current?.getRootState()?.routes || [];
40
- const routesLength = routes.length;
41
- let screenName = routes?.[0]?.params?.screen?.name;
42
- if (routesLength > 1) {
43
- screenName = routes[routesLength - 2]?.params?.screen?.name;
44
- }
45
-
46
- context?.autoTracking?.({
47
- ...context,
48
- componentName: 'TouchableOpacity',
49
- componentId: 'bottomsheet_faq_item',
50
- screenName: screenName,
51
- });
52
-
53
- onRequestClose?.(() => {
54
- navigator?.maxApi?.startFeatureCode?.(
55
- 'helpcenter_problemlevel1',
56
- context?.toolkitConfig?.faq
57
- );
58
- });
59
- };
60
-
61
- const onPressChatbot = () => {
62
- const routes = navigator?.ref.current?.getRootState()?.routes || [];
63
- const routesLength = routes.length;
64
- let screenName = routes?.[0]?.params?.screen?.name;
65
- if (routesLength > 1) {
66
- screenName = routes[routesLength - 2]?.params?.screen?.name;
67
- }
68
-
69
- context?.autoTracking?.({
70
- ...context,
71
- componentName: 'TouchableOpacity',
72
- componentId: 'bottomsheet_chatbot_item',
73
- screenName: screenName,
74
- });
75
-
76
- onRequestClose?.(() => {
77
- navigator?.maxApi?.getDataObserver('CURRENT_SCREEN', (data: any) => {
78
- let screenName = data?.screenName;
79
- navigator?.maxApi?.startFeatureCode?.('chatbot', {
80
- botId: 'botGptCs',
81
- forwardParams: {
82
- forService: 'navigation',
83
- mini_app_id: context?.appId,
84
- feature_code: context?.code,
85
- screen_name: screenName,
86
- },
87
- });
88
- });
89
- });
90
- };
91
-
92
- const onPressFeedback = () => {
93
- const routes = navigator?.ref.current?.getRootState()?.routes || [];
94
- const routesLength = routes.length;
95
- let screenName = routes?.[0]?.params?.screen?.name;
96
- if (routesLength > 1) {
97
- screenName = routes[routesLength - 2]?.params?.screen?.name;
98
- }
99
-
100
- context?.autoTracking?.({
101
- ...context,
102
- componentName: 'TouchableOpacity',
103
- componentId: 'bottomsheet_feedback_item',
104
- screenName: screenName,
105
- });
106
-
107
- onRequestClose?.(() => {
108
- navigator?.maxApi?.startFeatureCode?.('feedback', {
109
- forService: 'navigation',
110
- loggedStatus: true,
111
- application: {
112
- appId: context?.appId,
113
- appCode: context?.code,
114
- appName: context?.name?.['en'],
115
- buildNumber: context?.buildNumber,
116
- },
117
- newUi: true,
118
- stepFeedback: 1,
119
- });
120
- });
121
- };
122
-
123
- const services = [
124
- {
125
- title: {vi: 'Câu hỏi thường gặp', en: 'Câu hỏi thường gặp'},
126
- description: {
127
- vi: 'Giải đáp các thắc mắc mọi người thường gặp',
128
- en: 'Giải đáp các thắc mắc mọi người thường gặp',
129
- },
130
- icon: 'notifications_circle_question',
131
- onPress: onPressFaq,
132
- },
133
- {
134
- title: {vi: 'Hỗ trợ trực tuyến', en: 'Hỗ trợ trực tuyến'},
135
- description: {
136
- vi: 'Trả lời mọi câu hỏi của bạn 24/7',
137
- en: 'Trả lời mọi câu hỏi của bạn 24/7',
138
- },
139
- icon: 'ic_support',
140
- onPress: onPressChatbot,
141
- },
142
- {
143
- title: {vi: 'Chia sẻ góp ý', en: 'Chia sẻ góp ý'},
144
- description: {
145
- vi: 'Đề xuất cải thiện hoặc báo lỗi sản phẩm/dịch vụ',
146
- en: 'Đề xuất cải thiện hoặc báo lỗi sản phẩm/dịch vụ',
147
- },
148
- icon: 'file_mail',
149
- onPress: onPressFeedback,
150
- },
151
- ];
152
-
153
- return (
154
- <View
155
- style={[
156
- styles.container,
157
- {
158
- backgroundColor: theme.colors.background.surface,
159
- },
160
- ]}>
161
- {services.map((item, index) => {
162
- return (
163
- <>
164
- <ServiceItem service={item} />
165
- {index !== services.length - 1 && <View style={styles.divider} />}
166
- </>
167
- );
168
- })}
169
- </View>
170
- );
171
- };
172
-
173
- const styles = StyleSheet.create({
174
- container: {height: 300, width: '100%', padding: Spacing.M},
175
- divider: {
176
- marginVertical: Spacing.M,
177
- backgroundColor: Colors.black_02,
178
- height: 1,
179
- width: '100%',
180
- },
181
- iconWrapper: {
182
- width: 36,
183
- height: 36,
184
- backgroundColor: Colors.black_02,
185
- borderRadius: Radius.M,
186
- marginRight: Spacing.S,
187
- alignItems: 'center',
188
- justifyContent: 'center',
189
- },
190
- });
191
-
192
- export {BottomSheetHelpCenter};