cdslibrary 1.2.28 → 1.2.30
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.
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import React, { useState } from "react";
|
|
2
|
+
import { Text, StyleSheet, TouchableOpacity, View, Image } from "react-native";
|
|
3
|
+
import { MaterialIcons } from "@expo/vector-icons";
|
|
4
|
+
import { useTheme } from "../context/CDSThemeContext";
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
export const CDSImageButton = ({ object, isActive, onPress }) => { // 👈 Añadimos isActive
|
|
9
|
+
const { theme } = useTheme();
|
|
10
|
+
|
|
11
|
+
return (
|
|
12
|
+
<TouchableOpacity
|
|
13
|
+
onPress={onPress}
|
|
14
|
+
style={[
|
|
15
|
+
styles.mainContainer,
|
|
16
|
+
{
|
|
17
|
+
backgroundColor: isActive
|
|
18
|
+
? theme.surface.neutral.primaryVariant // Color cuando está presionado
|
|
19
|
+
: theme.surface.neutral.primary,
|
|
20
|
+
gap: theme.space.xs,
|
|
21
|
+
padding: theme.space.xs,
|
|
22
|
+
// borderColor: isActive
|
|
23
|
+
// ? theme.outline.neutral.primary // Borde de color de marca si está activo
|
|
24
|
+
// : theme.outline.neutral.primary,
|
|
25
|
+
borderRadius: theme.radius.lg,
|
|
26
|
+
// Si está activo, quitamos la sombra o usamos una más pequeña (md)
|
|
27
|
+
...(!isActive && theme.shadows.lg),
|
|
28
|
+
// Si quieres que se vea "hundido", podrías bajar la escala
|
|
29
|
+
transform: [{ scale: isActive ? 0.99 : 1 }]
|
|
30
|
+
},
|
|
31
|
+
]}
|
|
32
|
+
>
|
|
33
|
+
<Image
|
|
34
|
+
source={object.image}
|
|
35
|
+
resizeMode="cover"
|
|
36
|
+
style={{
|
|
37
|
+
width: "100%",
|
|
38
|
+
height: 60,
|
|
39
|
+
}}
|
|
40
|
+
/>
|
|
41
|
+
<Text style={{ fontWeight: isActive ? 'bold' : 'normal' }}>
|
|
42
|
+
{object.label}
|
|
43
|
+
</Text>
|
|
44
|
+
</TouchableOpacity>
|
|
45
|
+
);
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
const styles = StyleSheet.create ({
|
|
51
|
+
|
|
52
|
+
mainContainer:{
|
|
53
|
+
alignItems: 'center',
|
|
54
|
+
flexGrow: 1,
|
|
55
|
+
maxWidth: 200,
|
|
56
|
+
height: 120
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
})
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { StyleSheet, Text, View, Image } from 'react-native';
|
|
2
|
+
import { CDSImageButton } from './CDSImageButton';
|
|
3
|
+
import { useState } from 'react';
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
export const CDSImageButtonGroup = ({ array, onSelect }) => {
|
|
7
|
+
const [selectedId, setSelectedId] = useState(null);
|
|
8
|
+
|
|
9
|
+
const handlePress = (id) => {
|
|
10
|
+
const nextId = id === selectedId ? null : id;
|
|
11
|
+
setSelectedId(nextId);
|
|
12
|
+
|
|
13
|
+
// Avisamos al padre qué objeto se seleccionó (o null si se deseleccionó)
|
|
14
|
+
if (onSelect) {
|
|
15
|
+
const selectedItem = array.find(item => item.id === nextId);
|
|
16
|
+
onSelect(selectedItem || null);
|
|
17
|
+
}
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
return (
|
|
21
|
+
<View style={{ width: '100%' }}>
|
|
22
|
+
<View style={{
|
|
23
|
+
flexDirection: 'row', gap: 10,
|
|
24
|
+
width: '100%', justifyContent: 'center'
|
|
25
|
+
}}>
|
|
26
|
+
{array.map((item) => (
|
|
27
|
+
<CDSImageButton
|
|
28
|
+
key={item.id}
|
|
29
|
+
object={item}
|
|
30
|
+
isActive={selectedId === item.id}
|
|
31
|
+
onPress={() => handlePress(item.id)}
|
|
32
|
+
/>
|
|
33
|
+
))}
|
|
34
|
+
</View>
|
|
35
|
+
</View>
|
|
36
|
+
);
|
|
37
|
+
}
|
package/index.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
|
|
2
|
-
|
|
2
|
+
// import { registerRootComponent } from 'expo';
|
|
3
3
|
|
|
4
|
-
import App from './App';
|
|
5
|
-
registerRootComponent(App);
|
|
4
|
+
// import App from './App';
|
|
5
|
+
// registerRootComponent(App);
|
|
6
6
|
|
|
7
7
|
export {CDSBottomSheet} from './components/CDSBottomSheet';
|
|
8
8
|
export {CDSButton} from './components/CDSButton';
|
package/package.json
CHANGED
|
@@ -164,26 +164,15 @@ export const CDSPrimitiveSpacing =
|
|
|
164
164
|
|
|
165
165
|
export const CDSPrimitiveShadows = (mode) => ({
|
|
166
166
|
md: {
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
height: mode==='dark' ? 8 : 2
|
|
171
|
-
},
|
|
172
|
-
shadowOpacity: mode==='dark' ? 0.4 : 0.1,
|
|
173
|
-
shadowRadius: 6,
|
|
174
|
-
elevation: 3, // Valor aproximado para Android
|
|
167
|
+
// Usamos el formato de string que entiende el nuevo motor
|
|
168
|
+
boxShadow: `0px 2px 4px ${mode === 'dark' ? 'rgba(0,0,0,0.4)' : 'rgba(0,0,0,0.08)'}`,
|
|
169
|
+
elevation: 3, // Indispensable para Android nativo
|
|
175
170
|
},
|
|
176
171
|
|
|
177
|
-
// Basado en tu captura "lg": Y: 4, Blur: 8
|
|
178
172
|
lg: {
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
height: mode==='dark' ? 10 : 4
|
|
183
|
-
},
|
|
184
|
-
shadowOpacity: mode==='dark' ? 0.5 : 0.1,
|
|
185
|
-
shadowRadius: 8,
|
|
186
|
-
elevation: 5, // Valor aproximado para Android
|
|
173
|
+
// Sombra más elegante con más blur (8px) y desplazamiento (4px)
|
|
174
|
+
boxShadow: `0px 4px 12px ${mode === 'dark' ? 'rgba(0,0,0,0.6)' : 'rgba(0,0,0,0.15)'}`,
|
|
175
|
+
elevation: 8,
|
|
187
176
|
},
|
|
188
177
|
});
|
|
189
178
|
|