mg-library 1.0.799 → 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 +97 -4
- package/package.json +1 -1
package/components.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import React, { useRef, useState } from "react";
|
|
2
2
|
import { Platform, Animated } from "react-native";
|
|
3
|
-
import {
|
|
3
|
+
import { OverlayProvider } from '@react-native-aria/overlays';
|
|
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
|
|
|
6
7
|
import * as mgFunctionsLib from './functions.js';
|
|
@@ -167,7 +168,7 @@ export function MGButton({
|
|
|
167
168
|
);
|
|
168
169
|
}
|
|
169
170
|
|
|
170
|
-
export function MGPopover(props) {
|
|
171
|
+
/* export function MGPopover(props) {
|
|
171
172
|
const { title, icon, language, callback } = props;
|
|
172
173
|
const [open, setOpen] = useState(false);
|
|
173
174
|
|
|
@@ -219,6 +220,98 @@ export function MGPopover(props) {
|
|
|
219
220
|
</PopoverContent>
|
|
220
221
|
</Popover>
|
|
221
222
|
);
|
|
223
|
+
} */
|
|
224
|
+
|
|
225
|
+
export function MGPopover(props) {
|
|
226
|
+
const { title, icon, language, callback } = props;
|
|
227
|
+
const [open, setOpen] = useState(false);
|
|
228
|
+
|
|
229
|
+
const handleConfirm = async () => {
|
|
230
|
+
try {
|
|
231
|
+
await callback?.();
|
|
232
|
+
} finally {
|
|
233
|
+
setOpen(false);
|
|
234
|
+
}
|
|
235
|
+
};
|
|
236
|
+
|
|
237
|
+
return (
|
|
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>
|
|
314
|
+
);
|
|
222
315
|
}
|
|
223
316
|
|
|
224
317
|
export function MGDivider({ style, ...props }) {
|
|
@@ -227,9 +320,9 @@ export function MGDivider({ style, ...props }) {
|
|
|
227
320
|
h="$0.55"
|
|
228
321
|
flexGrow={1}
|
|
229
322
|
alignSelf="stretch"
|
|
230
|
-
style={style}
|
|
323
|
+
style={style}
|
|
231
324
|
{...props}
|
|
232
|
-
bg="$gray400"
|
|
325
|
+
bg="$gray400"
|
|
233
326
|
/>
|
|
234
327
|
);
|
|
235
328
|
}
|