@hoddy-ui/core 1.0.15 → 1.0.17
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/index.ts +1 -0
- package/package.json +1 -1
- package/src/Components/Animator.tsx +43 -0
- package/src/types.ts +8 -1
package/index.ts
CHANGED
|
@@ -9,6 +9,7 @@ export { default as Button } from "./src/Components/Button";
|
|
|
9
9
|
export * from "./src/Components/Checkbox";
|
|
10
10
|
export * from "./src/Components/FlashMessage";
|
|
11
11
|
export * from "./src/Components/Grid";
|
|
12
|
+
export * from "./src/Components/Animator";
|
|
12
13
|
export * from "./src/Components/Locator";
|
|
13
14
|
export * from "./src/Components/Popup";
|
|
14
15
|
export * from "./src/Components/SafeAreaView";
|
package/package.json
CHANGED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { useFocusEffect } from "@react-navigation/native";
|
|
2
|
+
import React, { FC, useCallback, useState } from "react";
|
|
3
|
+
import { LayoutAnimation, View } from "react-native";
|
|
4
|
+
import { ScaledSheet } from "react-native-size-matters";
|
|
5
|
+
import { AnimatorProps } from "../types";
|
|
6
|
+
|
|
7
|
+
export const Animator: FC<AnimatorProps> = ({
|
|
8
|
+
style = {},
|
|
9
|
+
duration = 500,
|
|
10
|
+
children,
|
|
11
|
+
delay = 100,
|
|
12
|
+
animationType = "easeInEaseOut",
|
|
13
|
+
type = "fade",
|
|
14
|
+
}) => {
|
|
15
|
+
const [play, setPlay] = useState(false);
|
|
16
|
+
const toggleAnimation = () => {
|
|
17
|
+
setPlay(false);
|
|
18
|
+
|
|
19
|
+
setTimeout(() => {
|
|
20
|
+
LayoutAnimation.configureNext({
|
|
21
|
+
...LayoutAnimation.Presets[animationType],
|
|
22
|
+
duration,
|
|
23
|
+
});
|
|
24
|
+
setPlay(true);
|
|
25
|
+
}, delay);
|
|
26
|
+
};
|
|
27
|
+
const styles = ScaledSheet.create({
|
|
28
|
+
root: {
|
|
29
|
+
opacity: play ? 1 : 0,
|
|
30
|
+
left: type === "slideInLeft" ? (!play ? -200 : 0) : undefined,
|
|
31
|
+
right: type === "slideInRight" ? (!play ? -200 : 0) : undefined,
|
|
32
|
+
bottom: type === "slideInUp" ? (!play ? -100 : 0) : undefined,
|
|
33
|
+
top: type === "slideInDown" ? (!play ? -100 : 0) : undefined,
|
|
34
|
+
...style,
|
|
35
|
+
},
|
|
36
|
+
});
|
|
37
|
+
useFocusEffect(
|
|
38
|
+
useCallback(() => {
|
|
39
|
+
toggleAnimation();
|
|
40
|
+
}, [])
|
|
41
|
+
);
|
|
42
|
+
return <View style={styles.root}>{play && children}</View>;
|
|
43
|
+
};
|
package/src/types.ts
CHANGED
|
@@ -75,7 +75,14 @@ export interface AvatarProps {
|
|
|
75
75
|
size?: number;
|
|
76
76
|
style?: ViewStyle;
|
|
77
77
|
}
|
|
78
|
-
|
|
78
|
+
export interface AnimatorProps {
|
|
79
|
+
style?: ViewStyle;
|
|
80
|
+
duration?: number;
|
|
81
|
+
children: ReactNode;
|
|
82
|
+
delay?: number;
|
|
83
|
+
animationType?: "easeInEaseOut" | "linear" | "spring";
|
|
84
|
+
type?: "fade" | "slideInLeft" | "slideInRight" | "slideInUp" | "slideInDown";
|
|
85
|
+
}
|
|
79
86
|
export interface ButtonProps {
|
|
80
87
|
color?: colorTypes;
|
|
81
88
|
variant?: "text" | "outlined" | "contained";
|