@momo-kits/foundation 0.81.1-beta.6 → 0.81.1-optimize.11
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 +238 -0
- package/Application/BottomTab/BottomTabBar.tsx +291 -0
- package/Application/BottomTab/index.tsx +138 -0
- package/Application/Components.tsx +274 -211
- package/Application/ModalScreen.tsx +10 -226
- package/Application/Navigation.ts +17 -6
- package/Application/NavigationContainer.tsx +66 -65
- package/Application/Navigator.ts +106 -53
- package/Application/StackScreen.tsx +123 -28
- package/Application/index.ts +15 -9
- package/Application/types.ts +56 -31
- package/Application/utils.tsx +36 -6
- 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 +60 -24
- package/Button/styles.ts +19 -0
- package/CheckBox/index.tsx +37 -27
- package/CheckBox/types.ts +5 -3
- package/Consts/colors+spacing+radius.ts +17 -3
- package/Icon/index.tsx +14 -9
- package/Icon/types.ts +4 -3
- package/IconButton/index.tsx +24 -15
- package/Image/index.tsx +61 -55
- package/Image/styles.ts +1 -9
- package/Image/types.ts +5 -1
- package/Input/Input.tsx +102 -25
- package/Input/InputDropDown.tsx +32 -23
- package/Input/InputMoney.tsx +67 -18
- package/Input/InputOTP.tsx +194 -148
- package/Input/InputSearch.tsx +72 -36
- package/Input/InputTextArea.tsx +33 -18
- package/Input/common.tsx +25 -16
- package/Input/index.tsx +62 -16
- package/Input/styles.ts +5 -8
- package/Layout/Card.tsx +20 -11
- package/Layout/FloatingButton.tsx +168 -0
- package/Layout/GridSystem.tsx +1 -2
- package/Layout/Item.tsx +0 -1
- package/Layout/ItemList.tsx +39 -40
- package/Layout/ItemSectionList.tsx +39 -0
- package/Layout/Screen.tsx +151 -65
- package/Layout/Section.tsx +17 -19
- package/Layout/index.ts +2 -1
- package/Layout/styles.ts +20 -15
- package/Layout/types.ts +2 -5
- package/Layout/utils.ts +2 -2
- package/Pagination/PaginationNumber.tsx +1 -1
- package/Pagination/PaginationScroll.tsx +0 -1
- package/Popup/PopupNotify.tsx +105 -37
- package/Popup/PopupPromotion.tsx +44 -9
- package/Popup/types.ts +12 -9
- package/Radio/index.tsx +35 -21
- package/Radio/types.ts +5 -3
- 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 +172 -63
- package/Title/styles.ts +48 -15
- package/Title/types.ts +16 -47
- package/code-scanner.js +131 -39
- package/index.ts +9 -0
- package/migrate_typo.js +56 -0
- package/package.json +8 -8
- package/verify.js +24 -6
- package/Application/BottomTab.tsx +0 -65
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
|
|
|
@@ -1,52 +1,147 @@
|
|
|
1
|
-
import React, {useContext, useEffect, useLayoutEffect} from 'react';
|
|
1
|
+
import React, {useContext, useEffect, useLayoutEffect, useRef} from 'react';
|
|
2
2
|
import {ScreenParams} from './types';
|
|
3
3
|
import Navigation from './Navigation';
|
|
4
|
-
import {ApplicationContext} from './index';
|
|
4
|
+
import {ApplicationContext, MiniAppContext, ScreenContext} from './index';
|
|
5
5
|
import {GridSystem} from '../Layout';
|
|
6
|
-
|
|
7
|
-
|
|
6
|
+
import {useHeaderHeight} from '@react-navigation/stack';
|
|
7
|
+
import {Alert, InteractionManager} from 'react-native';
|
|
8
8
|
|
|
9
9
|
const StackScreen: React.FC<ScreenParams> = props => {
|
|
10
|
-
const {
|
|
11
|
-
const
|
|
10
|
+
const {theme, showGrid, navigator} = useContext(ApplicationContext);
|
|
11
|
+
const startTime = useRef(Date.now());
|
|
12
|
+
const endTime = useRef(Date.now());
|
|
13
|
+
const timeLoad = useRef(0);
|
|
14
|
+
const timeInteraction = useRef(0);
|
|
15
|
+
const timeoutLoad = useRef<any>();
|
|
16
|
+
const tracked = useRef<any>({
|
|
17
|
+
releaseLoad: undefined,
|
|
18
|
+
releaseInteraction: undefined,
|
|
19
|
+
timeoutLoad: undefined,
|
|
20
|
+
timeoutInteraction: undefined,
|
|
21
|
+
});
|
|
22
|
+
const interaction = useRef<any>();
|
|
23
|
+
const context = useContext<any>(MiniAppContext);
|
|
24
|
+
|
|
25
|
+
const {screen: Component, options, initialParams} = props.route.params;
|
|
12
26
|
const navigation = new Navigation(props.navigation, theme);
|
|
27
|
+
const heightHeader = useHeaderHeight();
|
|
13
28
|
|
|
14
|
-
const
|
|
29
|
+
const data = {
|
|
30
|
+
...initialParams,
|
|
15
31
|
...props.route.params,
|
|
16
32
|
navigation,
|
|
17
33
|
};
|
|
18
34
|
|
|
19
|
-
delete
|
|
35
|
+
delete data.screen;
|
|
36
|
+
delete data.initialParams;
|
|
20
37
|
|
|
21
|
-
const
|
|
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
|
-
|
|
28
|
-
useEffect(() => {
|
|
29
|
-
if (appInfo) {
|
|
30
|
-
navigator?.maxApi?.trackEvent('service_frame_displayed', {
|
|
31
|
-
...appInfo,
|
|
32
|
-
screen_name: Component.name,
|
|
33
|
-
pre_screen_name,
|
|
34
|
-
trigger_id: TRIGGER_ID,
|
|
35
|
-
});
|
|
36
|
-
}
|
|
37
|
-
}, []);
|
|
38
|
+
const screenName = Component?.name || Component?.type?.name || 'Invalid';
|
|
38
39
|
|
|
40
|
+
/**
|
|
41
|
+
* set options for screen
|
|
42
|
+
*/
|
|
39
43
|
useLayoutEffect(() => {
|
|
40
44
|
if (options) {
|
|
41
45
|
navigation.setOptions(options);
|
|
42
46
|
}
|
|
43
47
|
}, [options]);
|
|
44
48
|
|
|
49
|
+
/**
|
|
50
|
+
* tracking for screen
|
|
51
|
+
*/
|
|
52
|
+
useEffect(() => {
|
|
53
|
+
if (__DEV__ && (!screenName || screenName == 'Invalid')) {
|
|
54
|
+
Alert.alert('Design system', `Unvalidated screen name "${screenName}" !`);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
navigator?.maxApi?.of?.({screenName});
|
|
58
|
+
|
|
59
|
+
tracked.current.timeoutLoad = setTimeout(() => {
|
|
60
|
+
onScreenLoad();
|
|
61
|
+
}, 5000);
|
|
62
|
+
tracked.current.timeoutInteraction = setTimeout(() => {
|
|
63
|
+
onScreenInteraction();
|
|
64
|
+
}, 5000);
|
|
65
|
+
|
|
66
|
+
return () => {
|
|
67
|
+
onScreenLoad();
|
|
68
|
+
onScreenInteraction();
|
|
69
|
+
};
|
|
70
|
+
}, []);
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* tracking for screen load
|
|
74
|
+
*/
|
|
75
|
+
const onScreenLoad = () => {
|
|
76
|
+
clearTimeout(tracked.current.timeoutLoad);
|
|
77
|
+
if (!tracked.current?.releaseLoad) {
|
|
78
|
+
context.autoTracking?.({
|
|
79
|
+
appId: context.appId,
|
|
80
|
+
code: context.code,
|
|
81
|
+
buildNumber: context.buildNumber,
|
|
82
|
+
screenName,
|
|
83
|
+
componentName: 'Screen',
|
|
84
|
+
state: 'load',
|
|
85
|
+
duration: timeLoad.current,
|
|
86
|
+
});
|
|
87
|
+
navigator?.maxApi?.showToastDebug?.({
|
|
88
|
+
appId: `auto - ${context.appId}`,
|
|
89
|
+
message: `${screenName} screen_load_time ${timeLoad.current}`,
|
|
90
|
+
});
|
|
91
|
+
tracked.current.releaseLoad = true;
|
|
92
|
+
}
|
|
93
|
+
};
|
|
94
|
+
|
|
95
|
+
/**
|
|
96
|
+
* tracking for screen load
|
|
97
|
+
*/
|
|
98
|
+
const onScreenInteraction = () => {
|
|
99
|
+
clearTimeout(tracked.current.timeoutInteraction);
|
|
100
|
+
if (!tracked.current?.releaseInteraction) {
|
|
101
|
+
context.autoTracking?.({
|
|
102
|
+
appId: context.appId,
|
|
103
|
+
code: context.code,
|
|
104
|
+
buildNumber: context.buildNumber,
|
|
105
|
+
screenName,
|
|
106
|
+
componentName: 'Screen',
|
|
107
|
+
state: 'interaction',
|
|
108
|
+
duration: timeInteraction.current - timeLoad.current,
|
|
109
|
+
});
|
|
110
|
+
|
|
111
|
+
navigator?.maxApi?.showToastDebug?.({
|
|
112
|
+
appId: `auto - ${context.appId}`,
|
|
113
|
+
message: `${screenName} screen_interaction_time ${timeInteraction.current}`,
|
|
114
|
+
});
|
|
115
|
+
tracked.current.releaseInteraction = true;
|
|
116
|
+
}
|
|
117
|
+
};
|
|
118
|
+
|
|
45
119
|
return (
|
|
46
|
-
|
|
47
|
-
|
|
120
|
+
<ScreenContext.Provider
|
|
121
|
+
value={{
|
|
122
|
+
screenName,
|
|
123
|
+
onElementLoad: () => {
|
|
124
|
+
endTime.current = Date.now();
|
|
125
|
+
interaction.current?.cancel?.();
|
|
126
|
+
interaction.current = InteractionManager.runAfterInteractions(() => {
|
|
127
|
+
timeInteraction.current = Date.now() - startTime.current;
|
|
128
|
+
});
|
|
129
|
+
clearTimeout(timeoutLoad.current);
|
|
130
|
+
timeoutLoad.current = setTimeout(() => {
|
|
131
|
+
if (timeLoad.current === 0) {
|
|
132
|
+
timeLoad.current = endTime.current - startTime.current;
|
|
133
|
+
}
|
|
134
|
+
}, 2000);
|
|
135
|
+
},
|
|
136
|
+
}}>
|
|
137
|
+
<Component
|
|
138
|
+
heightHeader={heightHeader}
|
|
139
|
+
{...data}
|
|
140
|
+
onScreenLoad={onScreenLoad}
|
|
141
|
+
onScreenInteraction={onScreenInteraction}
|
|
142
|
+
/>
|
|
48
143
|
{showGrid && <GridSystem />}
|
|
49
|
-
|
|
144
|
+
</ScreenContext.Provider>
|
|
50
145
|
);
|
|
51
146
|
};
|
|
52
147
|
|
package/Application/index.ts
CHANGED
|
@@ -1,31 +1,37 @@
|
|
|
1
|
+
import {Platform} from 'react-native';
|
|
1
2
|
import {NavigationContainer} from './NavigationContainer';
|
|
2
3
|
import Screen from '../Layout/Screen';
|
|
3
4
|
import {
|
|
4
|
-
|
|
5
|
-
HeaderTitle,
|
|
6
|
-
HeaderLeft,
|
|
5
|
+
HeaderAnimated,
|
|
7
6
|
HeaderBackground,
|
|
8
|
-
HeaderRightAction,
|
|
9
|
-
HeaderToolkitAction,
|
|
10
7
|
HeaderCustom,
|
|
11
|
-
|
|
8
|
+
HeaderRightAction,
|
|
9
|
+
HeaderTitle,
|
|
10
|
+
NavigationButton,
|
|
12
11
|
} from './Components';
|
|
13
12
|
import BottomTab from './BottomTab';
|
|
14
13
|
import {createContext} from 'react';
|
|
15
14
|
import {defaultContext} from '../Consts';
|
|
16
15
|
|
|
16
|
+
const Context = createContext({});
|
|
17
17
|
const ApplicationContext = createContext(defaultContext);
|
|
18
|
+
|
|
19
|
+
const MiniAppContext = (Platform as any).MiniAppContext ?? createContext({});
|
|
20
|
+
const ScreenContext = (Platform as any).ScreenContext ?? createContext({});
|
|
21
|
+
const ComponentContext = (Platform as any).ComponentContext ?? Context;
|
|
22
|
+
|
|
18
23
|
export {
|
|
19
|
-
NavigationContainer,
|
|
20
24
|
ApplicationContext,
|
|
25
|
+
MiniAppContext,
|
|
26
|
+
ScreenContext,
|
|
27
|
+
ComponentContext,
|
|
28
|
+
NavigationContainer,
|
|
21
29
|
Screen,
|
|
22
30
|
BottomTab,
|
|
23
31
|
NavigationButton,
|
|
24
32
|
HeaderTitle,
|
|
25
|
-
HeaderLeft,
|
|
26
33
|
HeaderBackground,
|
|
27
34
|
HeaderRightAction,
|
|
28
|
-
HeaderToolkitAction,
|
|
29
35
|
HeaderCustom,
|
|
30
36
|
HeaderAnimated,
|
|
31
37
|
};
|
package/Application/types.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import {Animated} from 'react-native';
|
|
2
1
|
import {StackNavigationOptions} from '@react-navigation/stack';
|
|
3
2
|
import React from 'react';
|
|
4
|
-
import
|
|
3
|
+
import {Animated, ViewProps} from 'react-native';
|
|
5
4
|
import {PopupNotifyProps} from '../Popup/types';
|
|
6
5
|
import Navigation from './Navigation';
|
|
6
|
+
import Navigator from './Navigator';
|
|
7
7
|
|
|
8
8
|
type Screen = React.ComponentType<NavigationScreenProps>;
|
|
9
9
|
|
|
@@ -63,12 +63,11 @@ export type Theme = {
|
|
|
63
63
|
};
|
|
64
64
|
|
|
65
65
|
export type Context = {
|
|
66
|
+
[key: string]: any;
|
|
66
67
|
theme: Theme;
|
|
67
68
|
navigator?: Navigator;
|
|
68
69
|
showGrid?: boolean;
|
|
69
|
-
language?: 'vi' | 'en';
|
|
70
70
|
translate?: (key: string) => string;
|
|
71
|
-
appInfo: MiniAppInfo;
|
|
72
71
|
};
|
|
73
72
|
|
|
74
73
|
export type LocalizationObject = {
|
|
@@ -80,20 +79,13 @@ export type LocalizationObject = {
|
|
|
80
79
|
};
|
|
81
80
|
};
|
|
82
81
|
|
|
83
|
-
export type MiniAppInfo = {
|
|
84
|
-
feature_code: string;
|
|
85
|
-
app_id: string;
|
|
86
|
-
build_number: number;
|
|
87
|
-
flow_partner_id?: string;
|
|
88
|
-
};
|
|
89
|
-
|
|
90
82
|
export type NavigationContainerProps = {
|
|
91
83
|
screen: Screen;
|
|
92
84
|
options?: NavigationOptions;
|
|
93
85
|
theme: Theme;
|
|
94
86
|
maxApi: any;
|
|
95
87
|
localization?: LocalizationObject;
|
|
96
|
-
|
|
88
|
+
initialParams?: any;
|
|
97
89
|
};
|
|
98
90
|
|
|
99
91
|
export type NavigationScreenProps = {
|
|
@@ -106,50 +98,75 @@ export type ScreenParams = {
|
|
|
106
98
|
[key: string]: any;
|
|
107
99
|
screen: Screen;
|
|
108
100
|
options?: NavigationOptions;
|
|
109
|
-
tracking?: any;
|
|
110
101
|
};
|
|
111
102
|
|
|
112
|
-
export
|
|
103
|
+
export type ModalParams = {
|
|
113
104
|
[key: string]: any;
|
|
114
|
-
|
|
105
|
+
screen: Screen;
|
|
115
106
|
onDismiss?: () => void;
|
|
116
107
|
barrierDismissible?: boolean;
|
|
117
|
-
}
|
|
108
|
+
};
|
|
118
109
|
|
|
119
|
-
export
|
|
110
|
+
export type BottomSheetParams = {
|
|
120
111
|
[key: string]: any;
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
112
|
+
screen: Screen;
|
|
113
|
+
options: {
|
|
114
|
+
title: string;
|
|
115
|
+
surface?: boolean;
|
|
116
|
+
};
|
|
117
|
+
snapPoint?: '30%' | '50%' | '70%' | '90%' | 'content';
|
|
118
|
+
surface?: boolean;
|
|
119
|
+
onDismiss?: (type?: string) => void;
|
|
120
|
+
barrierDismissible?: boolean;
|
|
121
|
+
draggable?: boolean;
|
|
122
|
+
dragOnContent?: boolean;
|
|
123
|
+
useBottomInset?: boolean;
|
|
124
|
+
};
|
|
124
125
|
|
|
125
126
|
export type NavigationButtonProps = {
|
|
126
127
|
icon: string;
|
|
127
128
|
tintColor?: string;
|
|
128
|
-
backgroundColor?: string;
|
|
129
129
|
useBorder?: boolean;
|
|
130
130
|
onPress: () => void;
|
|
131
|
+
badgeType?: 'dot' | 'number';
|
|
132
|
+
badgeValue?: number;
|
|
131
133
|
accessibilityLabel?: string;
|
|
132
134
|
};
|
|
133
135
|
|
|
136
|
+
export type PinnedToolType = {
|
|
137
|
+
key: string;
|
|
138
|
+
badgeValue?: number;
|
|
139
|
+
badgeType?: 'number' | 'dot';
|
|
140
|
+
};
|
|
141
|
+
|
|
142
|
+
export type RuntimeToolType = {
|
|
143
|
+
title: {vi: string; en: string};
|
|
144
|
+
icon: string;
|
|
145
|
+
key: string;
|
|
146
|
+
};
|
|
147
|
+
|
|
134
148
|
export interface NavigationOptions extends StackNavigationOptions {
|
|
135
149
|
preventBack?: PopupNotifyProps;
|
|
136
150
|
onPressLeftHeader?: () => void;
|
|
137
151
|
surface?: boolean;
|
|
138
152
|
hiddenBack?: boolean;
|
|
139
153
|
customTitle?: TitleCustomProps;
|
|
154
|
+
toolkitParams?: {
|
|
155
|
+
pinnedTool?: PinnedToolType;
|
|
156
|
+
runtimeTools?: RuntimeToolType[];
|
|
157
|
+
preventClose?: PopupNotifyProps;
|
|
158
|
+
};
|
|
140
159
|
}
|
|
141
160
|
|
|
142
161
|
export interface HeaderBackProps extends NavigationButtonProps {
|
|
143
162
|
preventBack?: PopupNotifyProps;
|
|
144
163
|
onPressLeftHeader?: () => void;
|
|
145
|
-
accessibilityLabel?: string;
|
|
146
164
|
}
|
|
147
165
|
|
|
148
166
|
export type HeaderBackgroundProps = {
|
|
149
167
|
image?: string | null;
|
|
150
|
-
backgroundColor?: string | null;
|
|
151
168
|
animatedValue?: Animated.Value;
|
|
152
|
-
|
|
169
|
+
useSurface?: boolean;
|
|
153
170
|
};
|
|
154
171
|
|
|
155
172
|
export type TitleCustomProps = {
|
|
@@ -165,37 +182,45 @@ export type TitleCustomProps = {
|
|
|
165
182
|
export type HeaderToolkitProps = {
|
|
166
183
|
[key: string]: any;
|
|
167
184
|
appCode: string;
|
|
168
|
-
|
|
169
|
-
type: string;
|
|
170
|
-
onAction?: (action: string) => void;
|
|
185
|
+
configs: any[];
|
|
171
186
|
};
|
|
172
187
|
|
|
173
|
-
export
|
|
188
|
+
export interface HeaderAnimatedProps extends ViewProps {
|
|
174
189
|
animatedValue: Animated.Value;
|
|
175
190
|
image: string;
|
|
176
|
-
|
|
177
|
-
};
|
|
191
|
+
}
|
|
178
192
|
|
|
179
193
|
export type BottomTabItemProps = {
|
|
180
194
|
name: string;
|
|
181
195
|
label: string;
|
|
182
196
|
icon: string;
|
|
183
197
|
showDot?: boolean;
|
|
184
|
-
badgeLabel?: string;
|
|
198
|
+
badgeLabel?: string | number;
|
|
185
199
|
screen: Screen;
|
|
186
200
|
options: NavigationOptions;
|
|
187
201
|
};
|
|
188
202
|
|
|
189
203
|
export type BottomTabProps = {
|
|
204
|
+
nested?: boolean;
|
|
190
205
|
tabs: BottomTabItemProps[];
|
|
206
|
+
initialRouteName?: string;
|
|
191
207
|
navigation: Navigation;
|
|
192
208
|
listeners?: {
|
|
193
209
|
tabPress?: any;
|
|
194
210
|
focus?: any;
|
|
195
211
|
};
|
|
212
|
+
floatingButton?: FloatingButtonProps;
|
|
213
|
+
};
|
|
214
|
+
|
|
215
|
+
export type FloatingButtonProps = {
|
|
216
|
+
container?: React.ReactNode;
|
|
217
|
+
icon: string | React.ReactNode;
|
|
218
|
+
label: string;
|
|
219
|
+
onPress: () => void;
|
|
196
220
|
};
|
|
197
221
|
|
|
198
222
|
export type AnimatedHeader = {
|
|
199
223
|
type: 'default' | 'surface';
|
|
200
224
|
component?: (props?: any) => React.ReactElement;
|
|
225
|
+
headerTitle?: (props?: any) => React.ReactElement;
|
|
201
226
|
};
|
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
|
|
|
@@ -88,11 +100,7 @@ const getOptions = (params: NavigationOptions, theme: Theme) => {
|
|
|
88
100
|
...options,
|
|
89
101
|
headerTintColor: theme.colors.text.default,
|
|
90
102
|
headerBackground: () => (
|
|
91
|
-
<HeaderBackground
|
|
92
|
-
image={null}
|
|
93
|
-
backgroundColor={theme.colors.background.surface}
|
|
94
|
-
useBorder={true}
|
|
95
|
-
/>
|
|
103
|
+
<HeaderBackground image={null} useSurface={true} />
|
|
96
104
|
),
|
|
97
105
|
};
|
|
98
106
|
} else {
|
|
@@ -114,10 +122,32 @@ const getOptions = (params: NavigationOptions, theme: Theme) => {
|
|
|
114
122
|
};
|
|
115
123
|
}
|
|
116
124
|
|
|
125
|
+
if (params.toolkitParams) {
|
|
126
|
+
options = {
|
|
127
|
+
...options,
|
|
128
|
+
headerRight: (props: any) => {
|
|
129
|
+
return <HeaderToolkitAction {...params.toolkitParams} {...props} />;
|
|
130
|
+
},
|
|
131
|
+
};
|
|
132
|
+
}
|
|
133
|
+
|
|
117
134
|
return {
|
|
118
135
|
...params,
|
|
119
136
|
...options,
|
|
120
137
|
};
|
|
121
138
|
};
|
|
122
139
|
|
|
123
|
-
|
|
140
|
+
const formatNameLength = (name = '') => {
|
|
141
|
+
let formattedName = name;
|
|
142
|
+
if (formattedName.length > 100) {
|
|
143
|
+
formattedName = formattedName.substring(0, 100);
|
|
144
|
+
}
|
|
145
|
+
return formattedName;
|
|
146
|
+
};
|
|
147
|
+
export {
|
|
148
|
+
getStackOptions,
|
|
149
|
+
getDialogOptions,
|
|
150
|
+
getModalOptions,
|
|
151
|
+
getOptions,
|
|
152
|
+
formatNameLength,
|
|
153
|
+
};
|