ikualo-ui-kit-mobile 2.1.17 → 2.1.18
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/package.json
CHANGED
|
@@ -1,6 +1,15 @@
|
|
|
1
1
|
import { Icon, Text } from 'react-native-paper';
|
|
2
2
|
import { getStylesDialog } from '../../../assets/styles/elements/dialog';
|
|
3
|
-
import {
|
|
3
|
+
import {
|
|
4
|
+
View,
|
|
5
|
+
TouchableWithoutFeedback,
|
|
6
|
+
Modal,
|
|
7
|
+
Keyboard,
|
|
8
|
+
TouchableHighlight,
|
|
9
|
+
Animated,
|
|
10
|
+
BackHandler,
|
|
11
|
+
Platform,
|
|
12
|
+
} from 'react-native';
|
|
4
13
|
import { useEffect, useState, useRef } from 'react';
|
|
5
14
|
import useStore from '../../store';
|
|
6
15
|
import { IDialogDown } from '../../models';
|
|
@@ -8,7 +17,7 @@ import { IDialogDown } from '../../models';
|
|
|
8
17
|
// Sistema simple de prioridades global
|
|
9
18
|
class PriorityManager {
|
|
10
19
|
private static instance: PriorityManager;
|
|
11
|
-
private currentDialog: { id: string; priority: number; onDismiss
|
|
20
|
+
private currentDialog: { id: string; priority: number; onDismiss?: () => void } | null = null;
|
|
12
21
|
private readonly listeners: Set<() => void> = new Set();
|
|
13
22
|
|
|
14
23
|
static getInstance(): PriorityManager {
|
|
@@ -27,10 +36,10 @@ class PriorityManager {
|
|
|
27
36
|
this.listeners.forEach((listener) => listener());
|
|
28
37
|
}
|
|
29
38
|
|
|
30
|
-
showDialog(id: string, priority: number, onDismiss
|
|
39
|
+
showDialog(id: string, priority: number, onDismiss?: () => void) {
|
|
31
40
|
// Si hay un diálogo actual y el nuevo tiene mayor prioridad, cerrar el actual
|
|
32
41
|
if (this.currentDialog && priority > this.currentDialog.priority) {
|
|
33
|
-
this.currentDialog.onDismiss();
|
|
42
|
+
this.currentDialog.onDismiss?.();
|
|
34
43
|
this.currentDialog = null;
|
|
35
44
|
}
|
|
36
45
|
|
|
@@ -129,16 +138,38 @@ export const DialogDown = (props: IDialogDown & { priority?: 0 | 1 | 2 | 3 | 4 |
|
|
|
129
138
|
};
|
|
130
139
|
}, []);
|
|
131
140
|
|
|
141
|
+
useEffect(() => {
|
|
142
|
+
if (Platform.OS === 'android' && !onDismiss && isVisible) {
|
|
143
|
+
const backHandler = BackHandler.addEventListener('hardwareBackPress', () => {
|
|
144
|
+
// Si no hay onDismiss, prevenir el cierre
|
|
145
|
+
return true;
|
|
146
|
+
});
|
|
147
|
+
return () => backHandler.remove();
|
|
148
|
+
}
|
|
149
|
+
}, [isVisible, onDismiss]);
|
|
150
|
+
|
|
132
151
|
const handleDismiss = () => {
|
|
133
152
|
priorityManager.current.hideDialog(dialogId);
|
|
134
|
-
onDismiss();
|
|
153
|
+
onDismiss?.();
|
|
154
|
+
};
|
|
155
|
+
|
|
156
|
+
const handleRequestClose = () => {
|
|
157
|
+
if (onDismiss) {
|
|
158
|
+
handleDismiss();
|
|
159
|
+
}
|
|
160
|
+
// Si no hay onDismiss, no hacer nada - previene el cierre
|
|
135
161
|
};
|
|
136
162
|
|
|
137
163
|
// Solo renderizar si este diálogo es el actual
|
|
138
164
|
const isCurrentDialog = Boolean(isVisible && currentDialog && currentDialog.id === dialogId);
|
|
139
165
|
|
|
140
166
|
return (
|
|
141
|
-
<Modal
|
|
167
|
+
<Modal
|
|
168
|
+
visible={isCurrentDialog}
|
|
169
|
+
transparent={true}
|
|
170
|
+
animationType="none"
|
|
171
|
+
onRequestClose={handleRequestClose}
|
|
172
|
+
>
|
|
142
173
|
<TouchableWithoutFeedback onPress={handleDismissKeyboard}>
|
|
143
174
|
<View style={stylesDialog.modalBackground}>
|
|
144
175
|
<Animated.View
|
|
@@ -64,8 +64,19 @@ export const DialogExamples = () => {
|
|
|
64
64
|
setIsVisible2(true);
|
|
65
65
|
}}
|
|
66
66
|
/>
|
|
67
|
-
<DialogDown
|
|
67
|
+
<DialogDown
|
|
68
|
+
isVisible={isVisible2}
|
|
69
|
+
showCloseButton={false}
|
|
70
|
+
title="Titulo de prueba"
|
|
71
|
+
//onDismiss={() => setIsVisible2(false)}
|
|
72
|
+
>
|
|
68
73
|
<Text>Texto de prueba</Text>
|
|
74
|
+
<BtnContained
|
|
75
|
+
text="Aceptar"
|
|
76
|
+
onPress={() => {
|
|
77
|
+
setIsVisible2(false);
|
|
78
|
+
}}
|
|
79
|
+
/>
|
|
69
80
|
</DialogDown>
|
|
70
81
|
<BtnContained
|
|
71
82
|
text="Modal bajo animacion"
|