mg-library 1.0.453 → 1.0.455

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 +59 -11
  2. package/package.json +1 -1
package/blocks.js CHANGED
@@ -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,7 +357,7 @@ export function MGCamera(props) {
362
357
  </View>
363
358
  </View>
364
359
  );
365
- /* return (
360
+ return (
366
361
  <View>
367
362
  <Card header={cardHeader} footer={cardFooter}>
368
363
  <View style={{ alignItems: 'center' }}>
@@ -376,12 +371,65 @@ export function MGCamera(props) {
376
371
  </View>
377
372
  </Card>
378
373
  </View>
379
- ) */
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('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
+ );
380
428
  return (
381
429
  <View>
382
430
  <Card header={cardHeader} footer={cardFooter}>
383
431
  <View style={{ alignItems: 'center' }}>
384
- <CameraView style={{ width: captureWidth, height: captureHeight }} facing={type}>
432
+ <CameraView style={{ width: captureWidth, height: captureHeight }} facing={facing}>
385
433
  </CameraView>
386
434
  </View>
387
435
  </Card>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mg-library",
3
- "version": "1.0.453",
3
+ "version": "1.0.455",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "scripts": {