cdslibrary 1.2.18 → 1.2.20

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.
@@ -17,7 +17,7 @@ export const CDSBottomSheet = ({
17
17
  customSlot,
18
18
  primaryButtonLabel = "Aceptar",
19
19
  primaryButtonOnPress,
20
- secondaryButtonLabel = "Cancelar",
20
+ secondaryButtonLabel,
21
21
  onFinish,
22
22
  }) => {
23
23
  const { theme } = useTheme();
@@ -1,73 +1,67 @@
1
- import { View, StyleSheet } from "react-native";
1
+ import { StyleSheet } from "react-native";
2
2
  import LottieView from "lottie-react-native";
3
- import { useRef, useEffect } from "react";
3
+ import { useEffect } from "react";
4
4
  import Animated, {
5
5
  useSharedValue,
6
6
  useAnimatedStyle,
7
7
  withTiming,
8
+ runOnJS,
8
9
  } from "react-native-reanimated";
9
10
  import { useTheme } from "../context/CDSThemeContext";
10
11
 
11
- export const CDSSplashScreen = ({ navigation, nextScreen }) => {
12
+ export const CDSSplashScreen = ({ onAnimationFinish }) => {
12
13
  const { theme } = useTheme();
13
- const animation = useRef(null);
14
- const translateY = useSharedValue(0); // Definir un sharedValue para la posición vertical.
15
- const size = useSharedValue(200); // Definir un sharedValue para el tamaño inicial.
16
- const backgroundOpacity = useSharedValue(1);
14
+ const translateY = useSharedValue(0);
15
+ const size = useSharedValue(200);
16
+ const opacity = useSharedValue(1);
17
+
17
18
  useEffect(() => {
18
- // Después de 6 segundos, mover la animación hacia arriba y cambiar el tamaño.
19
- setTimeout(() => {
20
- translateY.value = withTiming(-350, { duration: 1000 }); // Mover hacia arriba
21
- size.value = withTiming(120, { duration: 1000 }); // Reducir el tamaño
22
- backgroundOpacity.value = withTiming(0, { duration: 1000 });
23
- // Esperar 1 segundo más antes de hacer el cambio de pantalla
24
- setTimeout(() => {
25
- navigation.replace(nextScreen);
26
- }, 600);
27
- }, 6000); // Esperar 6 segundos antes de la animación
28
- }, [translateY, size]);
19
+ // 1. Tiempo de espera de la animación principal (4 seg)
20
+ const timer = setTimeout(() => {
21
+ // 2. Animamos hacia arriba, achicamos y desvanecemos TODO
22
+ translateY.value = withTiming(-350, { duration: 1000 });
23
+ size.value = withTiming(120, { duration: 1000 });
24
+ opacity.value = withTiming(0, { duration: 1000 }, (isFinished) => {
25
+ if (isFinished && onAnimationFinish) {
26
+ // 3. Ejecutamos la función de cierre justo al terminar la animación
27
+ runOnJS(onAnimationFinish)();
28
+ }
29
+ });
30
+ }, 4000);
31
+
32
+ return () => clearTimeout(timer);
33
+ }, []);
34
+
35
+ const animatedContainerStyle = useAnimatedStyle(() => ({
36
+ opacity: opacity.value,
37
+ backgroundColor: theme.surface.special.progress,
38
+ }));
29
39
 
30
- // Aplicar el estilo animado para la animación
31
- const animatedStyle = useAnimatedStyle(() => {
32
- return {
33
- transform: [{ translateY: translateY.value }],
34
- width: size.value, // Usar el tamaño animado
35
- height: size.value, // Usar el tamaño animado
36
- };
37
- },[]);
40
+ const animatedIconStyle = useAnimatedStyle(() => ({
41
+ transform: [{ translateY: translateY.value }],
42
+ width: size.value,
43
+ height: size.value,
44
+ }));
38
45
 
39
46
  return (
40
- <View style={styles.background}>
41
- <View
42
- style={[
43
- styles.animationContainer,
44
- { backgroundColor: theme.surface.special.progress },
45
- ]}
46
- >
47
- <Animated.View
48
- style={[
49
- { justifyContent: "center", alignItems: "center" },
50
- animatedStyle,
51
- ]}
52
- >
53
- <LottieView
54
- autoPlay
55
- loop={false}
56
- source={require("../assets/animations/animation.json")}
57
- style={{ width: "100%", height: "100%" }} // Usar 100% del tamaño del contenedor
58
- />
59
- </Animated.View>
60
- </View>
61
- </View>
47
+ <Animated.View style={[styles.background, animatedContainerStyle]}>
48
+ <Animated.View style={animatedIconStyle}>
49
+ <LottieView
50
+ autoPlay
51
+ loop={false}
52
+ source={require("../assets/animations/animation.json")}
53
+ style={{ width: "100%", height: "100%" }}
54
+ />
55
+ </Animated.View>
56
+ </Animated.View>
62
57
  );
63
- }
58
+ };
64
59
 
65
60
  const styles = StyleSheet.create({
66
61
  background: {
67
62
  flex: 1,
68
63
  justifyContent: "center",
69
64
  alignItems: "center",
70
- backgroundColor: 'blue',
71
65
  width: "100%",
72
66
  },
73
67
  animationContainer: {
@@ -78,4 +72,4 @@ const styles = StyleSheet.create({
78
72
  gap: 16,
79
73
  padding: 16,
80
74
  },
81
- });
75
+ });
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "cdslibrary",
3
3
  "license": "0BSD",
4
- "version": "1.2.18",
4
+ "version": "1.2.20",
5
5
  "main": "index.js",
6
6
  "author": "Nat Viramontes",
7
7
  "description": "A library of components for the CDS project",