Skip to content

Commit d8d25ca

Browse files
committed
Initial beta version of zebra scanner with hooks
0 parents  commit d8d25ca

File tree

91 files changed

+18286
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

91 files changed

+18286
-0
lines changed

.eslintignore

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
**/node_modules
2+
example/
3+
lib/

.eslintrc.json

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
{
2+
"extends": [
3+
"eslint:recommended",
4+
"plugin:@typescript-eslint/recommended",
5+
"@react-native-community",
6+
"plugin:prettier/recommended"
7+
],
8+
"plugins": ["simple-import-sort"],
9+
"root": true,
10+
"rules": {
11+
"@typescript-eslint/explicit-module-boundary-types": "off",
12+
"@typescript-eslint/member-delimiter-style": [
13+
"error",
14+
{
15+
"multiline": {
16+
"delimiter": "none",
17+
"requireLast": false
18+
},
19+
"singleline": {
20+
"delimiter": "semi"
21+
}
22+
}
23+
],
24+
"simple-import-sort/sort": [
25+
"error",
26+
{ "groups": [["^\\u0000", "^@?\\w", "^[^.]", "^\\."]] }
27+
],
28+
"sort-imports": "off"
29+
}
30+
}

.gitignore

+73
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
# OSX
2+
#
3+
.DS_Store
4+
5+
# Xcode
6+
#
7+
build/
8+
*.pbxuser
9+
!default.pbxuser
10+
*.mode1v3
11+
!default.mode1v3
12+
*.mode2v3
13+
!default.mode2v3
14+
*.perspectivev3
15+
!default.perspectivev3
16+
xcuserdata
17+
*.xccheckout
18+
*.moved-aside
19+
DerivedData
20+
*.hmap
21+
*.ipa
22+
*.xcuserstate
23+
project.xcworkspace
24+
25+
# example
26+
example/ios/Podfile.lock
27+
28+
# Android/IntelliJ
29+
#
30+
build/
31+
.idea
32+
.gradle
33+
local.properties
34+
*.iml
35+
/android/gradlew
36+
/android/gradlew.bat
37+
/android/gradle/
38+
39+
# Visual Studio Code
40+
#
41+
.vscode/
42+
43+
# node.js
44+
#
45+
node_modules/
46+
npm-debug.log
47+
yarn-error.log
48+
49+
# BUCK
50+
buck-out/
51+
\.buckd/
52+
*.keystore
53+
!debug.keystore
54+
55+
# fastlane
56+
#
57+
# It is recommended to not store the screenshots in the git repo. Instead, use fastlane to re-generate the
58+
# screenshots whenever they are needed.
59+
# For more information about the recommended setup visit:
60+
# https://docs.fastlane.tools/best-practices/source-control/
61+
62+
*/fastlane/report.xml
63+
*/fastlane/Preview.html
64+
*/fastlane/screenshots
65+
66+
# Bundle artifact
67+
*.jsbundle
68+
69+
# CocoaPods
70+
/ios/Pods/
71+
72+
# Library
73+
lib/

.prettierrc.js

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
module.exports = {
2+
jsxSingleQuote: true,
3+
semi: false,
4+
singleQuote: true,
5+
}

LICENSE

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2020 Crypton
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

+37
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
# react-native-scanner-zebra
2+
3+
*Note: This package is still under beta version**
4+
5+
## Getting started
6+
7+
`$ npm install react-native-scanner-zebra --save`
8+
9+
### Mostly automatic installation
10+
11+
`$ react-native link react-native-scanner-zebra`
12+
13+
14+
### Additions steps for IOS Application
15+
16+
* Configure the Xcode project to support one or more external accessory communication protocols through the UISupportedExternalAccessoryProtocols key in your application Info.plist file or via the Info tab of your project settings.
17+
18+
|Communication Protocol|Zebra Scanner|
19+
|-----|-----|
20+
|com.motorolasolutions.CS4070_ssi|CS4070|
21+
|com.zebra.scanner.SSI|RFD8500|
22+
|com.motorolasolutions.scanner|RFD8500|
23+
* Select your Target, and then its Build Phases tab. Expand the Link Binary With Libraries item. Add the following frameworks by clicking the + button:
24+
1. ExternalAccessory
25+
2. CoreBluetooth
26+
27+
## Usage
28+
```javascript
29+
import useZebraScanner from 'react-native-scanner-zebra';
30+
31+
const onScan = useCallback((barcode, scannerId) => {
32+
// Handle the barcode
33+
}, []);
34+
35+
useZebraScanner(onScan);
36+
37+
```

