mg-library 1.0.721 → 1.0.722
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 +36 -93
- package/package.json +1 -1
package/components.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
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,
|
|
3
|
+
import { Box, Text, Divider, Button, ButtonText, ButtonIcon, Icon, Popover, PopoverAnchor, PopoverBackdrop, PopoverContent, PopoverArrow, PopoverCloseButton, PopoverBody, PopoverFooter } from '@gluestack-ui/themed';
|
|
4
4
|
import MaterialCommunityIcons from 'react-native-vector-icons/MaterialCommunityIcons';
|
|
5
5
|
|
|
6
6
|
import * as mgFunctionsLib from './functions.js';
|
|
@@ -167,110 +167,53 @@ export function MGButton({
|
|
|
167
167
|
);
|
|
168
168
|
}
|
|
169
169
|
|
|
170
|
-
export function MGPopover({
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
try {
|
|
194
|
-
setLoading(true);
|
|
195
|
-
await callback?.();
|
|
196
|
-
} finally {
|
|
197
|
-
setLoading(false);
|
|
198
|
-
setOpen(false);
|
|
199
|
-
}
|
|
200
|
-
};
|
|
170
|
+
export function MGPopover(props) {
|
|
171
|
+
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
|
+
);
|
|
201
193
|
return (
|
|
202
|
-
<Popover
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
{...tp}
|
|
212
|
-
action={triggerProps.action ?? "primary"}
|
|
213
|
-
variant={triggerProps.variant ?? "solid"}
|
|
214
|
-
py={triggerProps.py ?? "$4"}
|
|
215
|
-
bg={triggerProps.bg}
|
|
216
|
-
borderColor={triggerProps.borderColor}
|
|
217
|
-
isDisabled={triggerProps.isDisabled}
|
|
218
|
-
>
|
|
219
|
-
{icon ? (
|
|
220
|
-
<Icon as={MaterialCommunityIcons} name={icon} mr="$2" color="$white" />
|
|
221
|
-
) : null}
|
|
222
|
-
<ButtonText>{title}</ButtonText>
|
|
223
|
-
</Button>
|
|
224
|
-
)}
|
|
225
|
-
</PopoverTrigger>
|
|
194
|
+
<Popover isOpen={open} onOpenChange={setOpen}>
|
|
195
|
+
<PopoverAnchor>
|
|
196
|
+
<Button action="primary" variant="solid" py="$4" onPress={() => setOpen(true)}>
|
|
197
|
+
{props.icon ? (
|
|
198
|
+
<Icon as={MaterialCommunityIcons} name={props.icon} mr="$2" color="$white" />
|
|
199
|
+
) : null}
|
|
200
|
+
<ButtonText>{props.title}</ButtonText>
|
|
201
|
+
</Button>
|
|
202
|
+
</PopoverAnchor>
|
|
226
203
|
<PopoverBackdrop />
|
|
227
|
-
<PopoverContent w={
|
|
204
|
+
<PopoverContent w={300} bg="$white">
|
|
228
205
|
<PopoverArrow />
|
|
229
206
|
<PopoverCloseButton />
|
|
230
207
|
<PopoverBody>
|
|
231
208
|
<Box alignItems="center" justifyContent="center">
|
|
232
209
|
<Icon as={MaterialCommunityIcons} name="alert-outline" size={16} color="$primary500" mb="$3" />
|
|
233
210
|
<MGText textAlign="center">
|
|
234
|
-
{mgFunctionsLib.i18nString("confirm", language)}?
|
|
211
|
+
{mgFunctionsLib.i18nString("confirm", props.language)}?
|
|
235
212
|
</MGText>
|
|
236
213
|
</Box>
|
|
237
214
|
</PopoverBody>
|
|
238
|
-
<PopoverFooter>
|
|
239
|
-
<Box flexDirection="row" justifyContent="space-around" mt="$5" mb="$5">
|
|
240
|
-
<MGButton
|
|
241
|
-
title={confirmText}
|
|
242
|
-
action={confirmColor}
|
|
243
|
-
variant={confirmVariant}
|
|
244
|
-
py="$4"
|
|
245
|
-
icon={confirmIcon}
|
|
246
|
-
isLoading={loading}
|
|
247
|
-
disabled={loading}
|
|
248
|
-
callback={handleConfirm}
|
|
249
|
-
/>
|
|
250
|
-
<MGButton
|
|
251
|
-
title={cancelText}
|
|
252
|
-
action="primary"
|
|
253
|
-
variant="outline"
|
|
254
|
-
py="$4"
|
|
255
|
-
disabled={loading}
|
|
256
|
-
callback={() => setOpen(false)}
|
|
257
|
-
/>
|
|
258
|
-
</Box>
|
|
259
|
-
</PopoverFooter>
|
|
215
|
+
<PopoverFooter>{footer}</PopoverFooter>
|
|
260
216
|
</PopoverContent>
|
|
261
217
|
</Popover>
|
|
262
218
|
);
|
|
263
|
-
}
|
|
264
|
-
|
|
265
|
-
export function MGDivider({ style, ...props }) {
|
|
266
|
-
return (
|
|
267
|
-
<Divider
|
|
268
|
-
h="$0.50"
|
|
269
|
-
flexGrow={1}
|
|
270
|
-
alignSelf="stretch"
|
|
271
|
-
bg="$gray300"
|
|
272
|
-
style={style}
|
|
273
|
-
{...props}
|
|
274
|
-
/>
|
|
275
|
-
);
|
|
276
219
|
}
|