@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.
- package/Application/BottomSheet.tsx +212 -0
- package/Application/BottomTab/BottomTabBar.tsx +278 -0
- package/Application/BottomTab/index.tsx +143 -0
- package/Application/Components.tsx +384 -213
- package/Application/ModalScreen.tsx +14 -178
- package/Application/Navigation.ts +15 -19
- package/Application/NavigationContainer.tsx +66 -63
- package/Application/Navigator.ts +106 -53
- package/Application/StackScreen.tsx +123 -9
- package/Application/index.ts +19 -6
- package/Application/types.ts +83 -26
- package/Application/utils.tsx +62 -74
- package/Assets/icon.json +83 -5
- package/Assets/icon_bank.json +506 -0
- package/Assets/language.json +3 -1
- package/Badge/Badge.tsx +56 -0
- package/Badge/BadgeDot.tsx +11 -0
- package/Badge/BadgeRibbon.tsx +125 -0
- package/Badge/Shape.tsx +29 -0
- package/Badge/index.tsx +7 -0
- package/Badge/styles.ts +58 -0
- package/Badge/types.ts +63 -0
- package/Button/index.tsx +64 -28
- package/Button/styles.ts +19 -0
- package/CheckBox/index.tsx +37 -27
- package/CheckBox/types.ts +5 -3
- package/Consts/colors+spacing+radius.ts +18 -0
- package/Icon/index.tsx +14 -9
- package/Icon/types.ts +4 -3
- package/IconButton/index.tsx +24 -15
- package/Image/index.tsx +62 -47
- package/Image/styles.ts +1 -9
- package/Image/types.ts +5 -1
- package/Input/Input.tsx +104 -25
- package/Input/InputDropDown.tsx +115 -110
- package/Input/InputMoney.tsx +79 -18
- package/Input/InputOTP.tsx +190 -149
- package/Input/InputSearch.tsx +96 -44
- package/Input/InputTextArea.tsx +33 -17
- package/Input/common.tsx +26 -17
- package/Input/index.tsx +108 -41
- package/Input/styles.ts +5 -7
- package/Input/utils.ts +1 -1
- package/Layout/AnimatedInputSearch.tsx +44 -0
- package/Layout/Card.tsx +37 -13
- package/Layout/FloatingButton.tsx +168 -0
- package/Layout/GridSystem.tsx +2 -3
- package/Layout/Item.tsx +1 -2
- package/Layout/ItemList.tsx +55 -0
- package/Layout/ItemSectionList.tsx +39 -0
- package/Layout/Screen.tsx +404 -181
- package/Layout/Section.tsx +22 -22
- package/Layout/TextTyping.tsx +114 -0
- package/Layout/index.ts +12 -2
- package/Layout/styles.ts +46 -13
- package/Layout/types.ts +13 -5
- package/Layout/utils.ts +7 -12
- package/Loader/index.tsx +2 -0
- package/Pagination/PaginationDot.tsx +6 -1
- package/Pagination/PaginationNumber.tsx +7 -4
- package/Pagination/PaginationScroll.tsx +0 -1
- package/Pagination/PaginationWhiteDot.tsx +6 -1
- package/Pagination/styles.ts +3 -0
- package/Pagination/types.ts +2 -0
- package/Popup/PopupNotify.tsx +108 -40
- package/Popup/PopupPromotion.tsx +45 -10
- package/Popup/types.ts +13 -10
- package/Radio/index.tsx +35 -21
- package/Radio/types.ts +7 -5
- package/Skeleton/index.tsx +1 -1
- package/Switch/index.tsx +32 -19
- package/Switch/types.ts +5 -3
- package/Tag/index.tsx +2 -4
- package/Text/index.tsx +26 -6
- package/Text/styles.ts +38 -0
- package/Text/types.ts +25 -13
- package/Title/index.tsx +177 -64
- package/Title/styles.ts +48 -15
- package/Title/types.ts +16 -7
- package/code-scanner.js +125 -16
- package/index.ts +9 -0
- package/migrate_typo.js +56 -0
- package/package.json +8 -7
- package/publish.sh +21 -16
- package/tsconfig.json +1 -2
- package/verify.js +24 -6
- package/Application/BottomTab.tsx +0 -65
|
@@ -1,36 +1,19 @@
|
|
|
1
|
-
import React, {useContext, useEffect,
|
|
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
|
-
|
|
11
|
-
import {
|
|
12
|
-
|
|
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 {
|
|
18
|
-
import
|
|
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}
|
|
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}
|
|
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
|
-
|
|
10
|
-
|
|
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.
|
|
19
|
-
|
|
20
|
-
|
|
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
|
-
|
|
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 =
|
|
28
|
-
const
|
|
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
|
|
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
|
-
|
|
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
|
-
<
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
theme
|
|
79
|
-
|
|
80
|
-
colors
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
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
|
};
|
package/Application/Navigator.ts
CHANGED
|
@@ -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.
|
|
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.
|
|
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.
|
|
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.
|
|
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.
|
|
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.
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
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.
|
|
90
|
+
if (this.isReady.current) {
|
|
91
|
+
this.ref.current.dispatch(StackActions.popToTop());
|
|
92
|
+
}
|
|
49
93
|
};
|
|
50
94
|
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
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
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
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
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
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
|
|