cdslibrary 1.2.82 → 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/CDSCheckbox.jsx +71 -0
- package/index.js +2 -0
- package/package.json +1 -1
|
@@ -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';
|