@momo-kits/foundation 0.81.33 → 0.81.34
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 +24 -11
- package/Application/Components.tsx +3 -2
- package/Application/NavigationContainer.tsx +17 -16
- package/Application/types.ts +1 -0
- package/Application/utils.tsx +1 -23
- package/Badge/Badge.tsx +1 -1
- package/Badge/types.ts +3 -5
- package/Button/index.tsx +2 -3
- package/Button/styles.ts +4 -0
- package/Consts/theme.ts +2 -2
- package/Layout/ItemList.tsx +0 -7
- package/Layout/Screen.tsx +3 -2
- package/package.json +1 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React, {useContext, useEffect} from 'react';
|
|
2
|
-
import {View} from 'react-native';
|
|
2
|
+
import {Platform, StyleSheet, View} from 'react-native';
|
|
3
3
|
import {BottomTabProps, NavigationScreenProps} from './types';
|
|
4
4
|
import {createBottomTabNavigator} from '@react-navigation/bottom-tabs';
|
|
5
5
|
import {createStackNavigator} from '@react-navigation/stack';
|
|
@@ -8,6 +8,8 @@ import {Text} from '../Text';
|
|
|
8
8
|
import {ApplicationContext} from './index';
|
|
9
9
|
import {getStackOptions} from './utils';
|
|
10
10
|
import StackScreen from './StackScreen';
|
|
11
|
+
import {Spacing} from '../Consts';
|
|
12
|
+
import {useSafeAreaInsets} from 'react-native-safe-area-context';
|
|
11
13
|
|
|
12
14
|
const Tab = createBottomTabNavigator();
|
|
13
15
|
const Stack = createStackNavigator();
|
|
@@ -31,6 +33,7 @@ const BottomTab: React.FC<BottomTabProps> = ({
|
|
|
31
33
|
initialRouteName,
|
|
32
34
|
}) => {
|
|
33
35
|
const {theme} = useContext(ApplicationContext);
|
|
36
|
+
const insets = useSafeAreaInsets();
|
|
34
37
|
|
|
35
38
|
useEffect(() => {
|
|
36
39
|
navigation?.setOptions({
|
|
@@ -43,7 +46,16 @@ const BottomTab: React.FC<BottomTabProps> = ({
|
|
|
43
46
|
return (
|
|
44
47
|
<Tab.Navigator
|
|
45
48
|
initialRouteName={initialRouteName}
|
|
46
|
-
backBehavior={'firstRoute'}
|
|
49
|
+
backBehavior={'firstRoute'}
|
|
50
|
+
tabBarOptions={{
|
|
51
|
+
style: {
|
|
52
|
+
height: 68 + insets.bottom,
|
|
53
|
+
},
|
|
54
|
+
tabStyle: {
|
|
55
|
+
height: 68,
|
|
56
|
+
paddingVertical: 8,
|
|
57
|
+
},
|
|
58
|
+
}}>
|
|
47
59
|
{tabs.map(item => {
|
|
48
60
|
return (
|
|
49
61
|
<Tab.Screen
|
|
@@ -55,14 +67,12 @@ const BottomTab: React.FC<BottomTabProps> = ({
|
|
|
55
67
|
options={{
|
|
56
68
|
tabBarLabel: ({color, focused}) => {
|
|
57
69
|
return (
|
|
58
|
-
<
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
</Text>
|
|
65
|
-
</View>
|
|
70
|
+
<Text
|
|
71
|
+
numberOfLines={1}
|
|
72
|
+
typography={focused ? 'label_xs' : 'description_xs'}
|
|
73
|
+
color={color}>
|
|
74
|
+
{item.label}
|
|
75
|
+
</Text>
|
|
66
76
|
);
|
|
67
77
|
},
|
|
68
78
|
tabBarBadge: item?.badgeLabel,
|
|
@@ -70,11 +80,14 @@ const BottomTab: React.FC<BottomTabProps> = ({
|
|
|
70
80
|
borderColor: 'white',
|
|
71
81
|
borderWidth: 2,
|
|
72
82
|
fontSize: 10,
|
|
73
|
-
lineHeight: 14,
|
|
83
|
+
lineHeight: Platform.OS === 'android' ? 17 : 14,
|
|
74
84
|
fontWeight: 'bold',
|
|
75
85
|
alignSelf: 'center',
|
|
76
86
|
fontFamily: `${theme.font}-Bold`,
|
|
87
|
+
left: item?.showDot ? 8 : 4,
|
|
88
|
+
top: item?.showDot ? -2 : -6,
|
|
77
89
|
},
|
|
90
|
+
|
|
78
91
|
tabBarIcon: ({color}) => (
|
|
79
92
|
<Icon source={item.icon} color={color} size={28} />
|
|
80
93
|
),
|
|
@@ -242,8 +242,9 @@ const HeaderBackground: React.FC<HeaderBackgroundProps> = ({
|
|
|
242
242
|
animatedValue,
|
|
243
243
|
useBorder = false,
|
|
244
244
|
}) => {
|
|
245
|
-
const {theme} = useContext(ApplicationContext);
|
|
246
|
-
let headerImage =
|
|
245
|
+
const {theme, config} = useContext(ApplicationContext);
|
|
246
|
+
let headerImage =
|
|
247
|
+
config?.navigationBar?.headerBar ?? theme.assets?.headerBackground;
|
|
247
248
|
if (image === null) {
|
|
248
249
|
headerImage = undefined;
|
|
249
250
|
}
|
|
@@ -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
10
|
import StackScreen from './StackScreen';
|
|
10
11
|
import ModalScreen from './ModalScreen';
|
|
11
12
|
import Navigator from './Navigator';
|
|
12
13
|
import {getDialogOptions, getModalOptions, getStackOptions} from './utils';
|
|
13
14
|
import {LocalizationObject, NavigationContainerProps} from './types';
|
|
14
15
|
import {ApplicationContext} from './index';
|
|
15
|
-
import {DeviceEventEmitter} from 'react-native';
|
|
16
16
|
import kitLocalization from '../Assets/language.json';
|
|
17
17
|
|
|
18
18
|
const Stack = createStackNavigator();
|
|
@@ -29,24 +29,11 @@ const NavigationContainer: React.FC<NavigationContainerProps> = ({
|
|
|
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
|
-
|
|
33
|
-
/**
|
|
34
|
-
* engine only shake to enable grid view
|
|
35
|
-
*/
|
|
36
|
-
useEffect(() => {
|
|
37
|
-
const subscription = DeviceEventEmitter.addListener(
|
|
38
|
-
'onChangeGrid',
|
|
39
|
-
enable => {
|
|
40
|
-
setShowGrid(!!enable);
|
|
41
|
-
},
|
|
42
|
-
);
|
|
43
|
-
return () => {
|
|
44
|
-
subscription?.remove?.();
|
|
45
|
-
};
|
|
46
|
-
}, []);
|
|
32
|
+
const [config, setConfig] = useState(undefined);
|
|
47
33
|
|
|
48
34
|
/**
|
|
49
35
|
* handle mini language & listen change
|
|
36
|
+
* engine only shake to enable grid view
|
|
50
37
|
*/
|
|
51
38
|
useEffect(() => {
|
|
52
39
|
maxApi?.getLanguage?.((lang: 'vi' | 'en') => {
|
|
@@ -55,8 +42,21 @@ const NavigationContainer: React.FC<NavigationContainerProps> = ({
|
|
|
55
42
|
const listener = maxApi?.observer?.('language', (lang: 'vi' | 'en') => {
|
|
56
43
|
setLanguage(lang);
|
|
57
44
|
});
|
|
45
|
+
const subscription = DeviceEventEmitter.addListener(
|
|
46
|
+
'onChangeGrid',
|
|
47
|
+
enable => {
|
|
48
|
+
setShowGrid(!!enable);
|
|
49
|
+
},
|
|
50
|
+
);
|
|
51
|
+
try {
|
|
52
|
+
const result = JSON.parse(
|
|
53
|
+
NativeModules?.ConfigsModule?.getConfigSync?.('DESIGN_SYSTEM'),
|
|
54
|
+
);
|
|
55
|
+
setConfig(result);
|
|
56
|
+
} catch (e) {}
|
|
58
57
|
return () => {
|
|
59
58
|
listener?.remove?.();
|
|
59
|
+
subscription?.remove?.();
|
|
60
60
|
};
|
|
61
61
|
}, []);
|
|
62
62
|
|
|
@@ -87,6 +87,7 @@ const NavigationContainer: React.FC<NavigationContainerProps> = ({
|
|
|
87
87
|
navigator: navigator.current,
|
|
88
88
|
showGrid,
|
|
89
89
|
language,
|
|
90
|
+
config,
|
|
90
91
|
translate,
|
|
91
92
|
}}>
|
|
92
93
|
<ReactNavigationContainer
|
package/Application/types.ts
CHANGED
package/Application/utils.tsx
CHANGED
|
@@ -12,11 +12,6 @@ import {
|
|
|
12
12
|
} from './Components';
|
|
13
13
|
import {NavigationOptions, Theme} from './types';
|
|
14
14
|
import {Colors} from '../Consts';
|
|
15
|
-
import {NativeModules} from 'react-native';
|
|
16
|
-
|
|
17
|
-
let config: {
|
|
18
|
-
[key: string]: any;
|
|
19
|
-
};
|
|
20
15
|
|
|
21
16
|
/**
|
|
22
17
|
* default options for stack screen
|
|
@@ -137,21 +132,4 @@ const getOptions = (params: NavigationOptions, theme: Theme) => {
|
|
|
137
132
|
};
|
|
138
133
|
};
|
|
139
134
|
|
|
140
|
-
|
|
141
|
-
if (!config) {
|
|
142
|
-
try {
|
|
143
|
-
config = JSON.parse(
|
|
144
|
-
NativeModules?.ConfigsModule?.getConfigSync?.('DESIGN_SYSTEM'),
|
|
145
|
-
);
|
|
146
|
-
} catch (e) {}
|
|
147
|
-
}
|
|
148
|
-
return config;
|
|
149
|
-
};
|
|
150
|
-
|
|
151
|
-
export {
|
|
152
|
-
getStackOptions,
|
|
153
|
-
getDialogOptions,
|
|
154
|
-
getModalOptions,
|
|
155
|
-
getOptions,
|
|
156
|
-
getThemeConfig,
|
|
157
|
-
};
|
|
135
|
+
export {getStackOptions, getDialogOptions, getModalOptions, getOptions};
|
package/Badge/Badge.tsx
CHANGED
|
@@ -4,7 +4,7 @@ import {View} from 'react-native';
|
|
|
4
4
|
import {ApplicationContext} from '../Application';
|
|
5
5
|
import {BadgeProps} from './types';
|
|
6
6
|
import styles from './styles';
|
|
7
|
-
import {Colors
|
|
7
|
+
import {Colors} from '../Consts';
|
|
8
8
|
import {Text} from '../Text';
|
|
9
9
|
|
|
10
10
|
const Badge: FC<BadgeProps> = ({label = 'Label', style, backgroundColor}) => {
|
package/Badge/types.ts
CHANGED
|
@@ -1,10 +1,5 @@
|
|
|
1
1
|
import {ViewStyle} from 'react-native';
|
|
2
2
|
|
|
3
|
-
/**
|
|
4
|
-
* Defines the types of badges that can be used. This helps in rendering the appropriate badge style.
|
|
5
|
-
*/
|
|
6
|
-
export type BadgeType = 'badge' | 'badge_number' | 'dot' | 'dot_small';
|
|
7
|
-
|
|
8
3
|
/**
|
|
9
4
|
* Props for a general Badge component. It can display a wide range of badges including simple labels, numbers, or dots.
|
|
10
5
|
*/
|
|
@@ -19,6 +14,9 @@ export type BadgeProps = {
|
|
|
19
14
|
*/
|
|
20
15
|
style?: ViewStyle | ViewStyle[];
|
|
21
16
|
|
|
17
|
+
/**
|
|
18
|
+
* Optional. Custom background badge.
|
|
19
|
+
*/
|
|
22
20
|
backgroundColor?: string;
|
|
23
21
|
};
|
|
24
22
|
|
package/Button/index.tsx
CHANGED
|
@@ -15,7 +15,6 @@ import {Colors, Spacing} from '../Consts';
|
|
|
15
15
|
import styles from './styles';
|
|
16
16
|
import {Icon} from '../Icon';
|
|
17
17
|
import {Loader} from '../Loader';
|
|
18
|
-
import {getThemeConfig} from '../Application/utils';
|
|
19
18
|
|
|
20
19
|
const AnimationLinear = Animated.createAnimatedComponent(LinearGradient);
|
|
21
20
|
|
|
@@ -85,8 +84,8 @@ const Button: FC<ButtonProps> = ({
|
|
|
85
84
|
onPress,
|
|
86
85
|
...rest
|
|
87
86
|
}) => {
|
|
88
|
-
const {theme} = useContext(ApplicationContext);
|
|
89
|
-
const {gradient, color} =
|
|
87
|
+
const {theme, config} = useContext(ApplicationContext);
|
|
88
|
+
const {gradient, color} = config?.navigationBar?.buttonColors ?? {};
|
|
90
89
|
let gradientPros;
|
|
91
90
|
if (gradient?.length > 0 && type == 'primary') {
|
|
92
91
|
gradientPros = {
|
package/Button/styles.ts
CHANGED
package/Consts/theme.ts
CHANGED
|
@@ -4,7 +4,7 @@ import {Colors} from './colors+spacing+radius';
|
|
|
4
4
|
const defaultTheme: Theme = {
|
|
5
5
|
dark: false,
|
|
6
6
|
colors: {
|
|
7
|
-
primary:
|
|
7
|
+
primary: Colors.pink_03,
|
|
8
8
|
secondary: Colors.pink_07,
|
|
9
9
|
background: {
|
|
10
10
|
default: '#f2f2f6',
|
|
@@ -53,7 +53,7 @@ const defaultTheme: Theme = {
|
|
|
53
53
|
font: 'SFProText',
|
|
54
54
|
assets: {
|
|
55
55
|
headerBackground:
|
|
56
|
-
'https://static.momocdn.net/app/img/
|
|
56
|
+
'https://static.momocdn.net/app/img/app/img/header-background.png',
|
|
57
57
|
},
|
|
58
58
|
};
|
|
59
59
|
|
package/Layout/ItemList.tsx
CHANGED
|
@@ -5,11 +5,6 @@ import {GridContext} from './index';
|
|
|
5
5
|
import styles from './styles';
|
|
6
6
|
|
|
7
7
|
export interface ItemListProps extends FlatListProps<any> {
|
|
8
|
-
/**
|
|
9
|
-
* Require key support number columns change grid system
|
|
10
|
-
*/
|
|
11
|
-
|
|
12
|
-
key: string;
|
|
13
8
|
/**
|
|
14
9
|
* Represents the width of the Card component in terms of span numbers (1-12).
|
|
15
10
|
*/
|
|
@@ -17,7 +12,6 @@ export interface ItemListProps extends FlatListProps<any> {
|
|
|
17
12
|
}
|
|
18
13
|
|
|
19
14
|
const ItemList: FC<ItemListProps> = ({
|
|
20
|
-
key,
|
|
21
15
|
renderItem,
|
|
22
16
|
widthSpan,
|
|
23
17
|
style,
|
|
@@ -42,7 +36,6 @@ const ItemList: FC<ItemListProps> = ({
|
|
|
42
36
|
return (
|
|
43
37
|
<FlatList
|
|
44
38
|
{...props}
|
|
45
|
-
key={`${key ?? 'ItemList'}${numColumns}}`}
|
|
46
39
|
numColumns={numColumns}
|
|
47
40
|
renderItem={_renderItem}
|
|
48
41
|
horizontal={false}
|
package/Layout/Screen.tsx
CHANGED
|
@@ -101,7 +101,7 @@ const Screen = forwardRef(
|
|
|
101
101
|
ref,
|
|
102
102
|
) => {
|
|
103
103
|
const animatedValue = useRef<Animated.Value | undefined>(undefined);
|
|
104
|
-
const {theme} = useContext(ApplicationContext);
|
|
104
|
+
const {theme, config} = useContext(ApplicationContext);
|
|
105
105
|
const insets = useSafeAreaInsets();
|
|
106
106
|
const heightHeader = useHeaderHeight();
|
|
107
107
|
const currentTint = useRef(Colors.black_01);
|
|
@@ -117,7 +117,8 @@ const Screen = forwardRef(
|
|
|
117
117
|
}
|
|
118
118
|
|
|
119
119
|
if (headerType == 'extended') {
|
|
120
|
-
headerBackground =
|
|
120
|
+
headerBackground =
|
|
121
|
+
config?.navigationBar?.headerBar ?? theme.assets?.headerBackground;
|
|
121
122
|
}
|
|
122
123
|
|
|
123
124
|
useEffect(() => {
|