mg-library 1.0.452 → 1.0.454

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 +76 -18
  2. package/package.json +1 -1
package/blocks.js CHANGED
@@ -4,7 +4,7 @@ import { View, ActivityIndicator, Pressable, Image, FlatList, Keyboard, Dimensio
4
4
  import { Text, Divider, Button, Popover, Card, Layout, Input } from '@ui-kitten/components';
5
5
  import MaterialCommunityIcons from 'react-native-vector-icons/MaterialCommunityIcons';
6
6
  import * as ImageManipulator from 'expo-image-manipulator';
7
- import { Camera, CameraType } from 'expo-camera';
7
+ import { Camera, CameraType, CameraView } from 'expo-camera';
8
8
  import axios from 'axios';
9
9
  import { uploadFile } from '@uploadcare/upload-client';
10
10
  import { useSafeAreaInsets } from 'react-native-safe-area-context';
@@ -150,7 +150,7 @@ export function MGLogin(props) {
150
150
  source={require('./assets/clubonline.png')}
151
151
  style={{ width: 300, height: 150 }} />
152
152
  {!isKeyboardVisible &&
153
- <View style={{ flexDirection: 'column', flexGrow: 1, alignItems: 'center'}}>
153
+ <View style={{ flexDirection: 'column', flexGrow: 1, alignItems: 'center' }}>
154
154
  <Text style={{ alignSelf: 'center', textAlign: 'center' }} category='h6'>{props.appDescription}</Text>
155
155
  <Text style={{ alignSelf: 'center' }} category='p2'>{props.appVersion}</Text>
156
156
  </View>
@@ -204,7 +204,7 @@ export function MGLogin(props) {
204
204
  />
205
205
  )}
206
206
  name="password" />
207
- }
207
+ }
208
208
  </Card>
209
209
  </View>
210
210
  </View>
@@ -280,7 +280,7 @@ function getHeightForCamera() {
280
280
  return Dimensions.get('window').height;
281
281
  }
282
282
 
283
- export function MGCamera(props) {
283
+ /* export function MGCamera(props) {
284
284
  let camera;
285
285
  let captureWidth = 0;
286
286
  let captureHeight = 0;
@@ -310,11 +310,7 @@ export function MGCamera(props) {
310
310
  props.process.goForward(props.nextStep);
311
311
  props.dispatch(props.actions.endProcessing());
312
312
  }
313
-
314
- //const [type, setType] = useState(Camera.Constants.Type.front);
315
-
316
- const [type, setType] = useState<CameraType>('front');
317
-
313
+ const [type, setType] = useState(Camera.Constants.Type.front);
318
314
  const FlipIcon = () => (
319
315
  <MaterialCommunityIcons
320
316
  name='camera-flip-outline'
@@ -343,8 +339,7 @@ export function MGCamera(props) {
343
339
  accessoryLeft={FlipIcon}
344
340
  onPress={() => {
345
341
  setType(
346
- // type === Camera.Constants.Type.back ? Camera.Constants.Type.front : Camera.Constants.Type.back
347
- type === 'back' ? 'front' : 'back'
342
+ type === Camera.Constants.Type.back ? Camera.Constants.Type.front : Camera.Constants.Type.back
348
343
  )
349
344
  }}>
350
345
  <Text>{mgFunctionsLib.i18nString('doInvertCamera', props.language)}</Text>
@@ -362,17 +357,80 @@ export function MGCamera(props) {
362
357
  </View>
363
358
  </View>
364
359
  );
360
+ return (
361
+ <View>
362
+ <Card header={cardHeader} footer={cardFooter}>
363
+ <View style={{ alignItems: 'center' }}>
364
+ <Camera
365
+ style={{ width: captureWidth, height: captureHeight }}
366
+ type={type}
367
+ ref={(r) => {
368
+ camera = r
369
+ }}>
370
+ </Camera>
371
+ </View>
372
+ </Card>
373
+ </View>
374
+ )
375
+ } */
376
+
377
+ export function MGCamera(props) {
378
+ let camera;
379
+ let captureWidth = 0;
380
+ let captureHeight = 0;
381
+ try {
382
+ captureWidth = Math.floor(getWidthForCamera() * 0.47);
383
+ captureHeight = Math.floor(getHeightForCamera() * 0.31);
384
+ } catch (error) {
385
+ captureWidth = 205;
386
+ captureHeight = 275;
387
+ }
388
+ const __takePicture = async () => {
389
+ if (!camera)
390
+ return;
391
+ let photo = await camera.takePictureAsync({ quality: 1 });
392
+ props.dispatch(props.actions.startProcessing());
393
+ photo = await ImageManipulator.manipulateAsync(
394
+ photo.uri,
395
+ [{ resize: { width: captureWidth, height: captureHeight } }],
396
+ { compress: 1, format: ImageManipulator.SaveFormat.JPEG }
397
+ );
398
+ photo = await ImageManipulator.manipulateAsync(
399
+ photo.uri,
400
+ [{ flip: 'horizontal' }],
401
+ { compress: 1, format: ImageManipulator.SaveFormat.JPEG }
402
+ );
403
+ props.process.fileUri = photo.uri;
404
+ props.process.goForward(props.nextStep);
405
+ props.dispatch(props.actions.endProcessing());
406
+ }
407
+ const [facing, setFacing] = useState < CameraType > ('front');
408
+ const FlipIcon = () => (
409
+ <MaterialCommunityIcons
410
+ name='camera-flip-outline'
411
+ size={30}
412
+ style={{ color: 'white' }} />
413
+ );
414
+ const TakeIcon = () => (
415
+ <MaterialCommunityIcons
416
+ name='camera-outline'
417
+ size={30}
418
+ style={{ color: 'white' }} />
419
+ );
420
+ const cardHeader = (
421
+ <View>
422
+ </View>
423
+ );
424
+ const cardFooter = (
425
+ <View>
426
+ </View>
427
+ );
365
428
  return (
366
429
  <View>
367
430
  <Card header={cardHeader} footer={cardFooter}>
368
431
  <View style={{ alignItems: 'center' }}>
369
- <Camera
370
- style={{ width: captureWidth, height: captureHeight }}
371
- type={type}
372
- ref={(r) => {
373
- camera = r
374
- }}>
375
- </Camera>
432
+ <CameraView style={{ width: captureWidth, height: captureHeight }} facing={facing}>
433
+ </CameraView>
376
434
  </View>
377
435
  </Card>
378
436
  </View>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mg-library",
3
- "version": "1.0.452",
3
+ "version": "1.0.454",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "scripts": {