mg-library 1.0.726 → 1.0.728

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 CHANGED
@@ -1,6 +1,7 @@
1
1
  import React, { useRef, useState } from "react";
2
2
  import { Platform, Animated, View } from "react-native";
3
- import { Box, Text, Divider, Button, ButtonText, ButtonIcon, Icon, Popover, PopoverAnchor, PopoverBackdrop, PopoverContent, PopoverArrow, PopoverCloseButton, PopoverBody, PopoverFooter } from '@gluestack-ui/themed';
3
+ import { Box, Text, Divider, ButtonIcon, Icon, Popover, PopoverTrigger, PopoverBackdrop, PopoverContent, PopoverArrow, PopoverCloseButton, PopoverBody, PopoverFooter } from '@gluestack-ui/themed';
4
+ import { Button, ButtonText } from '@gluestack-ui/button';
4
5
  import MaterialCommunityIcons from 'react-native-vector-icons/MaterialCommunityIcons';
5
6
 
6
7
  import * as mgFunctionsLib from './functions.js';
@@ -168,41 +169,23 @@ export function MGButton({
168
169
  }
169
170
 
170
171
  export function MGPopover(props) {
172
+ const { title, icon, language, callback } = props;
171
173
  const [open, setOpen] = useState(false);
172
- const footer = (
173
- <Box flexDirection="row" justifyContent="space-around" mt="$5" mb="$5">
174
- <MGButton
175
- title={mgFunctionsLib.i18nString("yes", props.language)}
176
- action="primary"
177
- variant="solid"
178
- py="$4"
179
- callback={async () => {
180
- setOpen(false);
181
- await props.callback?.();
182
- }}
183
- />
184
- <MGButton
185
- title={mgFunctionsLib.i18nString("no", props.language)}
186
- action="primary"
187
- variant="outline"
188
- py="$4"
189
- callback={() => setOpen(false)}
190
- />
191
- </Box>
192
- );
174
+ const handleConfirm = async () => {
175
+ try {
176
+ await callback?.();
177
+ } finally {
178
+ setOpen(false);
179
+ }
180
+ };
193
181
  return (
194
- <Popover
195
- isOpen={open}
196
- onOpenChange={setOpen}
197
- trigger={(triggerProps) => (
198
- <Button {...triggerProps} action="primary" variant="solid">
199
- {props.icon ? (
200
- <Icon as={MaterialCommunityIcons} name={props.icon} mr="$2" color="$white" />
201
- ) : null}
202
- <ButtonText>{props.title}</ButtonText>
182
+ <Popover isOpen={open} onOpenChange={setOpen}>
183
+ <PopoverTrigger>
184
+ <Button action="primary" variant="solid" onPress={() => setOpen(true)}>
185
+ {icon ? <Icon as={MaterialCommunityIcons} name={icon} mr="$2" color="$white" /> : null}
186
+ <ButtonText>{title}</ButtonText>
203
187
  </Button>
204
- )}
205
- >
188
+ </PopoverTrigger>
206
189
  <PopoverBackdrop />
207
190
  <PopoverContent w={300} bg="$white">
208
191
  <PopoverArrow />
@@ -211,11 +194,20 @@ export function MGPopover(props) {
211
194
  <Box alignItems="center" justifyContent="center">
212
195
  <Icon as={MaterialCommunityIcons} name="alert-outline" size={16} color="$primary500" mb="$3" />
213
196
  <MGText textAlign="center">
214
- {mgFunctionsLib.i18nString("confirm", props.language)}?
197
+ {mgFunctionsLib.i18nString('confirm', language)}?
215
198
  </MGText>
216
199
  </Box>
217
200
  </PopoverBody>
218
- <PopoverFooter>{footer}</PopoverFooter>
201
+ <PopoverFooter>
202
+ <Box flexDirection="row" justifyContent="space-around" mt="$5" mb="$5">
203
+ <Button action="primary" variant="solid" py="$4" onPress={handleConfirm}>
204
+ <ButtonText>{mgFunctionsLib.i18nString('yes', language)}</ButtonText>
205
+ </Button>
206
+ <Button action="primary" variant="outline" py="$4" onPress={() => setOpen(false)}>
207
+ <ButtonText>{mgFunctionsLib.i18nString('no', language)}</ButtonText>
208
+ </Button>
209
+ </Box>
210
+ </PopoverFooter>
219
211
  </PopoverContent>
220
212
  </Popover>
221
213
  );
package/mg-library.rar CHANGED
Binary file
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mg-library",
3
- "version": "1.0.726",
3
+ "version": "1.0.728",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "react-native": "index.js",