@momo-kits/foundation 0.80.8 → 0.81.1-beta.0

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.
Files changed (87) hide show
  1. package/Application/BottomSheet.tsx +212 -0
  2. package/Application/BottomTab/BottomTabBar.tsx +278 -0
  3. package/Application/BottomTab/index.tsx +143 -0
  4. package/Application/Components.tsx +384 -213
  5. package/Application/ModalScreen.tsx +14 -178
  6. package/Application/Navigation.ts +15 -19
  7. package/Application/NavigationContainer.tsx +66 -63
  8. package/Application/Navigator.ts +106 -53
  9. package/Application/StackScreen.tsx +123 -9
  10. package/Application/index.ts +19 -6
  11. package/Application/types.ts +83 -26
  12. package/Application/utils.tsx +62 -74
  13. package/Assets/icon.json +83 -5
  14. package/Assets/icon_bank.json +506 -0
  15. package/Assets/language.json +3 -1
  16. package/Badge/Badge.tsx +56 -0
  17. package/Badge/BadgeDot.tsx +11 -0
  18. package/Badge/BadgeRibbon.tsx +125 -0
  19. package/Badge/Shape.tsx +29 -0
  20. package/Badge/index.tsx +7 -0
  21. package/Badge/styles.ts +58 -0
  22. package/Badge/types.ts +63 -0
  23. package/Button/index.tsx +64 -28
  24. package/Button/styles.ts +19 -0
  25. package/CheckBox/index.tsx +37 -27
  26. package/CheckBox/types.ts +5 -3
  27. package/Consts/colors+spacing+radius.ts +18 -0
  28. package/Icon/index.tsx +14 -9
  29. package/Icon/types.ts +4 -3
  30. package/IconButton/index.tsx +24 -15
  31. package/Image/index.tsx +62 -47
  32. package/Image/styles.ts +1 -9
  33. package/Image/types.ts +5 -1
  34. package/Input/Input.tsx +104 -25
  35. package/Input/InputDropDown.tsx +115 -110
  36. package/Input/InputMoney.tsx +79 -18
  37. package/Input/InputOTP.tsx +190 -149
  38. package/Input/InputSearch.tsx +96 -44
  39. package/Input/InputTextArea.tsx +33 -17
  40. package/Input/common.tsx +26 -17
  41. package/Input/index.tsx +108 -41
  42. package/Input/styles.ts +5 -7
  43. package/Input/utils.ts +1 -1
  44. package/Layout/AnimatedInputSearch.tsx +44 -0
  45. package/Layout/Card.tsx +37 -13
  46. package/Layout/FloatingButton.tsx +168 -0
  47. package/Layout/GridSystem.tsx +2 -3
  48. package/Layout/Item.tsx +1 -2
  49. package/Layout/ItemList.tsx +55 -0
  50. package/Layout/ItemSectionList.tsx +39 -0
  51. package/Layout/Screen.tsx +404 -181
  52. package/Layout/Section.tsx +22 -22
  53. package/Layout/TextTyping.tsx +114 -0
  54. package/Layout/index.ts +12 -2
  55. package/Layout/styles.ts +46 -13
  56. package/Layout/types.ts +13 -5
  57. package/Layout/utils.ts +7 -12
  58. package/Loader/index.tsx +2 -0
  59. package/Pagination/PaginationDot.tsx +6 -1
  60. package/Pagination/PaginationNumber.tsx +7 -4
  61. package/Pagination/PaginationScroll.tsx +0 -1
  62. package/Pagination/PaginationWhiteDot.tsx +6 -1
  63. package/Pagination/styles.ts +3 -0
  64. package/Pagination/types.ts +2 -0
  65. package/Popup/PopupNotify.tsx +108 -40
  66. package/Popup/PopupPromotion.tsx +45 -10
  67. package/Popup/types.ts +13 -10
  68. package/Radio/index.tsx +35 -21
  69. package/Radio/types.ts +7 -5
  70. package/Skeleton/index.tsx +1 -1
  71. package/Switch/index.tsx +32 -19
  72. package/Switch/types.ts +5 -3
  73. package/Tag/index.tsx +2 -4
  74. package/Text/index.tsx +26 -6
  75. package/Text/styles.ts +38 -0
  76. package/Text/types.ts +25 -13
  77. package/Title/index.tsx +177 -64
  78. package/Title/styles.ts +48 -15
  79. package/Title/types.ts +16 -7
  80. package/code-scanner.js +125 -16
  81. package/index.ts +9 -0
  82. package/migrate_typo.js +56 -0
  83. package/package.json +8 -7
  84. package/publish.sh +21 -16
  85. package/tsconfig.json +1 -2
  86. package/verify.js +24 -6
  87. package/Application/BottomTab.tsx +0 -65
