mg-library 1.0.320 → 1.0.322

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 (2) hide show
  1. package/blocks.js +87 -0
  2. package/package.json +1 -1
package/blocks.js CHANGED
@@ -2,9 +2,96 @@ import { useCallback, useState } from 'react';
2
2
  import { View, ActivityIndicator, Pressable } from 'react-native';
3
3
  import { Text, Divider, Button, Popover, Card } from '@ui-kitten/components';
4
4
  import MaterialCommunityIcons from 'react-native-vector-icons/MaterialCommunityIcons';
5
+ import * as ImageManipulator from 'expo-image-manipulator';
6
+ import { Camera } from 'expo-camera';
5
7
 
6
8
  import * as mgFunctionsLib from './functions.js';
7
9
 
10
+ export function MGCamera(props) {
11
+ let camera;
12
+ const __takePicture = async () => {
13
+ if (!camera)
14
+ return;
15
+ let photo = await camera.takePictureAsync({ quality: 1 });
16
+ props.dispatch(props.actions.startProcessing());
17
+ photo = await ImageManipulator.manipulateAsync(
18
+ photo.uri,
19
+ [{ resize: { width: 287, height: 385 } }],
20
+ { compress: 1, format: ImageManipulator.SaveFormat.JPEG }
21
+ );
22
+ photo = await ImageManipulator.manipulateAsync(
23
+ photo.uri,
24
+ [{ flip: 'horizontal' }],
25
+ { compress: 1, format: ImageManipulator.SaveFormat.JPEG }
26
+ );
27
+ props.process.fileUri = photo.uri;
28
+ props.process.goForward(props.nextStep);
29
+ props.dispatch(props.actions.endProcessing());
30
+ }
31
+ const [type, setType] = useState(Camera.Constants.Type.front);
32
+ const FlipIcon = () => (
33
+ <MaterialCommunityIcons
34
+ name='camera-flip-outline'
35
+ size={30}
36
+ style={{ color: 'white' }} />
37
+ );
38
+ const TakeIcon = () => (
39
+ <MaterialCommunityIcons
40
+ name='camera-outline'
41
+ size={30}
42
+ style={{ color: 'white' }} />
43
+ );
44
+ const cardHeader = (
45
+ <View style={{ marginLeft: 15, marginTop: 10, marginBottom: 10 }}>
46
+ <Text category='h6'>{mgFunctionsLib.i18nString('photo',props.language)}</Text>
47
+ <Text>{mgFunctionsLib.i18nString('takePhoto',props.language)}</Text>
48
+ </View>
49
+ );
50
+ const cardFooter = (
51
+ <View>
52
+ <View style={{ flexDirection: 'row' }}>
53
+ <View style={{ flex: 1, alignItems: 'center' }}>
54
+ <Button
55
+ style={{ width: 150 }}
56
+ status='primary'
57
+ accessoryLeft={FlipIcon}
58
+ onPress={() => {
59
+ setType(
60
+ type === Camera.Constants.Type.back ? Camera.Constants.Type.front : Camera.Constants.Type.back
61
+ )
62
+ }}>
63
+ <Text>{mgFunctionsLib.i18nString('doInvertCamera',props.language)}</Text>
64
+ </Button>
65
+ </View>
66
+ <View style={{ flex: 1, alignItems: 'center' }}>
67
+ <Button
68
+ style={{ width: 150 }}
69
+ status='primary'
70
+ accessoryLeft={TakeIcon}
71
+ onPress={__takePicture}>
72
+ <Text>{mgFunctionsLib.i18nString('doTakePhoto',props.language)}</Text>
73
+ </Button>
74
+ </View>
75
+ </View>
76
+ </View>
77
+ );
78
+ return (
79
+ <View>
80
+ <Card header={cardHeader} footer={cardFooter}>
81
+ <View style={{ alignItems: 'center' }}>
82
+ <Camera
83
+ style={{ width: 287, height: 385 }}
84
+ type={type}
85
+ ref={(r) => {
86
+ camera = r
87
+ }}>
88
+ </Camera>
89
+ </View>
90
+ </Card>
91
+ </View>
92
+ )
93
+ }
94
+
8
95
  export function MGButton(props) {
9
96
  const icon = () => (
10
97
  <MaterialCommunityIcons
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mg-library",
3
- "version": "1.0.320",
3
+ "version": "1.0.322",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "scripts": {