在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
开源软件名称(OpenSource Name):ekreutz/react-native-barcode-scanner-google开源软件地址(OpenSource Url):https://github.com/ekreutz/react-native-barcode-scanner-google开源编程语言(OpenSource Language):Java 95.9%开源软件介绍(OpenSource Introduction):react-native-barcode-scanner-googleAuthor's notes
Very fast barcode scanner view for React Native applications. Only for Android. Use something like Compared to other barcode scanners for Android that don't rely on Google's Barcode API, this implementation should prove to be:
Note that this barcode scanner doesn't ship with a fancy overlay to display a scanning interface to the user. It's just a fast scanner view that shows the camera stream, ontop of which you can overlay your own UI. InstructionsTo include the latest version (1.3.0)
Simple usage exampleExample import React, { Component } from 'react';
import { AppRegistry, StyleSheet, Text, View, Alert } from 'react-native';
import BarcodeScanner from 'react-native-barcode-scanner-google';
export default class BarcodeApp extends Component {
render() {
return (
<View style={{ flex: 1 }}>
<BarcodeScanner
style={{ flex: 1 }}
onBarcodeRead={({ data, type }) => {
// handle your scanned barcodes here!
// as an example, we show an alert:
Alert.alert(
`Barcode '${data}' of type '${type}' was scanned.`
);
}}
/>
</View>
);
}
}
AppRegistry.registerComponent('BarcodeApp', () => BarcodeApp); Advanced usage example (all properties used)Note: even though they're not used in this example, notice how we import the functions import React, { Component } from 'react';
import { AppRegistry, StyleSheet, Text, View, Alert } from 'react-native';
import BarcodeScanner, {
Exception,
FocusMode,
TorchMode,
CameraFillMode,
BarcodeType,
pauseScanner,
resumeScanner
} from 'react-native-barcode-scanner-google';
export default class BarcodeApp extends Component {
render() {
return (
<View style={{ flex: 1 }}>
<BarcodeScanner
style={{ flex: 1 }}
onBarcodeRead={({ data, type }) => {
// handle your scanned barcodes here!
// as an example, we show an alert:
Alert.alert(
`Barcode '${data}' of type '${type}' was scanned.`
);
}}
onException={exceptionKey => {
// check instructions on Github for a more detailed overview of these exceptions.
switch (exceptionKey) {
case Exception.NO_PLAY_SERVICES:
// tell the user they need to update Google Play Services
case Exception.LOW_STORAGE:
// tell the user their device doesn't have enough storage to fit the barcode scanning magic
case Exception.NOT_OPERATIONAL:
// Google's barcode magic is being downloaded, but is not yet operational.
default:
break;
}
}}
focusMode={FocusMode.AUTO /* could also be TAP or FIXED */}
torchMode={TorchMode.ON /* could be the default OFF */}
cameraFillMode={
CameraFillMode.COVER /* could also be FIT */
}
barcodeType={
BarcodeType.CODE_128 |
BarcodeType.EAN_13 |
BarcodeType.EAN_8 /* replace with ALL for all alternatives */
}
/>
</View>
);
}
}
AppRegistry.registerComponent('BarcodeApp', () => BarcodeApp); Properties
|
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论