@momo-kits/foundation 0.81.32 → 0.81.34-beta.1

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.
@@ -1,5 +1,5 @@
1
1
  import React, {useContext, useEffect} from 'react';
2
- import {View} from 'react-native';
2
+ import {Platform} 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,7 @@ import {Text} from '../Text';
8
8
  import {ApplicationContext} from './index';
9
9
  import {getStackOptions} from './utils';
10
10
  import StackScreen from './StackScreen';
11
+ import {useSafeAreaInsets} from 'react-native-safe-area-context';
11
12
 
12
13
  const Tab = createBottomTabNavigator();
13
14
  const Stack = createStackNavigator();
@@ -31,6 +32,7 @@ const BottomTab: React.FC<BottomTabProps> = ({
31
32
  initialRouteName,
32
33
  }) => {
33
34
  const {theme} = useContext(ApplicationContext);
35
+ const insets = useSafeAreaInsets();
34
36
 
35
37
  useEffect(() => {
36
38
  navigation?.setOptions({
@@ -43,7 +45,16 @@ const BottomTab: React.FC<BottomTabProps> = ({
43
45
  return (
44
46
  <Tab.Navigator
45
47
  initialRouteName={initialRouteName}
46
- backBehavior={'firstRoute'}>
48
+ backBehavior={'firstRoute'}
49
+ tabBarOptions={{
50
+ style: {
51
+ height: 68 + Math.min(insets.bottom, 21),
52
+ },
53
+ tabStyle: {
54
+ height: 68,
55
+ paddingVertical: 8,
56
+ },
57
+ }}>
47
58
  {tabs.map(item => {
48
59
  return (
49
60
  <Tab.Screen
@@ -55,14 +66,12 @@ const BottomTab: React.FC<BottomTabProps> = ({
55
66
  options={{
56
67
  tabBarLabel: ({color, focused}) => {
57
68
  return (
58
- <View style={{paddingHorizontal: 16}}>
59
- <Text
60
- numberOfLines={1}
61
- typography={focused ? 'label_xs' : 'description_xs'}
62
- color={color}>
63
- {item.label}
64
- </Text>
65
- </View>
69
+ <Text
70
+ numberOfLines={1}
71
+ typography={focused ? 'label_xs' : 'description_xs'}
72
+ color={color}>
73
+ {item.label}
74
+ </Text>
66
75
  );
67
76
  },
68
77
  tabBarBadge: item?.badgeLabel,
@@ -70,11 +79,14 @@ const BottomTab: React.FC<BottomTabProps> = ({
70
79
  borderColor: 'white',
71
80
  borderWidth: 2,
72
81
  fontSize: 10,
73
- lineHeight: 14,
82
+ lineHeight: Platform.OS === 'android' ? 17 : 14,
74
83
  fontWeight: 'bold',
75
84
  alignSelf: 'center',
76
85
  fontFamily: `${theme.font}-Bold`,
86
+ left: item?.showDot ? 8 : 4,
87
+ top: item?.showDot ? -2 : -6,
77
88
  },
89
+
78
90
  tabBarIcon: ({color}) => (
79
91
  <Icon source={item.icon} color={color} size={28} />
80
92
  ),
@@ -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 = theme.assets?.headerBackground;
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
@@ -63,6 +63,7 @@ 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;
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, Spacing} from '../Consts';
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
@@ -1,10 +1,13 @@
1
1
  import React, {FC, useContext} from 'react';
2
2
  import {
3
+ Animated,
3
4
  StyleSheet,
4
5
  TouchableOpacity,
5
6
  TouchableOpacityProps,
6
7
  View,
7
8
  } from 'react-native';
9
+
10
+ import LinearGradient from 'react-native-linear-gradient';
8
11
  import {ApplicationContext} from '../Application';
9
12
  import {Text} from '../Text';
10
13
  import {Typography} from '../Text/types';
@@ -13,6 +16,8 @@ import styles from './styles';
13
16
  import {Icon} from '../Icon';
14
17
  import {Loader} from '../Loader';
15
18
 
19
+ const AnimationLinear = Animated.createAnimatedComponent(LinearGradient);
20
+
16
21
  export interface ButtonProps extends TouchableOpacityProps {
17
22
  /**
18
23
  * Defines the visual style of the button.
@@ -79,7 +84,16 @@ const Button: FC<ButtonProps> = ({
79
84
  onPress,
80
85
  ...rest
81
86
  }) => {
82
- const {theme} = useContext(ApplicationContext);
87
+ const {theme, config} = useContext(ApplicationContext);
88
+ const {gradient, color} = config?.navigationBar?.buttonColors ?? {};
89
+ let gradientPros;
90
+ if (gradient?.length > 0 && type == 'primary') {
91
+ gradientPros = {
92
+ colors: gradient,
93
+ start: {x: 1, y: 0.5},
94
+ end: {x: 0, y: 0.5},
95
+ };
96
+ }
83
97
  const getSizeStyle = () => {
84
98
  const styleSheet: {[key: string]: any} = styles;
85
99
  return styleSheet[size ?? 'small'];
@@ -103,7 +117,7 @@ const Button: FC<ButtonProps> = ({
103
117
  return {
104
118
  backgroundColor: theme.colors.background.surface,
105
119
  borderWidth: 1,
106
- borderColor: theme.colors.primary,
120
+ borderColor: color ?? theme.colors.primary,
107
121
  };
108
122
  case 'tonal':
109
123
  return {
@@ -178,13 +192,13 @@ const Button: FC<ButtonProps> = ({
178
192
  case 'secondary':
179
193
  return theme.colors.text.default;
180
194
  case 'outline':
181
- return theme.colors.primary;
195
+ return color ?? theme.colors.primary;
182
196
  case 'tonal':
183
197
  return theme.colors.primary;
184
198
  case 'danger':
185
199
  return Colors.black_01;
186
200
  case 'text':
187
- return theme.colors.primary;
201
+ return color ?? theme.colors.primary;
188
202
  default:
189
203
  return Colors.black_01;
190
204
  }
@@ -286,6 +300,10 @@ const Button: FC<ButtonProps> = ({
286
300
  {renderLeading()}
287
301
  {renderTitle()}
288
302
  {renderTrailing()}
303
+ {gradientPros && (
304
+ <AnimationLinear {...gradientPros} style={styles.gradientView} />
305
+ )}
306
+ {gradientPros && <View style={styles.strokeView} />}
289
307
  </TouchableOpacity>
290
308
  );
291
309
  };
package/Button/styles.ts CHANGED
@@ -38,4 +38,23 @@ export default StyleSheet.create({
38
38
  alignItems: 'center',
39
39
  justifyContent: 'center',
40
40
  },
41
+ gradientView: {
42
+ position: 'absolute',
43
+ zIndex: -1,
44
+ borderRadius: 8,
45
+ top: 0,
46
+ bottom: 0,
47
+ left: 0,
48
+ right: 0,
49
+ },
50
+ strokeView: {
51
+ position: 'absolute',
52
+ top: 2,
53
+ bottom: 2,
54
+ left: 2,
55
+ right: 2,
56
+ borderRadius: 6,
57
+ borderWidth: 0.5,
58
+ borderColor: '#FFF9E1',
59
+ },
41
60
  });
@@ -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 = theme.assets?.headerBackground;
120
+ headerBackground =
121
+ config?.navigationBar?.headerBar ?? theme.assets?.headerBackground;
121
122
  }
122
123
 
123
124
  useEffect(() => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@momo-kits/foundation",
3
- "version": "0.81.32",
3
+ "version": "0.81.34-beta.1",
4
4
  "description": "React Native Component Kits",
5
5
  "main": "index.ts",
6
6
  "scripts": {