ikualo-ui-kit-mobile 2.0.6 → 2.0.7

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/app.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "name": "ikualo-app-2.0",
4
4
  "slug": "ikualo-app-20",
5
5
  "owner": "ikualo",
6
- "version": "2.0.6",
6
+ "version": "2.0.7",
7
7
  "orientation": "portrait",
8
8
  "icon": "./assets/icon.png",
9
9
  "userInterfaceStyle": "automatic",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ikualo-ui-kit-mobile",
3
- "version": "2.0.6",
3
+ "version": "2.0.7",
4
4
  "main": "src/index.ts",
5
5
  "scripts": {
6
6
  "start": "expo start",
@@ -8,7 +8,7 @@ import { IDialogDown } from '../../models';
8
8
  // Sistema de cola de diálogos global
9
9
  interface DialogQueueItem extends IDialogDown {
10
10
  id: string;
11
- priority: 0 |1 | 2 | 3 | 4 | 5;
11
+ priority: 0 | 1 | 2 | 3 | 4 | 5;
12
12
  }
13
13
 
14
14
  class DialogManager {
@@ -33,10 +33,7 @@ class DialogManager {
33
33
  this.listeners.forEach((listener) => listener());
34
34
  }
35
35
 
36
- addDialog(dialog: Omit<DialogQueueItem, 'id'>) {
37
- const id = Math.random().toString(36).substr(2, 9);
38
- const dialogWithId = { ...dialog, id };
39
-
36
+ addDialog(dialog: DialogQueueItem) {
40
37
  // Solo cerrar el diálogo actual si el nuevo tiene prioridad explícita (1-5)
41
38
  // y es mayor que la prioridad del diálogo actual
42
39
  if (this.currentDialog && dialog.priority > 0 && dialog.priority > this.currentDialog.priority) {
@@ -44,7 +41,7 @@ class DialogManager {
44
41
  }
45
42
 
46
43
  // Agregar a la cola
47
- this.dialogs.push(dialogWithId);
44
+ this.dialogs.push(dialog);
48
45
 
49
46
  // Si no hay diálogo actual, mostrar el nuevo
50
47
  if (!this.currentDialog) {
@@ -91,12 +88,13 @@ class DialogManager {
91
88
  }
92
89
  }
93
90
 
94
- export const DialogDown = (props: IDialogDown) => {
91
+ export const DialogDown = (props: IDialogDown & { priority?: 0 | 1 | 2 | 3 | 4 | 5 }) => {
95
92
  const theme = useStore().theme;
96
93
  const stylesDialog = getStylesDialog(theme);
97
- const { isVisible, title, children, onDismiss, image, showCloseButton = true, priority } = props;
94
+ const { isVisible, title, children, onDismiss, image, showCloseButton = true, priority = 0 } = props;
98
95
  const slideAnim = useRef(new Animated.Value(0)).current;
99
96
  const [currentDialog, setCurrentDialog] = useState<DialogQueueItem | null>(null);
97
+ const [dialogId, setDialogId] = useState<string | null>(null);
100
98
  const dialogManager = useRef(DialogManager.getInstance());
101
99
 
102
100
  const handleDismissKeyboard = () => {
@@ -117,8 +115,12 @@ export const DialogDown = (props: IDialogDown) => {
117
115
  // Manejar cuando se debe mostrar/ocultar el diálogo
118
116
  useEffect(() => {
119
117
  if (isVisible) {
118
+ const newDialogId = Math.random().toString(36).substr(2, 9);
119
+ setDialogId(newDialogId);
120
+
120
121
  dialogManager.current.addDialog({
121
122
  ...props,
123
+ id: newDialogId,
122
124
  priority: priority || 0, // Si no se especifica prioridad, usar 0 (sin prioridad)
123
125
  onDismiss: () => {
124
126
  Animated.timing(slideAnim, {
@@ -126,21 +128,22 @@ export const DialogDown = (props: IDialogDown) => {
126
128
  duration: 200,
127
129
  useNativeDriver: true,
128
130
  }).start(() => {
129
- dialogManager.current.removeDialog(currentDialog?.id || '');
131
+ dialogManager.current.removeDialog(newDialogId);
130
132
  onDismiss();
131
133
  });
132
134
  },
133
135
  });
134
136
  } else {
135
- if (currentDialog?.id) {
136
- dialogManager.current.removeDialog(currentDialog.id);
137
+ if (dialogId) {
138
+ dialogManager.current.removeDialog(dialogId);
139
+ setDialogId(null);
137
140
  }
138
141
  }
139
142
  }, [isVisible, priority]);
140
143
 
141
144
  // Animación basada en si este diálogo es el actual
142
145
  useEffect(() => {
143
- const isCurrentDialog = currentDialog?.id === props.title; // Usar title como identificador único
146
+ const isCurrentDialog = currentDialog?.id === dialogId;
144
147
  if (isCurrentDialog) {
145
148
  Animated.timing(slideAnim, {
146
149
  toValue: 1,
@@ -150,7 +153,7 @@ export const DialogDown = (props: IDialogDown) => {
150
153
  } else {
151
154
  slideAnim.setValue(0);
152
155
  }
153
- }, [currentDialog, slideAnim, props.title]);
156
+ }, [currentDialog, slideAnim, dialogId]);
154
157
 
155
158
  useEffect(() => {
156
159
  const keyboardDidShowListener = Keyboard.addListener('keyboardDidShow', () => setIsKeyboardVisible(true));
@@ -165,13 +168,23 @@ export const DialogDown = (props: IDialogDown) => {
165
168
  }, []);
166
169
 
167
170
  const handleDismiss = () => {
168
- if (currentDialog?.id) {
169
- dialogManager.current.removeDialog(currentDialog.id);
171
+ if (dialogId) {
172
+ dialogManager.current.removeDialog(dialogId);
170
173
  }
171
174
  };
172
175
 
173
176
  // Solo renderizar si este diálogo es el actual
174
- const isCurrentDialog = Boolean(currentDialog && currentDialog.title === title);
177
+ const isCurrentDialog = Boolean(currentDialog && currentDialog.id === dialogId);
178
+
179
+ // Debug logging
180
+ console.log('DialogDown Debug:', {
181
+ title,
182
+ dialogId,
183
+ currentDialogId: currentDialog?.id,
184
+ isCurrentDialog,
185
+ isVisible,
186
+ priority,
187
+ });
175
188
 
176
189
  return (
177
190
  <Modal visible={isCurrentDialog} transparent={true} animationType="none" onRequestClose={handleDismiss}>