-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
65 changed files
with
6,680 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
*.[aod] | ||
*.DS_Store | ||
.DS_Store | ||
*Thumbs.db | ||
*.iml | ||
.gradle | ||
.idea | ||
node_modules | ||
npm-debug.log | ||
/android/build | ||
/ios/**/*xcuserdata* | ||
/ios/**/*xcshareddata* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
*.[aod] | ||
*.DS_Store | ||
.DS_Store | ||
*Thumbs.db | ||
*.iml | ||
.gradle | ||
.idea | ||
node_modules | ||
npm-debug.log | ||
/android/build | ||
/ios/**/*xcuserdata* | ||
/ios/**/*xcshareddata* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
|
||
import React, { | ||
PropTypes, | ||
Component, | ||
} from 'react' | ||
import { | ||
View, | ||
requireNativeComponent, | ||
NativeModules, | ||
AppState, | ||
Platform, | ||
} from 'react-native' | ||
|
||
const BarcodeManager = Platform.OS == 'ios' ? NativeModules.Barcode : NativeModules.CaptureModule; | ||
|
||
|
||
export default class Barcode extends Component { | ||
|
||
static defaultProps = { | ||
barCodeTypes: Object.values(BarcodeManager.barCodeTypes), | ||
scannerRectWidth: 255, | ||
scannerRectHeight: 255, | ||
scannerRectTop: 0, | ||
scannerRectLeft: 0, | ||
scannerLineInterval: 3000, | ||
scannerRectCornerColor: `#09BB0D`, | ||
} | ||
|
||
static propTypes = { | ||
...View.propTypes, | ||
onBarCodeRead: PropTypes.func.isRequired, | ||
barCodeTypes: PropTypes.array, | ||
scannerRectWidth: PropTypes.number, | ||
scannerRectHeight: PropTypes.number, | ||
scannerRectTop: PropTypes.number, | ||
scannerRectLeft: PropTypes.number, | ||
scannerLineInterval: PropTypes.number, | ||
scannerRectCornerColor: PropTypes.string, | ||
} | ||
|
||
render() { | ||
return ( | ||
<NativeBarCode | ||
{...this.props} | ||
/> | ||
) | ||
} | ||
|
||
componentDidMount() { | ||
AppState.addEventListener('change', this._handleAppStateChange); | ||
} | ||
componentWillUnmount() { | ||
AppState.removeEventListener('change', this._handleAppStateChange); | ||
} | ||
|
||
startScan() { | ||
BarcodeManager.startSession() | ||
} | ||
|
||
stopScan() { | ||
BarcodeManager.stopSession() | ||
} | ||
|
||
_handleAppStateChange = (currentAppState) => { | ||
if(currentAppState !== 'active' ) { | ||
this.stopScan() | ||
} | ||
else { | ||
this.startScan() | ||
} | ||
} | ||
} | ||
|
||
const NativeBarCode = requireNativeComponent(Platform.OS == 'ios' ? 'RCTBarcode' : 'CaptureView', Barcode) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,7 @@ | ||
# react-native-smart-barcode | ||
# react-native-smart-barcode | ||
|
||
A smart barcode scanner component for React Native app. | ||
The library uses [https://github.com/zxing/zxing][1] to decode the barcodes for android. | ||
|
||
[0]: https://github.com/cyqresig/ReactNativeComponentDemos | ||
[1]: https://github.com/zxing/zxing |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
apply plugin: 'com.android.library' | ||
|
||
android { | ||
compileSdkVersion 23 | ||
buildToolsVersion "24.0.0" | ||
|
||
defaultConfig { | ||
minSdkVersion 16 | ||
targetSdkVersion 23 | ||
versionCode 1 | ||
versionName "1.0" | ||
} | ||
buildTypes { | ||
release { | ||
minifyEnabled false | ||
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' | ||
} | ||
} | ||
} | ||
|
||
dependencies { | ||
compile fileTree(dir: 'libs', include: ['*.jar']) | ||
compile 'com.android.support:appcompat-v7:23.4.0' | ||
compile 'com.facebook.react:react-native:+' | ||
compile 'com.google.zxing:core:3.2.1' | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
# Add project specific ProGuard rules here. | ||
# By default, the flags in this file are appended to flags specified | ||
# in /Users/cyqresig/Library/Android/sdk/tools/proguard/proguard-android.txt | ||
# You can edit the include path and order by changing the proguardFiles | ||
# directive in build.gradle. | ||
# | ||
# For more details, see | ||
# http://developer.android.com/guide/developing/tools/proguard.html | ||
|
||
# Add any project specific keep options here: | ||
|
||
# If your project uses WebView with JS, uncomment the following | ||
# and specify the fully qualified class name to the JavaScript interface | ||
# class: | ||
#-keepclassmembers class fqcn.of.javascript.interface.for.webview { | ||
# public *; | ||
#} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
<manifest xmlns:android="http://schemas.android.com/apk/res/android" | ||
package="com.reactnativecomponent.barcode"> | ||
</manifest> |
Oops, something went wrong.