mg-library 1.0.321 → 1.0.323

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 +73 -1
  2. package/package.json +1 -1
package/blocks.js CHANGED
@@ -1,8 +1,11 @@
1
1
  import { useCallback, useState } from 'react';
2
- import { View, ActivityIndicator, Pressable, Camera } from 'react-native';
2
+ import { View, ActivityIndicator, Pressable, Image } 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
5
  import * as ImageManipulator from 'expo-image-manipulator';
6
+ import { Camera } from 'expo-camera';
7
+ import axios from 'axios';
8
+ import { uploadFile } from '@uploadcare/upload-client';
6
9
 
7
10
  import * as mgFunctionsLib from './functions.js';
8
11
 
@@ -91,6 +94,75 @@ export function MGCamera(props) {
91
94
  )
92
95
  }
93
96
 
97
+ export function MGCameraPreview(props) {
98
+ let fileName = 'photo-' + Math.random().toString(36).substring(7) + '-' + Math.random().toString(36).substring(7);
99
+ const __savePicture = async () => {
100
+ const asset = {
101
+ uri: props.process.fileUri,
102
+ name: fileName,
103
+ type: 'image/jpg'
104
+ }
105
+ uploadFile(asset, { publicKey: props.mediaAppPublicKey })
106
+ .then((file) => {
107
+ let fileUUID = file.uuid;
108
+ let requestData = props.requestData;
109
+ requestData.photoMediaAppId = fileUUID;
110
+ requestData.photoMediaAppFileName = fileName;
111
+ props.dispatch(props.actions.apiSuccess());
112
+ props.dispatch(props.actions.apiRequest());
113
+ axios.post(props.url, requestData, mgFunctionsLib.getRequestHeader())
114
+ .then(response => {
115
+ props.onSavePicture(response.data.photoUrl);
116
+ props.dispatch(props.actions.apiSuccess());
117
+ })
118
+ .catch(error => {
119
+ props.dispatch(props.actions.apiError());
120
+ mgFunctionsLib.showToastError(error);
121
+ })
122
+ })
123
+ .catch(error => {
124
+ props.dispatch(props.actions.apiError());
125
+ mgFunctionsLib.showToastError(error);
126
+ })
127
+ }
128
+ const SaveIcon = () => (
129
+ <MaterialCommunityIcons
130
+ name='cloud-upload-outline'
131
+ size={40}
132
+ style={{ color: 'white' }} />
133
+ );
134
+ const cardHeader = (
135
+ <View style={{ marginLeft: 15, marginTop: 10, marginBottom: 10 }}>
136
+ <Text category='h6'>{mgFunctionsLib.i18nString('photo', props.language)}</Text>
137
+ <Text>{mgFunctionsLib.i18nString('previewPhoto', props.language)}</Text>
138
+ </View>
139
+ );
140
+ const cardFooter = (
141
+ <View>
142
+ <View style={{ flexDirection: 'row' }}>
143
+ <View style={{ flex: 1, alignItems: 'center' }}>
144
+ <Button
145
+ style={{ width: 150 }}
146
+ status='primary'
147
+ accessoryLeft={SaveIcon}
148
+ onPress={__savePicture}>
149
+ <Text>{mgFunctionsLib.i18nString('doSavePhoto', props.language)}</Text>
150
+ </Button>
151
+ </View>
152
+ </View>
153
+ </View>
154
+ );
155
+ return (
156
+ <View>
157
+ <Card header={cardHeader} footer={cardFooter}>
158
+ <View style={{ alignItems: 'center' }}>
159
+ <Image source={{ uri: props.process.fileUri }} style={{ width: 200, height: 200 }} />
160
+ </View>
161
+ </Card>
162
+ </View>
163
+ )
164
+ }
165
+
94
166
  export function MGButton(props) {
95
167
  const icon = () => (
96
168
  <MaterialCommunityIcons
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mg-library",
3
- "version": "1.0.321",
3
+ "version": "1.0.323",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "scripts": {