mg-library 1.0.800 → 1.0.801
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/components.js +84 -33
- package/package.json +1 -1
package/components.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import React, { useRef, useState } from "react";
|
|
2
2
|
import { Platform, Animated } from "react-native";
|
|
3
|
+
import { OverlayProvider } from '@react-native-aria/overlays';
|
|
3
4
|
import { AlertDialog, AlertDialogBackdrop, AlertDialogContent, AlertDialogBody, AlertDialogFooter, Box, Text, Divider, Button, ButtonText, ButtonIcon, Icon, Popover, PopoverTrigger, PopoverBackdrop, PopoverContent, PopoverArrow, PopoverBody, PopoverFooter } from '@gluestack-ui/themed';
|
|
4
5
|
import MaterialCommunityIcons from 'react-native-vector-icons/MaterialCommunityIcons';
|
|
5
6
|
|
|
@@ -224,42 +225,92 @@ export function MGButton({
|
|
|
224
225
|
export function MGPopover(props) {
|
|
225
226
|
const { title, icon, language, callback } = props;
|
|
226
227
|
const [open, setOpen] = useState(false);
|
|
228
|
+
|
|
227
229
|
const handleConfirm = async () => {
|
|
228
|
-
try {
|
|
230
|
+
try {
|
|
231
|
+
await callback?.();
|
|
232
|
+
} finally {
|
|
233
|
+
setOpen(false);
|
|
234
|
+
}
|
|
229
235
|
};
|
|
236
|
+
|
|
230
237
|
return (
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
238
|
+
<OverlayProvider>
|
|
239
|
+
<>
|
|
240
|
+
<Button
|
|
241
|
+
action="primary"
|
|
242
|
+
variant="solid"
|
|
243
|
+
h={50}
|
|
244
|
+
onPress={() => setOpen(true)}
|
|
245
|
+
>
|
|
246
|
+
{icon ? (
|
|
247
|
+
<Icon
|
|
248
|
+
as={MaterialCommunityIcons}
|
|
249
|
+
name={icon}
|
|
250
|
+
mr="$2"
|
|
251
|
+
color="$white"
|
|
252
|
+
/>
|
|
253
|
+
) : null}
|
|
254
|
+
<ButtonText>{title}</ButtonText>
|
|
255
|
+
</Button>
|
|
256
|
+
<AlertDialog
|
|
257
|
+
isOpen={open}
|
|
258
|
+
onClose={() => setOpen(false)}
|
|
259
|
+
>
|
|
260
|
+
<AlertDialogBackdrop />
|
|
261
|
+
<AlertDialogContent
|
|
262
|
+
w={300}
|
|
263
|
+
alignSelf="center"
|
|
264
|
+
>
|
|
265
|
+
<AlertDialogBody>
|
|
266
|
+
<Box alignItems="center" justifyContent="center" py="$2">
|
|
267
|
+
<Icon
|
|
268
|
+
as={MaterialCommunityIcons}
|
|
269
|
+
name="alert-outline"
|
|
270
|
+
size={48}
|
|
271
|
+
color="$primary500"
|
|
272
|
+
mb="$3"
|
|
273
|
+
/>
|
|
274
|
+
<MGText textAlign="center">
|
|
275
|
+
{mgFunctionsLib.i18nString('confirm', language)}?
|
|
276
|
+
</MGText>
|
|
277
|
+
</Box>
|
|
278
|
+
</AlertDialogBody>
|
|
279
|
+
<AlertDialogFooter>
|
|
280
|
+
<Box
|
|
281
|
+
flex={1}
|
|
282
|
+
flexDirection="row"
|
|
283
|
+
justifyContent="space-around"
|
|
284
|
+
mt="$2"
|
|
285
|
+
mb="$2"
|
|
286
|
+
w="$full"
|
|
287
|
+
>
|
|
288
|
+
<Button
|
|
289
|
+
h={50}
|
|
290
|
+
action="primary"
|
|
291
|
+
variant="solid"
|
|
292
|
+
onPress={handleConfirm}
|
|
293
|
+
>
|
|
294
|
+
<ButtonText>
|
|
295
|
+
{mgFunctionsLib.i18nString('yes', language)}
|
|
296
|
+
</ButtonText>
|
|
297
|
+
</Button>
|
|
298
|
+
<Button
|
|
299
|
+
h={50}
|
|
300
|
+
action="primary"
|
|
301
|
+
variant="outline"
|
|
302
|
+
onPress={() => setOpen(false)}
|
|
303
|
+
>
|
|
304
|
+
<ButtonText>
|
|
305
|
+
{mgFunctionsLib.i18nString('no', language)}
|
|
306
|
+
</ButtonText>
|
|
307
|
+
</Button>
|
|
308
|
+
</Box>
|
|
309
|
+
</AlertDialogFooter>
|
|
310
|
+
</AlertDialogContent>
|
|
311
|
+
</AlertDialog>
|
|
312
|
+
</>
|
|
313
|
+
</OverlayProvider>
|
|
263
314
|
);
|
|
264
315
|
}
|
|
265
316
|
|