mg-library 1.0.567 → 1.0.570

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.
Files changed (3) hide show
  1. package/blocks.js +179 -18
  2. package/functions.js +0 -23
  3. package/package.json +1 -1
package/blocks.js CHANGED
@@ -356,7 +356,7 @@ function getHeightForCamera() {
356
356
  return Dimensions.get('window').height;
357
357
  }
358
358
 
359
- export function MGCamera(props) {
359
+ /* export function MGCamera(props) {
360
360
  let camera;
361
361
  let captureWidth = 0;
362
362
  let captureHeight = 0;
@@ -450,6 +450,184 @@ export function MGCamera(props) {
450
450
  )
451
451
  }
452
452
 
453
+ export function MGCameraPreview(props) {
454
+ let fileName = 'photo-' + Math.random().toString(36).substring(7) + '-' + Math.random().toString(36).substring(7);
455
+ const __savePicture = async () => {
456
+ const asset = {
457
+ uri: props.process.fileUri,
458
+ name: fileName,
459
+ type: 'image/jpg'
460
+ }
461
+ uploadFile(asset, { publicKey: props.mediaAppPublicKey })
462
+ .then((file) => {
463
+ let fileUUID = file.uuid;
464
+ let requestData = props.requestData;
465
+ requestData.photoMediaAppId = fileUUID;
466
+ requestData.photoMediaAppFileName = fileName;
467
+ props.dispatch(props.actions.apiSuccess());
468
+ props.dispatch(props.actions.apiRequest());
469
+ axios.post(props.url, requestData, mgFunctionsLib.getRequestHeader())
470
+ .then(response => {
471
+ props.onSavePicture(response.data.photoUrl);
472
+ props.dispatch(props.actions.apiSuccess());
473
+ })
474
+ .catch(error => {
475
+ props.dispatch(props.actions.apiError());
476
+ mgFunctionsLib.showToastError(error);
477
+ })
478
+ })
479
+ .catch(error => {
480
+ props.dispatch(props.actions.apiError());
481
+ mgFunctionsLib.showToastError(error);
482
+ })
483
+ }
484
+ const SaveIcon = () => (
485
+ <MaterialCommunityIcons
486
+ name='cloud-upload-outline'
487
+ size={40}
488
+ style={{ color: 'white' }} />
489
+ );
490
+ const cardHeader = (
491
+ <View style={{ marginLeft: 15, marginTop: 10, marginBottom: 10 }}>
492
+ <MGText category='h6'>{mgFunctionsLib.i18nString('photo', props.language)}</MGText>
493
+ <MGText>{mgFunctionsLib.i18nString('previewPhoto', props.language)}</MGText>
494
+ </View>
495
+ );
496
+ const cardFooter = (
497
+ <View>
498
+ <View style={{ flexDirection: 'row' }}>
499
+ <View style={{ flex: 1, alignItems: 'center' }}>
500
+ <Button
501
+ style={{ width: 150 }}
502
+ status='primary'
503
+ accessoryLeft={SaveIcon}
504
+ onPress={__savePicture}>
505
+ <MGText>{mgFunctionsLib.i18nString('doSavePhoto', props.language)}</MGText>
506
+ </Button>
507
+ </View>
508
+ </View>
509
+ </View>
510
+ );
511
+ return (
512
+ <View>
513
+ <Card header={cardHeader} footer={cardFooter}>
514
+ <View style={{ alignItems: 'center' }}>
515
+ <Image source={{ uri: props.process.fileUri }} style={{ width: 200, height: 200 }} />
516
+ </View>
517
+ </Card>
518
+ </View>
519
+ )
520
+ }
521
+ */
522
+
523
+ export function MGCamera(props) {
524
+ let camera;
525
+ let captureWidth = 0;
526
+ let captureHeight = 0;
527
+ try {
528
+ captureWidth = Math.floor(getWidthForCamera() * 0.47);
529
+ captureHeight = Math.floor(getHeightForCamera() * 0.31);
530
+ } catch (error) {
531
+ captureWidth = 205;
532
+ captureHeight = 275;
533
+ }
534
+ const __takePicture = async () => {
535
+ if (!camera)
536
+ return;
537
+ let photo = await camera.takePictureAsync({ quality: 1 });
538
+ props.dispatch(props.actions.startProcessing());
539
+ photo = await ImageManipulator.manipulateAsync(
540
+ photo.uri,
541
+ [{ resize: { width: captureWidth, height: captureHeight } }],
542
+ { compress: 1, format: ImageManipulator.SaveFormat.JPEG }
543
+ );
544
+ photo = await ImageManipulator.manipulateAsync(
545
+ photo.uri,
546
+ [{ flip: 'horizontal' }],
547
+ { compress: 1, format: ImageManipulator.SaveFormat.JPEG }
548
+ );
549
+ props.process.fileUri = photo.uri;
550
+ props.process.goForward(props.nextStep);
551
+ props.dispatch(props.actions.endProcessing());
552
+ }
553
+ const [facing, setFacing] = useState(mgConstantsLib.CAMERA_FACING_FRONT);
554
+ const FlipIcon = () => (
555
+ <MaterialCommunityIcons
556
+ name='camera-flip-outline'
557
+ size={30}
558
+ style={{ color: 'white' }} />
559
+ );
560
+ const TakeIcon = () => (
561
+ <MaterialCommunityIcons
562
+ name='camera-outline'
563
+ size={30}
564
+ style={{ color: 'white' }} />
565
+ );
566
+ const cardHeader = (
567
+ <View style={{ marginLeft: 15, marginTop: 10, marginBottom: 10 }}>
568
+ <MGText category='h6'>{mgFunctionsLib.i18nString('photo', props.language)}</MGText>
569
+ <MGText>{mgFunctionsLib.i18nString('takePhoto', props.language)}</MGText>
570
+ </View>
571
+ );
572
+ const cardFooter = (
573
+ <View>
574
+ <View style={{ flexDirection: 'row' }}>
575
+ <View style={{ flex: 1, alignItems: 'center' }}>
576
+
577
+ <NBButton
578
+ style={{ width: 150 }}
579
+ colorScheme="primary"
580
+ leftIcon={
581
+ <NBIcon
582
+ as={MaterialCommunityIcons}
583
+ name="camera-flip-outline"
584
+ size="lg"
585
+ color="white"
586
+ />
587
+ }
588
+ onPress={() => {
589
+ setFacing(
590
+ facing === mgConstantsLib.CAMERA_FACING_BACK
591
+ ? mgConstantsLib.CAMERA_FACING_FRONT
592
+ : mgConstantsLib.CAMERA_FACING_BACK
593
+ );
594
+ }}
595
+ >
596
+ <MGText category="p1" color="white">
597
+ {mgFunctionsLib.i18nString('doInvertCamera', props.language)}
598
+ </MGText>
599
+ </NBButton>
600
+
601
+ </View>
602
+ <View style={{ flex: 1, alignItems: 'center' }}>
603
+ <Button
604
+ style={{ width: 150 }}
605
+ status='primary'
606
+ accessoryLeft={TakeIcon}
607
+ onPress={__takePicture}>
608
+ <MGText>{mgFunctionsLib.i18nString('doTakePhoto', props.language)}</MGText>
609
+ </Button>
610
+ </View>
611
+ </View>
612
+ </View>
613
+ );
614
+ return (
615
+ <View>
616
+ <Card header={cardHeader} footer={cardFooter}>
617
+ <View style={{ alignItems: 'center' }}>
618
+ <CameraView
619
+ style={{ width: captureWidth, height: captureHeight }}
620
+ facing={facing}
621
+ ref={(r) => {
622
+ camera = r
623
+ }}>
624
+ </CameraView>
625
+ </View>
626
+ </Card>
627
+ </View>
628
+ )
629
+ }
630
+
453
631
  export function MGCameraPreview(props) {
454
632
  let fileName = 'photo-' + Math.random().toString(36).substring(7) + '-' + Math.random().toString(36).substring(7);
455
633
  const __savePicture = async () => {
@@ -584,23 +762,6 @@ export function MGPopover(props) {
584
762
  )
585
763
  }
586
764
 
587
- /* export function MGGoBack(props) {
588
- const goBackIcon = () => (
589
- <MaterialCommunityIcons
590
- name='keyboard-backspace'
591
- size={40}
592
- color={props.theme['color-primary-500']}
593
- onPress={() => props.process.goBack()} />
594
- );
595
- return (
596
- <View style={{ alignItems: 'flex-start', marginTop: -20 }}>
597
- <Button
598
- appearance='ghost'
599
- accessoryLeft={goBackIcon} />
600
- </View>
601
- )
602
- } */
603
-
604
765
  export function MGGoBack(props) {
605
766
  return (
606
767
  <View style={{ alignItems: 'flex-start', marginTop: -20 }}>
package/functions.js CHANGED
@@ -13,29 +13,6 @@ import * as mgConstants from './constants.js';
13
13
 
14
14
  // Navigator
15
15
 
16
- /*
17
- const logoutIcon = () => (
18
- <MaterialCommunityIcons name='logout' color='white' sie={20} style={{ flex: 1 }} />
19
- );
20
-
21
- export function navigatorHeader(insets, theme, onPressLogout, company) {
22
- let companyDescription = company.description;
23
- if (companyDescription.length > 25)
24
- companyDescription = companyDescription.substring(0, 25) + '...';
25
- return (
26
- <Box style={[safeAreaViewForNavigatorHeaderStyleSheet(insets).safeAreaView, { backgroundColor: theme['color-primary-500'], flexDirection: 'column', justifyContent: 'flex-end' }]}>
27
- <View style={{ flexDirection: 'row', flexGrow: 1 }}>
28
- <View style={{ flexGrow: 0.9, marginLeft: 10, alignSelf: 'center' }}>
29
- <MGText category='h5' style={{ color: 'white' }}>{companyDescription}</MGText>
30
- </View>
31
- <View style={{ flexGrow: 0.1, flexDirection: 'column' }}>
32
- <Button style={{ alignSelf: 'center' }} accessoryLeft={logoutIcon} onPress={() => { onPressLogout() }} />
33
- </View>
34
- </View>
35
- </Box>
36
- );
37
- } */
38
-
39
16
  export function navigatorHeader(insets, theme, onPressLogout, company) {
40
17
  let companyDescription = company.description;
41
18
  if (companyDescription.length > 25)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mg-library",
3
- "version": "1.0.567",
3
+ "version": "1.0.570",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "scripts": {