@@ -1,36 +1,19 @@
1
- import React, {useContext, useEffect, useMemo, useRef} from 'react';
1
+ import React, {useContext, useEffect, useRef} from 'react';
2
2
  import {
3
3
  KeyboardAvoidingView,
4
4
  Platform,
5
5
  Pressable,
6
6
  StyleSheet,
7
7
  View,
8
- Keyboard,
9
8
  } from 'react-native';
10
- import {SafeAreaView, useSafeAreaInsets} from 'react-native-safe-area-context';
11
- import {
12
- BottomSheetBackdrop,
13
- BottomSheetModal,
14
- BottomSheetView,
15
- } from '@gorhom/bottom-sheet';
9
+
10
+ import {ApplicationContext} from './index';
11
+ import {Styles} from '../Consts';
16
12
  import Navigation from './Navigation';
17
- import {BottomSheetParams, ModalParams} from './types';
18
- import {Radius, Spacing, Styles} from '../Consts';
19
- import {
20
- ApplicationContext,
21
- HeaderRightAction,
22
- NavigationButton,
23
- NavigationContainer,
24
- } from './index';
25
- import {HeaderBackground, HeaderLeft, HeaderTitle} from './Components';
13
+ import {ModalParams} from './types';
14
+ import BottomSheet from './BottomSheet';
26
15
 
