mg-library 1.0.633 → 1.0.634
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/blocks.js +167 -12
- package/package.json +1 -1
package/blocks.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { useCallback, useState, useEffect } from 'react';
|
|
2
2
|
import { useForm, Controller } from 'react-hook-form';
|
|
3
|
-
import { View, ActivityIndicator, Pressable, Image, FlatList, Keyboard, Dimensions } from 'react-native';
|
|
3
|
+
import { View, ActivityIndicator, Pressable, Image, FlatList, Keyboard, Dimensions, TextInput, StyleSheet } from 'react-native';
|
|
4
4
|
import MaterialCommunityIcons from 'react-native-vector-icons/MaterialCommunityIcons';
|
|
5
5
|
import * as ImageManipulator from 'expo-image-manipulator';
|
|
6
6
|
import { Camera, CameraType, CameraView } from 'expo-camera';
|
|
@@ -159,7 +159,7 @@ export function MGBenefits(props) {
|
|
|
159
159
|
|
|
160
160
|
}
|
|
161
161
|
|
|
162
|
-
export function MGLogin(props) {
|
|
162
|
+
/* export function MGLogin(props) {
|
|
163
163
|
|
|
164
164
|
const [isKeyboardVisible, setIsKeyboardVisible] = useState(false);
|
|
165
165
|
|
|
@@ -245,20 +245,17 @@ export function MGLogin(props) {
|
|
|
245
245
|
<Controller
|
|
246
246
|
control={control}
|
|
247
247
|
rules={{ maxLength: 50 }}
|
|
248
|
-
render={({ field: { onChange, value } }) => (
|
|
249
|
-
|
|
250
|
-
<NBInput placeholder="Test" />
|
|
251
|
-
|
|
252
|
-
/* <NBInput
|
|
248
|
+
render={({ field: { onChange, value } }) => (
|
|
249
|
+
<NBInput
|
|
253
250
|
size="lg"
|
|
254
251
|
py={3}
|
|
255
252
|
placeholder={mgFunctionsLib.i18nString('userName', props.language)}
|
|
256
253
|
onChangeText={onChange}
|
|
257
254
|
value={value}
|
|
258
|
-
/>
|
|
255
|
+
/>
|
|
259
256
|
)}
|
|
260
257
|
name="userName" />
|
|
261
|
-
{
|
|
258
|
+
{props.useNumericKeyboardOnPassword &&
|
|
262
259
|
<Controller
|
|
263
260
|
control={control}
|
|
264
261
|
rules={{ maxLength: 50 }}
|
|
@@ -292,7 +289,165 @@ export function MGLogin(props) {
|
|
|
292
289
|
/>
|
|
293
290
|
)}
|
|
294
291
|
name="password" />
|
|
295
|
-
}
|
|
292
|
+
}
|
|
293
|
+
</MGCard>
|
|
294
|
+
</View>
|
|
295
|
+
</View>
|
|
296
|
+
</Box>
|
|
297
|
+
</View>
|
|
298
|
+
);
|
|
299
|
+
|
|
300
|
+
} */
|
|
301
|
+
|
|
302
|
+
const nbStyles = StyleSheet.create({
|
|
303
|
+
input: {
|
|
304
|
+
height: 50,
|
|
305
|
+
borderWidth: 1,
|
|
306
|
+
borderColor: '#ccc',
|
|
307
|
+
borderRadius: 8,
|
|
308
|
+
paddingHorizontal: 12,
|
|
309
|
+
fontSize: 16,
|
|
310
|
+
backgroundColor: 'white'
|
|
311
|
+
}
|
|
312
|
+
});
|
|
313
|
+
|
|
314
|
+
export function MGLogin(props) {
|
|
315
|
+
|
|
316
|
+
const [isKeyboardVisible, setIsKeyboardVisible] = useState(false);
|
|
317
|
+
|
|
318
|
+
const { control, handleSubmit, formState: { errors } } = useForm({
|
|
319
|
+
defaultValues: props.defaultValues,
|
|
320
|
+
});
|
|
321
|
+
|
|
322
|
+
useEffect(() => {
|
|
323
|
+
Keyboard.addListener("keyboardDidShow", () => setIsKeyboardVisible(true));
|
|
324
|
+
Keyboard.addListener("keyboardDidHide", () => setIsKeyboardVisible(false));
|
|
325
|
+
return () => {
|
|
326
|
+
Keyboard.removeAllListeners("keyboardDidShow");
|
|
327
|
+
Keyboard.removeAllListeners("keyboardDidHide");
|
|
328
|
+
};
|
|
329
|
+
}, []);
|
|
330
|
+
|
|
331
|
+
const insets = useSafeAreaInsets();
|
|
332
|
+
|
|
333
|
+
let cardHeader = (
|
|
334
|
+
<View>
|
|
335
|
+
<MGText category='h6' style={{ alignSelf: 'center', color: props.colors.primary['500'] }}>{mgFunctionsLib.i18nString('credentials', props.language)}</MGText>
|
|
336
|
+
</View>
|
|
337
|
+
);
|
|
338
|
+
|
|
339
|
+
const loginIcon = () => (
|
|
340
|
+
<MaterialCommunityIcons name='logout' color='white' size={20} />
|
|
341
|
+
);
|
|
342
|
+
|
|
343
|
+
let cardFooter = (
|
|
344
|
+
<View>
|
|
345
|
+
<NBButton
|
|
346
|
+
py={4} colorScheme="primary"
|
|
347
|
+
leftIcon={
|
|
348
|
+
<NBIcon as={MaterialCommunityIcons} name="login" size="lg" color="white" />
|
|
349
|
+
}
|
|
350
|
+
onPress={handleSubmit((data) => {
|
|
351
|
+
props.setNavigator(undefined);
|
|
352
|
+
mgLoginLib.onPressLogin(
|
|
353
|
+
props.dispatch,
|
|
354
|
+
props.actions,
|
|
355
|
+
props.app,
|
|
356
|
+
props.apiUrl,
|
|
357
|
+
props.language,
|
|
358
|
+
data);
|
|
359
|
+
})}>
|
|
360
|
+
<MGText category='p1' color='white'>
|
|
361
|
+
{mgFunctionsLib.i18nString('login', props.language)}
|
|
362
|
+
</MGText>
|
|
363
|
+
</NBButton>
|
|
364
|
+
</View>
|
|
365
|
+
);
|
|
366
|
+
|
|
367
|
+
return (
|
|
368
|
+
<View style={{ flex: 1 }}>
|
|
369
|
+
<Box style={[mgFunctionsLib.safeAreaViewStyleSheet(insets).safeAreaView, { display: 'flex', flexDirection: 'column', flexGrow: 1 }]}>
|
|
370
|
+
<View style={{ flexDirection: 'column', flexGrow: 1, justifyContent: 'center' }}>
|
|
371
|
+
{isKeyboardVisible &&
|
|
372
|
+
<View style={{ flexDirection: 'column', alignItems: 'center', marginBottom: 10 }}>
|
|
373
|
+
<>
|
|
374
|
+
<Image
|
|
375
|
+
source={require('./assets/clubonline.png')}
|
|
376
|
+
style={{ width: 180, height: 90 }} />
|
|
377
|
+
</>
|
|
378
|
+
</View>
|
|
379
|
+
}
|
|
380
|
+
{!isKeyboardVisible &&
|
|
381
|
+
<View style={{ flexDirection: 'column', alignItems: 'center', marginBottom: 100 }}>
|
|
382
|
+
<>
|
|
383
|
+
<Image
|
|
384
|
+
source={require('./assets/clubonline.png')}
|
|
385
|
+
style={{ width: 300, height: 150 }} />
|
|
386
|
+
<View style={{ marginHorizontal: 10, flexDirection: 'column', alignItems: 'center' }}>
|
|
387
|
+
<MGText style={{ alignSelf: 'center', textAlign: 'center' }} category='h6'>{props.appDescription}</MGText>
|
|
388
|
+
<MGText style={{ alignSelf: 'center' }} category='p2'>{props.appVersion}</MGText>
|
|
389
|
+
</View>
|
|
390
|
+
</>
|
|
391
|
+
</View>
|
|
392
|
+
}
|
|
393
|
+
<View>
|
|
394
|
+
<MGCard style={{ flexDirection: 'column', justifyContent: 'center', alignContent: 'center', marginLeft: 30, marginRight: 30 }}
|
|
395
|
+
header={cardHeader}
|
|
396
|
+
footer={cardFooter}>
|
|
397
|
+
<Controller
|
|
398
|
+
control={control}
|
|
399
|
+
rules={{ maxLength: 50 }}
|
|
400
|
+
render={({ field: { onChange, value } }) => (
|
|
401
|
+
<TextInput
|
|
402
|
+
style={nbStyles.input}
|
|
403
|
+
placeholder={mgFunctionsLib.i18nString('userName', props.language)}
|
|
404
|
+
placeholderTextColor="#888"
|
|
405
|
+
onChangeText={onChange}
|
|
406
|
+
value={value}
|
|
407
|
+
/>
|
|
408
|
+
)}
|
|
409
|
+
name="userName" />
|
|
410
|
+
{props.useNumericKeyboardOnPassword &&
|
|
411
|
+
<Controller
|
|
412
|
+
control={control}
|
|
413
|
+
rules={{ maxLength: 50 }}
|
|
414
|
+
render={({ field: { onChange, value } }) => (
|
|
415
|
+
<TextInput
|
|
416
|
+
style={nbStyles.input}
|
|
417
|
+
placeholder={mgFunctionsLib.i18nString('password', props.language)}
|
|
418
|
+
placeholderTextColor="#888"
|
|
419
|
+
onChangeText={onChange}
|
|
420
|
+
value={value}
|
|
421
|
+
secureTextEntry
|
|
422
|
+
maxLength={12}
|
|
423
|
+
keyboardType="numeric"
|
|
424
|
+
autoCapitalize="none"
|
|
425
|
+
autoCorrect={false}
|
|
426
|
+
returnKeyType="done"
|
|
427
|
+
/>
|
|
428
|
+
)}
|
|
429
|
+
name='password' />
|
|
430
|
+
}
|
|
431
|
+
{!props.useNumericKeyboardOnPassword &&
|
|
432
|
+
<Controller
|
|
433
|
+
control={control}
|
|
434
|
+
rules={{ maxLength: 50 }}
|
|
435
|
+
render={({ field: { onChange, value } }) => (
|
|
436
|
+
<TextInput
|
|
437
|
+
style={nbStyles.input}
|
|
438
|
+
placeholder={mgFunctionsLib.i18nString('password', props.language)}
|
|
439
|
+
placeholderTextColor="#888"
|
|
440
|
+
onChangeText={onChange}
|
|
441
|
+
value={value}
|
|
442
|
+
secureTextEntry
|
|
443
|
+
maxLength={12}
|
|
444
|
+
autoCapitalize="none"
|
|
445
|
+
autoCorrect={false}
|
|
446
|
+
returnKeyType="done"
|
|
447
|
+
/>
|
|
448
|
+
)}
|
|
449
|
+
name="password" />
|
|
450
|
+
}
|
|
296
451
|
</MGCard>
|
|
297
452
|
</View>
|
|
298
453
|
</View>
|
|
@@ -455,7 +610,7 @@ export function MGCamera(props) {
|
|
|
455
610
|
</View>
|
|
456
611
|
);
|
|
457
612
|
return (
|
|
458
|
-
<View style={{marginTop: 10}}>
|
|
613
|
+
<View style={{ marginTop: 10 }}>
|
|
459
614
|
<MGCard header={cardHeader} footer={cardFooter}>
|
|
460
615
|
<View style={{ alignItems: 'center' }}>
|
|
461
616
|
<CameraView
|
|
@@ -533,7 +688,7 @@ export function MGCameraPreview(props) {
|
|
|
533
688
|
</View>
|
|
534
689
|
);
|
|
535
690
|
return (
|
|
536
|
-
<View style={{marginTop: 10}}>
|
|
691
|
+
<View style={{ marginTop: 10 }}>
|
|
537
692
|
<MGCard header={cardHeader} footer={cardFooter}>
|
|
538
693
|
<View style={{ alignItems: 'center' }}>
|
|
539
694
|
<Image source={{ uri: props.process.fileUri }} style={{ width: 200, height: 200 }} />
|