-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.android.js
67 lines (58 loc) · 1.84 KB
/
index.android.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
/**
* Sample React Native App
* https://github.com/facebook/react-native
* @flow
*/
import React, {Component} from 'react';
import {
AppRegistry,
StyleSheet,
Text,
View,
Alert,
ActivityIndicator,
ProgressBarAndroid,
ActivityIndicatorIOS,
} from 'react-native';
import Barcode from 'react-native-smart-barcode'
export default class barcodetest extends Component {
render() {
return (
<View style={{flex: 1, backgroundColor: 'black', justifyContent: 'center', alignItems: 'center',}}>
<Barcode style={{flex: 1, alignSelf: 'stretch', }}
ref={ component => this._barCode = component }
onBarCodeRead={this._onBarCodeRead}/>
</View>
);
}
_onBarCodeRead = (e) => {
console.log(`e.nativeEvent.data.type = ${e.nativeEvent.data.type}, e.nativeEvent.data.code = ${e.nativeEvent.data.code}`)
this._stopScan()
Alert.alert(e.nativeEvent.data.type, e.nativeEvent.data.code, [
{text: 'OK', onPress: () => this._startScan()},
])
}
_startScan = (e) => {
this._barCode.startScan()
}
_stopScan = (e) => {
this._barCode.stopScan()
}
_renderActivityIndicator() {
return ActivityIndicator ? (
<ActivityIndicator
style={{position: 'relative', left: 1, top: 1,}}
animating={true}
size={'large'}/>
) : Platform.OS == 'android' ?
(
<ProgressBarAndroid
styleAttr={'large'}/>
) : (
<ActivityIndicatorIOS
animating={true}
size={'large'}/>
)
}
}
AppRegistry.registerComponent('barcodetest', () => barcodetest);