@momo-kits/foundation 0.89.2 → 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.
@@ -104,7 +104,6 @@ const BottomTab: React.FC<BottomTabProps> = ({
104
104
  left: item?.showDot ? 8 : 4,
105
105
  top: item?.showDot ? -2 : -6,
106
106
  },
107
-
108
107
  tabBarIcon: ({color}) => (
109
108
  <Icon source={item.icon} color={color} size={28} />
110
109
  ),
@@ -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, NativeModules} from 'react-native';
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 [language, setLanguage] = useState<'vi' | 'en'>('vi');
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
- try {
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
@@ -67,7 +67,6 @@ export type Context = {
67
67
  theme: Theme;
68
68
  navigator?: Navigator;
69
69
  showGrid?: boolean;
70
- language?: 'vi' | 'en';
71
70
  translate?: (key: string) => string;
72
71
  };
73
72
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@momo-kits/foundation",
3
- "version": "0.89.2",
3
+ "version": "0.89.3",
4
4
  "description": "React Native Component Kits",
5
5
  "main": "index.ts",
6
6
  "scripts": {