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