ikualo-ui-kit-mobile 2.0.10 → 2.0.11
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 +1 -1
- package/package.json +1 -1
- package/src/elements/dialogs/DialogDown.tsx +70 -28
package/app.json
CHANGED
package/package.json
CHANGED
|
@@ -51,17 +51,17 @@ class DialogManager {
|
|
|
51
51
|
// Agregar a la cola
|
|
52
52
|
this.dialogs.push(dialog);
|
|
53
53
|
|
|
54
|
-
//
|
|
55
|
-
|
|
56
|
-
this.showNextDialog();
|
|
57
|
-
}
|
|
54
|
+
// Siempre mostrar el siguiente diálogo (por prioridad)
|
|
55
|
+
this.showNextDialog();
|
|
58
56
|
|
|
59
57
|
this.notify();
|
|
60
58
|
}
|
|
61
59
|
|
|
62
60
|
removeDialog(id: string) {
|
|
61
|
+
// Remover de la cola
|
|
63
62
|
this.dialogs = this.dialogs.filter((dialog) => dialog.id !== id);
|
|
64
63
|
|
|
64
|
+
// Si el diálogo que se está removiendo es el actual, limpiar y mostrar el siguiente
|
|
65
65
|
if (this.currentDialog?.id === id) {
|
|
66
66
|
this.currentDialog = null;
|
|
67
67
|
this.showNextDialog();
|
|
@@ -82,6 +82,8 @@ class DialogManager {
|
|
|
82
82
|
// Ordenar por prioridad (mayor prioridad primero)
|
|
83
83
|
this.dialogs.sort((a, b) => b.priority - a.priority);
|
|
84
84
|
this.currentDialog = this.dialogs[0];
|
|
85
|
+
} else {
|
|
86
|
+
this.currentDialog = null;
|
|
85
87
|
}
|
|
86
88
|
}
|
|
87
89
|
|
|
@@ -90,10 +92,25 @@ class DialogManager {
|
|
|
90
92
|
}
|
|
91
93
|
|
|
92
94
|
clear() {
|
|
95
|
+
console.log('DialogManager: Clearing all dialogs');
|
|
93
96
|
this.dialogs = [];
|
|
94
97
|
this.currentDialog = null;
|
|
95
98
|
this.notify();
|
|
96
99
|
}
|
|
100
|
+
|
|
101
|
+
// Método para forzar la limpieza de un diálogo específico
|
|
102
|
+
forceRemoveDialog(id: string) {
|
|
103
|
+
console.log('DialogManager: Force removing dialog', { id });
|
|
104
|
+
this.dialogs = this.dialogs.filter((dialog) => dialog.id !== id);
|
|
105
|
+
|
|
106
|
+
if (this.currentDialog?.id === id) {
|
|
107
|
+
this.currentDialog = null;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
// Mostrar el siguiente diálogo si hay alguno
|
|
111
|
+
this.showNextDialog();
|
|
112
|
+
this.notify();
|
|
113
|
+
}
|
|
97
114
|
}
|
|
98
115
|
|
|
99
116
|
export const DialogDown = (props: IDialogDown & { priority?: 0 | 1 | 2 | 3 | 4 | 5 }) => {
|
|
@@ -113,41 +130,62 @@ export const DialogDown = (props: IDialogDown & { priority?: 0 | 1 | 2 | 3 | 4 |
|
|
|
113
130
|
// Suscribirse a cambios en el diálogo actual
|
|
114
131
|
useEffect(() => {
|
|
115
132
|
const unsubscribe = dialogManager.current.subscribe(() => {
|
|
116
|
-
|
|
133
|
+
const newCurrentDialog = dialogManager.current.getCurrentDialog();
|
|
134
|
+
setCurrentDialog(newCurrentDialog);
|
|
117
135
|
});
|
|
118
136
|
return () => {
|
|
119
137
|
unsubscribe();
|
|
120
138
|
};
|
|
121
139
|
}, []);
|
|
122
140
|
|
|
141
|
+
// Función helper para agregar diálogo al manager
|
|
142
|
+
const addDialogToManager = (dialogId: string) => {
|
|
143
|
+
dialogManager.current.addDialog({
|
|
144
|
+
...props,
|
|
145
|
+
id: dialogId,
|
|
146
|
+
priority: priority || 0,
|
|
147
|
+
onDismiss: () => {
|
|
148
|
+
Animated.timing(slideAnim, {
|
|
149
|
+
toValue: 0,
|
|
150
|
+
duration: 200,
|
|
151
|
+
useNativeDriver: true,
|
|
152
|
+
}).start(() => {
|
|
153
|
+
dialogManager.current.removeDialog(dialogId);
|
|
154
|
+
setDialogId(null);
|
|
155
|
+
onDismiss();
|
|
156
|
+
});
|
|
157
|
+
},
|
|
158
|
+
});
|
|
159
|
+
};
|
|
160
|
+
|
|
123
161
|
// Manejar cuando se debe mostrar/ocultar el diálogo
|
|
124
162
|
useEffect(() => {
|
|
125
163
|
if (isVisible) {
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
164
|
+
if (!dialogId) {
|
|
165
|
+
// Generar nuevo ID cada vez que se muestra el diálogo
|
|
166
|
+
const newDialogId = Math.random().toString(36).substring(2, 11);
|
|
167
|
+
setDialogId(newDialogId);
|
|
168
|
+
} else if (dialogId && !currentDialog) {
|
|
169
|
+
// Si ya tiene ID pero no está en el manager, agregarlo
|
|
170
|
+
addDialogToManager(dialogId);
|
|
171
|
+
} else if (dialogId && currentDialog && currentDialog.id !== dialogId) {
|
|
172
|
+
// Si ya tiene ID pero hay otro diálogo actual, agregarlo (el manager manejará prioridades)
|
|
173
|
+
addDialogToManager(dialogId);
|
|
174
|
+
}
|
|
175
|
+
} else if (dialogId) {
|
|
176
|
+
dialogManager.current.removeDialog(dialogId);
|
|
177
|
+
setDialogId(null);
|
|
178
|
+
}
|
|
179
|
+
}, [isVisible, dialogId, currentDialog, priority, title]);
|
|
180
|
+
|
|
181
|
+
// Cleanup al desmontar el componente
|
|
182
|
+
useEffect(() => {
|
|
183
|
+
return () => {
|
|
145
184
|
if (dialogId) {
|
|
146
185
|
dialogManager.current.removeDialog(dialogId);
|
|
147
|
-
setDialogId(null);
|
|
148
186
|
}
|
|
149
|
-
}
|
|
150
|
-
}, [
|
|
187
|
+
};
|
|
188
|
+
}, [dialogId]);
|
|
151
189
|
|
|
152
190
|
// Animación basada en si este diálogo es el actual
|
|
153
191
|
useEffect(() => {
|
|
@@ -178,11 +216,15 @@ export const DialogDown = (props: IDialogDown & { priority?: 0 | 1 | 2 | 3 | 4 |
|
|
|
178
216
|
const handleDismiss = () => {
|
|
179
217
|
if (dialogId) {
|
|
180
218
|
dialogManager.current.removeDialog(dialogId);
|
|
219
|
+
// Limpiar el dialogId inmediatamente después de remover
|
|
220
|
+
setDialogId(null);
|
|
181
221
|
}
|
|
222
|
+
// Llamar onDismiss para que el componente padre cambie isVisible a false
|
|
223
|
+
onDismiss();
|
|
182
224
|
};
|
|
183
225
|
|
|
184
226
|
// Solo renderizar si este diálogo es el actual
|
|
185
|
-
const isCurrentDialog = Boolean(currentDialog && currentDialog.id === dialogId);
|
|
227
|
+
const isCurrentDialog = Boolean(isVisible && dialogId && currentDialog && currentDialog.id === dialogId);
|
|
186
228
|
|
|
187
229
|
return (
|
|
188
230
|
<Modal visible={isCurrentDialog} transparent={true} animationType="none" onRequestClose={handleDismiss}>
|