mg-library 1.0.319 → 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.
Files changed (3) hide show
  1. package/blocks.js +133 -3
  2. package/functions.js +4 -2
  3. package/package.json +1 -1
package/blocks.js CHANGED
@@ -1,10 +1,96 @@
1
- import { useCallback } from 'react';
2
- import { View, ActivityIndicator, Pressable } from 'react-native';
3
- import { Text, Divider, Button } from '@ui-kitten/components';
1
+ import { useCallback, useState } from 'react';
2
+ import { View, ActivityIndicator, Pressable, Camera } from 'react-native';
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
@@ -26,6 +112,50 @@ export function MGButton(props) {
26
112
  )
27
113
  }
28
114
 
115
+ export function MGPopover(props) {
116
+ const [visible, setVisible] = useState(false);
117
+ const icon = () => (
118
+ <MaterialCommunityIcons
119
+ name={props.icon}
120
+ size={30}
121
+ style={{ color: 'white' }} />
122
+ );
123
+ const button = () => (
124
+ <Button
125
+ onPress={() => setVisible(true)}
126
+ status='primary'
127
+ accessoryLeft={icon}>
128
+ {props.title}
129
+ </Button>
130
+ );
131
+ let cardFooter = (
132
+ <>
133
+ <View style={{ flexGrow: 1, flexDirection: 'row', justifyContent: 'space-around', marginTop: 20, marginBottom: 20 }}>
134
+ <Button style={{ flexGrow: 0.3 }} onPress={() => { setVisible(false); props.callback() }}>
135
+ <Text>{mgFunctionsLib.i18nString('yes', props.language)}</Text>
136
+ </Button>
137
+ <Button style={{ flexGrow: 0.3 }} onPress={() => { setVisible(false) }}>
138
+ <Text>{mgFunctionsLib.i18nString('no', props.language)}</Text>
139
+ </Button>
140
+ </View>
141
+ </>
142
+ );
143
+ return (
144
+ <Popover
145
+ style={{ width: 300 }}
146
+ backdropStyle={{ backgroundColor: 'rgba(0, 0, 0, 0.5)' }}
147
+ visible={visible}
148
+ anchor={button}>
149
+ <Card footer={cardFooter}>
150
+ <View style={{ flexDirection: 'column', justifyContent: 'center', alignItems: 'center' }}>
151
+ <MaterialCommunityIcons name='alert-outline' color={props.theme['color-primary-500']} size={70} style={{ marginBottom: 10 }} />
152
+ <Text>{mgFunctionsLib.i18nString('confirm', props.language)} ?</Text>
153
+ </View>
154
+ </Card>
155
+ </Popover>
156
+ )
157
+ }
158
+
29
159
  export function MGGoBack(props) {
30
160
  const goBackIcon = () => (
31
161
  <MaterialCommunityIcons
package/functions.js CHANGED
@@ -100,13 +100,15 @@ export function i18nString(key, language, stringsSpanish, stringsEnglish) {
100
100
  case mgConstants.LANGUAGE_SPANISH.code: {
101
101
  value = mgStringsSpanish[key];
102
102
  if (value === undefined)
103
- value = stringsSpanish[key];
103
+ if (stringsSpanish != undefined)
104
+ value = stringsSpanish[key];
104
105
  break;
105
106
  }
106
107
  case mgConstants.LANGUAGE_ENGLISH.code: {
107
108
  value = mgStringsEnglish[key];
108
109
  if (value === undefined)
109
- value = stringsEnglish[key];
110
+ if (stringsEnglish != undefined)
111
+ value = stringsEnglish[key];
110
112
  break;
111
113
  }
112
114
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mg-library",
3
- "version": "1.0.319",
3
+ "version": "1.0.321",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "scripts": {