@scrumble-nl/react-native-honeywell-scanner 1.0.97 → 1.1.1
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/README.md +56 -22
- package/android/build.gradle +5 -5
- package/package.json +5 -5
package/README.md
CHANGED
|
@@ -1,36 +1,70 @@
|
|
|
1
|
-
#
|
|
1
|
+
# React Native Honeywell Scanner
|
|
2
2
|
|
|
3
|
-
This module is
|
|
3
|
+
This module is forked and upgraded from react-native-honeywell-scanner-v2.
|
|
4
4
|
|
|
5
5
|
## Getting started
|
|
6
6
|
|
|
7
|
-
`$ npm install react-native-honeywell-scanner
|
|
7
|
+
`$ npm install @scrumble-nl/react-native-honeywell-scanner --save`
|
|
8
8
|
|
|
9
9
|
## Usage
|
|
10
|
-
```
|
|
11
|
-
import HoneywellScanner from 'react-native-honeywell-scanner
|
|
10
|
+
```typescript jsx
|
|
11
|
+
import HoneywellScanner from '@scrumble-nl/react-native-honeywell-scanner';
|
|
12
12
|
|
|
13
13
|
...
|
|
14
14
|
|
|
15
15
|
useEffect(() => {
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
16
|
+
if (HoneywellScanner.isCompatible) {
|
|
17
|
+
HoneywellScanner.startReader().then(() => {
|
|
18
|
+
HoneywellScanner.onBarcodeReadSuccess((event: {data: string}) => {
|
|
19
|
+
console.log('Received data', event.data);
|
|
20
|
+
});
|
|
21
|
+
});
|
|
22
22
|
|
|
23
|
+
return () => {
|
|
24
|
+
HoneywellScanner.stopReader().then(() => {
|
|
25
|
+
HoneywellScanner.offBarcodeReadSuccess();
|
|
23
26
|
});
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
}, []);
|
|
30
|
+
```
|
|
24
31
|
|
|
32
|
+
### Example code in custom scanner hook
|
|
33
|
+
```typescript jsx
|
|
34
|
+
import {useEffect, useRef} from 'react';
|
|
25
35
|
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
36
|
+
import HoneywellScanner from '@scrumble-nl/react-native-honeywell-scanner';
|
|
37
|
+
|
|
38
|
+
type ScanCallback = (scanValue: string) => void;
|
|
39
|
+
type Scanner = {
|
|
40
|
+
startScanner: () => void;
|
|
41
|
+
stopScanner: () => void;
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
export const useScanner = (onScan: ScanCallback): Scanner => {
|
|
45
|
+
const callbackRef = useRef<ScanCallback>(onScan);
|
|
46
|
+
|
|
47
|
+
useEffect(() => {
|
|
48
|
+
callbackRef.current = onScan;
|
|
49
|
+
}, [onScan]);
|
|
50
|
+
|
|
51
|
+
const startScanner = (): void => {
|
|
52
|
+
setTimeout(() => {
|
|
53
|
+
HoneywellScanner.startReader().then(() => {
|
|
54
|
+
HoneywellScanner.onBarcodeReadSuccess((event: {data: string}) => {
|
|
55
|
+
callbackRef.current(event.data.trim());
|
|
56
|
+
});
|
|
57
|
+
});
|
|
58
|
+
}, 100);
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
const stopScanner = (): void => {
|
|
62
|
+
HoneywellScanner.stopReader().then(HoneywellScanner.offBarcodeReadSuccess);
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
return {
|
|
66
|
+
stopScanner,
|
|
67
|
+
startScanner,
|
|
68
|
+
};
|
|
69
|
+
};
|
|
70
|
+
```
|
package/android/build.gradle
CHANGED
|
@@ -10,10 +10,10 @@
|
|
|
10
10
|
// original location:
|
|
11
11
|
// - https://github.com/facebook/react-native/blob/0.58-stable/local-cli/templates/HelloWorld/android/app/build.gradle
|
|
12
12
|
|
|
13
|
-
def DEFAULT_COMPILE_SDK_VERSION =
|
|
14
|
-
def DEFAULT_BUILD_TOOLS_VERSION = '
|
|
15
|
-
def DEFAULT_MIN_SDK_VERSION =
|
|
16
|
-
def DEFAULT_TARGET_SDK_VERSION =
|
|
13
|
+
def DEFAULT_COMPILE_SDK_VERSION = 30
|
|
14
|
+
def DEFAULT_BUILD_TOOLS_VERSION = '30.0.2'
|
|
15
|
+
def DEFAULT_MIN_SDK_VERSION = 21
|
|
16
|
+
def DEFAULT_TARGET_SDK_VERSION = 30
|
|
17
17
|
|
|
18
18
|
def safeExtGet(prop, fallback) {
|
|
19
19
|
rootProject.ext.has(prop) ? rootProject.ext.get(prop) : fallback
|
|
@@ -33,7 +33,7 @@ buildscript {
|
|
|
33
33
|
jcenter()
|
|
34
34
|
}
|
|
35
35
|
dependencies {
|
|
36
|
-
classpath 'com.android.tools.build:gradle:
|
|
36
|
+
classpath 'com.android.tools.build:gradle:4.2.2'
|
|
37
37
|
}
|
|
38
38
|
}
|
|
39
39
|
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@scrumble-nl/react-native-honeywell-scanner",
|
|
3
|
-
"title": "React Native Honeywell Scanner
|
|
4
|
-
"version": "1.
|
|
3
|
+
"title": "React Native Honeywell Scanner",
|
|
4
|
+
"version": "1.1.1",
|
|
5
5
|
"description": "Bridge to use the Honeywell scanner",
|
|
6
6
|
"main": "dist/index.js",
|
|
7
7
|
"types": "dist/index.d.ts",
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
"test": "echo \"Error: no test specified\" && exit 1",
|
|
10
10
|
"build": "tsc"
|
|
11
11
|
},
|
|
12
|
-
"repository": "https://gitlab.com/Scrumble/
|
|
12
|
+
"repository": "https://gitlab.com/Scrumble/Packages/react-native-honeywell-scanner",
|
|
13
13
|
"keywords": [
|
|
14
14
|
"react-native",
|
|
15
15
|
"honeywell"
|
|
@@ -19,9 +19,9 @@
|
|
|
19
19
|
"AMI3GO Ltd <enquiry@ami3go.com> (https://ami3go.com)"
|
|
20
20
|
],
|
|
21
21
|
"bugs": {
|
|
22
|
-
"url": "https://gitlab.com/Scrumble/
|
|
22
|
+
"url": "https://gitlab.com/Scrumble/packages/react-native-honeywell-scanner/issues"
|
|
23
23
|
},
|
|
24
|
-
"homepage": "https://gitlab.com/Scrumble/
|
|
24
|
+
"homepage": "https://gitlab.com/Scrumble/packages/react-native-honeywell-scanner#readme",
|
|
25
25
|
"license": "MIT",
|
|
26
26
|
"licenseFilename": "LICENSE",
|
|
27
27
|
"readmeFilename": "README.md",
|