@momo-kits/foundation 0.89.1-rc.7 → 0.89.3
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/BottomTab.tsx +0 -1
- package/Application/NavigationContainer.tsx +9 -28
- package/Application/types.ts +0 -1
- package/Icon/index.tsx +5 -1
- package/Icon/types.ts +1 -1
- package/package.json +2 -2
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React, {useEffect, useRef, useState} from 'react';
|
|
1
|
+
import React, {useContext, useEffect, useRef, useState} from 'react';
|
|
2
2
|
import {BottomSheetModalProvider} from '@gorhom/bottom-sheet';
|
|
3
3
|
import {SafeAreaProvider} from 'react-native-safe-area-context';
|
|
4
4
|
import {
|
|
@@ -6,13 +6,13 @@ import {
|
|
|
6
6
|
NavigationContainerRef,
|
|
7
7
|
} from '@react-navigation/native';
|
|
8
8
|
import {createStackNavigator} from '@react-navigation/stack';
|
|
9
|
-
import {DeviceEventEmitter
|
|
9
|
+
import {DeviceEventEmitter} from 'react-native';
|
|
10
10
|
import StackScreen from './StackScreen';
|
|
11
11
|
import ModalScreen from './ModalScreen';
|
|
12
12
|
import Navigator from './Navigator';
|
|
13
13
|
import {getDialogOptions, getModalOptions, getStackOptions} from './utils';
|
|
14
14
|
import {LocalizationObject, NavigationContainerProps} from './types';
|
|
15
|
-
import {ApplicationContext} from './index';
|
|
15
|
+
import {ApplicationContext, MiniAppContext} from './index';
|
|
16
16
|
import kitLocalization from '../Assets/language.json';
|
|
17
17
|
|
|
18
18
|
const Stack = createStackNavigator();
|
|
@@ -24,41 +24,25 @@ const NavigationContainer: React.FC<NavigationContainerProps> = ({
|
|
|
24
24
|
maxApi,
|
|
25
25
|
localization,
|
|
26
26
|
}) => {
|
|
27
|
+
const context = useContext(MiniAppContext);
|
|
27
28
|
const navigationRef = React.useRef<NavigationContainerRef>(null);
|
|
28
29
|
const navigator = useRef(new Navigator(navigationRef));
|
|
29
30
|
const [showGrid, setShowGrid] = useState(false);
|
|
30
|
-
const
|
|
31
|
-
const [config, setConfig] = useState<any>(undefined);
|
|
32
|
-
let assets = theme.assets;
|
|
33
|
-
if (config && theme.assets?.headerBackground) {
|
|
34
|
-
assets = {...assets, headerBackground: config.navigationBar?.headerBar};
|
|
35
|
-
}
|
|
31
|
+
const config = useRef<any>();
|
|
36
32
|
|
|
37
33
|
/**
|
|
38
34
|
* handle mini language & listen change
|
|
39
35
|
* engine only shake to enable grid view
|
|
40
36
|
*/
|
|
41
37
|
useEffect(() => {
|
|
42
|
-
maxApi?.getLanguage?.((lang: 'vi' | 'en') => {
|
|
43
|
-
setLanguage(lang);
|
|
44
|
-
});
|
|
45
|
-
const listener = maxApi?.observer?.('language', (lang: 'vi' | 'en') => {
|
|
46
|
-
setLanguage(lang);
|
|
47
|
-
});
|
|
48
38
|
const subscription = DeviceEventEmitter.addListener(
|
|
49
39
|
'onChangeGrid',
|
|
50
40
|
enable => {
|
|
51
41
|
setShowGrid(!!enable);
|
|
52
42
|
},
|
|
53
43
|
);
|
|
54
|
-
|
|
55
|
-
const result = JSON.parse(
|
|
56
|
-
NativeModules?.ConfigsModule?.getConfigSync?.('DESIGN_SYSTEM'),
|
|
57
|
-
);
|
|
58
|
-
setConfig(result);
|
|
59
|
-
} catch (e) {}
|
|
44
|
+
|
|
60
45
|
return () => {
|
|
61
|
-
listener?.remove?.();
|
|
62
46
|
subscription?.remove?.();
|
|
63
47
|
};
|
|
64
48
|
}, []);
|
|
@@ -73,6 +57,7 @@ const NavigationContainer: React.FC<NavigationContainerProps> = ({
|
|
|
73
57
|
* @param key
|
|
74
58
|
*/
|
|
75
59
|
const translate = (key: string) => {
|
|
60
|
+
const language: 'vi' | 'en' = context?.language ?? 'vi';
|
|
76
61
|
const mergedLocalization: LocalizationObject = {
|
|
77
62
|
vi: {...localization?.vi, ...kitLocalization.vi},
|
|
78
63
|
en: {...localization?.en, ...kitLocalization.en},
|
|
@@ -85,14 +70,10 @@ const NavigationContainer: React.FC<NavigationContainerProps> = ({
|
|
|
85
70
|
<BottomSheetModalProvider>
|
|
86
71
|
<ApplicationContext.Provider
|
|
87
72
|
value={{
|
|
88
|
-
theme: {
|
|
89
|
-
...theme,
|
|
90
|
-
assets: assets,
|
|
91
|
-
},
|
|
92
73
|
navigator: navigator.current,
|
|
74
|
+
config: config.current,
|
|
75
|
+
theme,
|
|
93
76
|
showGrid,
|
|
94
|
-
language,
|
|
95
|
-
config,
|
|
96
77
|
translate,
|
|
97
78
|
}}>
|
|
98
79
|
<ReactNavigationContainer
|
package/Application/types.ts
CHANGED
package/Icon/index.tsx
CHANGED
|
@@ -18,12 +18,16 @@ const Icon: React.FC<IconProps> = ({source, size, color, style = {}}) => {
|
|
|
18
18
|
return {uri: source};
|
|
19
19
|
};
|
|
20
20
|
|
|
21
|
+
const tintColorProps = color !== null && {
|
|
22
|
+
tintColor: color ?? theme.colors.text.default
|
|
23
|
+
}
|
|
24
|
+
|
|
21
25
|
return (
|
|
22
26
|
<Image
|
|
23
27
|
loading={false}
|
|
24
28
|
source={getIconSource()}
|
|
25
29
|
style={[style, {width: size, height: size}]}
|
|
26
|
-
|
|
30
|
+
{...tintColorProps}
|
|
27
31
|
/>
|
|
28
32
|
);
|
|
29
33
|
};
|
package/Icon/types.ts
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@momo-kits/foundation",
|
|
3
|
-
"version": "0.89.
|
|
3
|
+
"version": "0.89.3",
|
|
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
|
+
}
|