@momo-kits/foundation 0.121.3 → 0.10000.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.
@@ -50,7 +50,7 @@ const BottomSheet: React.FC<BottomSheetParams> = props => {
50
50
  useKeyboardAvoidingView = true,
51
51
  useScrollOverflow = false,
52
52
  keyboardVerticalOffset,
53
- useDivider,
53
+ useDivider = true,
54
54
  }: BottomSheetParams = props.route.params;
55
55
 
56
56
  const customEasingOpen = Easing.bezier(0.05, 0.7, 0.1, 1);
@@ -55,6 +55,7 @@ const HeaderToolkitAction: React.FC<any> = ({
55
55
  useShortcut = false,
56
56
  useMore = false,
57
57
  tools = [],
58
+ useCloseIcon = false,
58
59
  }) => {
59
60
  const {navigator} = useContext(ApplicationContext);
60
61
  const context = useContext<any>(MiniAppContext);
@@ -104,14 +105,14 @@ const HeaderToolkitAction: React.FC<any> = ({
104
105
  );
105
106
 
106
107
  const onDismiss = () => {
107
- if (isWhiteList) {
108
- navigator?.maxApi?.dispatchFunction?.('dismissAll');
109
- } else {
108
+ if (useCloseIcon && !isWhiteList) {
110
109
  navigator?.maxApi?.dispatchFunction?.(
111
110
  'dismiss',
112
111
  navigator?.dismissData,
113
112
  undefined
114
113
  );
114
+ } else {
115
+ navigator?.maxApi?.dispatchFunction?.('dismissAll');
115
116
  }
116
117
  };
117
118
 
@@ -299,7 +300,9 @@ const HeaderToolkitAction: React.FC<any> = ({
299
300
  <Icon
300
301
  color={tintColor}
301
302
  source={
302
- isWhiteList ? '16_basic_home' : '16_navigation_close_circle'
303
+ useCloseIcon && !isWhiteList
304
+ ? '16_navigation_close_circle'
305
+ : '16_basic_home'
303
306
  }
304
307
  size={20}
305
308
  />
@@ -96,7 +96,7 @@ const Modal: React.FC<ModalParams> = props => {
96
96
  style={StyleSheet.absoluteFillObject}>
97
97
  <KeyboardAvoidingView
98
98
  style={Styles.flexCenter}
99
- behavior={Platform.OS === 'ios' ? 'padding' : 'height'}>
99
+ behavior={Platform.OS === 'ios' ? 'padding' : undefined}>
100
100
  <Pressable
101
101
  style={StyleSheet.absoluteFillObject}
102
102
  onPress={() => onDismiss(undefined, barrierDismissible)}>
@@ -30,7 +30,7 @@ const NavigationContainer: React.FC<NavigationContainerProps> = ({
30
30
  }) => {
31
31
  const context = useContext<any>(MiniAppContext);
32
32
  const navigationRef = useRef<NavigationContainerRef>(null);
33
- const routes = useRef<any>();
33
+ const routes = useRef<any>(undefined);
34
34
  const isReady = useRef(false);
35
35
  const navigator = useRef(new Navigator(navigationRef, isReady));
36
36
  const [showGrid, setShowGrid] = useState(false);
@@ -62,8 +62,21 @@ 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 current = currentRoute?.params?.screen;
69
+ const screenName = current?.name ?? current?.type?.name;
70
+
71
+ maxApi?.getDataObserver?.('current_screen', (data: any) => {
72
+ onScreenNavigated(data?.screenName, screenName, 'push', 'Screen');
73
+ maxApi?.setObserver?.('current_screen', {screenName});
74
+ });
75
+ });
76
+
65
77
  return () => {
66
78
  subscription?.remove?.();
79
+ onFocusApp?.remove?.();
67
80
  };
68
81
  }, []);
69
82
 
@@ -159,16 +172,15 @@ const NavigationContainer: React.FC<NavigationContainerProps> = ({
159
172
  onReady={() => {
160
173
  isReady.current = true;
161
174
  routes.current = navigationRef.current?.getRootState?.()?.routes;
162
- maxApi?.getDataObserver('CURRENT_SCREEN', (data: any) => {
175
+ const screenName = screen?.name ?? (screen as any)?.type?.name;
176
+ maxApi?.getDataObserver?.('current_screen', (data: any) => {
163
177
  onScreenNavigated(
164
178
  data?.screenName,
165
- screen?.name,
179
+ screenName,
166
180
  'push',
167
181
  'Screen'
168
182
  );
169
- maxApi?.setObserver('CURRENT_SCREEN', {
170
- screenName: screen?.name,
171
- });
183
+ maxApi?.setObserver?.('current_screen', {screenName});
172
184
  });
173
185
  }}
174
186
  onStateChange={state => {
@@ -208,7 +220,7 @@ const NavigationContainer: React.FC<NavigationContainerProps> = ({
208
220
 
209
221
  routes.current = state?.routes;
210
222
  maxApi?.of?.({screenName});
211
- maxApi?.setObserver('CURRENT_SCREEN', {screenName});
223
+ maxApi?.setObserver?.('current_screen', {screenName});
212
224
  }}
213
225
  independent={true}>
214
226
  <Stack.Navigator initialRouteName="Stack" headerMode="screen">
@@ -21,6 +21,9 @@ const MiniAppContext = (Platform as any).MiniAppContext ?? Context;
21
21
  const ScreenContext = (Platform as any).ScreenContext ?? Context;
22
22
  const ComponentContext = (Platform as any).ComponentContext ?? Context;
23
23
  const SkeletonContext = createContext({loading: false});
24
+ const TrackingScopeContext = createContext<{scopeName?: string}>({
25
+ scopeName: undefined,
26
+ });
24
27
 
25
28
  export {
26
29
  ApplicationContext,
@@ -39,4 +42,5 @@ export {
39
42
  HeaderAnimated,
40
43
  setAutomationID,
41
44
  useComponentId,
45
+ TrackingScopeContext,
42
46
  };
@@ -192,6 +192,7 @@ export type HeaderRightToolkit = {
192
192
  tools?: ToolGroup[];
193
193
  preventClose?: PopupNotifyProps;
194
194
  useMore?: boolean;
195
+ useCloseIcon?: boolean;
195
196
  };
196
197
 
197
198
  export interface HeaderBackProps extends NavigationButtonProps {
@@ -13,7 +13,7 @@ import {
13
13
  import {HeaderTitleProps, NavigationOptions} from './types';
14
14
  import {Colors} from '../Consts';
15
15
  import {Animated, Platform} from 'react-native';
16
- import {MiniAppContext, ScreenContext} from './index';
16
+ import {MiniAppContext, ScreenContext, TrackingScopeContext} from './index';
17
17
 
18
18
  /**
19
19
  * default options for stack screen
@@ -173,12 +173,13 @@ const setAutomationID = (accessibilityLabel = '') => {
173
173
  const useComponentId = (componentName: string, accessibilityLabel?: string) => {
174
174
  const app = useContext<any>(MiniAppContext);
175
175
  const screen = useContext<any>(ScreenContext);
176
+ const {scopeName} = useContext<any>(TrackingScopeContext);
176
177
 
177
178
  const componentId = useMemo(() => {
178
179
  if (accessibilityLabel) {
179
180
  return accessibilityLabel;
180
181
  }
181
- return `${app.appId}/${app.code}/${screen.screenName}/${componentName}`;
182
+ return `${app.appId}/${app.code}/${screen.screenName}/${scopeName}/${componentName}`;
182
183
  }, [componentName, accessibilityLabel, app, screen]);
183
184
 
184
185
  return {componentId};
@@ -0,0 +1,18 @@
1
+ import React from 'react';
2
+ import {TrackingScopeContext} from './Application';
3
+
4
+ const TrackingScope = ({
5
+ scopeName,
6
+ children,
7
+ }: {
8
+ scopeName: string;
9
+ children: any;
10
+ }) => {
11
+ return (
12
+ <TrackingScopeContext.Provider value={{scopeName}}>
13
+ {children}
14
+ </TrackingScopeContext.Provider>
15
+ );
16
+ };
17
+
18
+ export default TrackingScope;
package/package.json CHANGED
@@ -1,8 +1,8 @@
1
1
  {
2
2
  "name": "@momo-kits/foundation",
3
- "version": "0.121.3",
3
+ "version": "0.10000.1",
4
4
  "minimumDeployTarget": 32,
5
- "deploymentTarget": 120,
5
+ "deploymentTarget": 10000,
6
6
  "description": "React Native Component Kits",
7
7
  "main": "index.ts",
8
8
  "scripts": {},
@@ -16,13 +16,13 @@
16
16
  "react-native-linear-gradient": "2.8.3",
17
17
  "react-native-gesture-handler": "1.10.3",
18
18
  "react-native-fast-image": "8.1.5",
19
+ "@react-navigation/bottom-tabs": "https://oauth2:TGi6oBj-LdzsKpLXQSoH@gitlab.mservice.com.vn/momo-platform/public/react-native-bottom-tabs.git",
19
20
  "@react-navigation/core": "5.16.1",
20
21
  "@react-navigation/native": "5.9.8",
21
22
  "@react-navigation/routers": "5.7.4",
22
- "react-native-reanimated": "git+https://oauth2:TGi6oBj-LdzsKpLXQSoH@gitlab.mservice.com.vn/momo-platform/public/react-native-reanimated.git#v1.13.4_gradle_7",
23
- "lottie-react-native": "https://oauth2:TGi6oBj-LdzsKpLXQSoH@gitlab.mservice.com.vn/momo-platform/public/momo-lottie-react-native.git",
24
- "@react-navigation/stack": "https://oauth2:TGi6oBj-LdzsKpLXQSoH@gitlab.mservice.com.vn/momo-platform/public/react-navigation-stack.git",
25
- "@react-navigation/bottom-tabs": "https://oauth2:TGi6oBj-LdzsKpLXQSoH@gitlab.mservice.com.vn/momo-platform/public/react-native-bottom-tabs.git"
23
+ "react-native-reanimated": "https://oauth2:TGi6oBj-LdzsKpLXQSoH@gitlab.mservice.com.vn/momo-platform/public/react-native-reanimated.git#v1.13.4_gradle_7",
24
+ "lottie-react-native": "https://oauth2:TGi6oBj-LdzsKpLXQSoH@gitlab.mservice.com.vn/momo-platform/public/momo-lottie-react-native.git#test_lottie_ios",
25
+ "@react-navigation/stack": "https://oauth2:TGi6oBj-LdzsKpLXQSoH@gitlab.mservice.com.vn/momo-platform/public/react-navigation-stack.git"
26
26
  },
27
27
  "peerDependencies": {
28
28
  "react-native": "*"
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};