27
16
  const ModalScreen: React.FC<any> = props => {
28
- useEffect(() => {
29
- return () => {
30
- props.route.params?.onDismiss?.();
31
- };
32
- }, []);
33
-
34
17
  if (props.route?.params?.isBottomSheet) {
35
18
  return <BottomSheet {...props} />;
36
19
  }
@@ -39,16 +22,21 @@ const ModalScreen: React.FC<any> = props => {
39
22
 
40
23
  const Modal: React.FC<ModalParams> = props => {
41
24
  const {theme, navigator} = useContext(ApplicationContext);
42
- const {screen, barrierDismissible}: ModalParams = props.route.params;
25
+ const {screen, barrierDismissible} = props.route.params;
43
26
  const Component = useRef(screen).current;
44
27
  const navigation = new Navigation(props.navigation, theme);
45
28
  const params = {
46
29
  ...props.route.params,
47
30
  navigation,
48
31
  };
49
-
50
32
  delete params.screen;
51
33
 
34
+ useEffect(() => {
35
+ return () => {
36
+ props.route.params?.onDismiss?.();
37
+ };
38
+ }, []);
39
+
52
40
  const onDismiss = () => {
53
41
  if (barrierDismissible) {
54
42
  return;
@@ -70,7 +58,7 @@ const Modal: React.FC<ModalParams> = props => {
70
58
  style={styles.modalSpaceVertical}
71
59
  onPress={() => onDismiss()}
72
60
  />
73
- <View style={styles.modalContent} accessibilityLabel={'Modal'}>
61
+ <View style={styles.modalContent}>
74
62
  <Component {...params} />
75
63
  </View>
76
64
  <Pressable
@@ -87,139 +75,6 @@ const Modal: React.FC<ModalParams> = props => {
87
75
  );
88
76
  };
89
77
 
90
- const BottomSheet: React.FC<BottomSheetParams> = props => {
91
- const insets = useSafeAreaInsets();
92
- const {theme, navigator} = useContext(ApplicationContext);
93
- const {screen, options, snapPoint}: BottomSheetParams = props.route.params;
94
- const Component = useRef(screen).current;
95
- const navigation = new Navigation(props.navigation, theme);
96
- const params = {
97
- ...props.route.params,
98
- navigation,
99
- };
100
-
101
- delete params.screen;
102
-
103
- const snapPoints = useMemo(() => {
104
- if (snapPoint) {
105
- return [snapPoint];
106
- }
107
- return ['50%', '70%', '90%'];
108
- }, []);
109
-
110
- const bottomSheetRef = useRef<any>(null);
111
- const mountedRef = useRef(true);
112
-
113
- let backgroundColor = theme.colors.background.default;
114
- if (options?.surface) {
115
- backgroundColor = theme.colors.background.surface;
116
- }
117
-
118
- useEffect(() => {
119
- const keyboardDidShow = Keyboard.addListener('keyboardDidShow', () =>
120
- bottomSheetRef.current?.expand(),
121
- );
122
-
123
- bottomSheetRef.current?.present();
124
- return () => {
125
- mountedRef.current = false;
126
- keyboardDidShow.remove();
127
- };
128
- }, []);
129
-
130
- const backdropComponent = (backdropProps: any) => (
131
- <BottomSheetBackdrop
132
- disappearsOnIndex={-1}
133
- appearsOnIndex={0}
134
- {...backdropProps}
135
- />
136
- );
137
-
138
- return (
139
- <SafeAreaView style={Styles.flex}>
140
- <BottomSheetModal
141
- ref={bottomSheetRef}
142
- snapPoints={snapPoints}
143
- onDismiss={() => {
144
- if (mountedRef.current) {
145
- navigator?.pop();
146
- }
147
- }}
148
- handleComponent={null}
149
- backdropComponent={backdropComponent}>
150
- <BottomSheetView accessibilityLabel={'BottomSheet'}>
151
- <View
152
- style={[
153
- styles.sheetContainer,
154
- {
155
- backgroundColor,
156
- paddingBottom: Math.min(insets.bottom, 20) + Spacing.S,
157
- },
158
- ]}>
159
- <View style={styles.indicatorContainer}>
160
- <View
161
- style={[
162
- styles.indicator,
163
- {backgroundColor: theme.colors.text.disable},
164
- ]}
165
- />
166
- </View>
167
- <NavigationContainer
168
- theme={{
169
- ...theme,
170
- assets: {...theme.assets, headerBackground: undefined},
171
- }}
172
- screen={props => <Component {...props} {...params} />}
173
- options={{
174
- ...options,
175
- ...{
176
- headerLeft: (props: any) => {
177
- if (props.canGoBack) {
178
- return (
179
- <HeaderLeft
180
- {...props}
181
- useBorder={false}
182
- backgroundColor="transparent"
183
- accessibilityLabel={'BottomSheet/'}
184
- />
185
- );
186
- }
187
- },
188
- headerTitle: (props: any) => {
189
- return (
190
- <HeaderTitle
191
- {...props}
192
- accessibilityLabel={'BottomSheet/'}
193
- />
194
- );
195
- },
196
- headerBackground: () => (
197
- <HeaderBackground backgroundColor={backgroundColor} />
198
- ),
199
- headerTransparent: false,
200
- },
201
- headerTitleAlign: 'center',
202
- headerRight: props => (
203
- <HeaderRightAction>
204
- <NavigationButton
205
- {...props}
206
- icon="24_navigation_close"
207
- backgroundColor="transparent"
208
- useBorder={false}
209
- onPress={bottomSheetRef.current?.dismiss}
210
- accessibilityLabel={'BottomSheet/Close'}
211
- />
212
- </HeaderRightAction>
213
- ),
214
- }}
215
- />
216
- </View>
217
- </BottomSheetView>
218
- </BottomSheetModal>
219
- </SafeAreaView>
220
- );
221
- };
222
-
223
78
  const styles = StyleSheet.create({
224
79
  container: {flex: 1, flexDirection: 'row'},
225
80
  modalContent: {
@@ -237,25 +92,6 @@ const styles = StyleSheet.create({
237
92
  flex: 1,
238
93
  minHeight: '10%',
239
94
  },
240
- sheetContainer: {
241
- height: '100%',
242
- width: '100%',
243
- borderTopLeftRadius: Radius.M,
244
- borderTopRightRadius: Radius.M,
245
- overflow: 'hidden',
246
- },
247
- indicatorContainer: {
248
- width: '100%',
249
- paddingTop: Spacing.S,
250
- paddingBottom: Spacing.XS,
251
- alignItems: 'center',
252
- justifyContent: 'center',
253
- },
254
- indicator: {
255
- width: 40,
256
- height: 4,
257
- borderRadius: Radius.S,
258
- },
259
95
  });
260
96
 
261
97
  export default ModalScreen;
@@ -1,39 +1,35 @@
1
1
  import {NavigationProp} from '@react-navigation/native';
2
- import {Alert} from 'react-native';
3
2
  import {NavigationOptions, Theme} from './types';
4
- import {HeaderRightAction} from './index';
5
3
  import {getOptions} from './utils';
6
- import {HeaderToolkitAction} from './Components';
7
4
 
8
5
  class Navigation {
9
- private instance: NavigationProp<any>;
10
- private readonly theme: Theme;
6
+ instance: NavigationProp<any>;
7
+ readonly theme: Theme;
11
8
 
12
9
  constructor(instance: any, theme: Theme) {
13
10
  this.instance = instance;
14
11
  this.theme = theme;
15
12
  }
16
13
 
14
+ /**
15
+ * navigation options filter by design system rule
16
+ * @param params
17
+ */
17
18
  private filterParams = (params: NavigationOptions) => {
18
- if (params.headerRight) {
19
- const headerRight = params.headerRight?.();
20
- const type = headerRight?.type;
21
- if (type !== HeaderRightAction && type !== HeaderToolkitAction) {
22
- Alert.alert(
23
- 'Rule',
24
- 'headerRight contains element type of HeaderRightAction | HeaderToolkitAction, Please check again.',
25
- );
26
- delete params.headerRight;
27
- }
19
+ if (params.headerLeft) {
20
+ console.warn('headerLeft not allow override render by design system!');
21
+ delete params.headerLeft;
28
22
  }
23
+
29
24
  return params;
30
25
  };
31
26
 
27
+ /**
28
+ * navigation setOptions support props NavigationOptions base on react-navigation options
29
+ * @param params
30
+ */
32
31
  setOptions = (params: NavigationOptions) => {
33
- if (__DEV__) {
34
- params = this.filterParams(params);
35
- }
36
- params = getOptions(params, this.theme);
32
+ params = getOptions(this.filterParams(params), this.theme);
37
33
  this.instance.setOptions(params);
38
34
  };
39
35
  }
@@ -1,18 +1,17 @@
1
1
  import React, {useEffect, useRef, useState} from 'react';
2
- import {BottomSheetModalProvider} from '@gorhom/bottom-sheet';
3
2
  import {SafeAreaProvider} from 'react-native-safe-area-context';
4
3
  import {
5
4
  NavigationContainer as ReactNavigationContainer,
6
5
  NavigationContainerRef,
7
6
  } from '@react-navigation/native';
8
7
  import {createStackNavigator} from '@react-navigation/stack';
8
+ import {DeviceEventEmitter} from 'react-native';
9
9
  import StackScreen from './StackScreen';
10
10
  import ModalScreen from './ModalScreen';
11
11
  import Navigator from './Navigator';
12
12
  import {getDialogOptions, getModalOptions, getStackOptions} from './utils';
13
13
  import {LocalizationObject, NavigationContainerProps} from './types';
14
14
  import {ApplicationContext} from './index';
15
- import {DeviceEventEmitter} from 'react-native';
16
15
  import kitLocalization from '../Assets/language.json';
17
16
 
18
17
  const Stack = createStackNavigator();
@@ -23,12 +22,18 @@ const NavigationContainer: React.FC<NavigationContainerProps> = ({
23
22
  options,
24
23
  maxApi,
25
24
  localization,
25
+ initialParams,
26
26
  }) => {
27
- const navigationRef = React.useRef<NavigationContainerRef>(null);
28
- const navigator = useRef(new Navigator(navigationRef));
27
+ const navigationRef = useRef<NavigationContainerRef>(null);
28
+ const isReady = useRef(false);
29
+ const navigator = useRef(new Navigator(navigationRef, isReady));
29
30
  const [showGrid, setShowGrid] = useState(false);
30
- const [language, setLanguage] = useState<'vi' | 'en'>('vi');
31
+ const config = useRef<any>();
31
32
 
33
+ /**
34
+ * handle mini language & listen change
35
+ * engine only shake to enable grid view
36
+ */
32
37
  useEffect(() => {
33
38
  const subscription = DeviceEventEmitter.addListener(
34
39
  'onChangeGrid',
@@ -36,26 +41,23 @@ const NavigationContainer: React.FC<NavigationContainerProps> = ({
36
41
  setShowGrid(!!enable);
37
42
  },
38
43
  );
39
- return () => {
40
- subscription.remove();
41
- };
42
- }, []);
43
44
 
44
- useEffect(() => {
45
- maxApi?.getLanguage?.((lang: 'vi' | 'en') => {
46
- setLanguage(lang);
47
- });
48
- const listener = maxApi?.observer?.('language', (lang: 'vi' | 'en') => {
49
- setLanguage(lang);
50
- });
51
45
  return () => {
52
- listener?.();
46
+ subscription?.remove?.();
53
47
  };
54
48
  }, []);
55
49
 
50
+ /**
51
+ * inject data for navigator
52
+ */
56
53
  navigator.current.maxApi = maxApi;
57
54
 
55
+ /**
56
+ * translate
57
+ * @param key
58
+ */
58
59
  const translate = (key: string) => {
60
+ const language: 'vi' | 'en' = 'vi';
59
61
  const mergedLocalization: LocalizationObject = {
60
62
  vi: {...localization?.vi, ...kitLocalization.vi},
61
63
  en: {...localization?.en, ...kitLocalization.en},
@@ -65,52 +67,53 @@ const NavigationContainer: React.FC<NavigationContainerProps> = ({
65
67
 
66
68
  return (
67
69
  <SafeAreaProvider>
68
- <BottomSheetModalProvider>
69
- <ApplicationContext.Provider
70
- value={{
71
- theme,
72
- navigator: navigator.current,
73
- showGrid,
74
- language,
75
- translate,
76
- }}>
77
- <ReactNavigationContainer
78
- theme={{
79
- ...theme,
80
- colors: {
81
- ...theme.colors,
82
- background: theme.colors.background.default,
83
- card: theme.colors.background.surface,
84
- text: theme.colors.text.default,
85
- border: theme.colors.border.default,
86
- notification: theme.colors.error.primary,
87
- },
88
- }}
89
- ref={navigator.current?.ref}
90
- independent={true}>
91
- <Stack.Navigator initialRouteName="Stack" headerMode="screen">
92
- <Stack.Screen
93
- name="Stack"
94
- component={StackScreen}
95
- initialParams={{screen}}
96
- options={{...getStackOptions(theme), ...options}}
97
- />
98
- <Stack.Screen
99
- name="Dialog"
100
- component={StackScreen}
101
- options={getDialogOptions(theme)}
102
- initialParams={{screen}}
103
- />
104
- <Stack.Screen
105
- name="Modal"
106
- component={ModalScreen}
107
- options={getModalOptions()}
108
- initialParams={{screen}}
109
- />
110
- </Stack.Navigator>
111
- </ReactNavigationContainer>
112
- </ApplicationContext.Provider>
113
- </BottomSheetModalProvider>
70
+ <ApplicationContext.Provider
71
+ value={{
72
+ navigator: navigator.current,
73
+ config: config.current,
74
+ theme,
75
+ showGrid,
76
+ translate,
77
+ }}>
78
+ <ReactNavigationContainer
79
+ theme={{
80
+ ...theme,
81
+ colors: {
82
+ ...theme.colors,
83
+ background: theme.colors.background.default,
84
+ card: theme.colors.background.surface,
85
+ text: theme.colors.text.default,
86
+ border: theme.colors.border.default,
87
+ notification: theme.colors.error.primary,
88
+ },
89
+ }}
90
+ ref={navigator.current?.ref}
91
+ onReady={() => {
92
+ isReady.current = true;
93
+ }}
94
+ independent={true}>
95
+ <Stack.Navigator initialRouteName="Stack" headerMode="screen">
96
+ <Stack.Screen
97
+ name="Stack"
98
+ component={StackScreen}
99
+ initialParams={{screen, initialParams}}
100
+ options={{...getStackOptions(), ...options}}
101
+ />
102
+ <Stack.Screen
103
+ name="Dialog"
104
+ component={StackScreen}
105
+ options={getDialogOptions()}
106
+ initialParams={{screen}}
107
+ />
108
+ <Stack.Screen
109
+ name="Modal"
110
+ component={ModalScreen}
111
+ options={getModalOptions()}
112
+ initialParams={{screen}}
113
+ />
114
+ </Stack.Navigator>
115
+ </ReactNavigationContainer>
116
+ </ApplicationContext.Provider>
114
117
  </SafeAreaProvider>
115
118
  );
116
119
  };
@@ -8,90 +8,143 @@ import {
8
8
 
9
9
  class Navigator {
10
10
  ref?: any;
11
+ isReady?: any;
11
12
  toolkitConfig?: HeaderToolkitProps;
12
13
  maxApi?: any;
14
+ dismissData?: any;
15
+ toolkitCallback?: (item: any) => void;
13
16
 
14
- constructor(navigation: any) {
17
+ constructor(navigation: any, isReady: any) {
15
18
  this.ref = navigation;
19
+ this.isReady = isReady;
16
20
  }
17
21
 
22
+ /**
23
+ * push new stack screen
24
+ * @param params
25
+ */
18
26
  push = (params: ScreenParams) => {
19
- this.ref.current.dispatch(StackActions.push('Stack', params));
27
+ if (this.isReady.current) {
28
+ this.ref.current.dispatch(StackActions.push('Stack', params));
29
+ }
20
30
  };
21
31
 
32
+ /**
33
+ * replace current screen with new screen
34
+ * @param params
35
+ */
22
36
  replace = (params: ScreenParams) => {
23
- this.ref.current.dispatch(StackActions.replace('Stack', params));
37
+ if (this.isReady.current) {
38
+ this.ref.current.dispatch(StackActions.replace('Stack', params));
39
+ }
24
40
  };
25
-
41
+ /**
42
+ * pop to dismiss a screen
43
+ * @param count
44
+ */
26
45
  pop = (count?: number) => {
27
- this.ref.current.dispatch(StackActions.pop(count ?? 1));
46
+ if (this.isReady.current) {
47
+ this.ref.current.dispatch(StackActions.pop(count ?? 1));
48
+ }
28
49
  };
29
50
 
51
+ /**
52
+ * present a new screen, show from bottom iOS
53
+ * @param params
54
+ */
30
55
  present = (params: ScreenParams) => {
31
- this.ref.current.dispatch(StackActions.push('Dialog', params));
56
+ if (this.isReady.current) {
57
+ this.ref.current.dispatch(StackActions.push('Dialog', params));
58
+ }
32
59
  };
33
60
 
61
+ /**
62
+ * show a modal popup
63
+ * @param params
64
+ */
34
65
  showModal = (params: ModalParams) => {
35
- this.ref.current.dispatch(StackActions.push('Modal', params));
66
+ if (this.isReady.current) {
67
+ this.ref.current.dispatch(StackActions.push('Modal', params));
68
+ }
36
69
  };
37
70
 
71
+ /**
72
+ * show a bottom sheet
73
+ * @param params
74
+ */
38
75
  showBottomSheet = (params: BottomSheetParams) => {
39
- this.ref.current.dispatch(
40
- StackActions.push('Modal', {
41
- ...params,
42
- isBottomSheet: true,
43
- }),
44
- );
76
+ if (this.isReady.current) {
77
+ this.ref.current.dispatch(
78
+ StackActions.push('Modal', {
79
+ ...params,
80
+ isBottomSheet: true,
81
+ }),
82
+ );
83
+ }
45
84
  };
46
85
 
86
+ /**
87
+ * pop all screen route
88
+ */
47
89
  popToTop = () => {
48
- this.ref.current.dispatch(StackActions.popToTop());
90
+ if (this.isReady.current) {
91
+ this.ref.current.dispatch(StackActions.popToTop());
92
+ }
49
93
  };
50
94
 
51
- reset = (params: ScreenParams) => {
52
- this.ref.current.dispatch(
53
- CommonActions.reset({
54
- index: 0,
55
- routes: [
56
- {
57
- name: 'Stack',
58
- key: `Stack_${new Date().getTime()}`,
59
- params,
60
- },
61
- ],
62
- }),
63
- );
95
+ /**
96
+ * navigate
97
+ * @param name
98
+ * @param params
99
+ */
100
+ navigate = (name: string, params: any) => {
101
+ if (this.isReady.current) {
102
+ this.ref.current.dispatch(
103
+ CommonActions.navigate({
104
+ name,
105
+ params,
106
+ }),
107
+ );
108
+ }
64
109
  };
65
110
 
66
- requestApi = (func: any, args: any = [], callback: any) => {
67
- if (this.maxApi) {
68
- this.maxApi[func]?.(...args, callback);
69
- } else {
70
- const instance: any = global;
71
- instance?.miniAppApi?.dispatch?.(func, ...args, callback);
111
+ /**
112
+ * reset a navigation flow with new screen
113
+ * @param params
114
+ */
115
+ reset = (params: ScreenParams) => {
116
+ if (this.isReady.current) {
117
+ this.ref.current.dispatch(
118
+ CommonActions.reset({
119
+ index: 0,
120
+ routes: [
121
+ {
122
+ name: 'Stack',
123
+ key: `Stack_${new Date().getTime()}`,
124
+ params,
125
+ },
126
+ ],
127
+ }),
128
+ );
72
129
  }
73
130
  };
74
131
 
75
- getToolkit = async (): Promise<HeaderToolkitProps | undefined> => {
76
- return new Promise(resolve => {
77
- if (this.toolkitConfig) {
78
- resolve(this.toolkitConfig);
79
- return;
80
- }
81
- this.requestApi('getToolkit', [undefined], (result: boolean) => {
82
- if (result) {
83
- this.requestApi('getToolkitConfig', [undefined], (config: any) => {
84
- this.toolkitConfig = {
85
- ...config?.utilityToolConfig,
86
- appCode: config?.appCode,
87
- };
88
- resolve(this.toolkitConfig);
89
- });
90
- } else {
91
- resolve(undefined);
92
- }
93
- });
94
- });
132
+ /**
133
+ * dismiss a feature data
134
+ * @param data
135
+ */
136
+ setDismissData = (data: any) => {
137
+ this.dismissData = data;
138
+ };
139
+
140
+ /**
141
+ * set callback function for toolkit
142
+ * @param callback
143
+ */
144
+ setToolkitCallback = (
145
+ callback: (item: {key: string; action: string}) => void,
146
+ ) => {
147
+ this.toolkitCallback = callback;
95
148
  };
96
149
  }
97
150