@react-native-ohos/react-native-qr-decode-image-camera 1.2.0-rc.2 → 1.2.0
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.
- package/CHANGELOG.md +18 -0
- package/README.md +2 -2
- package/harmony/qr_decode_image_camera/BuildProfile.ets +16 -16
- package/harmony/qr_decode_image_camera/oh-package.json5 +1 -1
- package/harmony/qr_decode_image_camera.har +0 -0
- package/package.json +1 -1
- package/src/Camera.tsx +22 -10
- package/src/QRScanner.harmony.jsx +9 -0
package/CHANGELOG.md
CHANGED
package/README.md
CHANGED
|
@@ -4,9 +4,9 @@ This project is based on [react-native-qr-decode-image-camera@1.1.3](https://git
|
|
|
4
4
|
|
|
5
5
|
## Documentation URL
|
|
6
6
|
|
|
7
|
-
- [中文 ](https://
|
|
7
|
+
- [中文 ](https://gitcode.com/OpenHarmony-RN/usage-docs/blob/master/zh-cn/react-native-qr-decode-image-camera.md)
|
|
8
8
|
|
|
9
|
-
- [英文 ](https://
|
|
9
|
+
- [英文 ](https://gitcode.com/OpenHarmony-RN/usage-docs/blob/master/en/react-native-qr-decode-image-camera.md)
|
|
10
10
|
|
|
11
11
|
## License
|
|
12
12
|
|
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Use these variables when you tailor your ArkTS code. They must be of the const type.
|
|
3
|
-
*/
|
|
4
|
-
export const HAR_VERSION = '1.2.0
|
|
5
|
-
export const BUILD_MODE_NAME = 'debug';
|
|
6
|
-
export const DEBUG = true;
|
|
7
|
-
export const TARGET_NAME = 'default';
|
|
8
|
-
|
|
9
|
-
/**
|
|
10
|
-
* BuildProfile Class is used only for compatibility purposes.
|
|
11
|
-
*/
|
|
12
|
-
export default class BuildProfile {
|
|
13
|
-
static readonly HAR_VERSION = HAR_VERSION;
|
|
14
|
-
static readonly BUILD_MODE_NAME = BUILD_MODE_NAME;
|
|
15
|
-
static readonly DEBUG = DEBUG;
|
|
16
|
-
static readonly TARGET_NAME = TARGET_NAME;
|
|
1
|
+
/**
|
|
2
|
+
* Use these variables when you tailor your ArkTS code. They must be of the const type.
|
|
3
|
+
*/
|
|
4
|
+
export const HAR_VERSION = '1.2.0';
|
|
5
|
+
export const BUILD_MODE_NAME = 'debug';
|
|
6
|
+
export const DEBUG = true;
|
|
7
|
+
export const TARGET_NAME = 'default';
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* BuildProfile Class is used only for compatibility purposes.
|
|
11
|
+
*/
|
|
12
|
+
export default class BuildProfile {
|
|
13
|
+
static readonly HAR_VERSION = HAR_VERSION;
|
|
14
|
+
static readonly BUILD_MODE_NAME = BUILD_MODE_NAME;
|
|
15
|
+
static readonly DEBUG = DEBUG;
|
|
16
|
+
static readonly TARGET_NAME = TARGET_NAME;
|
|
17
17
|
}
|
|
Binary file
|
package/package.json
CHANGED
package/src/Camera.tsx
CHANGED
|
@@ -9,7 +9,7 @@ import {
|
|
|
9
9
|
PixelRatio,
|
|
10
10
|
StyleSheet
|
|
11
11
|
} from "react-native";
|
|
12
|
-
import { Camera, useCameraDevice, useCameraPermission } from 'react-native-vision-camera'
|
|
12
|
+
import { Camera, useCameraDevice, useCameraFormat, useCameraPermission, useCodeScanner } from 'react-native-vision-camera'
|
|
13
13
|
export const ComponentCamera = (props) => {
|
|
14
14
|
const CODE_TYPES = [
|
|
15
15
|
'code-128',
|
|
@@ -27,34 +27,46 @@ export const ComponentCamera = (props) => {
|
|
|
27
27
|
'data-matrix'
|
|
28
28
|
]
|
|
29
29
|
const device = useCameraDevice('back');
|
|
30
|
+
const format = useCameraFormat(device, [
|
|
31
|
+
{ videoResolution: { width: 3048, height: 2160 } },
|
|
32
|
+
{ fps: 60 },
|
|
33
|
+
]);
|
|
30
34
|
const { hasPermission, requestPermission } = useCameraPermission();
|
|
31
35
|
|
|
32
|
-
if (!hasPermission) {
|
|
33
|
-
requestPermission();
|
|
34
|
-
}
|
|
35
36
|
|
|
36
|
-
const codeScanner =
|
|
37
|
+
const codeScanner = useCodeScanner({
|
|
37
38
|
codeTypes: CODE_TYPES,
|
|
38
39
|
onCodeScanned: (codes) => {
|
|
39
40
|
// console.log(`Scanned ${codes.length} codes:`, codes)
|
|
40
41
|
const value = codes[0]
|
|
41
42
|
if (value) {
|
|
42
43
|
props.onRead(value)
|
|
43
|
-
} else {
|
|
44
|
-
if (value == null) return
|
|
45
44
|
}
|
|
46
45
|
}
|
|
47
|
-
|
|
46
|
+
});
|
|
48
47
|
|
|
48
|
+
if (!hasPermission) {
|
|
49
|
+
requestPermission();
|
|
50
|
+
return null;
|
|
51
|
+
}
|
|
49
52
|
|
|
50
53
|
return (
|
|
51
54
|
<Camera
|
|
52
|
-
style={
|
|
55
|
+
style={styles.camera}
|
|
53
56
|
isActive={props.isActive}
|
|
54
57
|
preview={true}
|
|
55
58
|
device={device}
|
|
56
59
|
codeScanner={codeScanner}
|
|
57
60
|
torch={props.torch ? "on" : "off"}
|
|
61
|
+
resizeMode={'cover'}
|
|
62
|
+
format={format}
|
|
58
63
|
/>
|
|
59
64
|
)
|
|
60
|
-
}
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
const styles = StyleSheet.create({
|
|
68
|
+
camera: {
|
|
69
|
+
width: '100%',
|
|
70
|
+
aspectRatio: 3 / 4,
|
|
71
|
+
},
|
|
72
|
+
});
|
|
@@ -70,6 +70,7 @@ export default class QRScannerHarmony extends Component {
|
|
|
70
70
|
<View style={[styles.topButtonsContainer, this.props.topViewStyle]}>
|
|
71
71
|
{this.props.renderTopView()}
|
|
72
72
|
</View>
|
|
73
|
+
<View style={styles.scanOverlayContainer}>
|
|
73
74
|
<QRScannerView
|
|
74
75
|
maskColor={this.props.maskColor}
|
|
75
76
|
cornerColor={this.props.cornerColor}
|
|
@@ -95,6 +96,7 @@ export default class QRScannerHarmony extends Component {
|
|
|
95
96
|
finderY={this.props.finderY}
|
|
96
97
|
returnSize={this.barCodeSize}
|
|
97
98
|
/>
|
|
99
|
+
</View>
|
|
98
100
|
<View
|
|
99
101
|
style={[styles.bottomButtonsContainer, this.props.bottomViewStyle]}
|
|
100
102
|
>
|
|
@@ -175,6 +177,13 @@ const styles = StyleSheet.create({
|
|
|
175
177
|
left: 0,
|
|
176
178
|
right: 0
|
|
177
179
|
},
|
|
180
|
+
scanOverlayContainer: {
|
|
181
|
+
position: "absolute",
|
|
182
|
+
top: 0,
|
|
183
|
+
left: 0,
|
|
184
|
+
right: 0,
|
|
185
|
+
bottom: 0,
|
|
186
|
+
},
|
|
178
187
|
authorizationContainer: {
|
|
179
188
|
flex: 1,
|
|
180
189
|
alignItems: "center",
|