android/README.md

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
README
2+
======
3+
4+
If you want to publish the lib as a maven dependency, follow these steps before publishing a new version to npm:
5+
6+
1. Be sure to have the Android [SDK](https://developer.android.com/studio/index.html) and [NDK](https://developer.android.com/ndk/guides/index.html) installed
7+
2. Be sure to have a `local.properties` file in this folder that points to the Android SDK and NDK
8+
```
9+
ndk.dir=/Users/{username}/Library/Android/sdk/ndk-bundle
10+
sdk.dir=/Users/{username}/Library/Android/sdk
11+
```
12+
3. Delete the `maven` folder
13+
4. Run `./gradlew installArchives`
14+
5. Verify that latest set of generated files is in the maven folder with the correct version number

android/build.gradle

+150
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,150 @@
1+
// android/build.gradle
2+
3+
// based on:
4+
//
5+
// * https://github.com/facebook/react-native/blob/0.60-stable/template/android/build.gradle
6+
// original location:
7+
// - https://github.com/facebook/react-native/blob/0.58-stable/local-cli/templates/HelloWorld/android/build.gradle
8+
//
9+
// * https://github.com/facebook/react-native/blob/0.60-stable/template/android/app/build.gradle
10+
// original location:
11+
// - https://github.com/facebook/react-native/blob/0.58-stable/local-cli/templates/HelloWorld/android/app/build.gradle
12+
13+
def DEFAULT_COMPILE_SDK_VERSION = 29
14+
def DEFAULT_BUILD_TOOLS_VERSION = '29.0.3'
15+
def DEFAULT_MIN_SDK_VERSION = 16
16+
def DEFAULT_TARGET_SDK_VERSION = 29
17+
18+
def safeExtGet(prop, fallback) {
19+
rootProject.ext.has(prop) ? rootProject.ext.get(prop) : fallback
20+
}
21+
22+
apply plugin: 'com.android.library'
23+
apply plugin: 'maven'
24+
25+
buildscript {
26+
// The Android Gradle plugin is only required when opening the android folder stand-alone.
27+
// This avoids unnecessary downloads and potential conflicts when the library is included as a
28+
// module dependency in an application project.
29+
// ref: https://docs.gradle.org/current/userguide/tutorial_using_tasks.html#sec:build_script_external_dependencies
30+
if (project == rootProject) {
31+
repositories {
32+
google()
33+
jcenter()
34+
}
35+
dependencies {
36+
classpath 'com.android.tools.build:gradle:3.4.1'
37+
}
38+
}
39+
}
40+
41+
apply plugin: 'com.android.library'
42+
apply plugin: 'maven'
43+
44+
android {
45+
compileSdkVersion safeExtGet('compileSdkVersion', DEFAULT_COMPILE_SDK_VERSION)
46+
buildToolsVersion safeExtGet('buildToolsVersion', DEFAULT_BUILD_TOOLS_VERSION)
47+
defaultConfig {
48+
minSdkVersion safeExtGet('minSdkVersion', DEFAULT_MIN_SDK_VERSION)
49+
targetSdkVersion safeExtGet('targetSdkVersion', DEFAULT_TARGET_SDK_VERSION)
50+
versionCode 1
51+
versionName "1.0"
52+
}
53+
lintOptions {
54+
abortOnError false
55+
}
56+
}
57+
58+
repositories {
59+
// ref: https://www.baeldung.com/maven-local-repository
60+
mavenLocal()
61+
maven {
62+
// All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
63+
url "$rootDir/../node_modules/react-native/android"
64+
}
65+
maven {
66+
// Android JSC is installed from npm
67+
url "$rootDir/../node_modules/jsc-android/dist"
68+
}
69+
google()
70+
jcenter()
71+
}
72+
73+
dependencies {
74+
implementation fileTree(dir: 'libs', include: ['*.aar'])
75+
//noinspection GradleDynamicVersion
76+
implementation 'com.facebook.react:react-native:+' // From node_modules
77+
}
78+
79+
def configureReactNativePom(def pom) {
80+
def packageJson = new groovy.json.JsonSlurper().parseText(file('../package.json').text)
81+
82+
pom.project {
83+
name packageJson.title
84+
artifactId packageJson.name
85+
version = packageJson.version
86+
group = "nl.crypton"
87+
description packageJson.description
88+
url packageJson.repository.baseUrl
89+
90+
licenses {
91+
license {
92+
name packageJson.license
93+
url packageJson.repository.baseUrl + '/blob/master/' + packageJson.licenseFilename
94+
distribution 'repo'
95+
}
96+
}
97+
98+
developers {
99+
developer {
100+
id packageJson.author.username
101+
name packageJson.author.name
102+
}
103+
}
104+
}
105+
}
106+
107+
afterEvaluate { project ->
108+
// some Gradle build hooks ref:
109+
// https://www.oreilly.com/library/view/gradle-beyond-the/9781449373801/ch03.html
110+
task androidJavadoc(type: Javadoc) {
111+
source = android.sourceSets.main.java.srcDirs
112+
classpath += files(android.bootClasspath)
113+
classpath += files(project.getConfigurations().getByName('compile').asList())
114+
include '**/*.java'
115+
}
116+
117+
task androidJavadocJar(type: Jar, dependsOn: androidJavadoc) {
118+
classifier = 'javadoc'
119+
from androidJavadoc.destinationDir
120+
}
121+
122+
task androidSourcesJar(type: Jar) {
123+
classifier = 'sources'
124+
from android.sourceSets.main.java.srcDirs
125+
include '**/*.java'
126+
}
127+
128+
android.libraryVariants.all { variant ->
129+
def name = variant.name.capitalize()
130+
def javaCompileTask = variant.javaCompileProvider.get()
131+
132+
task "jar${name}"(type: Jar, dependsOn: javaCompileTask) {
133+
from javaCompileTask.destinationDir
134+
}
135+
}
136+
137+
artifacts {
138+
archives androidSourcesJar
139+
archives androidJavadocJar
140+
}
141+
142+
task installArchives(type: Upload) {
143+
configuration = configurations.archives
144+
repositories.mavenDeployer {
145+
// Deploy to react-native-event-bridge/maven, ready to publish to npm
146+
repository url: "file://${projectDir}/../android/maven"
147+
configureReactNativePom pom
148+
}
149+
}
150+
}
256 KB
Binary file not shown.

android/src/main/AndroidManifest.xml

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
2+
package="nl.crypton.zebrascanner">
3+
4+
</manifest>

0 commit comments

Comments
 (0)