@momo-kits/foundation 0.77.8-beta.5 → 0.77.8-beta.6

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.
@@ -21,10 +21,12 @@ const NavigationContainer: React.FC<NavigationContainerProps> = ({
21
21
  theme,
22
22
  options,
23
23
  maxApi,
24
+ localization,
24
25
  }) => {
25
26
  const navigationRef = React.useRef<NavigationContainerRef>(null);
26
27
  const navigator = useRef(new Navigator(navigationRef));
27
28
  const [showGrid, setShowGrid] = useState(false);
29
+ const [language, setLanguage] = useState<'vi' | 'en'>('vi');
28
30
 
29
31
  useEffect(() => {
30
32
  const subscription = DeviceEventEmitter.addListener(
@@ -38,13 +40,32 @@ const NavigationContainer: React.FC<NavigationContainerProps> = ({
38
40
  };
39
41
  }, []);
40
42
 
43
+ useEffect(() => {
44
+ const listener = maxApi?.observer?.('language', (lang: 'vi' | 'en') => {
45
+ setLanguage(lang);
46
+ });
47
+ return () => {
48
+ listener?.();
49
+ };
50
+ }, []);
51
+
41
52
  navigator.current.maxApi = maxApi;
42
53
 
54
+ const translate = (key: string) => {
55
+ return localization?.[language]?.[key] || '';
56
+ };
57
+
43
58
  return (
44
59
  <SafeAreaProvider>
45
60
  <BottomSheetModalProvider>
46
61
  <ApplicationContext.Provider
47
- value={{theme, navigator: navigator.current, showGrid}}>
62
+ value={{
63
+ theme,
64
+ navigator: navigator.current,
65
+ showGrid,
66
+ language,
67
+ translate,
68
+ }}>
48
69
  <ReactNavigationContainer
49
70
  theme={{
50
71
  ...theme,
@@ -1,5 +1,5 @@
1
- import {Animated, ScrollViewProps, ViewProps} from 'react-native';
2
- import React, {ReactNode} from 'react';
1
+ import {Animated} from 'react-native';
2
+ import React from 'react';
3
3
  import Navigator from './Navigator';
4
4
  import {PopupNotifyProps} from '../Popup/types';
5
5
  import Navigation from './Navigation';
@@ -65,6 +65,17 @@ export type Context = {
65
65
  theme: Theme;
66
66
  navigator?: Navigator;
67
67
  showGrid?: boolean;
68
+ language: 'vi' | 'en';
69
+ translate: (key: string) => string;
70
+ };
71
+
72
+ export type LocalizationObject = {
73
+ vi: {
74
+ [key: string]: string;
75
+ };
76
+ en: {
77
+ [key: string]: string;
78
+ };
68
79
  };
69
80
 
70
81
  export type NavigationContainerProps = {
@@ -72,6 +83,7 @@ export type NavigationContainerProps = {
72
83
  options?: NavigationOptions;
73
84
  theme: Theme;
74
85
  maxApi?: any;
86
+ localization: LocalizationObject;
75
87
  };
76
88
 
77
89
  export type NavigationScreenProps = {
@@ -80,19 +92,6 @@ export type NavigationScreenProps = {
80
92
  navigation: Navigation;
81
93
  };
82
94
 
83
- export interface ScreenProps extends ViewProps {
84
- navigation?: Navigation;
85
- enableKeyboardAvoidingView?: boolean;
86
- headerBackground?: string;
87
- scrollable?: boolean;
88
- useAnimatedHeader?: boolean;
89
- useExtendedHeader?: boolean;
90
- scrollViewProps?: ScrollViewProps;
91
- footerComponent?: ReactNode;
92
- marginHeader?: number;
93
- backgroundColor?: string;
94
- }
95
-
96
95
  export type ScreenParams = {
97
96
  [key: string]: any;
98
97
  screen: Screen;
package/Divider/index.tsx CHANGED
@@ -1,6 +1,7 @@
1
1
  import React, {useContext} from 'react';
2
2
  import {View} from 'react-native';
3
3
  import {ApplicationContext} from '../Application';
4
+ import {Spacing} from '../Consts';
4
5
 
5
6
  const Divider = () => {
6
7
  const {theme} = useContext(ApplicationContext);
@@ -11,6 +12,7 @@ const Divider = () => {
11
12
  height: 1,
12
13
  width: '100%',
13
14
  backgroundColor: theme.colors.border.default,
15
+ marginVertical: Spacing.XS,
14
16
  }}
15
17
  />
16
18
  );
package/Layout/Card.tsx CHANGED
@@ -1,7 +1,7 @@
1
1
  import React, {useContext} from 'react';
2
- import {Dimensions, View} from 'react-native';
2
+ import {Dimensions, View, ViewProps} from 'react-native';
3
3
  import {useGridSystem, validateChildren} from './utils';
4
- import {CardProps, GridContextProps} from './types';
4
+ import {GridContextProps} from './types';
5
5
  import {GridContext, GridSystem} from './index';
6
6
  import Item from './Item';
7
7
  import {Image} from '../Image';
@@ -9,6 +9,13 @@ import {ApplicationContext} from '../Application';
9
9
  import styles from './styles';
10
10
  import {Colors, Spacing} from '../Consts';
11
11
 
12
+ export interface CardProps extends ViewProps {
13
+ /**
14
+ * Optional. Background image for the card.
15
+ */
16
+ backgroundImage?: string;
17
+ }
18
+
12
19
  const Card: React.FC<CardProps> = ({children, style, backgroundImage}) => {
13
20
  const {showGrid} = useContext(ApplicationContext);
14
21
  const {numberOfColumns} = useGridSystem();
package/Layout/Item.tsx CHANGED
@@ -1,11 +1,24 @@
1
1
  import React, {useContext} from 'react';
2
- import {View} from 'react-native';
2
+ import {View, ViewProps} from 'react-native';
3
3
 
4
- import {ItemProps} from './types';
5
4
  import {GridContext} from './index';
6
5
  import {ApplicationContext} from '../Application';
7
6
  import styles from './styles';
8
7
 
8
+ type SpanNumber = 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12;
9
+
10
+ export interface ItemProps extends ViewProps {
11
+ /**
12
+ * Represents the width of the Card component in terms of span numbers (1-12).
13
+ */
14
+ widthSpan?: SpanNumber;
15
+
16
+ /**
17
+ * Optional. Represents the height of the Card component in terms of span numbers (1-12).
18
+ */
19
+ heightSpan?: SpanNumber;
20
+ }
21
+
9
22
  const Item: React.FC<ItemProps> = ({
10
23
  widthSpan,
11
24
  heightSpan,
package/Layout/Screen.tsx CHANGED
@@ -1,13 +1,71 @@
1
- import {Animated, KeyboardAvoidingView, Platform, View} from 'react-native';
1
+ import {
2
+ Animated,
3
+ KeyboardAvoidingView,
4
+ Platform,
5
+ ScrollViewProps,
6
+ View,
7
+ ViewProps,
8
+ } from 'react-native';
2
9
  import {useHeaderHeight} from '@react-navigation/stack';
3
10
  import {useSafeAreaInsets} from 'react-native-safe-area-context';
4
- import React, {useContext, useEffect, useRef} from 'react';
5
- import {ScreenProps} from '../Application/types';
11
+ import React, {ReactNode, useContext, useEffect, useRef} from 'react';
6
12
  import {Spacing, Styles} from '../Consts';
7
13
  import {Card, Section, validateChildren} from './index';
8
14
  import {ApplicationContext, HeaderTitle} from '../Application';
9
15
  import Navigation from '../Application/Navigation';
10
16
 
17
+ export interface ScreenProps extends ViewProps {
18
+ /**
19
+ * Optional. Navigation object for handling navigation actions.
20
+ */
21
+ navigation?: Navigation;
22
+
23
+ /**
24
+ * Optional. If `true`, enable keyboard avoiding view for the screen.
25
+ */
26
+ enableKeyboardAvoidingView?: boolean;
27
+
28
+ /**
29
+ * Optional. Background color of the header.
30
+ */
31
+ headerBackground?: string;
32
+
33
+ /**
34
+ * Optional. If `true`, the screen content is scrollable.
35
+ */
36
+ scrollable?: boolean;
37
+
38
+ /**
39
+ * Optional. If `true`, use an animated header for the screen.
40
+ */
41
+ useAnimatedHeader?: boolean;
42
+
43
+ /**
44
+ * Optional. If `true`, use an extended header for the screen.
45
+ */
46
+ useExtendedHeader?: boolean;
47
+
48
+ /**
49
+ * Optional. Props for the underlying ScrollView component when `scrollable` is `true`.
50
+ */
51
+ scrollViewProps?: ScrollViewProps;
52
+
53
+ /**
54
+ * Optional. ReactNode representing the footer component of the screen.
55
+ */
56
+ footerComponent?: ReactNode;
57
+
58
+ /**
59
+ * Optional. Margin for the header component.
60
+ */
61
+ marginHeader?: number;
62
+
63
+ /**
64
+ * Optional. Background color of the screen.
65
+ */
66
+ backgroundColor?: string;
67
+ }
68
+
11
69
  const Screen: React.FC<ScreenProps> = ({
12
70
  children,
13
71
  enableKeyboardAvoidingView = false,
@@ -1,13 +1,37 @@
1
1
  import React, {useContext} from 'react';
2
- import {Dimensions, View} from 'react-native';
2
+ import {Dimensions, View, ViewProps} from 'react-native';
3
3
  import {useGridSystem, validateChildren} from './utils';
4
- import {GridContextProps, SectionProps} from './types';
4
+ import {GridContextProps} from './types';
5
5
  import {GridContext} from './index';
6
6
  import Item from './Item';
7
7
  import {ApplicationContext} from '../Application';
8
8
  import styles from './styles';
9
9
  import {Image} from '../Image';
10
10
 
11
+ export interface SectionProps extends ViewProps {
12
+ /**
13
+ * Optional. If `true`, the Section component will be displayed in an expanded state.
14
+ * Defaults to `false` if not provided.
15
+ */
16
+ expanded?: boolean;
17
+
18
+ /**
19
+ * Optional. If `true`, margin will be applied to the Section component.
20
+ * Defaults to `false` if not provided.
21
+ */
22
+ useMargin?: boolean;
23
+
24
+ /**
25
+ * Optional. Background color for the Section component.
26
+ */
27
+ backgroundColor?: string;
28
+
29
+ /**
30
+ * Optional. Background image for the Section component.
31
+ */
32
+ backgroundImage?: string;
33
+ }
34
+
11
35
  const Section: React.FC<SectionProps> = ({
12
36
  children,
13
37
  useMargin = true,
@@ -116,7 +140,16 @@ const Section: React.FC<SectionProps> = ({
116
140
  };
117
141
 
118
142
  return (
119
- <GridContext.Provider value={gridContext}>
143
+ <GridContext.Provider
144
+ value={{
145
+ numberOfColumns,
146
+ gutterSize,
147
+ margin,
148
+ sizePerSpan,
149
+ getSizeSpan: span => {
150
+ return span * sizePerSpan + (span - 1) * gutterSize;
151
+ },
152
+ }}>
120
153
  <View
121
154
  accessibilityLabel={`Section`}
122
155
  style={{
package/Layout/types.ts CHANGED
@@ -1,7 +1,3 @@
1
- import {ViewProps} from 'react-native';
2
-
3
- type SpanNumber = 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12;
4
-
5
1
  export type GridContextProps = {
6
2
  /**
7
3
  * Represents the number of columns in the grid.
@@ -28,36 +24,3 @@ export type GridContextProps = {
28
24
  */
29
25
  getSizeSpan: (span: number) => number;
30
26
  };
31
- export interface SectionProps extends ViewProps {
32
- /**
33
- * Optional. If `true`, the Section component will be displayed in an expanded state.
34
- * Defaults to `false` if not provided.
35
- */
36
- expanded?: boolean;
37
-
38
- /**
39
- * Optional. If `true`, margin will be applied to the Section component.
40
- * Defaults to `false` if not provided.
41
- */
42
- useMargin?: boolean;
43
-
44
- backgroundColor?: string;
45
-
46
- backgroundImage?: string;
47
- }
48
-
49
- export interface ItemProps extends ViewProps {
50
- /**
51
- * Represents the width of the Card component in terms of span numbers (1-12).
52
- */
53
- widthSpan?: SpanNumber;
54
-
55
- /**
56
- * Optional. Represents the height of the Card component in terms of span numbers (1-12).
57
- */
58
- heightSpan?: SpanNumber;
59
- }
60
-
61
- export interface CardProps extends ViewProps {
62
- backgroundImage?: string;
63
- }
package/Loader/types.ts CHANGED
@@ -1,13 +1,35 @@
1
1
  import {ViewStyle} from 'react-native';
2
2
 
3
3
  export type LoaderProps = {
4
+ /**
5
+ * Optional. Type of loader, can be 'dot' or 'spinner'.
6
+ */
4
7
  type?: 'dot' | 'spinner';
8
+
9
+ /**
10
+ * Optional. Color for the loader.
11
+ */
5
12
  color?: string;
13
+
14
+ /**
15
+ * Optional. Style or styles for the loader component.
16
+ */
6
17
  style?: ViewStyle | ViewStyle[];
7
18
  };
8
19
 
9
20
  export type ProgressBarProps = {
21
+ /**
22
+ * Required. Percentage value to display on the progress bar.
23
+ */
10
24
  percent: number;
25
+
26
+ /**
27
+ * Optional. Color for the progress bar.
28
+ */
11
29
  color?: string;
30
+
31
+ /**
32
+ * Optional. Style or styles for the progress bar component.
33
+ */
12
34
  style?: ViewStyle | ViewStyle[];
13
35
  };
@@ -10,8 +10,8 @@ import {Icon} from '../Icon';
10
10
 
11
11
  const PopupNotify: React.FC<PopupNotifyProps> = ({
12
12
  image,
13
- title,
14
- description,
13
+ title = 'Title',
14
+ description = 'Description',
15
15
  information,
16
16
  secondary,
17
17
  primary,
@@ -206,12 +206,4 @@ const styles = StyleSheet.create({
206
206
  },
207
207
  });
208
208
 
209
- PopupNotify.defaultProps = {
210
- title: 'Title',
211
- primary: {
212
- title: 'Primary',
213
- onPress: () => {},
214
- },
215
- };
216
-
217
209
  export default PopupNotify;
package/Skeleton/types.ts CHANGED
@@ -1,3 +1,6 @@
1
1
  export type SkeletonTypes = {
2
+ /**
3
+ * Optional. Custom styles for the Skeleton component.
4
+ */
2
5
  style?: object;
3
6
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@momo-kits/foundation",
3
- "version": "0.77.8-beta.05",
3
+ "version": "0.77.8-beta.06",
4
4
  "description": "React Native Component Kits",
5
5
  "main": "index.ts",
6
6
  "scripts": {