cdslibrary 1.2.32 → 1.2.34

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.
@@ -105,8 +105,11 @@ export const CDSBottomSheet = ({
105
105
  <View style={styles.scrollWrapper}>
106
106
  <ScrollView
107
107
  style={styles.scrollArea}
108
- contentContainerStyle={[styles.scrollContent, { paddingBottom: theme.space.md }]}
108
+ contentContainerStyle={[styles.scrollContent, { paddingBottom: theme.space.xl }]}
109
109
  showsVerticalScrollIndicator={true}
110
+ bounces={true}
111
+ alwaysBounceVertical={false}
112
+ scrollEventThrottle={16}
110
113
  >
111
114
  {!!description && (
112
115
  <Text style={[theme.typography.regular.md, { marginBottom: theme.space.md }]}>
@@ -0,0 +1,80 @@
1
+ import React, { useEffect } from "react";
2
+ import { StyleSheet, Text, TouchableOpacity } from "react-native";
3
+ import Animated, { SlideInDown, SlideOutDown } from "react-native-reanimated";
4
+ import { useTheme } from "../context/CDSThemeContext";
5
+
6
+ export const CDSSnackbar = ({ message, visible, onDismiss, hasClose }) => {
7
+ const { theme } = useTheme();
8
+
9
+ useEffect(() => {
10
+ let timer;
11
+ if (visible) {
12
+ // Configuramos el temporizador a 5000ms (5 segundos)
13
+ timer = setTimeout(() => {
14
+ if (onDismiss) onDismiss();
15
+ }, 5000);
16
+ }
17
+
18
+ // Limpieza: si el componente se desmonta o el usuario lo cierra antes,
19
+ // cancelamos el timer para evitar fugas de memoria.
20
+ return () => clearTimeout(timer);
21
+ }, [visible, onDismiss]);
22
+
23
+ // Reanimated necesita que el componente se desmonte para ejecutar 'exiting'
24
+ if (!visible) return null;
25
+
26
+ return (
27
+ <Animated.View
28
+ entering={SlideInDown.duration(400)}
29
+ exiting={SlideOutDown.duration(300)}
30
+ style={[
31
+ styles.snackbar,
32
+ {
33
+ backgroundColor: theme.surface.special.display,
34
+ bottom: theme.space.lg,
35
+ padding: theme.space.sm,
36
+ borderRadius: theme.radius.sm,
37
+ }
38
+ ]}
39
+ >
40
+ <Text style={[
41
+ theme.typography.regular.sm,
42
+ { color: theme.text.neutral.contrast, flex: 1 }
43
+ ]}>
44
+ {message}
45
+ </Text>
46
+
47
+ {hasClose && (
48
+ <TouchableOpacity onPress={onDismiss} style={styles.actionButton}>
49
+ <Text style={{
50
+ color: theme.colors?.brand?.secondary || theme.text.neutral.contrast,
51
+ fontWeight: '700'
52
+ }}>
53
+ CERRAR
54
+ </Text>
55
+ </TouchableOpacity>
56
+ )}
57
+ </Animated.View>
58
+ );
59
+ };
60
+
61
+ const styles = StyleSheet.create({
62
+ snackbar: {
63
+ alignSelf: 'center',
64
+ width: '90%',
65
+ maxWidth: 600,
66
+ position: 'absolute',
67
+ flexDirection: 'row',
68
+ alignItems: 'center',
69
+ justifyContent: 'space-between',
70
+ elevation: 5,
71
+ shadowColor: '#000',
72
+ shadowOffset: { width: 0, height: 2 },
73
+ shadowOpacity: 0.25,
74
+ shadowRadius: 3.84,
75
+ zIndex: 1000,
76
+ },
77
+ actionButton: {
78
+ marginLeft: 16,
79
+ }
80
+ });
@@ -1,21 +1,36 @@
1
- import React, { useState } from "react";
2
- import { View, Text, Switch, StyleSheet } from "react-native";
1
+ import React from "react";
2
+ import { View, Text, Switch, StyleSheet, Platform } from "react-native";
3
3
  import { useTheme } from "../context/CDSThemeContext";
4
- import {getSemanticTextStyles} from "../tokens/CDSsemanticTextStyles";
5
4
 
6
- export const CDSSwitch = ({ label }) => {
5
+ export const CDSSwitch = ({ label, onValueChange, value }) => {
7
6
  const { theme } = useTheme();
8
-
9
- const [isEnabled, setIsEnabled] = useState(false);
10
-
11
- const toggleSwitch = () => setIsEnabled((previousState) => !previousState);
12
7
 
13
8
  return (
14
- <View style={styles.container}>
15
- <Text style={theme.typography.label}>
16
- {label}
17
- </Text>
18
- <Switch onValueChange={toggleSwitch} value={isEnabled} />
9
+ <View style={[styles.container, { marginVertical: theme.space.xs }]}>
10
+ {label && (
11
+ <Text style={[
12
+ theme.typography.label,
13
+ { color: theme.text.neutral.primary, flex: 1, marginRight: theme.space.sm }
14
+ ]}>
15
+ {label}
16
+ </Text>
17
+ )}
18
+ <Switch
19
+ value={value}
20
+ onValueChange={onValueChange}
21
+ // Colores dinámicos basados en tu tema
22
+ trackColor={{
23
+ false: theme.outline.neutral.primary,
24
+ true: theme.surface.special.progress
25
+ }}
26
+ // Color del "círculo" (thumb)
27
+ thumbColor={Platform.OS === 'ios'
28
+ ? undefined // En iOS es mejor dejar el blanco nativo
29
+ : theme.surface.neutral.primary
30
+ }
31
+ // Color de fondo para Android cuando está apagado
32
+ ios_backgroundColor={theme.outline.neutral.primary}
33
+ />
19
34
  </View>
20
35
  );
21
36
  }
@@ -25,5 +40,7 @@ const styles = StyleSheet.create({
25
40
  flexDirection: "row",
26
41
  justifyContent: "space-between",
27
42
  alignItems: "center",
43
+ width: '100%',
44
+ minHeight: 40, // Mejora el área de toque
28
45
  },
29
- });
46
+ });
package/index.js CHANGED
@@ -20,5 +20,6 @@ export {CDSLoader} from './components/CDSLoader';
20
20
  export {CDSOffer} from './components/CDSOffer';
21
21
  export {CDSTable} from './components/CDSTable';
22
22
  export {CDSAccordion} from './components/CDSAccordion'
23
+ export {CDSSnackbar} from './components/CDSSnackbar'
23
24
 
24
25
  export {CDSThemeProvider, useTheme} from './context/CDSThemeContext';
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "cdslibrary",
3
3
  "license": "0BSD",
4
- "version": "1.2.32",
4
+ "version": "1.2.34",
5
5
  "main": "index.js",
6
6
  "author": "Nat Viramontes",
7
7
  "description": "A library of components for the CDS project",