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