@momo-kits/foundation 0.76.1-beta.2 → 0.77.1-optimize.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/BottomTabBar.tsx +478 -0
- package/Application/BottomTab/index.tsx +134 -0
- package/Application/Components.tsx +339 -161
- package/Application/ModalScreen.tsx +113 -99
- package/Application/Navigation.ts +22 -16
- package/Application/NavigationContainer.tsx +99 -48
- package/Application/Navigator.ts +110 -41
- package/Application/StackScreen.tsx +129 -8
- package/Application/index.ts +23 -4
- package/Application/types.ts +84 -33
- package/Application/utils.tsx +71 -49
- package/Assets/DotAnimation.json +256 -0
- package/Assets/SpinnerAnimation.json +1027 -0
- package/Assets/icon.json +83 -5
- package/Assets/icon_bank.json +506 -0
- package/Assets/language.json +202 -0
- package/Badge/Badge.tsx +56 -0
- package/Badge/BadgeDot.tsx +11 -0
- package/Badge/BadgeRibbon.tsx +125 -0
- package/Badge/Shape.tsx +29 -0
- package/Badge/index.tsx +7 -0
- package/Badge/styles.ts +58 -0
- package/Badge/types.ts +63 -0
- package/Button/index.tsx +90 -39
- package/Button/styles.ts +19 -0
- package/CheckBox/index.tsx +58 -43
- package/CheckBox/styles.ts +1 -1
- package/CheckBox/types.ts +6 -4
- package/Consts/colors+spacing+radius.ts +18 -0
- package/Consts/styles.ts +0 -26
- package/Consts/theme.ts +4 -0
- package/Divider/index.tsx +2 -0
- package/Icon/index.tsx +14 -9
- package/Icon/types.ts +4 -3
- package/IconButton/index.tsx +24 -15
- package/Image/index.tsx +63 -47
- package/Image/styles.ts +1 -9
- package/Image/types.ts +5 -1
- package/Input/Input.tsx +227 -116
- package/Input/InputDropDown.tsx +132 -0
- package/Input/InputMoney.tsx +174 -111
- package/Input/InputOTP.tsx +257 -0
- package/Input/InputSearch.tsx +160 -132
- package/Input/InputTextArea.tsx +150 -123
- package/Input/common.tsx +42 -17
- package/Input/index.tsx +204 -18
- package/Input/styles.ts +44 -7
- package/Input/utils.ts +2 -2
- package/Layout/Card.tsx +67 -29
- package/Layout/FloatingButton.tsx +149 -0
- package/Layout/GridSystem.tsx +31 -21
- package/Layout/Item.tsx +21 -25
- package/Layout/ItemList.tsx +55 -0
- package/Layout/ItemSectionList.tsx +39 -0
- package/Layout/Screen.tsx +343 -153
- package/Layout/Section.tsx +66 -34
- package/Layout/index.ts +13 -3
- package/Layout/styles.ts +101 -0
- package/Layout/types.ts +1 -39
- package/Layout/utils.ts +27 -52
- package/Loader/DotLoader.tsx +37 -0
- package/Loader/Loader.tsx +13 -0
- package/Loader/ProgressBar.tsx +44 -0
- package/Loader/Spinner.tsx +29 -0
- package/Loader/index.tsx +4 -0
- package/Loader/styles.ts +10 -0
- package/Loader/types.ts +35 -0
- package/Loader/utils.ts +25 -0
- package/Pagination/PaginationDot.tsx +7 -2
- package/Pagination/PaginationNumber.tsx +8 -6
- package/Pagination/PaginationScroll.tsx +0 -1
- package/Pagination/PaginationWhiteDot.tsx +8 -5
- package/Pagination/styles.ts +3 -0
- package/Pagination/types.ts +2 -0
- package/Popup/PopupNotify.tsx +108 -46
- package/Popup/PopupPromotion.tsx +63 -22
- package/Popup/types.ts +15 -4
- package/Radio/index.tsx +35 -21
- package/Radio/types.ts +7 -5
- package/Skeleton/index.tsx +1 -1
- package/Skeleton/types.ts +3 -0
- package/Switch/index.tsx +35 -24
- package/Switch/types.ts +5 -3
- package/Tag/index.tsx +2 -4
- package/Text/index.tsx +27 -22
- package/Text/styles.ts +38 -0
- package/Text/types.ts +25 -13
- package/Text/utils.ts +1 -1
- package/Title/index.tsx +186 -0
- package/Title/styles.ts +79 -0
- package/Title/types.ts +20 -0
- package/code-scanner.js +143 -0
- package/index.ts +6 -0
- package/migrate_typo.js +56 -0
- package/package.json +14 -9
- package/tsconfig.json +24 -0
- package/verify.js +47 -0
- package/Application/BottomTab.tsx +0 -52
- package/Application/NavigationButton.tsx +0 -54
- package/Assets/header-background.png +0 -0
package/Layout/index.ts
CHANGED
|
@@ -5,13 +5,23 @@ import {validateChildren} from './utils';
|
|
|
5
5
|
import {createContext} from 'react';
|
|
6
6
|
import {GridContextProps} from './types';
|
|
7
7
|
import Item from './Item';
|
|
8
|
+
import ItemList from './ItemList';
|
|
9
|
+
import ItemSectionList from './ItemSectionList';
|
|
8
10
|
|
|
9
11
|
const GridContext = createContext<GridContextProps>({
|
|
10
12
|
numberOfColumns: 12,
|
|
11
13
|
gutterSize: 12,
|
|
12
|
-
margin: 12,
|
|
13
14
|
sizePerSpan: 0,
|
|
14
|
-
getSizeSpan:
|
|
15
|
+
getSizeSpan: () => 0,
|
|
15
16
|
});
|
|
16
17
|
|
|
17
|
-
export {
|
|
18
|
+
export {
|
|
19
|
+
GridContext,
|
|
20
|
+
Card,
|
|
21
|
+
Section,
|
|
22
|
+
GridSystem,
|
|
23
|
+
validateChildren,
|
|
24
|
+
Item,
|
|
25
|
+
ItemList,
|
|
26
|
+
ItemSectionList,
|
|
27
|
+
};
|
package/Layout/styles.ts
ADDED
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
import {Platform, StyleSheet} from 'react-native';
|
|
2
|
+
import {Colors, Radius, Spacing} from '../Consts';
|
|
3
|
+
|
|
4
|
+
export default StyleSheet.create({
|
|
5
|
+
extendedHeader: {
|
|
6
|
+
aspectRatio: 1.75,
|
|
7
|
+
position: 'absolute',
|
|
8
|
+
width: '100%',
|
|
9
|
+
height: 210,
|
|
10
|
+
},
|
|
11
|
+
screenBanner: {
|
|
12
|
+
width: '100%',
|
|
13
|
+
},
|
|
14
|
+
boxGrid: {
|
|
15
|
+
position: 'absolute',
|
|
16
|
+
top: 0,
|
|
17
|
+
bottom: 0,
|
|
18
|
+
left: 0,
|
|
19
|
+
right: 0,
|
|
20
|
+
borderColor: 'red',
|
|
21
|
+
borderWidth: 1,
|
|
22
|
+
zIndex: 99,
|
|
23
|
+
},
|
|
24
|
+
boxGridSection: {
|
|
25
|
+
position: 'absolute',
|
|
26
|
+
top: 0,
|
|
27
|
+
bottom: 0,
|
|
28
|
+
left: 0,
|
|
29
|
+
right: 0,
|
|
30
|
+
borderColor: 'blue',
|
|
31
|
+
borderWidth: 2,
|
|
32
|
+
zIndex: 100,
|
|
33
|
+
},
|
|
34
|
+
boxGridCard: {
|
|
35
|
+
position: 'absolute',
|
|
36
|
+
top: 0,
|
|
37
|
+
bottom: 0,
|
|
38
|
+
left: 0,
|
|
39
|
+
right: 0,
|
|
40
|
+
borderColor: 'green',
|
|
41
|
+
borderWidth: 2,
|
|
42
|
+
zIndex: 100,
|
|
43
|
+
},
|
|
44
|
+
card: {
|
|
45
|
+
flexDirection: 'row',
|
|
46
|
+
flexWrap: 'wrap',
|
|
47
|
+
borderRadius: Radius.M,
|
|
48
|
+
padding: 12,
|
|
49
|
+
},
|
|
50
|
+
item: {
|
|
51
|
+
overflow: 'hidden',
|
|
52
|
+
margin: undefined,
|
|
53
|
+
marginTop: undefined,
|
|
54
|
+
marginBottom: undefined,
|
|
55
|
+
marginLeft: undefined,
|
|
56
|
+
marginRight: undefined,
|
|
57
|
+
marginVertical: undefined,
|
|
58
|
+
marginHorizontal: undefined,
|
|
59
|
+
},
|
|
60
|
+
imageBackground: {
|
|
61
|
+
position: 'absolute',
|
|
62
|
+
top: 0,
|
|
63
|
+
bottom: 0,
|
|
64
|
+
left: 0,
|
|
65
|
+
right: 0,
|
|
66
|
+
},
|
|
67
|
+
protectedStyle: {
|
|
68
|
+
marginTop: undefined,
|
|
69
|
+
marginBottom: undefined,
|
|
70
|
+
marginLeft: undefined,
|
|
71
|
+
marginRight: undefined,
|
|
72
|
+
paddingTop: undefined,
|
|
73
|
+
paddingBottom: undefined,
|
|
74
|
+
paddingLeft: undefined,
|
|
75
|
+
paddingRight: undefined,
|
|
76
|
+
padding: undefined,
|
|
77
|
+
margin: undefined,
|
|
78
|
+
marginHorizontal: undefined,
|
|
79
|
+
marginVertical: undefined,
|
|
80
|
+
paddingHorizontal: undefined,
|
|
81
|
+
paddingVertical: undefined,
|
|
82
|
+
},
|
|
83
|
+
shadow: {
|
|
84
|
+
paddingTop: Spacing.S,
|
|
85
|
+
...Platform.select({
|
|
86
|
+
ios: {
|
|
87
|
+
shadowColor: Colors.black_17,
|
|
88
|
+
shadowOffset: {
|
|
89
|
+
width: 2,
|
|
90
|
+
height: 2,
|
|
91
|
+
},
|
|
92
|
+
shadowOpacity: 0.25,
|
|
93
|
+
shadowRadius: 10,
|
|
94
|
+
},
|
|
95
|
+
android: {
|
|
96
|
+
shadowColor: Colors.black_20,
|
|
97
|
+
elevation: 24,
|
|
98
|
+
},
|
|
99
|
+
}),
|
|
100
|
+
},
|
|
101
|
+
});
|
package/Layout/types.ts
CHANGED
|
@@ -1,6 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
type SpanNumber = 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12;
|
|
1
|
+
export type HeaderType = 'default' | 'surface' | 'extended' | 'none';
|
|
4
2
|
|
|
5
3
|
export type GridContextProps = {
|
|
6
4
|
/**
|
|
@@ -13,11 +11,6 @@ export type GridContextProps = {
|
|
|
13
11
|
*/
|
|
14
12
|
gutterSize: number;
|
|
15
13
|
|
|
16
|
-
/**
|
|
17
|
-
* Optional. Represents the margin around the grid.
|
|
18
|
-
*/
|
|
19
|
-
margin?: number;
|
|
20
|
-
|
|
21
14
|
/**
|
|
22
15
|
* Represents the size (width or height) per span number.
|
|
23
16
|
*/
|
|
@@ -28,34 +21,3 @@ export type GridContextProps = {
|
|
|
28
21
|
*/
|
|
29
22
|
getSizeSpan: (span: number) => number;
|
|
30
23
|
};
|
|
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
|
-
|
|
47
|
-
export interface ItemProps extends ViewProps {
|
|
48
|
-
/**
|
|
49
|
-
* Represents the width of the Card component in terms of span numbers (1-12).
|
|
50
|
-
*/
|
|
51
|
-
widthSpan?: SpanNumber;
|
|
52
|
-
|
|
53
|
-
/**
|
|
54
|
-
* Optional. Represents the height of the Card component in terms of span numbers (1-12).
|
|
55
|
-
*/
|
|
56
|
-
heightSpan?: SpanNumber;
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
export interface CardProps extends ViewProps {
|
|
60
|
-
background?: string;
|
|
61
|
-
}
|
package/Layout/utils.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import
|
|
1
|
+
import React, {Fragment, ReactElement, useEffect, useState} from 'react';
|
|
2
|
+
import {Dimensions} from 'react-native';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* validate children type
|
|
@@ -7,53 +7,31 @@ import React, {useEffect, useState} from 'react';
|
|
|
7
7
|
* @param childrenTypes
|
|
8
8
|
*/
|
|
9
9
|
const validateChildren = (
|
|
10
|
-
children:
|
|
11
|
-
|
|
12
|
-
| string
|
|
13
|
-
| number
|
|
14
|
-
| {}
|
|
15
|
-
| Iterable<React.ReactNode>
|
|
16
|
-
| React.ReactPortal
|
|
17
|
-
| null
|
|
18
|
-
| undefined
|
|
19
|
-
| boolean,
|
|
20
|
-
childrenTypes: Array<React.FC<any>>,
|
|
10
|
+
children: React.ReactNode | React.ReactNode[],
|
|
11
|
+
childrenTypes: Array<React.ReactNode>,
|
|
21
12
|
) => {
|
|
22
|
-
if (!__DEV__) return children;
|
|
23
|
-
|
|
24
|
-
let results: React.ReactElement[] = [];
|
|
25
13
|
const validateType = (child: React.ReactElement) => {
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
const alertWrongType = () => {
|
|
30
|
-
Alert.alert(
|
|
31
|
-
'Component Kits',
|
|
32
|
-
`Wrong children type for this component, expected are ${childrenTypes
|
|
33
|
-
.map(type => type.displayName)
|
|
34
|
-
.join(', ')}.`,
|
|
14
|
+
const valid = childrenTypes.some(
|
|
15
|
+
childrenType => child?.type === childrenType || child?.type == Fragment,
|
|
35
16
|
);
|
|
17
|
+
if (!valid) {
|
|
18
|
+
console.warn(
|
|
19
|
+
`Wrong children type for this component, expected are ${childrenTypes
|
|
20
|
+
.map(item => item)
|
|
21
|
+
.join(', ')}.`,
|
|
22
|
+
);
|
|
23
|
+
}
|
|
36
24
|
};
|
|
37
|
-
|
|
38
25
|
if (Array.isArray(children)) {
|
|
39
|
-
const flattenChildren = children.flat();
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
return child;
|
|
43
|
-
} else {
|
|
44
|
-
alertWrongType();
|
|
45
|
-
}
|
|
46
|
-
});
|
|
47
|
-
} else {
|
|
48
|
-
const singleChild: any = children;
|
|
49
|
-
if (validateType(singleChild)) {
|
|
50
|
-
results = [singleChild];
|
|
51
|
-
} else {
|
|
52
|
-
alertWrongType();
|
|
26
|
+
const flattenChildren: React.ReactElement[] = children.flat();
|
|
27
|
+
for (const child of flattenChildren) {
|
|
28
|
+
validateType(child);
|
|
53
29
|
}
|
|
30
|
+
return flattenChildren;
|
|
31
|
+
} else {
|
|
32
|
+
validateType(children as ReactElement);
|
|
33
|
+
return children;
|
|
54
34
|
}
|
|
55
|
-
|
|
56
|
-
return results;
|
|
57
35
|
};
|
|
58
36
|
|
|
59
37
|
const useGridSystem = () => {
|
|
@@ -62,19 +40,16 @@ const useGridSystem = () => {
|
|
|
62
40
|
);
|
|
63
41
|
|
|
64
42
|
useEffect(() => {
|
|
65
|
-
const subscription: any = Dimensions.addEventListener(
|
|
66
|
-
'
|
|
67
|
-
(
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
}
|
|
72
|
-
},
|
|
73
|
-
);
|
|
43
|
+
const subscription: any = Dimensions.addEventListener('change', () => {
|
|
44
|
+
const newColumns = Dimensions.get('window').width > 600 ? 24 : 12;
|
|
45
|
+
if (newColumns != numberOfColumns) {
|
|
46
|
+
setNumberOfColumns(newColumns);
|
|
47
|
+
}
|
|
48
|
+
});
|
|
74
49
|
return () => subscription?.remove();
|
|
75
50
|
}, []);
|
|
76
51
|
|
|
77
52
|
return {numberOfColumns};
|
|
78
53
|
};
|
|
79
54
|
|
|
80
|
-
export {
|
|
55
|
+
export {useGridSystem, validateChildren};
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import React, {FC, useContext} from 'react';
|
|
2
|
+
import AnimatedLottieView from 'lottie-react-native';
|
|
3
|
+
import animation from '../Assets/DotAnimation.json';
|
|
4
|
+
import {ApplicationContext} from '../Application';
|
|
5
|
+
import {hexToRGBA} from './utils';
|
|
6
|
+
import {LoaderProps} from './types';
|
|
7
|
+
|
|
8
|
+
const DotLoader: FC<LoaderProps> = ({color}) => {
|
|
9
|
+
const {theme} = useContext(ApplicationContext);
|
|
10
|
+
|
|
11
|
+
const arrayColor = [
|
|
12
|
+
color ?? theme.colors.primary,
|
|
13
|
+
theme.colors.background.surface,
|
|
14
|
+
color ?? theme.colors.primary,
|
|
15
|
+
];
|
|
16
|
+
|
|
17
|
+
let source: any = animation;
|
|
18
|
+
source.assets[0].layers[0].shapes[0].it.forEach((item: any) => {
|
|
19
|
+
if (item.ty === 'fl' && item.c) {
|
|
20
|
+
item.c.k.forEach((fillItem: any, index: number) => {
|
|
21
|
+
if (typeof fillItem !== 'number') {
|
|
22
|
+
fillItem.s = hexToRGBA(arrayColor[index] as string);
|
|
23
|
+
}
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
return (
|
|
29
|
+
<AnimatedLottieView
|
|
30
|
+
source={source}
|
|
31
|
+
style={{width: 52, height: 18}}
|
|
32
|
+
autoPlay
|
|
33
|
+
/>
|
|
34
|
+
);
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
export default DotLoader;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import React, {FC} from 'react';
|
|
2
|
+
import {LoaderProps} from './types';
|
|
3
|
+
import DotLoader from './DotLoader';
|
|
4
|
+
import Spinner from './Spinner';
|
|
5
|
+
|
|
6
|
+
const Loader: FC<LoaderProps> = ({type = 'dot', ...props}) => {
|
|
7
|
+
if (type === 'spinner') {
|
|
8
|
+
return <Spinner {...props} key={props.color} />;
|
|
9
|
+
}
|
|
10
|
+
return <DotLoader {...props} key={props.color} />;
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
export default Loader;
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import React, {FC, useContext, useEffect, useRef} from 'react';
|
|
2
|
+
import {Animated, View} from 'react-native';
|
|
3
|
+
import styles from './styles';
|
|
4
|
+
import {ProgressBarProps} from './types';
|
|
5
|
+
import {ApplicationContext} from '../Application';
|
|
6
|
+
import {Radius} from '../Consts';
|
|
7
|
+
|
|
8
|
+
const ProgressBar: FC<ProgressBarProps> = ({percent = 0, style}) => {
|
|
9
|
+
const {theme} = useContext(ApplicationContext);
|
|
10
|
+
const animation = useRef(new Animated.Value(0)).current;
|
|
11
|
+
|
|
12
|
+
useEffect(() => {
|
|
13
|
+
Animated.timing(animation, {
|
|
14
|
+
toValue: percent,
|
|
15
|
+
duration: 200,
|
|
16
|
+
useNativeDriver: false,
|
|
17
|
+
}).start();
|
|
18
|
+
}, [percent, animation]);
|
|
19
|
+
|
|
20
|
+
const width = animation.interpolate({
|
|
21
|
+
inputRange: [0, 100],
|
|
22
|
+
outputRange: ['0%', '100%'],
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
return (
|
|
26
|
+
<View
|
|
27
|
+
style={[
|
|
28
|
+
style,
|
|
29
|
+
styles.progressContainer,
|
|
30
|
+
{backgroundColor: theme.colors.background.default},
|
|
31
|
+
]}>
|
|
32
|
+
<Animated.View
|
|
33
|
+
style={{
|
|
34
|
+
height: 4,
|
|
35
|
+
borderRadius: Radius.XXS,
|
|
36
|
+
width,
|
|
37
|
+
backgroundColor: theme.colors.primary,
|
|
38
|
+
}}
|
|
39
|
+
/>
|
|
40
|
+
</View>
|
|
41
|
+
);
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
export default ProgressBar;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import React, {FC, useContext} from 'react';
|
|
2
|
+
import AnimatedLottieView from 'lottie-react-native';
|
|
3
|
+
import animation from '../Assets/SpinnerAnimation.json';
|
|
4
|
+
import {hexToRGBA} from './utils';
|
|
5
|
+
import {ApplicationContext} from '../Application';
|
|
6
|
+
import {LoaderProps} from './types';
|
|
7
|
+
|
|
8
|
+
const Spinner: FC<LoaderProps> = ({color}) => {
|
|
9
|
+
const {theme} = useContext(ApplicationContext);
|
|
10
|
+
|
|
11
|
+
let source: any = animation;
|
|
12
|
+
source.assets[0].layers.forEach((layer: any) => {
|
|
13
|
+
layer.shapes[0].it.forEach((item: any) => {
|
|
14
|
+
if (item.ty === 'fl' && item.c) {
|
|
15
|
+
item.c.k = hexToRGBA(color ?? theme.colors.primary);
|
|
16
|
+
}
|
|
17
|
+
});
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
return (
|
|
21
|
+
<AnimatedLottieView
|
|
22
|
+
source={source}
|
|
23
|
+
style={{width: 24, height: 24}}
|
|
24
|
+
autoPlay
|
|
25
|
+
/>
|
|
26
|
+
);
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
export default Spinner;
|
package/Loader/index.tsx
ADDED
package/Loader/styles.ts
ADDED
package/Loader/types.ts
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import {ViewStyle} from 'react-native';
|
|
2
|
+
|
|
3
|
+
export type LoaderProps = {
|
|
4
|
+
/**
|
|
5
|
+
* Optional. Type of loader, can be 'dot' or 'spinner'.
|
|
6
|
+
*/
|
|
7
|
+
type?: 'dot' | 'spinner';
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Optional. Color for the loader.
|
|
11
|
+
*/
|
|
12
|
+
color?: string;
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Optional. Style or styles for the loader component.
|
|
16
|
+
*/
|
|
17
|
+
style?: ViewStyle | ViewStyle[];
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
export type ProgressBarProps = {
|
|
21
|
+
/**
|
|
22
|
+
* Required. Percentage value to display on the progress bar.
|
|
23
|
+
*/
|
|
24
|
+
percent: number;
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Optional. Color for the progress bar.
|
|
28
|
+
*/
|
|
29
|
+
color?: string;
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Optional. Style or styles for the progress bar component.
|
|
33
|
+
*/
|
|
34
|
+
style?: ViewStyle | ViewStyle[];
|
|
35
|
+
};
|
package/Loader/utils.ts
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
export const hexToRGBA = (hex: string) => {
|
|
2
|
+
const normalizedHex = hex.startsWith('#') ? hex.slice(1) : hex;
|
|
3
|
+
|
|
4
|
+
if (!/^([0-9A-Fa-f]{3}){1,2}$/.test(normalizedHex)) {
|
|
5
|
+
throw new Error('Invalid HEX color.');
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
const expandedHex =
|
|
9
|
+
normalizedHex.length === 3
|
|
10
|
+
? normalizedHex
|
|
11
|
+
.split('')
|
|
12
|
+
.map(val => val + val)
|
|
13
|
+
.join('')
|
|
14
|
+
: normalizedHex;
|
|
15
|
+
|
|
16
|
+
const hexMatch = expandedHex.match(/.{2}/g);
|
|
17
|
+
|
|
18
|
+
if (!hexMatch) {
|
|
19
|
+
throw new Error('HEX parsing failed.');
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
return hexMatch
|
|
23
|
+
.map(val => parseInt(val, 16))
|
|
24
|
+
.map(val => Math.round((val / 255) * 1000) / 1000);
|
|
25
|
+
};
|
|
@@ -9,10 +9,11 @@ import {ApplicationContext} from '../Application';
|
|
|
9
9
|
const PaginationDot: FC<ChildPaginationProps> = ({
|
|
10
10
|
dataLength = 2,
|
|
11
11
|
activeIndex = 0,
|
|
12
|
+
style,
|
|
12
13
|
}) => {
|
|
13
14
|
const {theme} = useContext(ApplicationContext);
|
|
14
15
|
const renderDots = () => {
|
|
15
|
-
const dots = [];
|
|
16
|
+
const dots: React.ReactElement[] = [];
|
|
16
17
|
for (let i = 0; i < dataLength; i++) {
|
|
17
18
|
dots.push(
|
|
18
19
|
<Dot
|
|
@@ -27,7 +28,11 @@ const PaginationDot: FC<ChildPaginationProps> = ({
|
|
|
27
28
|
}
|
|
28
29
|
return dots;
|
|
29
30
|
};
|
|
30
|
-
return
|
|
31
|
+
return (
|
|
32
|
+
<View style={[style, styles.row]}>
|
|
33
|
+
<View style={styles.paginationPinkContainer}>{renderDots()}</View>
|
|
34
|
+
</View>
|
|
35
|
+
);
|
|
31
36
|
};
|
|
32
37
|
|
|
33
38
|
export default PaginationDot;
|
|
@@ -1,20 +1,22 @@
|
|
|
1
|
-
import React, {FC
|
|
1
|
+
import React, {FC} from 'react';
|
|
2
2
|
import {View} from 'react-native';
|
|
3
3
|
import {ChildPaginationProps} from './types';
|
|
4
4
|
import styles from './styles';
|
|
5
5
|
import {Text} from '../Text';
|
|
6
|
-
import {ApplicationContext} from '../Application';
|
|
7
6
|
import {Colors} from '../Consts';
|
|
8
7
|
|
|
9
8
|
const PaginationNumber: FC<ChildPaginationProps> = ({
|
|
10
9
|
activeIndex = 0,
|
|
11
10
|
dataLength = 2,
|
|
11
|
+
style,
|
|
12
12
|
}) => {
|
|
13
13
|
return (
|
|
14
|
-
<View style={[styles.
|
|
15
|
-
<
|
|
16
|
-
|
|
17
|
-
|
|
14
|
+
<View style={[style, styles.row]}>
|
|
15
|
+
<View style={styles.paginationNumberContainer}>
|
|
16
|
+
<Text color={Colors.black_01} typography={'label_default_medium'}>{`${
|
|
17
|
+
activeIndex + 1
|
|
18
|
+
}/${dataLength}`}</Text>
|
|
19
|
+
</View>
|
|
18
20
|
</View>
|
|
19
21
|
);
|
|
20
22
|
};
|
|
@@ -1,18 +1,17 @@
|
|
|
1
|
-
import React, {FC
|
|
1
|
+
import React, {FC} from 'react';
|
|
2
2
|
import {View} from 'react-native';
|
|
3
3
|
import {ChildPaginationProps} from './types';
|
|
4
4
|
import styles from './styles';
|
|
5
5
|
import Dot from './Dot';
|
|
6
6
|
import {Colors, Spacing} from '../Consts';
|
|
7
|
-
import {ApplicationContext} from '../Application';
|
|
8
7
|
|
|
9
8
|
const PaginationWhiteDot: FC<ChildPaginationProps> = ({
|
|
10
9
|
dataLength = 2,
|
|
11
10
|
activeIndex = 0,
|
|
11
|
+
style,
|
|
12
12
|
}) => {
|
|
13
|
-
const {theme} = useContext(ApplicationContext);
|
|
14
13
|
const renderDots = () => {
|
|
15
|
-
const dots = [];
|
|
14
|
+
const dots: React.ReactElement[] = [];
|
|
16
15
|
for (let i = 0; i < dataLength; i++) {
|
|
17
16
|
dots.push(
|
|
18
17
|
<Dot
|
|
@@ -26,7 +25,11 @@ const PaginationWhiteDot: FC<ChildPaginationProps> = ({
|
|
|
26
25
|
}
|
|
27
26
|
return dots;
|
|
28
27
|
};
|
|
29
|
-
return
|
|
28
|
+
return (
|
|
29
|
+
<View style={[style, styles.row]}>
|
|
30
|
+
<View style={styles.paginationWhiteContainer}>{renderDots()}</View>
|
|
31
|
+
</View>
|
|
32
|
+
);
|
|
30
33
|
};
|
|
31
34
|
|
|
32
35
|
export default PaginationWhiteDot;
|
package/Pagination/styles.ts
CHANGED
|
@@ -25,6 +25,8 @@ export default StyleSheet.create({
|
|
|
25
25
|
paddingHorizontal: Spacing.S,
|
|
26
26
|
borderRadius: Radius.L,
|
|
27
27
|
backgroundColor: Colors.black_20 + '33',
|
|
28
|
+
alignItems: 'center',
|
|
29
|
+
justifyContent: 'center',
|
|
28
30
|
},
|
|
29
31
|
scrollContainer: {
|
|
30
32
|
alignItems: 'center',
|
|
@@ -44,4 +46,5 @@ export default StyleSheet.create({
|
|
|
44
46
|
height: 4,
|
|
45
47
|
borderRadius: Radius.XS,
|
|
46
48
|
},
|
|
49
|
+
row: {flexDirection: 'row'},
|
|
47
50
|
});
|