@aks-dev/easyui 1.2.30 → 1.2.31
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.
|
@@ -50,5 +50,11 @@
|
|
|
50
50
|
android:resource="@xml/file_paths" />
|
|
51
51
|
</provider>
|
|
52
52
|
</application>
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
<uses-permission android:name="android.permission.CAMERA" />
|
|
56
|
+
<!-- optionally, if you want to record audio: -->
|
|
57
|
+
<uses-permission android:name="android.permission.RECORD_AUDIO" />
|
|
58
|
+
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
|
|
53
59
|
</manifest>
|
|
54
60
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Scanner.d.ts","sourceRoot":"","sources":["../../../../src/components/Hud/Scanner/Scanner.tsx"],"names":[],"mappings":"AAOA,OAAO,KAAwC,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"Scanner.d.ts","sourceRoot":"","sources":["../../../../src/components/Hud/Scanner/Scanner.tsx"],"names":[],"mappings":"AAOA,OAAO,KAAwC,MAAM,OAAO,CAAC;AA4B7D,KAAK,QAAQ,GAAG,CAAC,CAAC,EAAE,MAAM,KAAK,IAAI,CAAC;AAEpC,KAAK,aAAa,GAAG;IACnB,WAAW,EAAE,CAAC,EAAE,EAAE,QAAQ,KAAK,IAAI,CAAC;IACpC,WAAW,EAAE,MAAM,IAAI,CAAC;CACzB,CAAC;AAEF,eAAO,MAAM,OAAO,qEA+MlB,CAAC;AAwHH,eAAO,MAAM,UAAU,uCAAmC,CAAC;AAC3D,eAAO,MAAM,WAAW,GAAI,IAAI,QAAQ,qBACH,CAAC;AACtC,eAAO,MAAM,WAAW,wBAA0C,CAAC"}
|
|
@@ -8,25 +8,25 @@
|
|
|
8
8
|
import React, { useImperativeHandle, useState } from "react";
|
|
9
9
|
import { Animated, BackHandler, Easing, Image, StyleSheet, Text, TouchableOpacity, View, } from "react-native";
|
|
10
10
|
import { Camera, useCameraDevice, useCameraPermission, useCodeScanner, } from "react-native-vision-camera";
|
|
11
|
-
import { PERMISSIONS, requestMultiple } from "react-native-permissions";
|
|
12
11
|
import { navigationBarHeight, px2dp, statusBarHeight, } from "../../../screen/px2dp";
|
|
13
12
|
import { px2sp } from "../../../screen/px2sp";
|
|
14
13
|
import * as utils from "../../../utils/lazy";
|
|
15
14
|
import { showToast } from "../Toast/Toast";
|
|
16
|
-
// enum SCANNER_TYPE {
|
|
17
|
-
// DENIED = -1,//没有开始权限
|
|
18
|
-
// START = 0,//没有扫描结果,继续扫描
|
|
19
|
-
// SUCCESS = 1,//已有扫描结果,停止扫描
|
|
20
|
-
// }
|
|
21
15
|
export const Scanner = React.forwardRef((_, ref) => {
|
|
22
16
|
const [show, setShow] = useState(false);
|
|
23
17
|
const moveAnim = React.useRef(new Animated.Value(0)).current;
|
|
24
18
|
const [pointStyle, setPointStyle] = React.useState();
|
|
25
|
-
const cameraRef = React.useRef(null);
|
|
26
19
|
const _cbRef = React.useRef(null);
|
|
27
20
|
const _scanerResultRef = React.useRef(null);
|
|
28
|
-
const device = useCameraDevice("back"
|
|
29
|
-
|
|
21
|
+
const device = useCameraDevice("back", {
|
|
22
|
+
physicalDevices: [
|
|
23
|
+
"ultra-wide-angle-camera",
|
|
24
|
+
"wide-angle-camera",
|
|
25
|
+
"telephoto-camera",
|
|
26
|
+
],
|
|
27
|
+
});
|
|
28
|
+
const { hasPermission, requestPermission } = useCameraPermission();
|
|
29
|
+
const [torchOn, setTorchOn] = React.useState(false);
|
|
30
30
|
React.useEffect(() => {
|
|
31
31
|
const onBackPress = () => {
|
|
32
32
|
if (show) {
|
|
@@ -42,12 +42,8 @@ export const Scanner = React.forwardRef((_, ref) => {
|
|
|
42
42
|
hideScanner: _hideScanner,
|
|
43
43
|
}), [show]);
|
|
44
44
|
const _showScanner = async (cb) => {
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
PERMISSIONS.ANDROID.CAMERA,
|
|
48
|
-
]);
|
|
49
|
-
if (res[PERMISSIONS.ANDROID.CAMERA] == "granted" ||
|
|
50
|
-
res[PERMISSIONS.IOS.CAMERA] == "granted") {
|
|
45
|
+
const cameraGranted = await requestPermission();
|
|
46
|
+
if (cameraGranted) {
|
|
51
47
|
_scanerResultRef.current = null;
|
|
52
48
|
setShow(true);
|
|
53
49
|
setPointStyle({});
|
|
@@ -80,7 +76,6 @@ export const Scanner = React.forwardRef((_, ref) => {
|
|
|
80
76
|
}),
|
|
81
77
|
]));
|
|
82
78
|
const animationStart = async () => {
|
|
83
|
-
cameraRef.current?.resumePreview();
|
|
84
79
|
animation.start(({ finished }) => {
|
|
85
80
|
// console.log('animationStart finished', finished)
|
|
86
81
|
if (finished) {
|
|
@@ -90,7 +85,6 @@ export const Scanner = React.forwardRef((_, ref) => {
|
|
|
90
85
|
});
|
|
91
86
|
};
|
|
92
87
|
const animationStop = (result) => {
|
|
93
|
-
cameraRef.current?.pausePreview();
|
|
94
88
|
animation.stop();
|
|
95
89
|
};
|
|
96
90
|
const codeScanner = useCodeScanner({
|
|
@@ -105,22 +99,30 @@ export const Scanner = React.forwardRef((_, ref) => {
|
|
|
105
99
|
}
|
|
106
100
|
},
|
|
107
101
|
});
|
|
108
|
-
if (!show)
|
|
102
|
+
if (!show || !hasPermission || device == null)
|
|
109
103
|
return null;
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
104
|
+
return (<TouchableOpacity disabled style={StyleSheet.absoluteFill}>
|
|
105
|
+
<Camera style={StyleSheet.absoluteFill} device={device} codeScanner={codeScanner} isActive={true} torch={torchOn ? "on" : "off"}></Camera>
|
|
106
|
+
|
|
107
|
+
<View style={[
|
|
108
|
+
StyleSheet.absoluteFill,
|
|
109
|
+
{
|
|
110
|
+
display: "flex",
|
|
111
|
+
flexDirection: "column",
|
|
112
|
+
justifyContent: "center",
|
|
113
|
+
alignItems: "center",
|
|
114
|
+
zIndex: 999,
|
|
115
|
+
},
|
|
116
|
+
]}>
|
|
116
117
|
{/* 导航栏 */}
|
|
117
118
|
<View style={{
|
|
118
119
|
display: "flex",
|
|
119
120
|
justifyContent: "center",
|
|
120
121
|
alignItems: "center",
|
|
121
122
|
height: navigationBarHeight,
|
|
122
|
-
|
|
123
|
-
|
|
123
|
+
top: statusBarHeight,
|
|
124
|
+
left: 0,
|
|
125
|
+
position: "absolute",
|
|
124
126
|
}}>
|
|
125
127
|
<TouchableOpacity onPress={() => _hideScanner()} style={{
|
|
126
128
|
height: navigationBarHeight,
|
|
@@ -163,22 +165,17 @@ export const Scanner = React.forwardRef((_, ref) => {
|
|
|
163
165
|
<View style={styles.rectangleRight}/>
|
|
164
166
|
</View>
|
|
165
167
|
|
|
166
|
-
|
|
167
|
-
<Image
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
: require("./assets/flashlight-white.png")
|
|
172
|
-
}
|
|
173
|
-
style={styles.flashlight}
|
|
174
|
-
/>
|
|
175
|
-
</TouchableOpacity> */}
|
|
168
|
+
<TouchableOpacity onPress={() => device.hasTorch && setTorchOn(!torchOn)}>
|
|
169
|
+
<Image source={torchOn
|
|
170
|
+
? require("./assets/flashlight-blue.png")
|
|
171
|
+
: require("./assets/flashlight-white.png")} style={styles.flashlight}/>
|
|
172
|
+
</TouchableOpacity>
|
|
176
173
|
<Text style={styles.rectangleText}>
|
|
177
174
|
将二维码/条码放入框内,即可自动扫描
|
|
178
175
|
</Text>
|
|
179
176
|
</View>
|
|
180
177
|
<View style={pointStyle}/>
|
|
181
|
-
</
|
|
178
|
+
</View>
|
|
182
179
|
</TouchableOpacity>);
|
|
183
180
|
});
|
|
184
181
|
const transparent = "#00000000";
|
|
@@ -191,7 +188,9 @@ const styles = StyleSheet.create({
|
|
|
191
188
|
display: "flex",
|
|
192
189
|
flex: 1,
|
|
193
190
|
flexDirection: "column",
|
|
194
|
-
backgroundColor: "red",
|
|
191
|
+
// backgroundColor: "red",
|
|
192
|
+
justifyContent: "center",
|
|
193
|
+
alignItems: "center",
|
|
195
194
|
},
|
|
196
195
|
cameraBackground: {
|
|
197
196
|
width: px2dp(scanW),
|
|
@@ -8,5 +8,11 @@
|
|
|
8
8
|
<string>APP需要使用访问您的相册</string>
|
|
9
9
|
<key>NSAppleMusicUsageDescription</key>
|
|
10
10
|
<string>APP需要使用访问您的媒体库</string>
|
|
11
|
+
<!-- VisionCamera -->
|
|
12
|
+
<key>NSCameraUsageDescription</key>
|
|
13
|
+
<string>$(PRODUCT_NAME) needs access to your Camera.</string>
|
|
14
|
+
<!-- optionally, if you want to record audio: -->
|
|
15
|
+
<key>NSMicrophoneUsageDescription</key>
|
|
16
|
+
<string>$(PRODUCT_NAME) needs access to your Microphone.</string>
|
|
11
17
|
</dict>
|
|
12
18
|
</plist>
|