cdslibrary 1.2.95 → 1.2.96
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.
|
@@ -4,7 +4,7 @@ import { MaterialIcons } from "@expo/vector-icons";
|
|
|
4
4
|
import { useTheme } from "../context/CDSThemeContext";
|
|
5
5
|
import { CDSTooltip } from "./CDSTooltip"; // Asegúrate de importar tu Tooltip
|
|
6
6
|
|
|
7
|
-
export const CDSImageButton = ({ object, isActive, onPress, hasHelper, helperMessage, arrowAlignment }) => {
|
|
7
|
+
export const CDSImageButton = ({ object, isActive, onPress, hasHelper, helperMessage, arrowAlignment, isGrid }) => {
|
|
8
8
|
const { theme } = useTheme();
|
|
9
9
|
|
|
10
10
|
// Estados para controlar el Tooltip interno
|
|
@@ -34,6 +34,7 @@ export const CDSImageButton = ({ object, isActive, onPress, hasHelper, helperMes
|
|
|
34
34
|
setTooltipVisible(true);
|
|
35
35
|
};
|
|
36
36
|
|
|
37
|
+
console.log(isGrid)
|
|
37
38
|
return (
|
|
38
39
|
<>
|
|
39
40
|
<TouchableOpacity
|
|
@@ -42,6 +43,8 @@ export const CDSImageButton = ({ object, isActive, onPress, hasHelper, helperMes
|
|
|
42
43
|
style={[
|
|
43
44
|
styles.mainContainer,
|
|
44
45
|
{
|
|
46
|
+
width: isGrid ? 192 : 'auto' ,
|
|
47
|
+
maxWidth: isGrid ? 192 : 160,
|
|
45
48
|
backgroundColor: isActive
|
|
46
49
|
? theme.surface.neutral.primaryVariant
|
|
47
50
|
: theme.surface.neutral.primary,
|
|
@@ -3,7 +3,7 @@ import { View, Animated, StyleSheet, ScrollView } from 'react-native';
|
|
|
3
3
|
import { CDSImageButton } from './CDSImageButton';
|
|
4
4
|
import { useTheme } from "../context/CDSThemeContext";
|
|
5
5
|
|
|
6
|
-
export const CDSImageButtonGroup = ({ array, onSelect, isCentered }) => {
|
|
6
|
+
export const CDSImageButtonGroup = ({ array, onSelect, isCentered, isGrid }) => {
|
|
7
7
|
const { theme } = useTheme();
|
|
8
8
|
const isMobile = theme.isMobile
|
|
9
9
|
const [selectedId, setSelectedId] = useState(null);
|
|
@@ -29,42 +29,56 @@ export const CDSImageButtonGroup = ({ array, onSelect, isCentered }) => {
|
|
|
29
29
|
const animatedLayout = {
|
|
30
30
|
maxHeight: animatedValue.interpolate({
|
|
31
31
|
inputRange: [0, 1],
|
|
32
|
-
outputRange: [0, 250]
|
|
32
|
+
outputRange: [0, 250]
|
|
33
33
|
}),
|
|
34
34
|
opacity: animatedValue,
|
|
35
35
|
};
|
|
36
36
|
|
|
37
|
+
const Container = isGrid ? View : ScrollView;
|
|
38
|
+
|
|
37
39
|
return (
|
|
38
40
|
<Animated.View style={[
|
|
39
41
|
animatedLayout,
|
|
40
42
|
{ width: '100%' } // Asegura que el contenedor ocupe todo el ancho disponible
|
|
41
43
|
]}>
|
|
42
|
-
<
|
|
43
|
-
|
|
44
|
+
<Container
|
|
45
|
+
// Props para ScrollView (se ignoran si es View)
|
|
46
|
+
horizontal={!isGrid}
|
|
44
47
|
showsHorizontalScrollIndicator={false}
|
|
45
|
-
style={
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
48
|
+
style={isGrid ? {
|
|
49
|
+
flexDirection: 'row',
|
|
50
|
+
flexWrap: 'wrap',
|
|
51
|
+
justifyContent: 'center',
|
|
52
|
+
gap: theme.space.sm,
|
|
53
|
+
padding: theme.space.md,
|
|
54
|
+
width: '100%'
|
|
55
|
+
} : styles.scrollView}
|
|
56
|
+
contentContainerStyle={!isGrid ? [
|
|
57
|
+
styles.scrollContent,
|
|
58
|
+
{
|
|
49
59
|
justifyContent: (isCentered || !isMobile || (isMobile && array.length <= 2) ? 'center' : 'flex-start'),
|
|
50
60
|
gap: theme.space.sm,
|
|
51
61
|
padding: theme.space.md,
|
|
52
|
-
minWidth: '100%'
|
|
62
|
+
minWidth: '100%'
|
|
53
63
|
}
|
|
54
|
-
]}
|
|
64
|
+
] : undefined}
|
|
65
|
+
|
|
55
66
|
>
|
|
56
67
|
{array.map((item) => (
|
|
57
68
|
<CDSImageButton
|
|
69
|
+
isGrid={isGrid}
|
|
58
70
|
key={item.id}
|
|
59
71
|
object={item}
|
|
60
72
|
isActive={selectedId === item.id}
|
|
61
73
|
onPress={() => handlePress(item.id)}
|
|
62
|
-
hasHelper={item.helper
|
|
74
|
+
hasHelper={!!item.helper}
|
|
63
75
|
helperMessage={item.helper}
|
|
64
76
|
arrowAlignment={item.arrowAlignment}
|
|
77
|
+
// Opcional: Ajustar ancho en grid
|
|
78
|
+
style={isGrid ? { width: '47%' } : undefined}
|
|
65
79
|
/>
|
|
66
80
|
))}
|
|
67
|
-
</
|
|
81
|
+
</Container>
|
|
68
82
|
</Animated.View>
|
|
69
83
|
);
|
|
70
84
|
}
|
package/components/CDSLoader.jsx
CHANGED