@momo-kits/foundation 0.81.7-beta.3 → 0.81.7-beta.5
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/Components.tsx +11 -25
- package/Application/ModalScreen.tsx +30 -36
- package/Application/Navigation.ts +4 -15
- package/Application/NavigationContainer.tsx +3 -16
- package/Application/Navigator.ts +26 -39
- package/Application/StackScreen.tsx +18 -22
- package/Application/types.ts +4 -3
- package/Application/utils.tsx +0 -12
- package/Consts/colors+spacing+radius.ts +3 -3
- package/Layout/Card.tsx +0 -1
- package/Layout/Section.tsx +13 -11
- package/Layout/index.ts +0 -2
- package/Layout/styles.ts +12 -0
- package/package.json +2 -2
- package/Layout/ItemSectionList.tsx +0 -39
|
@@ -23,6 +23,8 @@ import {scaleSize, Text} from '../Text';
|
|
|
23
23
|
import {Icon} from '../Icon';
|
|
24
24
|
import {PopupNotify} from '../Popup';
|
|
25
25
|
|
|
26
|
+
const TRIGGER_ID = "'111154000000000000";
|
|
27
|
+
|
|
26
28
|
const styles = StyleSheet.create({
|
|
27
29
|
navigationButton: {
|
|
28
30
|
height: 28,
|
|
@@ -149,7 +151,8 @@ const HeaderLeft: React.FC<HeaderBackProps> = ({
|
|
|
149
151
|
backgroundColor,
|
|
150
152
|
accessibilityLabel = '',
|
|
151
153
|
}) => {
|
|
152
|
-
const {navigator} = useContext(ApplicationContext);
|
|
154
|
+
const {navigator, appInfo} = useContext(ApplicationContext);
|
|
155
|
+
const screen_name = navigator?.ref?.current?.getCurrentRoute().name;
|
|
153
156
|
|
|
154
157
|
useEffect(() => {
|
|
155
158
|
const backHandler = BackHandler.addEventListener(
|
|
@@ -162,13 +165,12 @@ const HeaderLeft: React.FC<HeaderBackProps> = ({
|
|
|
162
165
|
|
|
163
166
|
const goBack = () => {
|
|
164
167
|
const canGoBack = navigator?.ref.current?.canGoBack();
|
|
165
|
-
const currentRoute = navigator?.ref?.current.getCurrentRoute();
|
|
166
168
|
|
|
167
|
-
if (
|
|
169
|
+
if (appInfo) {
|
|
168
170
|
navigator?.maxApi?.trackEvent('service_icon_clicked', {
|
|
169
|
-
...
|
|
170
|
-
screen_name
|
|
171
|
-
trigger_id:
|
|
171
|
+
...appInfo,
|
|
172
|
+
screen_name,
|
|
173
|
+
trigger_id: TRIGGER_ID,
|
|
172
174
|
icon_name: 'back',
|
|
173
175
|
});
|
|
174
176
|
}
|
|
@@ -331,25 +333,9 @@ const HeaderToolkitAction: React.FC<any> = ({tintColor}) => {
|
|
|
331
333
|
}
|
|
332
334
|
|
|
333
335
|
useEffect(() => {
|
|
334
|
-
|
|
335
|
-
setToolConfig(
|
|
336
|
-
}
|
|
337
|
-
navigator?.requestApi('getToolkit', [undefined], (result: boolean) => {
|
|
338
|
-
if (result) {
|
|
339
|
-
navigator?.requestApi(
|
|
340
|
-
'getToolkitConfig',
|
|
341
|
-
[undefined],
|
|
342
|
-
(config: any) => {
|
|
343
|
-
navigator.toolkitConfig = {
|
|
344
|
-
...config?.utilityToolConfig,
|
|
345
|
-
appCode: config?.appCode,
|
|
346
|
-
};
|
|
347
|
-
setToolConfig(navigator?.toolkitConfig);
|
|
348
|
-
},
|
|
349
|
-
);
|
|
350
|
-
}
|
|
351
|
-
});
|
|
352
|
-
}
|
|
336
|
+
navigator?.getToolkit().then((toolConfig: any) => {
|
|
337
|
+
setToolConfig(toolConfig);
|
|
338
|
+
});
|
|
353
339
|
}, []);
|
|
354
340
|
|
|
355
341
|
useEffect(() => {
|
|
@@ -26,9 +26,6 @@ import {
|
|
|
26
26
|
import {HeaderBackground, HeaderLeft, HeaderTitle} from './Components';
|
|
27
27
|
|
|
28
28
|
const ModalScreen: React.FC<any> = props => {
|
|
29
|
-
/**
|
|
30
|
-
* dismiss callback when modal | bottom sheet dismissed
|
|
31
|
-
*/
|
|
32
29
|
useEffect(() => {
|
|
33
30
|
return () => {
|
|
34
31
|
props.route.params?.onDismiss?.();
|
|
@@ -42,8 +39,10 @@ const ModalScreen: React.FC<any> = props => {
|
|
|
42
39
|
};
|
|
43
40
|
|
|
44
41
|
const Modal: React.FC<ModalParams> = props => {
|
|
45
|
-
const
|
|
46
|
-
const {
|
|
42
|
+
const TRIGGER_ID = '111012100000000000';
|
|
43
|
+
const {theme, navigator, appInfo} = useContext(ApplicationContext);
|
|
44
|
+
const {screen, barrierDismissible, modalName}: ModalParams =
|
|
45
|
+
props.route.params;
|
|
47
46
|
const Component = useRef(screen).current;
|
|
48
47
|
const navigation = new Navigation(props.navigation, theme);
|
|
49
48
|
const params = {
|
|
@@ -53,40 +52,35 @@ const Modal: React.FC<ModalParams> = props => {
|
|
|
53
52
|
|
|
54
53
|
delete params.screen;
|
|
55
54
|
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
55
|
+
const navigationRoutes = props.navigation.getState()?.routes || [];
|
|
56
|
+
const routesLength = navigationRoutes.length;
|
|
57
|
+
let screen_name = navigationRoutes?.[0]?.params?.screen?.name;
|
|
58
|
+
if (routesLength > 1) {
|
|
59
|
+
screen_name = navigationRoutes[routesLength - 2]?.params?.screen?.name;
|
|
60
|
+
}
|
|
61
|
+
const error_code = (screen as Function)?.()?.props?.information;
|
|
62
|
+
|
|
59
63
|
useEffect(() => {
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
64
|
+
navigator?.maxApi?.trackEvent('service_component_displayed', {
|
|
65
|
+
...appInfo,
|
|
66
|
+
screen_name,
|
|
67
|
+
trigger_id: TRIGGER_ID,
|
|
68
|
+
component_type: 'popup',
|
|
69
|
+
component_name: modalName,
|
|
70
|
+
error_code,
|
|
71
|
+
});
|
|
72
|
+
|
|
73
|
+
return () => {
|
|
74
|
+
navigator?.maxApi?.trackEvent('service_icon_clicked', {
|
|
75
|
+
...appInfo,
|
|
71
76
|
screen_name,
|
|
72
|
-
trigger_id: '
|
|
77
|
+
trigger_id: '111154100000000001',
|
|
73
78
|
component_type: 'popup',
|
|
74
79
|
component_name: modalName,
|
|
75
80
|
error_code,
|
|
81
|
+
icon_name: 'close',
|
|
76
82
|
});
|
|
77
|
-
|
|
78
|
-
return () => {
|
|
79
|
-
navigator?.maxApi?.trackEvent('service_icon_clicked', {
|
|
80
|
-
...navigator?.trackingInfo,
|
|
81
|
-
screen_name,
|
|
82
|
-
trigger_id: '111154100000000001',
|
|
83
|
-
component_type: 'popup',
|
|
84
|
-
component_name: modalName,
|
|
85
|
-
error_code,
|
|
86
|
-
icon_name: 'close',
|
|
87
|
-
});
|
|
88
|
-
};
|
|
89
|
-
}
|
|
83
|
+
};
|
|
90
84
|
}, []);
|
|
91
85
|
|
|
92
86
|
const onDismiss = () => {
|
|
@@ -129,7 +123,7 @@ const Modal: React.FC<ModalParams> = props => {
|
|
|
129
123
|
|
|
130
124
|
const BottomSheet: React.FC<BottomSheetParams> = props => {
|
|
131
125
|
const insets = useSafeAreaInsets();
|
|
132
|
-
const {theme, navigator} = useContext(ApplicationContext);
|
|
126
|
+
const {theme, navigator, appInfo} = useContext(ApplicationContext);
|
|
133
127
|
const [keyboardSnap, setKeyboardSnap] = useState(0);
|
|
134
128
|
const {screen, options, snapPoint}: BottomSheetParams = props.route.params;
|
|
135
129
|
const Component = useRef(screen).current;
|
|
@@ -220,7 +214,7 @@ const BottomSheet: React.FC<BottomSheetParams> = props => {
|
|
|
220
214
|
/>
|
|
221
215
|
</View>
|
|
222
216
|
<NavigationContainer
|
|
223
|
-
|
|
217
|
+
appInfo={appInfo}
|
|
224
218
|
maxApi={navigator?.maxApi}
|
|
225
219
|
theme={{
|
|
226
220
|
...theme,
|
|
@@ -264,7 +258,7 @@ const BottomSheet: React.FC<BottomSheetParams> = props => {
|
|
|
264
258
|
icon="24_navigation_close"
|
|
265
259
|
backgroundColor="transparent"
|
|
266
260
|
useBorder={false}
|
|
267
|
-
onPress={
|
|
261
|
+
onPress={bottomSheetRef.current?.dismiss}
|
|
268
262
|
accessibilityLabel={'BottomSheet/Close'}
|
|
269
263
|
/>
|
|
270
264
|
</HeaderRightAction>
|
|
@@ -14,10 +14,6 @@ class Navigation {
|
|
|
14
14
|
this.theme = theme;
|
|
15
15
|
}
|
|
16
16
|
|
|
17
|
-
/**
|
|
18
|
-
* navigation options filter by design system rule
|
|
19
|
-
* @param params
|
|
20
|
-
*/
|
|
21
17
|
private filterParams = (params: NavigationOptions) => {
|
|
22
18
|
if (params.headerRight) {
|
|
23
19
|
const headerRight = params.headerRight?.({}) as React.ReactElement;
|
|
@@ -28,21 +24,14 @@ class Navigation {
|
|
|
28
24
|
);
|
|
29
25
|
}
|
|
30
26
|
}
|
|
31
|
-
|
|
32
|
-
if (params.headerLeft) {
|
|
33
|
-
console.warn('headerLeft not allow override render by design system!');
|
|
34
|
-
delete params.headerLeft;
|
|
35
|
-
}
|
|
36
|
-
|
|
37
27
|
return params;
|
|
38
28
|
};
|
|
39
29
|
|
|
40
|
-
/**
|
|
41
|
-
* navigation setOptions support props NavigationOptions base on react-navigation options
|
|
42
|
-
* @param params
|
|
43
|
-
*/
|
|
44
30
|
setOptions = (params: NavigationOptions) => {
|
|
45
|
-
|
|
31
|
+
if (__DEV__) {
|
|
32
|
+
params = this.filterParams(params);
|
|
33
|
+
}
|
|
34
|
+
params = getOptions(params, this.theme);
|
|
46
35
|
this.instance.setOptions(params);
|
|
47
36
|
};
|
|
48
37
|
}
|
|
@@ -23,16 +23,13 @@ const NavigationContainer: React.FC<NavigationContainerProps> = ({
|
|
|
23
23
|
options,
|
|
24
24
|
maxApi,
|
|
25
25
|
localization,
|
|
26
|
-
|
|
26
|
+
appInfo,
|
|
27
27
|
}) => {
|
|
28
28
|
const navigationRef = React.useRef<NavigationContainerRef>(null);
|
|
29
29
|
const navigator = useRef(new Navigator(navigationRef));
|
|
30
30
|
const [showGrid, setShowGrid] = useState(false);
|
|
31
31
|
const [language, setLanguage] = useState<'vi' | 'en'>('vi');
|
|
32
32
|
|
|
33
|
-
/**
|
|
34
|
-
* engine only shake to enable grid view
|
|
35
|
-
*/
|
|
36
33
|
useEffect(() => {
|
|
37
34
|
const subscription = DeviceEventEmitter.addListener(
|
|
38
35
|
'onChangeGrid',
|
|
@@ -41,13 +38,10 @@ const NavigationContainer: React.FC<NavigationContainerProps> = ({
|
|
|
41
38
|
},
|
|
42
39
|
);
|
|
43
40
|
return () => {
|
|
44
|
-
subscription
|
|
41
|
+
subscription.remove();
|
|
45
42
|
};
|
|
46
43
|
}, []);
|
|
47
44
|
|
|
48
|
-
/**
|
|
49
|
-
* handle mini language & listen change
|
|
50
|
-
*/
|
|
51
45
|
useEffect(() => {
|
|
52
46
|
maxApi?.getLanguage?.((lang: 'vi' | 'en') => {
|
|
53
47
|
setLanguage(lang);
|
|
@@ -60,16 +54,8 @@ const NavigationContainer: React.FC<NavigationContainerProps> = ({
|
|
|
60
54
|
};
|
|
61
55
|
}, []);
|
|
62
56
|
|
|
63
|
-
/**
|
|
64
|
-
* inject data for navigator
|
|
65
|
-
*/
|
|
66
57
|
navigator.current.maxApi = maxApi;
|
|
67
|
-
navigator.current.trackingInfo = trackingInfo;
|
|
68
58
|
|
|
69
|
-
/**
|
|
70
|
-
* translate
|
|
71
|
-
* @param key
|
|
72
|
-
*/
|
|
73
59
|
const translate = (key: string) => {
|
|
74
60
|
const mergedLocalization: LocalizationObject = {
|
|
75
61
|
vi: {...localization?.vi, ...kitLocalization.vi},
|
|
@@ -88,6 +74,7 @@ const NavigationContainer: React.FC<NavigationContainerProps> = ({
|
|
|
88
74
|
showGrid,
|
|
89
75
|
language,
|
|
90
76
|
translate,
|
|
77
|
+
appInfo,
|
|
91
78
|
}}>
|
|
92
79
|
<ReactNavigationContainer
|
|
93
80
|
theme={{
|
package/Application/Navigator.ts
CHANGED
|
@@ -4,62 +4,37 @@ import {
|
|
|
4
4
|
HeaderToolkitProps,
|
|
5
5
|
ModalParams,
|
|
6
6
|
ScreenParams,
|
|
7
|
-
TrackingInfo,
|
|
8
7
|
} from './types';
|
|
9
8
|
|
|
10
9
|
class Navigator {
|
|
11
10
|
ref?: any;
|
|
12
11
|
toolkitConfig?: HeaderToolkitProps;
|
|
13
12
|
maxApi?: any;
|
|
14
|
-
trackingInfo?: TrackingInfo;
|
|
15
13
|
|
|
16
14
|
constructor(navigation: any) {
|
|
17
15
|
this.ref = navigation;
|
|
18
16
|
}
|
|
19
17
|
|
|
20
|
-
/**
|
|
21
|
-
* push new stack screen
|
|
22
|
-
* @param params
|
|
23
|
-
*/
|
|
24
18
|
push = (params: ScreenParams) => {
|
|
25
19
|
this.ref.current.dispatch(StackActions.push('Stack', params));
|
|
26
20
|
};
|
|
27
21
|
|
|
28
|
-
/**
|
|
29
|
-
* replace current screen with new screen
|
|
30
|
-
* @param params
|
|
31
|
-
*/
|
|
32
22
|
replace = (params: ScreenParams) => {
|
|
33
23
|
this.ref.current.dispatch(StackActions.replace('Stack', params));
|
|
34
24
|
};
|
|
35
|
-
|
|
36
|
-
* pop to dismiss a screen
|
|
37
|
-
* @param count
|
|
38
|
-
*/
|
|
25
|
+
|
|
39
26
|
pop = (count?: number) => {
|
|
40
27
|
this.ref.current.dispatch(StackActions.pop(count ?? 1));
|
|
41
28
|
};
|
|
42
29
|
|
|
43
|
-
/**
|
|
44
|
-
* present a new screen, show from bottom iOS
|
|
45
|
-
* @param params
|
|
46
|
-
*/
|
|
47
30
|
present = (params: ScreenParams) => {
|
|
48
31
|
this.ref.current.dispatch(StackActions.push('Dialog', params));
|
|
49
32
|
};
|
|
50
33
|
|
|
51
|
-
/**
|
|
52
|
-
* show a modal popup
|
|
53
|
-
* @param params
|
|
54
|
-
*/
|
|
55
34
|
showModal = (params: ModalParams) => {
|
|
56
35
|
this.ref.current.dispatch(StackActions.push('Modal', params));
|
|
57
36
|
};
|
|
58
37
|
|
|
59
|
-
/**
|
|
60
|
-
* show a bottom sheet
|
|
61
|
-
* @param params
|
|
62
|
-
*/
|
|
63
38
|
showBottomSheet = (params: BottomSheetParams) => {
|
|
64
39
|
this.ref.current.dispatch(
|
|
65
40
|
StackActions.push('Modal', {
|
|
@@ -69,17 +44,10 @@ class Navigator {
|
|
|
69
44
|
);
|
|
70
45
|
};
|
|
71
46
|
|
|
72
|
-
/**
|
|
73
|
-
* pop all screen route
|
|
74
|
-
*/
|
|
75
47
|
popToTop = () => {
|
|
76
48
|
this.ref.current.dispatch(StackActions.popToTop());
|
|
77
49
|
};
|
|
78
50
|
|
|
79
|
-
/**
|
|
80
|
-
* reset a navigation flow with new screen
|
|
81
|
-
* @param params
|
|
82
|
-
*/
|
|
83
51
|
reset = (params: ScreenParams) => {
|
|
84
52
|
this.ref.current.dispatch(
|
|
85
53
|
CommonActions.reset({
|
|
@@ -95,17 +63,36 @@ class Navigator {
|
|
|
95
63
|
);
|
|
96
64
|
};
|
|
97
65
|
|
|
98
|
-
/**
|
|
99
|
-
* request max api for mini app
|
|
100
|
-
* @param func
|
|
101
|
-
* @param args
|
|
102
|
-
* @param callback
|
|
103
|
-
*/
|
|
104
66
|
requestApi = (func: any, args: any = [], callback: any) => {
|
|
105
67
|
if (this.maxApi) {
|
|
106
68
|
this.maxApi[func]?.(...args, callback);
|
|
69
|
+
} else {
|
|
70
|
+
const instance: any = global;
|
|
71
|
+
instance?.miniAppApi?.dispatch?.(func, ...args, callback);
|
|
107
72
|
}
|
|
108
73
|
};
|
|
74
|
+
|
|
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
|
+
});
|
|
95
|
+
};
|
|
109
96
|
}
|
|
110
97
|
|
|
111
98
|
export default Navigator;
|
|
@@ -4,9 +4,11 @@ import Navigation from './Navigation';
|
|
|
4
4
|
import {ApplicationContext} from './index';
|
|
5
5
|
import {GridSystem} from '../Layout';
|
|
6
6
|
|
|
7
|
+
const TRIGGER_ID = '111378000000000000';
|
|
8
|
+
|
|
7
9
|
const StackScreen: React.FC<ScreenParams> = props => {
|
|
8
10
|
const {screen: Component, options}: ScreenParams = props.route.params;
|
|
9
|
-
const {theme, showGrid, navigator} = useContext(ApplicationContext);
|
|
11
|
+
const {theme, showGrid, navigator, appInfo} = useContext(ApplicationContext);
|
|
10
12
|
const navigation = new Navigation(props.navigation, theme);
|
|
11
13
|
|
|
12
14
|
const params = {
|
|
@@ -16,36 +18,30 @@ const StackScreen: React.FC<ScreenParams> = props => {
|
|
|
16
18
|
|
|
17
19
|
delete params.screen;
|
|
18
20
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
}
|
|
26
|
-
}, [options]);
|
|
21
|
+
const navigationRoutes = props.navigation.getState()?.routes || [];
|
|
22
|
+
const routesLength = navigationRoutes.length;
|
|
23
|
+
let pre_screen_name = navigationRoutes?.[0]?.params?.screen?.name;
|
|
24
|
+
if (routesLength > 1) {
|
|
25
|
+
pre_screen_name = navigationRoutes[routesLength - 2]?.params?.screen?.name;
|
|
26
|
+
}
|
|
27
27
|
|
|
28
|
-
/**
|
|
29
|
-
* tracking for screen
|
|
30
|
-
*/
|
|
31
28
|
useEffect(() => {
|
|
32
|
-
if (
|
|
33
|
-
const navigationRoutes = props.navigation.getState()?.routes || [];
|
|
34
|
-
const routesLength = navigationRoutes.length;
|
|
35
|
-
let pre_screen_name = navigationRoutes?.[0]?.params?.screen?.name;
|
|
36
|
-
if (routesLength > 1) {
|
|
37
|
-
pre_screen_name =
|
|
38
|
-
navigationRoutes[routesLength - 2]?.params?.screen?.name;
|
|
39
|
-
}
|
|
29
|
+
if (appInfo) {
|
|
40
30
|
navigator?.maxApi?.trackEvent('service_frame_displayed', {
|
|
41
|
-
...
|
|
31
|
+
...appInfo,
|
|
42
32
|
screen_name: Component.name,
|
|
43
33
|
pre_screen_name,
|
|
44
|
-
trigger_id:
|
|
34
|
+
trigger_id: TRIGGER_ID,
|
|
45
35
|
});
|
|
46
36
|
}
|
|
47
37
|
}, []);
|
|
48
38
|
|
|
39
|
+
useLayoutEffect(() => {
|
|
40
|
+
if (options) {
|
|
41
|
+
navigation.setOptions(options);
|
|
42
|
+
}
|
|
43
|
+
}, [options]);
|
|
44
|
+
|
|
49
45
|
return (
|
|
50
46
|
<>
|
|
51
47
|
<Component {...params} />
|
package/Application/types.ts
CHANGED
|
@@ -68,6 +68,7 @@ export type Context = {
|
|
|
68
68
|
showGrid?: boolean;
|
|
69
69
|
language?: 'vi' | 'en';
|
|
70
70
|
translate?: (key: string) => string;
|
|
71
|
+
appInfo: MiniAppInfo;
|
|
71
72
|
};
|
|
72
73
|
|
|
73
74
|
export type LocalizationObject = {
|
|
@@ -79,11 +80,11 @@ export type LocalizationObject = {
|
|
|
79
80
|
};
|
|
80
81
|
};
|
|
81
82
|
|
|
82
|
-
export type
|
|
83
|
-
[key: string]: any;
|
|
83
|
+
export type MiniAppInfo = {
|
|
84
84
|
feature_code: string;
|
|
85
85
|
app_id: string;
|
|
86
86
|
miniapp_version: number;
|
|
87
|
+
flow_partner_id?: string;
|
|
87
88
|
};
|
|
88
89
|
|
|
89
90
|
export type NavigationContainerProps = {
|
|
@@ -92,7 +93,7 @@ export type NavigationContainerProps = {
|
|
|
92
93
|
theme: Theme;
|
|
93
94
|
maxApi: any;
|
|
94
95
|
localization?: LocalizationObject;
|
|
95
|
-
|
|
96
|
+
appInfo: MiniAppInfo;
|
|
96
97
|
};
|
|
97
98
|
|
|
98
99
|
export type NavigationScreenProps = {
|
package/Application/utils.tsx
CHANGED
|
@@ -13,9 +13,6 @@ import {
|
|
|
13
13
|
import {NavigationOptions, Theme} from './types';
|
|
14
14
|
import {Colors} from '../Consts';
|
|
15
15
|
|
|
16
|
-
/**
|
|
17
|
-
* default options for stack screen
|
|
18
|
-
*/
|
|
19
16
|
const getStackOptions = (): StackNavigationOptions => {
|
|
20
17
|
return {
|
|
21
18
|
headerTitleAlign: 'left',
|
|
@@ -27,9 +24,6 @@ const getStackOptions = (): StackNavigationOptions => {
|
|
|
27
24
|
};
|
|
28
25
|
};
|
|
29
26
|
|
|
30
|
-
/**
|
|
31
|
-
* default options for dialog screen
|
|
32
|
-
*/
|
|
33
27
|
const getDialogOptions = (): StackNavigationOptions => {
|
|
34
28
|
return {
|
|
35
29
|
headerTitleAlign: 'left',
|
|
@@ -41,9 +35,6 @@ const getDialogOptions = (): StackNavigationOptions => {
|
|
|
41
35
|
};
|
|
42
36
|
};
|
|
43
37
|
|
|
44
|
-
/**
|
|
45
|
-
* default options for modal screen
|
|
46
|
-
*/
|
|
47
38
|
const getModalOptions = (): StackNavigationOptions => {
|
|
48
39
|
return {
|
|
49
40
|
headerShown: false,
|
|
@@ -69,9 +60,6 @@ const getModalOptions = (): StackNavigationOptions => {
|
|
|
69
60
|
};
|
|
70
61
|
};
|
|
71
62
|
|
|
72
|
-
/**
|
|
73
|
-
* build react-navigation options
|
|
74
|
-
*/
|
|
75
63
|
const getOptions = (params: NavigationOptions, theme: Theme) => {
|
|
76
64
|
let options = {};
|
|
77
65
|
|
package/Layout/Card.tsx
CHANGED
package/Layout/Section.tsx
CHANGED
|
@@ -22,6 +22,11 @@ export interface SectionProps extends ViewProps {
|
|
|
22
22
|
*/
|
|
23
23
|
useMargin?: boolean;
|
|
24
24
|
|
|
25
|
+
/**
|
|
26
|
+
* Optional. Background color for the Section component.
|
|
27
|
+
*/
|
|
28
|
+
backgroundColor?: string;
|
|
29
|
+
|
|
25
30
|
/**
|
|
26
31
|
* Optional. Background image for the Section component.
|
|
27
32
|
*/
|
|
@@ -31,8 +36,8 @@ export interface SectionProps extends ViewProps {
|
|
|
31
36
|
const Section: React.FC<SectionProps> = ({
|
|
32
37
|
children,
|
|
33
38
|
useMargin = true,
|
|
39
|
+
backgroundColor,
|
|
34
40
|
backgroundImage,
|
|
35
|
-
style,
|
|
36
41
|
}) => {
|
|
37
42
|
const {showGrid} = useContext(ApplicationContext);
|
|
38
43
|
const {numberOfColumns} = useGridSystem();
|
|
@@ -151,16 +156,13 @@ const Section: React.FC<SectionProps> = ({
|
|
|
151
156
|
}}>
|
|
152
157
|
<View
|
|
153
158
|
accessibilityLabel={`Section`}
|
|
154
|
-
style={
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
flexWrap: 'wrap',
|
|
162
|
-
},
|
|
163
|
-
]}>
|
|
159
|
+
style={{
|
|
160
|
+
width: widthSection,
|
|
161
|
+
marginHorizontal: gridContext.margin,
|
|
162
|
+
flexDirection: 'row',
|
|
163
|
+
flexWrap: 'wrap',
|
|
164
|
+
backgroundColor: backgroundColor,
|
|
165
|
+
}}>
|
|
164
166
|
{!!backgroundImage && (
|
|
165
167
|
<Image
|
|
166
168
|
source={{uri: backgroundImage}}
|
package/Layout/index.ts
CHANGED
|
@@ -6,7 +6,6 @@ import {createContext} from 'react';
|
|
|
6
6
|
import {GridContextProps} from './types';
|
|
7
7
|
import Item from './Item';
|
|
8
8
|
import ItemList from './ItemList';
|
|
9
|
-
import ItemSectionList from './ItemSectionList';
|
|
10
9
|
|
|
11
10
|
const GridContext = createContext<GridContextProps>({
|
|
12
11
|
numberOfColumns: 12,
|
|
@@ -24,5 +23,4 @@ export {
|
|
|
24
23
|
validateChildren,
|
|
25
24
|
Item,
|
|
26
25
|
ItemList,
|
|
27
|
-
ItemSectionList,
|
|
28
26
|
};
|
package/Layout/styles.ts
CHANGED
|
@@ -45,7 +45,19 @@ export default StyleSheet.create({
|
|
|
45
45
|
flexDirection: 'row',
|
|
46
46
|
flexWrap: 'wrap',
|
|
47
47
|
borderRadius: Radius.M,
|
|
48
|
+
paddingTop: undefined,
|
|
49
|
+
paddingBottom: undefined,
|
|
50
|
+
paddingLeft: undefined,
|
|
51
|
+
paddingRight: undefined,
|
|
52
|
+
paddingVertical: undefined,
|
|
53
|
+
paddingHorizontal: undefined,
|
|
48
54
|
padding: 12,
|
|
55
|
+
margin: undefined,
|
|
56
|
+
marginTop: undefined,
|
|
57
|
+
marginBottom: undefined,
|
|
58
|
+
marginLeft: undefined,
|
|
59
|
+
marginRight: undefined,
|
|
60
|
+
marginVertical: undefined,
|
|
49
61
|
},
|
|
50
62
|
item: {
|
|
51
63
|
overflow: 'hidden',
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@momo-kits/foundation",
|
|
3
|
-
"version": "0.81.7-beta.
|
|
3
|
+
"version": "0.81.7-beta.5",
|
|
4
4
|
"description": "React Native Component Kits",
|
|
5
5
|
"main": "index.ts",
|
|
6
6
|
"scripts": {
|
|
@@ -43,4 +43,4 @@
|
|
|
43
43
|
},
|
|
44
44
|
"author": "@momo-kits/foundation",
|
|
45
45
|
"license": "ISC"
|
|
46
|
-
}
|
|
46
|
+
}
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
import React, {FC, useContext} from 'react';
|
|
2
|
-
import {SectionList, SectionListProps, View} from 'react-native';
|
|
3
|
-
import Item, {SpanNumber} from './Item';
|
|
4
|
-
import {GridContext} from './index';
|
|
5
|
-
import styles from './styles';
|
|
6
|
-
|
|
7
|
-
export interface ItemSectionListProps extends SectionListProps<any> {
|
|
8
|
-
/**
|
|
9
|
-
* Represents the width of the Card component in terms of span numbers (1-12).
|
|
10
|
-
*/
|
|
11
|
-
widthSpan?: SpanNumber;
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
const ItemSectionList: FC<ItemSectionListProps> = ({
|
|
15
|
-
renderItem,
|
|
16
|
-
widthSpan,
|
|
17
|
-
style,
|
|
18
|
-
contentContainerStyle,
|
|
19
|
-
...props
|
|
20
|
-
}) => {
|
|
21
|
-
const {gutterSize, numberOfColumns} = useContext(GridContext);
|
|
22
|
-
const widthItem = (widthSpan ?? numberOfColumns) as SpanNumber;
|
|
23
|
-
const _renderItem = (item: any) => {
|
|
24
|
-
return <Item widthSpan={widthItem}>{renderItem?.(item)}</Item>;
|
|
25
|
-
};
|
|
26
|
-
|
|
27
|
-
return (
|
|
28
|
-
<SectionList
|
|
29
|
-
{...props}
|
|
30
|
-
renderItem={_renderItem}
|
|
31
|
-
horizontal={false}
|
|
32
|
-
ItemSeparatorComponent={() => <View style={{height: gutterSize}} />}
|
|
33
|
-
style={[style, styles.protectedStyle]}
|
|
34
|
-
contentContainerStyle={[contentContainerStyle, styles.protectedStyle]}
|
|
35
|
-
/>
|
|
36
|
-
);
|
|
37
|
-
};
|
|
38
|
-
|
|
39
|
-
export default ItemSectionList;
|