@momo-kits/foundation 0.75.1-beta.10
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/Assets/header-background.png +0 -0
- package/Assets/icon.json +3947 -0
- package/Button/index.tsx +278 -0
- package/Button/styles.ts +41 -0
- package/CheckBox/index.tsx +61 -0
- package/CheckBox/styles.ts +15 -0
- package/CheckBox/types.ts +38 -0
- package/Consts/colors+spacing+radius.ts +214 -0
- package/Consts/index.ts +4 -0
- package/Consts/styles.ts +78 -0
- package/Consts/theme.ts +121 -0
- package/Divider/index.tsx +19 -0
- package/Icon/index.tsx +37 -0
- package/Icon/types.ts +27 -0
- package/IconButton/index.tsx +140 -0
- package/IconButton/styles.ts +19 -0
- package/Image/index.tsx +80 -0
- package/Image/styles.ts +13 -0
- package/Image/types.ts +3 -0
- package/Input/Input.tsx +136 -0
- package/Input/InputMoney.tsx +132 -0
- package/Input/InputSearch.tsx +161 -0
- package/Input/InputTextArea.tsx +152 -0
- package/Input/common.tsx +118 -0
- package/Input/index.tsx +96 -0
- package/Input/styles.ts +122 -0
- package/Input/utils.ts +69 -0
- package/Layout/Card.tsx +141 -0
- package/Layout/GridSystem.tsx +124 -0
- package/Layout/Item.tsx +60 -0
- package/Layout/ScreenContainer.tsx +121 -0
- package/Layout/Section.tsx +141 -0
- package/Layout/index.ts +17 -0
- package/Layout/types.ts +59 -0
- package/Layout/utils.ts +60 -0
- package/Navigation/BottomTab.tsx +39 -0
- package/Navigation/Components.tsx +365 -0
- package/Navigation/ModalScreen.tsx +226 -0
- package/Navigation/Navigation.ts +44 -0
- package/Navigation/NavigationButton.tsx +54 -0
- package/Navigation/NavigationContainer.tsx +77 -0
- package/Navigation/Navigator.ts +82 -0
- package/Navigation/StackScreen.tsx +27 -0
- package/Navigation/index.ts +14 -0
- package/Navigation/types.ts +158 -0
- package/Navigation/utils.tsx +138 -0
- package/Pagination/Dot.tsx +16 -0
- package/Pagination/PaginationDot.tsx +33 -0
- package/Pagination/PaginationNumber.tsx +23 -0
- package/Pagination/PaginationScroll.tsx +88 -0
- package/Pagination/PaginationWhiteDot.tsx +32 -0
- package/Pagination/index.tsx +25 -0
- package/Pagination/styles.ts +47 -0
- package/Pagination/types.ts +38 -0
- package/Popup/PopupNotify.tsx +215 -0
- package/Popup/PopupPromotion.tsx +77 -0
- package/Popup/index.tsx +4 -0
- package/Popup/types.ts +70 -0
- package/Radio/index.tsx +65 -0
- package/Radio/styles.ts +11 -0
- package/Radio/types.ts +38 -0
- package/Skeleton/index.tsx +72 -0
- package/Skeleton/styles.ts +5 -0
- package/Skeleton/types.ts +3 -0
- package/Switch/index.tsx +40 -0
- package/Switch/styles.ts +23 -0
- package/Switch/types.ts +26 -0
- package/Tag/index.tsx +79 -0
- package/Tag/styles.ts +24 -0
- package/Tag/types.ts +36 -0
- package/Text/index.tsx +123 -0
- package/Text/styles.ts +35 -0
- package/Text/types.ts +40 -0
- package/index.ts +38 -0
- package/package.json +41 -0
- package/publish.sh +26 -0
|
@@ -0,0 +1,226 @@
|
|
|
1
|
+
import React, {useContext, useEffect, useMemo, useRef} from 'react';
|
|
2
|
+
import {
|
|
3
|
+
KeyboardAvoidingView,
|
|
4
|
+
Platform,
|
|
5
|
+
Pressable,
|
|
6
|
+
StyleSheet,
|
|
7
|
+
View,
|
|
8
|
+
} from 'react-native';
|
|
9
|
+
import {SafeAreaView, useSafeAreaInsets} from 'react-native-safe-area-context';
|
|
10
|
+
import {BottomSheetBackdrop, BottomSheetModal} from '@gorhom/bottom-sheet';
|
|
11
|
+
import {BottomSheetModalMethods} from '@gorhom/bottom-sheet/lib/typescript/types';
|
|
12
|
+
import Navigation from './Navigation';
|
|
13
|
+
import {BottomSheetParams, ModalParams} from './types';
|
|
14
|
+
import {Radius, Spacing, Styles} from '../Consts';
|
|
15
|
+
import {
|
|
16
|
+
ApplicationContext,
|
|
17
|
+
HeaderRightAction,
|
|
18
|
+
NavigationButton,
|
|
19
|
+
NavigationContainer,
|
|
20
|
+
} from './index';
|
|
21
|
+
import {HeaderBackground, HeaderLeft} from './Components';
|
|
22
|
+
|
|
23
|
+
const ModalScreen: React.FC<any> = props => {
|
|
24
|
+
useEffect(() => {
|
|
25
|
+
return () => {
|
|
26
|
+
props.route.params?.onDismiss?.();
|
|
27
|
+
};
|
|
28
|
+
}, []);
|
|
29
|
+
|
|
30
|
+
if (props.route?.params?.isBottomSheet) {
|
|
31
|
+
return <BottomSheet {...props} />;
|
|
32
|
+
}
|
|
33
|
+
return <Modal {...props} />;
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
const Modal: React.FC<ModalParams> = ({navigation, route}) => {
|
|
37
|
+
const {theme} = useContext(ApplicationContext);
|
|
38
|
+
const {screen, barrierDismissible}: ModalParams = route.params;
|
|
39
|
+
const Component = useRef(screen).current;
|
|
40
|
+
const params = {
|
|
41
|
+
...route.params,
|
|
42
|
+
navigation: new Navigation(navigation, theme),
|
|
43
|
+
};
|
|
44
|
+
delete params.screen;
|
|
45
|
+
|
|
46
|
+
const onDismiss = (pop = true) => {
|
|
47
|
+
if (barrierDismissible) {
|
|
48
|
+
return;
|
|
49
|
+
}
|
|
50
|
+
navigation.pop();
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
return (
|
|
54
|
+
<KeyboardAvoidingView
|
|
55
|
+
style={Styles.flex}
|
|
56
|
+
behavior={Platform.OS === 'ios' ? 'padding' : 'height'}>
|
|
57
|
+
<View style={styles.container}>
|
|
58
|
+
<Pressable
|
|
59
|
+
style={styles.modalSpaceHorizontal}
|
|
60
|
+
onPress={() => onDismiss()}
|
|
61
|
+
/>
|
|
62
|
+
<View style={styles.modalCenterStage}>
|
|
63
|
+
<Pressable
|
|
64
|
+
style={styles.modalSpaceVertical}
|
|
65
|
+
onPress={() => onDismiss()}
|
|
66
|
+
/>
|
|
67
|
+
<View style={styles.modalContent} accessibilityLabel={'Modal'}>
|
|
68
|
+
<Component {...params} />
|
|
69
|
+
</View>
|
|
70
|
+
<Pressable
|
|
71
|
+
style={styles.modalSpaceVertical}
|
|
72
|
+
onPress={() => onDismiss()}
|
|
73
|
+
/>
|
|
74
|
+
</View>
|
|
75
|
+
<Pressable
|
|
76
|
+
style={styles.modalSpaceHorizontal}
|
|
77
|
+
onPress={() => onDismiss()}
|
|
78
|
+
/>
|
|
79
|
+
</View>
|
|
80
|
+
</KeyboardAvoidingView>
|
|
81
|
+
);
|
|
82
|
+
};
|
|
83
|
+
|
|
84
|
+
const BottomSheet: React.FC<BottomSheetParams> = ({navigation, route}) => {
|
|
85
|
+
const {theme} = useContext(ApplicationContext);
|
|
86
|
+
const {screen, options}: BottomSheetParams = route.params;
|
|
87
|
+
const Component = useRef(screen).current;
|
|
88
|
+
const params = {
|
|
89
|
+
...route.params,
|
|
90
|
+
navigation: new Navigation(navigation, theme),
|
|
91
|
+
};
|
|
92
|
+
delete params.screen;
|
|
93
|
+
|
|
94
|
+
const snapPoints = useMemo(() => ['50%', '90%'], []);
|
|
95
|
+
const {bottom} = useSafeAreaInsets();
|
|
96
|
+
const bottomSheetRef = useRef<BottomSheetModalMethods>(null);
|
|
97
|
+
const mountedRef = useRef(true);
|
|
98
|
+
|
|
99
|
+
useEffect(() => {
|
|
100
|
+
bottomSheetRef.current?.present();
|
|
101
|
+
return () => {
|
|
102
|
+
mountedRef.current = false;
|
|
103
|
+
};
|
|
104
|
+
}, []);
|
|
105
|
+
|
|
106
|
+
const backdropComponent = (backdropProps: any) => (
|
|
107
|
+
<BottomSheetBackdrop
|
|
108
|
+
disappearsOnIndex={-1}
|
|
109
|
+
appearsOnIndex={0}
|
|
110
|
+
{...backdropProps}
|
|
111
|
+
/>
|
|
112
|
+
);
|
|
113
|
+
|
|
114
|
+
let backgroundColor = theme.colors.background.default;
|
|
115
|
+
if (options?.surface) {
|
|
116
|
+
backgroundColor = theme.colors.background.surface;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
return (
|
|
120
|
+
<SafeAreaView style={Styles.flex}>
|
|
121
|
+
<BottomSheetModal
|
|
122
|
+
ref={bottomSheetRef}
|
|
123
|
+
snapPoints={snapPoints}
|
|
124
|
+
onDismiss={() => {
|
|
125
|
+
if (mountedRef.current) {
|
|
126
|
+
navigation.pop();
|
|
127
|
+
}
|
|
128
|
+
}}
|
|
129
|
+
handleComponent={null}
|
|
130
|
+
backdropComponent={backdropComponent}>
|
|
131
|
+
<View
|
|
132
|
+
style={{paddingBottom: bottom}}
|
|
133
|
+
accessibilityLabel={'BottomSheet'}>
|
|
134
|
+
<View style={[styles.sheetContainer, {backgroundColor}]}>
|
|
135
|
+
<View style={styles.indicatorContainer}>
|
|
136
|
+
<View
|
|
137
|
+
style={[
|
|
138
|
+
styles.indicator,
|
|
139
|
+
{backgroundColor: theme.colors.text.disable},
|
|
140
|
+
]}
|
|
141
|
+
/>
|
|
142
|
+
</View>
|
|
143
|
+
<NavigationContainer
|
|
144
|
+
theme={{
|
|
145
|
+
...theme,
|
|
146
|
+
assets: {...theme.assets, headerBackground: undefined},
|
|
147
|
+
}}
|
|
148
|
+
screen={props => <Component {...props} {...params} />}
|
|
149
|
+
options={{
|
|
150
|
+
...options,
|
|
151
|
+
...{
|
|
152
|
+
headerLeft: (props: any) => {
|
|
153
|
+
if (props.canGoBack) {
|
|
154
|
+
return (
|
|
155
|
+
<HeaderLeft
|
|
156
|
+
{...props}
|
|
157
|
+
useBorder={false}
|
|
158
|
+
backgroundColor="transparent"
|
|
159
|
+
/>
|
|
160
|
+
);
|
|
161
|
+
}
|
|
162
|
+
},
|
|
163
|
+
headerBackground: () => (
|
|
164
|
+
<HeaderBackground backgroundColor={backgroundColor} />
|
|
165
|
+
),
|
|
166
|
+
headerTransparent: false,
|
|
167
|
+
},
|
|
168
|
+
headerTitleAlign: 'center',
|
|
169
|
+
headerRight: props => (
|
|
170
|
+
<HeaderRightAction>
|
|
171
|
+
<NavigationButton
|
|
172
|
+
{...props}
|
|
173
|
+
icon="24_navigation_close"
|
|
174
|
+
backgroundColor="transparent"
|
|
175
|
+
useBorder={false}
|
|
176
|
+
onPress={bottomSheetRef.current?.dismiss}
|
|
177
|
+
/>
|
|
178
|
+
</HeaderRightAction>
|
|
179
|
+
),
|
|
180
|
+
}}
|
|
181
|
+
/>
|
|
182
|
+
</View>
|
|
183
|
+
</View>
|
|
184
|
+
</BottomSheetModal>
|
|
185
|
+
</SafeAreaView>
|
|
186
|
+
);
|
|
187
|
+
};
|
|
188
|
+
|
|
189
|
+
const styles = StyleSheet.create({
|
|
190
|
+
container: {flex: 1, flexDirection: 'row'},
|
|
191
|
+
modalContent: {
|
|
192
|
+
maxWidth: '100%',
|
|
193
|
+
maxHeight: '80%',
|
|
194
|
+
},
|
|
195
|
+
modalCenterStage: {
|
|
196
|
+
maxWidth: '90%',
|
|
197
|
+
},
|
|
198
|
+
modalSpaceHorizontal: {
|
|
199
|
+
flex: 1,
|
|
200
|
+
minWidth: '5%',
|
|
201
|
+
},
|
|
202
|
+
modalSpaceVertical: {
|
|
203
|
+
flex: 1,
|
|
204
|
+
minHeight: '10%',
|
|
205
|
+
},
|
|
206
|
+
sheetContainer: {
|
|
207
|
+
height: '100%',
|
|
208
|
+
width: '100%',
|
|
209
|
+
borderTopLeftRadius: Radius.M,
|
|
210
|
+
borderTopRightRadius: Radius.M,
|
|
211
|
+
overflow: 'hidden',
|
|
212
|
+
},
|
|
213
|
+
indicatorContainer: {
|
|
214
|
+
width: '100%',
|
|
215
|
+
paddingTop: Spacing.S,
|
|
216
|
+
alignItems: 'center',
|
|
217
|
+
justifyContent: 'center',
|
|
218
|
+
},
|
|
219
|
+
indicator: {
|
|
220
|
+
width: 64,
|
|
221
|
+
height: 4,
|
|
222
|
+
borderRadius: Radius.S,
|
|
223
|
+
},
|
|
224
|
+
});
|
|
225
|
+
|
|
226
|
+
export default ModalScreen;
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import {NavigationProp} from '@react-navigation/native';
|
|
2
|
+
import {NavigationOptions, Theme} from './types';
|
|
3
|
+
import {HeaderRightAction} from './index';
|
|
4
|
+
import {getOptions} from './utils';
|
|
5
|
+
import {HeaderToolkitAction} from './Components';
|
|
6
|
+
|
|
7
|
+
class Navigation {
|
|
8
|
+
instance: NavigationProp<any>;
|
|
9
|
+
theme: Theme;
|
|
10
|
+
|
|
11
|
+
constructor(instance: any, theme: Theme) {
|
|
12
|
+
this.instance = instance;
|
|
13
|
+
this.theme = theme;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
verifyParams = (params: NavigationOptions) => {
|
|
17
|
+
if (params.headerRight) {
|
|
18
|
+
const headerRight = params.headerRight?.();
|
|
19
|
+
if (
|
|
20
|
+
headerRight?.type !== HeaderRightAction &&
|
|
21
|
+
headerRight?.type !== HeaderToolkitAction
|
|
22
|
+
) {
|
|
23
|
+
console.warn(
|
|
24
|
+
'headerRight not return element type of HeaderRightAction | HeaderToolkitAction, Please migrate to use of kits.',
|
|
25
|
+
);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
return params;
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
filterParams = (params: NavigationOptions) => {
|
|
32
|
+
return params;
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
setOptions = (params: NavigationOptions) => {
|
|
36
|
+
if (__DEV__) {
|
|
37
|
+
params = this.verifyParams(params);
|
|
38
|
+
}
|
|
39
|
+
params = getOptions(params, this.theme);
|
|
40
|
+
this.instance.setOptions(params);
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
export default Navigation;
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import {Platform, StyleSheet, TouchableOpacity as TouchRN} from 'react-native';
|
|
2
|
+
import {TouchableOpacity as TouchGesture} from 'react-native-gesture-handler';
|
|
3
|
+
import React, {useContext} from 'react';
|
|
4
|
+
import {NavigationButtonProps} from './types';
|
|
5
|
+
import {ApplicationContext} from './index';
|
|
6
|
+
import {Icon} from '../Icon';
|
|
7
|
+
import {Colors} from '../Consts';
|
|
8
|
+
|
|
9
|
+
const TouchableOpacity = Platform.OS === 'ios' ? TouchRN : TouchGesture;
|
|
10
|
+
const NavigationButton: React.FC<NavigationButtonProps> = ({
|
|
11
|
+
icon,
|
|
12
|
+
tintColor,
|
|
13
|
+
onPress,
|
|
14
|
+
backgroundColor,
|
|
15
|
+
useBorder = true,
|
|
16
|
+
accessibilityLabel,
|
|
17
|
+
}) => {
|
|
18
|
+
const {theme} = useContext(ApplicationContext);
|
|
19
|
+
if (!backgroundColor && tintColor != Colors.black_01) {
|
|
20
|
+
backgroundColor = theme.colors.background.surface;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
return (
|
|
24
|
+
<TouchableOpacity
|
|
25
|
+
accessibilityLabel={`NavigationButton/${accessibilityLabel}`}
|
|
26
|
+
style={[
|
|
27
|
+
styles.container,
|
|
28
|
+
{
|
|
29
|
+
backgroundColor: backgroundColor ?? '#00000066',
|
|
30
|
+
borderWidth: useBorder && backgroundColor ? 0.5 : 0,
|
|
31
|
+
},
|
|
32
|
+
]}
|
|
33
|
+
onPress={onPress}>
|
|
34
|
+
<Icon
|
|
35
|
+
source={icon}
|
|
36
|
+
color={tintColor ?? theme.colors.text.default}
|
|
37
|
+
size={20}
|
|
38
|
+
/>
|
|
39
|
+
</TouchableOpacity>
|
|
40
|
+
);
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
const styles = StyleSheet.create({
|
|
44
|
+
container: {
|
|
45
|
+
height: 28,
|
|
46
|
+
width: 28,
|
|
47
|
+
borderRadius: 14,
|
|
48
|
+
borderColor: '#00000066',
|
|
49
|
+
justifyContent: 'center',
|
|
50
|
+
alignItems: 'center',
|
|
51
|
+
},
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
export default NavigationButton;
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import React, {createContext, useEffect, useRef} from 'react';
|
|
2
|
+
import {BottomSheetModalProvider} from '@gorhom/bottom-sheet';
|
|
3
|
+
import {SafeAreaProvider} from 'react-native-safe-area-context';
|
|
4
|
+
import {
|
|
5
|
+
NavigationContainer as ReactNavigationContainer,
|
|
6
|
+
NavigationContainerRef,
|
|
7
|
+
} from '@react-navigation/native';
|
|
8
|
+
import {createStackNavigator} from '@react-navigation/stack';
|
|
9
|
+
import StackScreen from './StackScreen';
|
|
10
|
+
import ModalScreen from './ModalScreen';
|
|
11
|
+
import Navigator from './Navigator';
|
|
12
|
+
import {getDialogOptions, getModalOptions, getStackOptions} from './utils';
|
|
13
|
+
import {GridSystem} from '../Layout';
|
|
14
|
+
import {defaultContext, GRIDVIEW} from '../Consts';
|
|
15
|
+
import {NavigationContainerProps} from './types';
|
|
16
|
+
|
|
17
|
+
const Stack = createStackNavigator();
|
|
18
|
+
|
|
19
|
+
const ApplicationContext = createContext(defaultContext);
|
|
20
|
+
const NavigationContainer: React.FC<NavigationContainerProps> = ({
|
|
21
|
+
screen,
|
|
22
|
+
theme,
|
|
23
|
+
options,
|
|
24
|
+
maxApi,
|
|
25
|
+
}) => {
|
|
26
|
+
const navigationRef = React.useRef<NavigationContainerRef>(null);
|
|
27
|
+
const navigator = useRef(new Navigator(navigationRef));
|
|
28
|
+
navigator.current.maxApi = maxApi;
|
|
29
|
+
|
|
30
|
+
return (
|
|
31
|
+
<SafeAreaProvider>
|
|
32
|
+
<BottomSheetModalProvider>
|
|
33
|
+
<ApplicationContext.Provider
|
|
34
|
+
value={{theme, navigator: navigator.current}}>
|
|
35
|
+
<ReactNavigationContainer
|
|
36
|
+
theme={{
|
|
37
|
+
...theme,
|
|
38
|
+
colors: {
|
|
39
|
+
...theme.colors,
|
|
40
|
+
background: theme.colors.background.default,
|
|
41
|
+
card: theme.colors.background.surface,
|
|
42
|
+
text: theme.colors.text.default,
|
|
43
|
+
border: theme.colors.border.default,
|
|
44
|
+
notification: theme.colors.error.primary,
|
|
45
|
+
},
|
|
46
|
+
}}
|
|
47
|
+
ref={navigator.current?.ref}
|
|
48
|
+
independent={true}>
|
|
49
|
+
<Stack.Navigator initialRouteName="Stack" headerMode="screen">
|
|
50
|
+
<Stack.Screen
|
|
51
|
+
name="Stack"
|
|
52
|
+
component={StackScreen}
|
|
53
|
+
initialParams={{screen}}
|
|
54
|
+
options={{...getStackOptions(theme), ...options}}
|
|
55
|
+
/>
|
|
56
|
+
<Stack.Screen
|
|
57
|
+
name="Dialog"
|
|
58
|
+
component={StackScreen}
|
|
59
|
+
options={getDialogOptions(theme)}
|
|
60
|
+
initialParams={{screen}}
|
|
61
|
+
/>
|
|
62
|
+
<Stack.Screen
|
|
63
|
+
name="Modal"
|
|
64
|
+
component={ModalScreen}
|
|
65
|
+
options={getModalOptions()}
|
|
66
|
+
initialParams={{screen}}
|
|
67
|
+
/>
|
|
68
|
+
</Stack.Navigator>
|
|
69
|
+
</ReactNavigationContainer>
|
|
70
|
+
</ApplicationContext.Provider>
|
|
71
|
+
</BottomSheetModalProvider>
|
|
72
|
+
{GRIDVIEW && <GridSystem />}
|
|
73
|
+
</SafeAreaProvider>
|
|
74
|
+
);
|
|
75
|
+
};
|
|
76
|
+
|
|
77
|
+
export {ApplicationContext, NavigationContainer};
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import {StackActions} from '@react-navigation/native';
|
|
2
|
+
import {
|
|
3
|
+
BottomSheetParams,
|
|
4
|
+
HeaderToolkitProps,
|
|
5
|
+
ModalParams,
|
|
6
|
+
ScreenParams,
|
|
7
|
+
} from './types';
|
|
8
|
+
|
|
9
|
+
class Navigator {
|
|
10
|
+
ref?: any;
|
|
11
|
+
toolkitConfig?: HeaderToolkitProps;
|
|
12
|
+
maxApi?: any;
|
|
13
|
+
|
|
14
|
+
constructor(navigation: any) {
|
|
15
|
+
this.ref = navigation;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
push = (params: ScreenParams) => {
|
|
19
|
+
this.ref.current.dispatch(StackActions.push('Stack', params));
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
replace = (params: ScreenParams) => {
|
|
23
|
+
this.ref.current.dispatch(StackActions.replace('Stack', params));
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
pop = (count?: number) => {
|
|
27
|
+
this.ref.current.dispatch(StackActions.pop(count ?? 1));
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
present = (params: ScreenParams) => {
|
|
31
|
+
this.ref.current.dispatch(StackActions.push('Dialog', params));
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
showModal = (params: ModalParams) => {
|
|
35
|
+
this.ref.current.dispatch(StackActions.push('Modal', params));
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
showBottomSheet = (params: BottomSheetParams) => {
|
|
39
|
+
this.ref.current.dispatch(
|
|
40
|
+
StackActions.push('Modal', {
|
|
41
|
+
...params,
|
|
42
|
+
isBottomSheet: true,
|
|
43
|
+
}),
|
|
44
|
+
);
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
popToTop = () => {
|
|
48
|
+
this.ref.current.dispatch(StackActions.popToTop());
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
requestApi = (func: any, args: any = [], callback: any) => {
|
|
52
|
+
if (this.maxApi) {
|
|
53
|
+
this.maxApi[func]?.(...args, callback);
|
|
54
|
+
} else {
|
|
55
|
+
const instance: any = global;
|
|
56
|
+
instance?.miniAppApi?.dispatch?.(func, ...args, callback);
|
|
57
|
+
}
|
|
58
|
+
};
|
|
59
|
+
getToolkit = async (): Promise<HeaderToolkitProps | undefined> => {
|
|
60
|
+
return new Promise(resolve => {
|
|
61
|
+
if (this.toolkitConfig) {
|
|
62
|
+
resolve(this.toolkitConfig);
|
|
63
|
+
return;
|
|
64
|
+
}
|
|
65
|
+
this.requestApi('getToolkit', [undefined], (result: boolean) => {
|
|
66
|
+
if (result) {
|
|
67
|
+
this.requestApi('getToolkitConfig', [undefined], (config: any) => {
|
|
68
|
+
this.toolkitConfig = {
|
|
69
|
+
...config?.utilityToolConfig,
|
|
70
|
+
appCode: config?.appCode,
|
|
71
|
+
};
|
|
72
|
+
resolve(this.toolkitConfig);
|
|
73
|
+
});
|
|
74
|
+
} else {
|
|
75
|
+
resolve(undefined);
|
|
76
|
+
}
|
|
77
|
+
});
|
|
78
|
+
});
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
export default Navigator;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import React, {useContext, useEffect} from 'react';
|
|
2
|
+
import {ScreenParams} from './types';
|
|
3
|
+
import Navigation from './Navigation';
|
|
4
|
+
import {ApplicationContext} from './NavigationContainer';
|
|
5
|
+
|
|
6
|
+
const StackScreen: React.FC<any> = props => {
|
|
7
|
+
const {route, navigation} = props;
|
|
8
|
+
const {screen: Component, options}: ScreenParams = route.params;
|
|
9
|
+
const {theme, navigator} = useContext(ApplicationContext);
|
|
10
|
+
|
|
11
|
+
const params = {
|
|
12
|
+
...route.params,
|
|
13
|
+
navigation: new Navigation(navigation, theme),
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
delete params.screen;
|
|
17
|
+
|
|
18
|
+
useEffect(() => {
|
|
19
|
+
if (options) {
|
|
20
|
+
params.navigation.setOptions(options);
|
|
21
|
+
}
|
|
22
|
+
}, [options]);
|
|
23
|
+
|
|
24
|
+
return <Component {...params} />;
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
export default StackScreen;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import {NavigationContainer, ApplicationContext} from './NavigationContainer';
|
|
2
|
+
import ScreenContainer from '../Layout/ScreenContainer';
|
|
3
|
+
import NavigationButton from './NavigationButton';
|
|
4
|
+
import {HeaderRightAction} from './Components';
|
|
5
|
+
import BottomTab from './BottomTab';
|
|
6
|
+
|
|
7
|
+
export {
|
|
8
|
+
NavigationContainer,
|
|
9
|
+
ApplicationContext,
|
|
10
|
+
ScreenContainer,
|
|
11
|
+
NavigationButton,
|
|
12
|
+
HeaderRightAction,
|
|
13
|
+
BottomTab,
|
|
14
|
+
};
|
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
import {Animated, ScrollViewProps, ViewProps} from 'react-native';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import Navigator from './Navigator';
|
|
4
|
+
import {PopupNotifyProps} from '../Popup/types';
|
|
5
|
+
|
|
6
|
+
export type Theme = {
|
|
7
|
+
dark: boolean;
|
|
8
|
+
colors: {
|
|
9
|
+
primary: string;
|
|
10
|
+
secondary: string;
|
|
11
|
+
background: {
|
|
12
|
+
default: string;
|
|
13
|
+
surface: string;
|
|
14
|
+
tonal: string;
|
|
15
|
+
pressed: string;
|
|
16
|
+
selected: string;
|
|
17
|
+
disable: string;
|
|
18
|
+
};
|
|
19
|
+
text: {
|
|
20
|
+
default: string;
|
|
21
|
+
secondary: string;
|
|
22
|
+
hint: string;
|
|
23
|
+
disable: string;
|
|
24
|
+
};
|
|
25
|
+
border: {
|
|
26
|
+
default: string;
|
|
27
|
+
disable: string;
|
|
28
|
+
};
|
|
29
|
+
success: {
|
|
30
|
+
primary: string;
|
|
31
|
+
secondary: string;
|
|
32
|
+
container: string;
|
|
33
|
+
};
|
|
34
|
+
warning: {
|
|
35
|
+
primary: string;
|
|
36
|
+
secondary: string;
|
|
37
|
+
container: string;
|
|
38
|
+
};
|
|
39
|
+
error: {
|
|
40
|
+
primary: string;
|
|
41
|
+
secondary: string;
|
|
42
|
+
container: string;
|
|
43
|
+
};
|
|
44
|
+
highlight: {
|
|
45
|
+
primary: string;
|
|
46
|
+
secondary: string;
|
|
47
|
+
container: string;
|
|
48
|
+
};
|
|
49
|
+
interactive: {
|
|
50
|
+
primary: string;
|
|
51
|
+
secondary: string;
|
|
52
|
+
container: string;
|
|
53
|
+
};
|
|
54
|
+
};
|
|
55
|
+
font: string;
|
|
56
|
+
assets?: {
|
|
57
|
+
headerBackground?: string;
|
|
58
|
+
};
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
export type Context = {
|
|
62
|
+
theme: Theme;
|
|
63
|
+
navigator?: Navigator;
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
export type NavigationContainerProps = {
|
|
67
|
+
screen: React.ElementType;
|
|
68
|
+
options?: NavigationOptions;
|
|
69
|
+
theme: Theme;
|
|
70
|
+
maxApi?: any;
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
export interface ScreenContainerProps extends ViewProps {
|
|
74
|
+
enableKeyboardAvoidingView?: boolean;
|
|
75
|
+
headerBackground?: string;
|
|
76
|
+
scrollable?: boolean;
|
|
77
|
+
scrollY?: Animated.Value;
|
|
78
|
+
scrollViewProps?: ScrollViewProps;
|
|
79
|
+
footerComponent?: React.ElementType;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
export type ScreenParams = {
|
|
83
|
+
[key: string]: any;
|
|
84
|
+
screen: React.ElementType;
|
|
85
|
+
options?: NavigationOptions;
|
|
86
|
+
};
|
|
87
|
+
|
|
88
|
+
export interface ModalParams extends ScreenParams {
|
|
89
|
+
[key: string]: any;
|
|
90
|
+
screen: React.ElementType;
|
|
91
|
+
onDismiss?: (mounted?: boolean) => void;
|
|
92
|
+
barrierDismissible?: boolean;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
export interface BottomSheetParams extends ScreenParams {
|
|
96
|
+
[key: string]: any;
|
|
97
|
+
onDismiss?: () => void;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
export type NavigationButtonProps = {
|
|
101
|
+
icon: string;
|
|
102
|
+
tintColor?: string;
|
|
103
|
+
backgroundColor?: string;
|
|
104
|
+
useBorder?: boolean;
|
|
105
|
+
onPress: () => void;
|
|
106
|
+
accessibilityLabel?: string;
|
|
107
|
+
};
|
|
108
|
+
|
|
109
|
+
export type NavigationOptions = {
|
|
110
|
+
preventBack?: PopupNotifyProps;
|
|
111
|
+
surface?: boolean;
|
|
112
|
+
title?: string;
|
|
113
|
+
headerTitleAlign?: 'left' | 'center';
|
|
114
|
+
customTitle?: TitleCustomProps;
|
|
115
|
+
headerRight?: (props?: any) => React.ReactElement;
|
|
116
|
+
animatedValue?: Animated.Value;
|
|
117
|
+
};
|
|
118
|
+
|
|
119
|
+
export interface HeaderBackProps extends NavigationButtonProps {
|
|
120
|
+
preventBack?: PopupNotifyProps;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
export type HeaderBackgroundProps = {
|
|
124
|
+
image?: string | null;
|
|
125
|
+
backgroundColor?: string | null;
|
|
126
|
+
animatedValue?: Animated.Value;
|
|
127
|
+
useBorder?: boolean;
|
|
128
|
+
};
|
|
129
|
+
|
|
130
|
+
export type TitleCustomProps = {
|
|
131
|
+
title?: string;
|
|
132
|
+
subTitle?: string;
|
|
133
|
+
image?: string;
|
|
134
|
+
imageShape?: 'circle' | 'square';
|
|
135
|
+
dotColor?: string;
|
|
136
|
+
tintColor?: string;
|
|
137
|
+
content?: React.ReactNode;
|
|
138
|
+
};
|
|
139
|
+
|
|
140
|
+
export type HeaderToolkitProps = {
|
|
141
|
+
[key: string]: any;
|
|
142
|
+
appCode: string;
|
|
143
|
+
hidden: boolean;
|
|
144
|
+
type: string;
|
|
145
|
+
onAction?: (action: string) => void;
|
|
146
|
+
};
|
|
147
|
+
|
|
148
|
+
export type BottomTabItemProps = {
|
|
149
|
+
label: string;
|
|
150
|
+
icon: string;
|
|
151
|
+
showDot?: boolean;
|
|
152
|
+
badgeLabel?: string;
|
|
153
|
+
screen: React.ComponentType<any>;
|
|
154
|
+
};
|
|
155
|
+
|
|
156
|
+
export type BottomTabProps = {
|
|
157
|
+
tabs: BottomTabItemProps[];
|
|
158
|
+
};
|