@momo-kits/camerakit 0.0.65-beta.4 → 0.0.65-beta.41

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/CameraKit.js +87 -83
  2. package/package.json +2 -2
package/CameraKit.js CHANGED
@@ -1,110 +1,114 @@
1
1
  import React from 'react';
2
2
  import PropTypes from 'prop-types';
3
- import { StyleSheet, View } from 'react-native';
4
- import { Camera } from 'camerakit';
3
+ import {StyleSheet, View} from 'react-native';
4
+ import {Camera} from 'camerakit';
5
5
 
6
6
  const styles = StyleSheet.create({
7
- container: {
8
- overflow: 'hidden',
9
- },
10
- camera: {
11
- flex: 1,
12
- backgroundColor: 'black'
13
- },
7
+ container: {
8
+ overflow: 'hidden',
9
+ },
10
+ camera: {
11
+ flex: 1,
12
+ backgroundColor: 'black',
13
+ },
14
14
  });
15
15
 
16
16
  const EventThrottleMs = 250;
17
17
 
18
18
  class CameraKit extends React.Component {
19
- constructor(props) {
20
- super(props);
21
- this.camera = null;
22
- }
19
+ constructor(props) {
20
+ super(props);
21
+ this.camera = null;
22
+ }
23
23
 
24
- readImageQRCode = (base64) => {
25
- this.camera?.readImageQRCode(base64);
26
- };
24
+ readImageQRCode = base64 => {
25
+ this.camera?.readImageQRCode(base64);
26
+ };
27
27
 
28
- startCamera = () => {
29
- this.camera?.startCamera();
30
- };
28
+ startCamera = () => {
29
+ this.camera?.startCamera();
30
+ };
31
31
 
32
- stopCamera = () => {
33
- this.camera?.stopCamera();
34
- };
32
+ stopCamera = () => {
33
+ this.camera?.stopCamera();
34
+ };
35
35
 
36
- async capture(options) {
37
- const { onImageCaptured } = this.props;
38
- try {
39
- const data = await this.camera?.capture(options);
40
- onImageCaptured?.({ ...data, url: data.uri });
41
- } catch (e) {
42
- onImageCaptured?.({ error: e.message });
43
- }
36
+ async capture(options) {
37
+ const {onImageCaptured} = this.props;
38
+ try {
39
+ const data = await this.camera?.capture(options);
40
+ onImageCaptured?.({...data, url: data.uri});
41
+ } catch (e) {
42
+ onImageCaptured?.({error: e.message});
44
43
  }
44
+ }
45
45
 
46
- onBarCodeRead = ({ nativeEvent }) => {
47
- const value = JSON.stringify(nativeEvent);
48
- const outdated = new Date() - this.lastEventTime > EventThrottleMs;
49
- if (value && value === this.lastEvent && !outdated) {
50
- return;
51
- }
52
- const { onBarCodeRead } = this.props;
53
- onBarCodeRead?.({ data: nativeEvent?.codeStringValue });
54
- this.lastEvent = value;
55
- this.lastEventTime = new Date();
56
- };
46
+ onBarCodeRead = ({nativeEvent}) => {
47
+ const value = JSON.stringify(nativeEvent);
48
+ const outdated = new Date() - this.lastEventTime > EventThrottleMs;
49
+ if (value && value === this.lastEvent && !outdated) {
50
+ return;
51
+ }
52
+ const {onBarCodeRead} = this.props;
53
+ onBarCodeRead?.({data: nativeEvent?.codeStringValue});
54
+ this.lastEvent = value;
55
+ this.lastEventTime = new Date();
56
+ };
57
57
 
58
- onOpenCamera = ({ nativeEvent }) => {
59
- const { onOpenCamera } = this.props;
60
- onOpenCamera?.(nativeEvent);
61
- };
58
+ onOpenCamera = ({nativeEvent}) => {
59
+ const {onOpenCamera} = this.props;
60
+ onOpenCamera?.(nativeEvent);
61
+ };
62
62
 
63
- render() {
64
- const {
65
- customFinder,
66
- style,
67
- torchMode,
68
- type,
69
- onBarCodeRead,
70
- zoomMode,
71
- } = this.props;
63
+ render() {
64
+ const {
65
+ customFinder,
66
+ style,
67
+ torchMode,
68
+ type,
69
+ onBarCodeRead,
70
+ zoomMode,
71
+ zoomRate,
72
+ } = this.props;
72
73
 
73
- return (
74
- <View style={[styles.container, style]}>
75
- <Camera
76
- ref={(cam) => (this.camera = cam)}
77
- style={styles.camera}
78
- cameraType={type}
79
- torchMode={torchMode}
80
- focusMode={torchMode}
81
- zoomMode={zoomMode}
82
- scanBarcode={!!onBarCodeRead}
83
- onReadCode={this.onBarCodeRead}
84
- onOpenCamera={this.onOpenCamera}
85
- />
86
- <View style={StyleSheet.absoluteFill}>
87
- {customFinder && customFinder()}
88
- </View>
89
- </View>
90
- );
91
- }
74
+ return (
75
+ <View style={[styles.container, style]}>
76
+ <Camera
77
+ ref={cam => (this.camera = cam)}
78
+ style={styles.camera}
79
+ cameraType={type}
80
+ torchMode={torchMode}
81
+ focusMode={torchMode}
82
+ zoomMode={zoomMode}
83
+ zoomRate={zoomRate}
84
+ scanBarcode={!!onBarCodeRead}
85
+ onReadCode={this.onBarCodeRead}
86
+ onOpenCamera={this.onOpenCamera}
87
+ />
88
+ {customFinder && (
89
+ <View style={StyleSheet.absoluteFill}>{customFinder()}</View>
90
+ )}
91
+ </View>
92
+ );
93
+ }
92
94
  }
93
95
 
94
96
  CameraKit.propTypes = {
95
- onBarCodeRead: PropTypes.func,
96
- onImageCaptured: PropTypes.func,
97
- type: PropTypes.oneOf(['front', 'back']),
98
- torchMode: PropTypes.oneOf(['on', 'off', 'auto']),
99
- zoomMode: PropTypes.oneOf(['on', 'off']),
100
- onOpenCamera: PropTypes.func,
97
+ onBarCodeRead: PropTypes.func,
98
+ onImageCaptured: PropTypes.func,
99
+ type: PropTypes.oneOf(['front', 'back']),
100
+ torchMode: PropTypes.oneOf(['on', 'off', 'auto']),
101
+ zoomMode: PropTypes.oneOf(['on', 'off']),
102
+ zoomRate: PropTypes.number,
103
+ onOpenCamera: PropTypes.func,
101
104
  };
102
105
 
103
106
  CameraKit.defaultProps = {
104
- type: 'back',
105
- torchMode: 'off',
106
- zoomMode: 'off',
107
- onOpenCamera: () => {},
107
+ type: 'back',
108
+ torchMode: 'off',
109
+ zoomMode: 'off',
110
+ zoomRate: 1.0,
111
+ onOpenCamera: () => {},
108
112
  };
109
113
 
110
114
  export default CameraKit;
package/package.json CHANGED
@@ -1,10 +1,10 @@
1
1
  {
2
2
  "name": "@momo-kits/camerakit",
3
- "version": "0.0.65-beta.4",
3
+ "version": "0.0.65-beta.41",
4
4
  "private": false,
5
5
  "main": "index.js",
6
6
  "dependencies": {
7
- "camerakit": "git+https://gitlab.mservice.com.vn/momo-platform/react-native-camera-kit.git#v1.6"
7
+ "camerakit": "git+https://gitlab.mservice.com.vn/momo-platform/react-native-camera-kit.git#v2.0.5"
8
8
  },
9
9
  "peerDependencies": {
10
10
  "react": "16.9.0",