cdslibrary 1.2.81 → 1.2.84
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/components/CDSCardFeedback.jsx +21 -9
- package/components/CDSCheckbox.jsx +71 -0
- package/index.js +2 -0
- package/package.json +1 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React, { useState, useRef } from "react";
|
|
1
|
+
import React, { useState, useRef, useEffect } from "react";
|
|
2
2
|
import { View, Text, StyleSheet, TouchableOpacity, Animated } from "react-native";
|
|
3
3
|
import { MaterialIcons } from "@expo/vector-icons";
|
|
4
4
|
import { useTheme } from "../context/CDSThemeContext";
|
|
@@ -14,7 +14,16 @@ export const CDSCardFeedback = ({
|
|
|
14
14
|
}) => {
|
|
15
15
|
const { theme } = useTheme();
|
|
16
16
|
const [isVisible, setIsVisible] = useState(true);
|
|
17
|
-
|
|
17
|
+
|
|
18
|
+
const fadeAnim = useRef(new Animated.Value(0)).current;
|
|
19
|
+
|
|
20
|
+
useEffect(() => {
|
|
21
|
+
Animated.timing(fadeAnim, {
|
|
22
|
+
toValue: 1,
|
|
23
|
+
duration: 400, // Un poco más lento que la salida se siente mejor
|
|
24
|
+
useNativeDriver: false,
|
|
25
|
+
}).start();
|
|
26
|
+
}, []);
|
|
18
27
|
|
|
19
28
|
const handleClose = () => {
|
|
20
29
|
// IMPORTANTE: useNativeDriver debe ser false para animar maxHeight y padding
|
|
@@ -40,14 +49,12 @@ export const CDSCardFeedback = ({
|
|
|
40
49
|
|
|
41
50
|
const currentStyle = feedbackStyles[style] || feedbackStyles.info;
|
|
42
51
|
|
|
43
|
-
|
|
44
|
-
|
|
52
|
+
const animatedLayout = {
|
|
53
|
+
opacity: fadeAnim,
|
|
45
54
|
maxHeight: fadeAnim.interpolate({
|
|
46
55
|
inputRange: [0, 1],
|
|
47
|
-
outputRange: [0, 600]
|
|
56
|
+
outputRange: [0, 600]
|
|
48
57
|
}),
|
|
49
|
-
opacity: fadeAnim,
|
|
50
|
-
// Animamos el padding y el margen para que no queden espacios vacíos al cerrar
|
|
51
58
|
paddingVertical: fadeAnim.interpolate({
|
|
52
59
|
inputRange: [0, 1],
|
|
53
60
|
outputRange: [0, theme.space.md]
|
|
@@ -56,8 +63,13 @@ export const CDSCardFeedback = ({
|
|
|
56
63
|
inputRange: [0, 1],
|
|
57
64
|
outputRange: [0, theme.space.sm]
|
|
58
65
|
}),
|
|
59
|
-
|
|
60
|
-
|
|
66
|
+
// También animamos la escala para un efecto más premium
|
|
67
|
+
transform: [{
|
|
68
|
+
scale: fadeAnim.interpolate({
|
|
69
|
+
inputRange: [0, 1],
|
|
70
|
+
outputRange: [0.95, 1]
|
|
71
|
+
})
|
|
72
|
+
}]
|
|
61
73
|
};
|
|
62
74
|
|
|
63
75
|
return (
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { View, Text, StyleSheet, TouchableOpacity } from "react-native";
|
|
3
|
+
import { MaterialIcons } from "@expo/vector-icons"; // O la librería que uses
|
|
4
|
+
import { useTheme } from "../context/CDSThemeContext";
|
|
5
|
+
|
|
6
|
+
export const CDSCheckbox = ({ label, onValueChange, value }) => {
|
|
7
|
+
const { theme } = useTheme();
|
|
8
|
+
|
|
9
|
+
const handlePress = () => {
|
|
10
|
+
if (onValueChange) {
|
|
11
|
+
onValueChange(!value);
|
|
12
|
+
}
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
return (
|
|
16
|
+
<TouchableOpacity
|
|
17
|
+
activeOpacity={0.7}
|
|
18
|
+
onPress={handlePress}
|
|
19
|
+
style={styles.container}
|
|
20
|
+
>
|
|
21
|
+
{/* Caja del Checkbox */}
|
|
22
|
+
|
|
23
|
+
{/* Label */}
|
|
24
|
+
{label && (
|
|
25
|
+
<Text style={[
|
|
26
|
+
theme.typography.regular.md, // O el que prefieras
|
|
27
|
+
{
|
|
28
|
+
color: theme.text.neutral.primary,
|
|
29
|
+
flex: 1,
|
|
30
|
+
marginLeft: theme.space.sm
|
|
31
|
+
}
|
|
32
|
+
]}>
|
|
33
|
+
{label}
|
|
34
|
+
</Text>
|
|
35
|
+
)}
|
|
36
|
+
<View style={[
|
|
37
|
+
styles.checkboxBase,
|
|
38
|
+
{
|
|
39
|
+
borderColor: value ? theme.surface.special.progress : theme.outline.tertiary,
|
|
40
|
+
backgroundColor: value ? theme.surface.special.progress : 'transparent',
|
|
41
|
+
borderRadius: theme.radius.xs || 4, // Un poco menos redondo que el switch
|
|
42
|
+
}
|
|
43
|
+
]}>
|
|
44
|
+
{value && (
|
|
45
|
+
<MaterialIcons
|
|
46
|
+
name="check"
|
|
47
|
+
size={18}
|
|
48
|
+
color={theme.text.neutral.onPrimary || '#FFFFFF'}
|
|
49
|
+
/>
|
|
50
|
+
)}
|
|
51
|
+
</View>
|
|
52
|
+
</TouchableOpacity>
|
|
53
|
+
);
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
const styles = StyleSheet.create({
|
|
57
|
+
container: {
|
|
58
|
+
flexDirection: "row",
|
|
59
|
+
alignItems: "center",
|
|
60
|
+
width: '100%',
|
|
61
|
+
minHeight: 40,
|
|
62
|
+
paddingVertical: 4,
|
|
63
|
+
},
|
|
64
|
+
checkboxBase: {
|
|
65
|
+
width: 24,
|
|
66
|
+
height: 24,
|
|
67
|
+
borderWidth: 2,
|
|
68
|
+
justifyContent: 'center',
|
|
69
|
+
alignItems: 'center',
|
|
70
|
+
},
|
|
71
|
+
});
|
package/index.js
CHANGED
|
@@ -24,5 +24,7 @@ export {CDSAccordion} from './components/CDSAccordion';
|
|
|
24
24
|
export {CDSSnackBar} from './components/CDSSnackBar';
|
|
25
25
|
export {CDSImageButton} from './components/CDSImageButton'
|
|
26
26
|
export {CDSImageButtonGroup} from './components/CDSImageButtonGroup'
|
|
27
|
+
export {CDSCheckbox} from './components/CDSCheckbox';
|
|
28
|
+
|
|
27
29
|
|
|
28
30
|
export {CDSThemeProvider, useTheme} from './context/CDSThemeContext';
|