related-ui-components 3.0.6 → 3.0.7
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,12 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
import React, {
|
|
4
|
-
import { View, StyleSheet, I18nManager } from "react-native";
|
|
5
|
-
import Animated, { useSharedValue, useAnimatedStyle, withRepeat, withSequence, withTiming, cancelAnimation, Easing } from "react-native-reanimated";
|
|
3
|
+
import React, { useEffect, useRef } from "react";
|
|
4
|
+
import { View, StyleSheet, Animated, Easing, I18nManager } from "react-native";
|
|
6
5
|
import { LinearGradient } from "expo-linear-gradient";
|
|
7
6
|
import { useTheme } from "../../theme/index.js";
|
|
8
7
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
9
|
-
const AnimatedLinearGradient = Animated.createAnimatedComponent(LinearGradient);
|
|
10
8
|
const Shimmer = ({
|
|
11
9
|
children,
|
|
12
10
|
width,
|
|
@@ -20,42 +18,25 @@ const Shimmer = ({
|
|
|
20
18
|
theme
|
|
21
19
|
} = useTheme();
|
|
22
20
|
const isRTL = I18nManager.isRTL;
|
|
23
|
-
|
|
24
|
-
// Shared animation values (Reanimated)
|
|
25
|
-
const containerWidth = useSharedValue(typeof width === "number" ? width : 400);
|
|
26
|
-
const translateX = useSharedValue(0);
|
|
27
|
-
const opacity = useSharedValue(1);
|
|
28
|
-
const shimmerColors = useMemo(() => [theme.skeletonBackgroundColor + "00", shimmerColor || theme.skeletonShimmer, theme.skeletonBackgroundColor + "00"], [theme, shimmerColor]);
|
|
29
|
-
|
|
30
|
-
// Define easing
|
|
31
|
-
const easing = Easing.bezier(0.76, 0, 0.24, 1);
|
|
32
|
-
|
|
33
|
-
// Start shimmer animation
|
|
34
|
-
const startAnimation = useCallback(() => {
|
|
35
|
-
"worklet";
|
|
36
|
-
|
|
37
|
-
const direction = isRTL ? -1 : 1;
|
|
38
|
-
translateX.value = withRepeat(withSequence(withTiming(-containerWidth.value * 1.5 * direction, {
|
|
39
|
-
duration: 0
|
|
40
|
-
}), withTiming(containerWidth.value * 1.5 * direction, {
|
|
41
|
-
duration,
|
|
42
|
-
easing
|
|
43
|
-
})), -1);
|
|
44
|
-
opacity.value = withTiming(1, {
|
|
45
|
-
duration: duration / 2,
|
|
46
|
-
easing
|
|
47
|
-
});
|
|
48
|
-
}, [containerWidth, duration, easing, isRTL]);
|
|
21
|
+
const animatedValue = useRef(new Animated.Value(0)).current;
|
|
49
22
|
useEffect(() => {
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
})
|
|
23
|
+
const animation = Animated.loop(Animated.timing(animatedValue, {
|
|
24
|
+
toValue: 1,
|
|
25
|
+
duration: duration,
|
|
26
|
+
easing: Easing.bezier(0.76, 0, 0.24, 1),
|
|
27
|
+
useNativeDriver: true
|
|
28
|
+
}));
|
|
29
|
+
animation.start();
|
|
30
|
+
return () => animation.stop();
|
|
31
|
+
}, [animatedValue, duration]);
|
|
32
|
+
const numericWidth = typeof width === "number" ? width : 400;
|
|
33
|
+
const ltrOutputRange = [-shimmerWidth, numericWidth + shimmerWidth];
|
|
34
|
+
const rtlOutputRange = [numericWidth + shimmerWidth, -shimmerWidth];
|
|
35
|
+
const translateX = animatedValue.interpolate({
|
|
36
|
+
inputRange: [0, 1],
|
|
37
|
+
outputRange: isRTL ? rtlOutputRange : ltrOutputRange
|
|
38
|
+
});
|
|
39
|
+
const shimmerColors = [theme.skeletonBackgroundColor + "00", shimmerColor || theme.skeletonShimmer, theme.skeletonBackgroundColor + "00"];
|
|
59
40
|
return /*#__PURE__*/_jsxs(View, {
|
|
60
41
|
style: [{
|
|
61
42
|
width,
|
|
@@ -63,20 +44,29 @@ const Shimmer = ({
|
|
|
63
44
|
overflow: "hidden",
|
|
64
45
|
backgroundColor: theme.skeletonBackgroundColor
|
|
65
46
|
}, style],
|
|
66
|
-
children: [children, /*#__PURE__*/_jsx(
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
end: {
|
|
73
|
-
x: 1,
|
|
74
|
-
y: 0.5
|
|
75
|
-
},
|
|
76
|
-
style: [StyleSheet.absoluteFill, {
|
|
77
|
-
width: shimmerWidth,
|
|
47
|
+
children: [children, /*#__PURE__*/_jsx(Animated.View, {
|
|
48
|
+
style: {
|
|
49
|
+
...StyleSheet.absoluteFillObject,
|
|
50
|
+
transform: [{
|
|
51
|
+
translateX
|
|
52
|
+
}],
|
|
78
53
|
zIndex: 1
|
|
79
|
-
},
|
|
54
|
+
},
|
|
55
|
+
children: /*#__PURE__*/_jsx(LinearGradient, {
|
|
56
|
+
colors: shimmerColors,
|
|
57
|
+
style: {
|
|
58
|
+
flex: 1,
|
|
59
|
+
width: shimmerWidth
|
|
60
|
+
},
|
|
61
|
+
start: {
|
|
62
|
+
x: 0,
|
|
63
|
+
y: 0.5
|
|
64
|
+
},
|
|
65
|
+
end: {
|
|
66
|
+
x: 1,
|
|
67
|
+
y: 0.5
|
|
68
|
+
}
|
|
69
|
+
})
|
|
80
70
|
})]
|
|
81
71
|
});
|
|
82
72
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["React","
|
|
1
|
+
{"version":3,"names":["React","useEffect","useRef","View","StyleSheet","Animated","Easing","I18nManager","LinearGradient","useTheme","jsx","_jsx","jsxs","_jsxs","Shimmer","children","width","height","style","shimmerColor","duration","shimmerWidth","theme","isRTL","animatedValue","Value","current","animation","loop","timing","toValue","easing","bezier","useNativeDriver","start","stop","numericWidth","ltrOutputRange","rtlOutputRange","translateX","interpolate","inputRange","outputRange","shimmerColors","skeletonBackgroundColor","skeletonShimmer","overflow","backgroundColor","absoluteFillObject","transform","zIndex","colors","flex","x","y","end"],"sourceRoot":"..\\..\\..\\..\\src","sources":["components/Skeleton/Shimmer.tsx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3,"file":"Shimmer.d.ts","sourceRoot":"","sources":["../../../../../src/components/Skeleton/Shimmer.tsx"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"Shimmer.d.ts","sourceRoot":"","sources":["../../../../../src/components/Skeleton/Shimmer.tsx"],"names":[],"mappings":"AAAA,OAAO,KAA4B,MAAM,OAAO,CAAC;AACjD,OAAO,EAKL,SAAS,EACT,cAAc,EACd,SAAS,EAEV,MAAM,cAAc,CAAC;AAItB,UAAU,YAAY;IACpB,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IAC3B,KAAK,EAAE,cAAc,CAAC;IACtB,MAAM,EAAE,cAAc,CAAC;IACvB,KAAK,CAAC,EAAE,SAAS,CAAC,SAAS,CAAC,CAAC;IAC7B,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB;AAED,QAAA,MAAM,OAAO,EAAE,KAAK,CAAC,EAAE,CAAC,YAAY,CAuEnC,CAAC;AAEF,eAAe,OAAO,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,27 +1,17 @@
|
|
|
1
|
-
import React, {
|
|
1
|
+
import React, { useEffect, useRef } from "react";
|
|
2
2
|
import {
|
|
3
3
|
View,
|
|
4
4
|
StyleSheet,
|
|
5
|
+
Animated,
|
|
6
|
+
Easing,
|
|
5
7
|
ViewStyle,
|
|
6
8
|
DimensionValue,
|
|
7
9
|
StyleProp,
|
|
8
10
|
I18nManager,
|
|
9
11
|
} from "react-native";
|
|
10
|
-
import Animated, {
|
|
11
|
-
useSharedValue,
|
|
12
|
-
useAnimatedStyle,
|
|
13
|
-
withRepeat,
|
|
14
|
-
withSequence,
|
|
15
|
-
withTiming,
|
|
16
|
-
cancelAnimation,
|
|
17
|
-
Easing,
|
|
18
|
-
useAnimatedReaction,
|
|
19
|
-
} from "react-native-reanimated";
|
|
20
12
|
import { LinearGradient } from "expo-linear-gradient";
|
|
21
13
|
import { useTheme } from "../../theme";
|
|
22
14
|
|
|
23
|
-
const AnimatedLinearGradient = Animated.createAnimatedComponent(LinearGradient);
|
|
24
|
-
|
|
25
15
|
interface ShimmerProps {
|
|
26
16
|
children?: React.ReactNode;
|
|
27
17
|
width: DimensionValue;
|
|
@@ -43,58 +33,36 @@ const Shimmer: React.FC<ShimmerProps> = ({
|
|
|
43
33
|
}) => {
|
|
44
34
|
const { theme } = useTheme();
|
|
45
35
|
const isRTL = I18nManager.isRTL;
|
|
36
|
+
const animatedValue = useRef(new Animated.Value(0)).current;
|
|
46
37
|
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
() => [
|
|
56
|
-
theme.skeletonBackgroundColor + "00",
|
|
57
|
-
shimmerColor || theme.skeletonShimmer,
|
|
58
|
-
theme.skeletonBackgroundColor + "00",
|
|
59
|
-
],
|
|
60
|
-
[theme, shimmerColor]
|
|
61
|
-
);
|
|
62
|
-
|
|
63
|
-
// Define easing
|
|
64
|
-
const easing = Easing.bezier(0.76, 0, 0.24, 1);
|
|
65
|
-
|
|
66
|
-
// Start shimmer animation
|
|
67
|
-
const startAnimation = useCallback(() => {
|
|
68
|
-
"worklet";
|
|
69
|
-
const direction = isRTL ? -1 : 1;
|
|
70
|
-
|
|
71
|
-
translateX.value = withRepeat(
|
|
72
|
-
withSequence(
|
|
73
|
-
withTiming(-containerWidth.value * 1.5 * direction, { duration: 0 }),
|
|
74
|
-
withTiming(containerWidth.value * 1.5 * direction, {
|
|
75
|
-
duration,
|
|
76
|
-
easing,
|
|
77
|
-
})
|
|
78
|
-
),
|
|
79
|
-
-1
|
|
38
|
+
useEffect(() => {
|
|
39
|
+
const animation = Animated.loop(
|
|
40
|
+
Animated.timing(animatedValue, {
|
|
41
|
+
toValue: 1,
|
|
42
|
+
duration: duration,
|
|
43
|
+
easing: Easing.bezier(0.76, 0, 0.24, 1),
|
|
44
|
+
useNativeDriver: true,
|
|
45
|
+
})
|
|
80
46
|
);
|
|
47
|
+
animation.start();
|
|
48
|
+
return () => animation.stop();
|
|
49
|
+
}, [animatedValue, duration]);
|
|
81
50
|
|
|
82
|
-
|
|
83
|
-
duration: duration / 2,
|
|
84
|
-
easing,
|
|
85
|
-
});
|
|
86
|
-
}, [containerWidth, duration, easing, isRTL]);
|
|
51
|
+
const numericWidth = typeof width === "number" ? width : 400;
|
|
87
52
|
|
|
88
|
-
|
|
89
|
-
|
|
53
|
+
const ltrOutputRange = [-shimmerWidth, numericWidth + shimmerWidth];
|
|
54
|
+
const rtlOutputRange = [numericWidth + shimmerWidth, -shimmerWidth];
|
|
90
55
|
|
|
91
|
-
|
|
92
|
-
|
|
56
|
+
const translateX = animatedValue.interpolate({
|
|
57
|
+
inputRange: [0, 1],
|
|
58
|
+
outputRange: isRTL ? rtlOutputRange : ltrOutputRange,
|
|
59
|
+
});
|
|
93
60
|
|
|
94
|
-
const
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
61
|
+
const shimmerColors = [
|
|
62
|
+
theme.skeletonBackgroundColor + "00",
|
|
63
|
+
shimmerColor || theme.skeletonShimmer,
|
|
64
|
+
theme.skeletonBackgroundColor + "00",
|
|
65
|
+
];
|
|
98
66
|
|
|
99
67
|
return (
|
|
100
68
|
<View
|
|
@@ -109,20 +77,22 @@ const Shimmer: React.FC<ShimmerProps> = ({
|
|
|
109
77
|
]}
|
|
110
78
|
>
|
|
111
79
|
{children}
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
{
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
80
|
+
<Animated.View
|
|
81
|
+
style={{
|
|
82
|
+
...StyleSheet.absoluteFillObject,
|
|
83
|
+
transform: [{ translateX }],
|
|
84
|
+
zIndex: 1,
|
|
85
|
+
}}
|
|
86
|
+
>
|
|
87
|
+
<LinearGradient
|
|
88
|
+
colors={shimmerColors as any}
|
|
89
|
+
style={{ flex: 1, width: shimmerWidth }}
|
|
90
|
+
start={{ x: 0, y: 0.5 }}
|
|
91
|
+
end={{ x: 1, y: 0.5 }}
|
|
92
|
+
/>
|
|
93
|
+
</Animated.View>
|
|
124
94
|
</View>
|
|
125
95
|
);
|
|
126
96
|
};
|
|
127
97
|
|
|
128
|
-
export default Shimmer;
|
|
98
|
+
export default Shimmer;
|