@momo-kits/foundation 0.77.7 → 0.77.8-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.
- package/Application/BottomTab.tsx +2 -2
- package/Application/Navigation.ts +4 -9
- package/Assets/DotAnimation.json +256 -0
- package/Assets/SpinnerAnimation.json +1027 -0
- package/Loader/DotLoader.tsx +39 -0
- package/Loader/Loader.tsx +14 -0
- package/Loader/ProgressBar.tsx +44 -0
- package/Loader/Spinner.tsx +31 -0
- package/Loader/index.tsx +4 -0
- package/Loader/styles.ts +10 -0
- package/Loader/types.ts +11 -0
- package/Loader/utils.ts +26 -0
- package/index.ts +2 -0
- package/package.json +1 -1
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import React, {FC, useContext} from 'react';
|
|
2
|
+
import {View, ViewProps} from 'react-native';
|
|
3
|
+
import AnimatedLottieView from 'lottie-react-native';
|
|
4
|
+
import animation from '../Assets/DotAnimation.json';
|
|
5
|
+
import {ApplicationContext} from '../Application';
|
|
6
|
+
import {hexToRGBA} from './utils';
|
|
7
|
+
|
|
8
|
+
const DotLoader: FC<ViewProps> = ({style}) => {
|
|
9
|
+
const {theme} = useContext(ApplicationContext);
|
|
10
|
+
|
|
11
|
+
const arrayColor = [
|
|
12
|
+
theme.colors.primary,
|
|
13
|
+
theme.colors.secondary,
|
|
14
|
+
theme.colors.primary,
|
|
15
|
+
];
|
|
16
|
+
|
|
17
|
+
let source = animation;
|
|
18
|
+
source.assets[0].layers[0].shapes[0].it.forEach(item => {
|
|
19
|
+
if (item.ty === 'fl' && item.c) {
|
|
20
|
+
item.c.k.forEach((fillItem, index) => {
|
|
21
|
+
if (typeof fillItem !== 'number') {
|
|
22
|
+
fillItem.s = hexToRGBA(arrayColor[index]);
|
|
23
|
+
}
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
return (
|
|
29
|
+
<View style={style}>
|
|
30
|
+
<AnimatedLottieView
|
|
31
|
+
source={source}
|
|
32
|
+
style={{width: 52, height: 18}}
|
|
33
|
+
autoPlay
|
|
34
|
+
/>
|
|
35
|
+
</View>
|
|
36
|
+
);
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
export default DotLoader;
|
|
@@ -0,0 +1,14 @@
|
|
|
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', style}) => {
|
|
7
|
+
if (type === 'spinner') {
|
|
8
|
+
return <Spinner style={style} />;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
return <DotLoader style={style} />;
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
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,31 @@
|
|
|
1
|
+
import React, {FC, useContext} from 'react';
|
|
2
|
+
import {View, ViewProps} from 'react-native';
|
|
3
|
+
import AnimatedLottieView from 'lottie-react-native';
|
|
4
|
+
import animation from '../Assets/SpinnerAnimation.json';
|
|
5
|
+
import {hexToRGBA} from './utils';
|
|
6
|
+
import {ApplicationContext} from '../Application';
|
|
7
|
+
|
|
8
|
+
const Spinner: FC<ViewProps> = ({style}) => {
|
|
9
|
+
const {theme} = useContext(ApplicationContext);
|
|
10
|
+
|
|
11
|
+
let source = animation;
|
|
12
|
+
source.assets[0].layers.forEach(layer => {
|
|
13
|
+
layer.shapes[0].it.forEach(item => {
|
|
14
|
+
if (item.ty === 'fl' && item.c) {
|
|
15
|
+
item.c.k = hexToRGBA(theme.colors.primary);
|
|
16
|
+
}
|
|
17
|
+
});
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
return (
|
|
21
|
+
<View style={style}>
|
|
22
|
+
<AnimatedLottieView
|
|
23
|
+
source={source}
|
|
24
|
+
style={{width: 24, height: 24}}
|
|
25
|
+
autoPlay
|
|
26
|
+
/>
|
|
27
|
+
</View>
|
|
28
|
+
);
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
export default Spinner;
|
package/Loader/index.tsx
ADDED
package/Loader/styles.ts
ADDED
package/Loader/types.ts
ADDED
package/Loader/utils.ts
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
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
|
+
console.log(hex);
|
|
6
|
+
throw new Error('Invalid HEX color.');
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
const expandedHex =
|
|
10
|
+
normalizedHex.length === 3
|
|
11
|
+
? normalizedHex
|
|
12
|
+
.split('')
|
|
13
|
+
.map(val => val + val)
|
|
14
|
+
.join('')
|
|
15
|
+
: normalizedHex;
|
|
16
|
+
|
|
17
|
+
const hexMatch = expandedHex.match(/.{2}/g);
|
|
18
|
+
|
|
19
|
+
if (!hexMatch) {
|
|
20
|
+
throw new Error('HEX parsing failed.');
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
return hexMatch
|
|
24
|
+
.map(val => parseInt(val, 16))
|
|
25
|
+
.map(val => Math.round((val / 255) * 1000) / 1000);
|
|
26
|
+
};
|
package/index.ts
CHANGED