@tarojs/taro-rn 3.4.0-beta.0 → 3.4.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.
|
@@ -10,7 +10,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
10
10
|
import { SafeAreaView } from 'react-native-safe-area-context';
|
|
11
11
|
import { Camera } from 'expo-camera';
|
|
12
12
|
import { BarCodeScanner } from 'expo-barcode-scanner';
|
|
13
|
-
import { BackHandler, Image, TouchableOpacity, StyleSheet, View, Dimensions, Platform } from 'react-native';
|
|
13
|
+
import { BackHandler, Image, TouchableOpacity, StyleSheet, View, Dimensions, Platform, StatusBar } from 'react-native';
|
|
14
14
|
import iconClose from './icon_close.png';
|
|
15
15
|
import iconPic from './icon_pic.png';
|
|
16
16
|
import * as Permissions from 'expo-permissions';
|
|
@@ -49,7 +49,7 @@ const BarCodeType = BarCodeScanner.Constants.BarCodeType;
|
|
|
49
49
|
function findKey(value, data, compare = (a, b) => a === b) {
|
|
50
50
|
return Object.keys(data).find(k => compare(data[k], value)) || '';
|
|
51
51
|
}
|
|
52
|
-
const { width, height } = Dimensions.get('
|
|
52
|
+
const { width, height } = Dimensions.get('screen');
|
|
53
53
|
function getBarCodeTypes(types) {
|
|
54
54
|
const result = [];
|
|
55
55
|
for (const t of types) {
|
|
@@ -97,6 +97,7 @@ const styles = StyleSheet.create({
|
|
|
97
97
|
closeImg: {
|
|
98
98
|
width: 25,
|
|
99
99
|
height: 25,
|
|
100
|
+
marginTop: StatusBar.currentHeight,
|
|
100
101
|
},
|
|
101
102
|
closeBtnBg: {
|
|
102
103
|
width: 40,
|
|
@@ -149,8 +150,10 @@ export function scanCode(option = {}) {
|
|
|
149
150
|
return Promise.reject(res);
|
|
150
151
|
}
|
|
151
152
|
const barCodeTypes = getBarCodeTypes(scanType);
|
|
153
|
+
const cameraRef = React.createRef();
|
|
152
154
|
return new Promise((resolve, reject) => {
|
|
153
155
|
scannerView = new RootSiblings((React.createElement(View, { style: [styles.container] },
|
|
156
|
+
React.createElement(StatusBar, { backgroundColor: "rgba(0, 0, 0, 0)", translucent: true, hidden: Platform.OS === 'ios' }),
|
|
154
157
|
React.createElement(Camera, { onBarCodeScanned: ({ type, data }) => {
|
|
155
158
|
const res = {
|
|
156
159
|
charSet: 'UTF-8',
|
|
@@ -164,7 +167,7 @@ export function scanCode(option = {}) {
|
|
|
164
167
|
complete === null || complete === void 0 ? void 0 : complete(res);
|
|
165
168
|
hide(scannerView);
|
|
166
169
|
resolve(res);
|
|
167
|
-
}, barCodeScannerSettings: {
|
|
170
|
+
}, ref: cameraRef, barCodeScannerSettings: {
|
|
168
171
|
barCodeTypes,
|
|
169
172
|
}, style: { width, height }, ratio: '16:9' }),
|
|
170
173
|
React.createElement(TouchableOpacity, { style: styles.closeIcon, onPress: () => hide(scannerView) }, safeViewWrapper(React.createElement(Image, { source: iconClose, style: styles.closeImg }))),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/lib/scanCode/index.tsx"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,gCAAgC,CAAA;AAC7D,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAA;AACpC,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAA;AACrD,OAAO,EAAE,WAAW,EAAE,KAAK,EAAE,gBAAgB,EAAE,UAAU,EAAE,IAAI,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAA;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/lib/scanCode/index.tsx"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,gCAAgC,CAAA;AAC7D,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAA;AACpC,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAA;AACrD,O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arojs/taro-rn",
|
|
3
|
-
"version": "3.4.0
|
|
3
|
+
"version": "3.4.0",
|
|
4
4
|
"description": "Taro RN framework",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"typings": "types/index.d.ts",
|
|
@@ -37,7 +37,7 @@
|
|
|
37
37
|
"@react-native-community/clipboard": "~1.5.1",
|
|
38
38
|
"@react-native-community/geolocation": "~2.0.2",
|
|
39
39
|
"@react-native-community/netinfo": "~7.1.2",
|
|
40
|
-
"@tarojs/runtime-rn": "3.4.0
|
|
40
|
+
"@tarojs/runtime-rn": "3.4.0",
|
|
41
41
|
"babel-preset-expo": "~8.5.1",
|
|
42
42
|
"base64-js": "^1.3.0",
|
|
43
43
|
"expo-av": "~9.2.3",
|
|
@@ -61,12 +61,11 @@
|
|
|
61
61
|
"react-native-unimodules": "~0.14.10"
|
|
62
62
|
},
|
|
63
63
|
"devDependencies": {
|
|
64
|
-
"@tarojs/taro": "3.4.0
|
|
64
|
+
"@tarojs/taro": "3.4.0",
|
|
65
65
|
"@types/react-native": "0.66.5",
|
|
66
66
|
"babel-plugin-jest-hoist": "^26.6.2",
|
|
67
67
|
"cpy-cli": "^3.1.1",
|
|
68
68
|
"jest-expo": "^39.0.0",
|
|
69
|
-
"mock-socket": "^7.1.0",
|
|
70
69
|
"react-native": "^0.66.0",
|
|
71
70
|
"rimraf": "^3.0.0"
|
|
72
71
|
},
|
|
@@ -95,5 +94,5 @@
|
|
|
95
94
|
"@types/react": "17.0.11",
|
|
96
95
|
"@types/node": "^14.14.41"
|
|
97
96
|
},
|
|
98
|
-
"gitHead": "
|
|
97
|
+
"gitHead": "a0e97bc937f878cc059f54748c9a3829fa3f4664"
|
|
99
98
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { SafeAreaView } from 'react-native-safe-area-context'
|
|
2
2
|
import { Camera } from 'expo-camera'
|
|
3
3
|
import { BarCodeScanner } from 'expo-barcode-scanner'
|
|
4
|
-
import { BackHandler, Image, TouchableOpacity, StyleSheet, View, Dimensions, Platform } from 'react-native'
|
|
4
|
+
import { BackHandler, Image, TouchableOpacity, StyleSheet, View, Dimensions, Platform, StatusBar } from 'react-native'
|
|
5
5
|
import iconClose from './icon_close.png'
|
|
6
6
|
import iconPic from './icon_pic.png'
|
|
7
7
|
import * as Permissions from 'expo-permissions'
|
|
@@ -46,7 +46,7 @@ function findKey (value:string, data, compare = (a, b) => a === b):string {
|
|
|
46
46
|
return Object.keys(data).find(k => compare(data[k], value)) || ''
|
|
47
47
|
}
|
|
48
48
|
|
|
49
|
-
const { width, height } = Dimensions.get('
|
|
49
|
+
const { width, height } = Dimensions.get('screen')
|
|
50
50
|
|
|
51
51
|
function getBarCodeTypes(types:string[]):string[] {
|
|
52
52
|
const result:string[] = []
|
|
@@ -101,6 +101,7 @@ const styles = StyleSheet.create({
|
|
|
101
101
|
closeImg: {
|
|
102
102
|
width: 25,
|
|
103
103
|
height: 25,
|
|
104
|
+
marginTop: StatusBar.currentHeight,
|
|
104
105
|
},
|
|
105
106
|
closeBtnBg: {
|
|
106
107
|
width: 40,
|
|
@@ -154,61 +155,64 @@ export async function scanCode(option: Taro.scanCode.Option = {}): Promise<Taro.
|
|
|
154
155
|
return Promise.reject(res)
|
|
155
156
|
}
|
|
156
157
|
const barCodeTypes = getBarCodeTypes(scanType)
|
|
158
|
+
const cameraRef = React.createRef<Camera>()
|
|
157
159
|
return new Promise((resolve, reject) => {
|
|
158
160
|
scannerView = new RootSiblings(
|
|
159
161
|
(<View style={[styles.container]}>
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
{
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
162
|
+
<StatusBar backgroundColor="rgba(0, 0, 0, 0)" translucent hidden={Platform.OS === 'ios'} />
|
|
163
|
+
<Camera
|
|
164
|
+
onBarCodeScanned={({ type, data }: {type: string, data: string}) => {
|
|
165
|
+
const res = {
|
|
166
|
+
charSet: 'UTF-8', // todo
|
|
167
|
+
path: '', // todo
|
|
168
|
+
rawData: '', // todo
|
|
169
|
+
errMsg: 'scanCode:ok',
|
|
170
|
+
result: data,
|
|
171
|
+
scanType: formatCodeType(type),
|
|
172
|
+
}
|
|
173
|
+
success?.(res)
|
|
174
|
+
complete?.(res)
|
|
175
|
+
hide(scannerView)
|
|
176
|
+
resolve(res)
|
|
177
|
+
}}
|
|
178
|
+
ref={cameraRef}
|
|
179
|
+
barCodeScannerSettings={{
|
|
180
|
+
barCodeTypes,
|
|
181
|
+
}}
|
|
182
|
+
style={{ width, height }}
|
|
183
|
+
ratio='16:9'
|
|
184
|
+
/>
|
|
185
|
+
<TouchableOpacity style={styles.closeIcon} onPress={() => hide(scannerView)}>
|
|
186
|
+
{safeViewWrapper(<Image source={iconClose} style={styles.closeImg}/>)}
|
|
187
|
+
</TouchableOpacity>
|
|
188
|
+
{!onlyFromCamera && (<TouchableOpacity style={styles.albumIcon} onPress={() => {
|
|
189
|
+
scanFromPhoto((data, type) => {
|
|
190
|
+
const res = {
|
|
191
|
+
charSet: 'UTF-8', // todo
|
|
192
|
+
path: '', // todo
|
|
193
|
+
rawData: '', // todo
|
|
194
|
+
errMsg: 'scanCode:ok',
|
|
195
|
+
result: data,
|
|
196
|
+
scanType: formatCodeType(type),
|
|
197
|
+
}
|
|
198
|
+
success?.(res)
|
|
199
|
+
complete?.(res)
|
|
200
|
+
hide(scannerView)
|
|
201
|
+
resolve(res)
|
|
202
|
+
}, (err) => {
|
|
203
|
+
const res = {
|
|
204
|
+
errMsg: 'scanCode fail',
|
|
205
|
+
err
|
|
206
|
+
}
|
|
207
|
+
fail?.(res)
|
|
208
|
+
complete?.(res)
|
|
209
|
+
hide(scannerView)
|
|
210
|
+
reject(res)
|
|
211
|
+
})
|
|
212
|
+
}}>
|
|
213
|
+
{safeViewWrapper(<Image source={iconPic} style={styles.albumImg}/>)}
|
|
214
|
+
</TouchableOpacity>)}
|
|
215
|
+
</View>)
|
|
212
216
|
)
|
|
213
217
|
BackHandler.addEventListener('hardwareBackPress', backAction)
|
|
214
218
|
})
|