以下是我的完整代码 QRCode 扫描仪
我的代码工作正常,但我想添加更多效果。
就像在后台扫描一条扫描移动线想要生成一样,就像从上到下移动绿色或红线一样。我应该添加哪些属性。
请帮助在QR码扫描仪中添加更多属性。
import React, { Component } from 'react';
import {
AppRegistry,
StyleSheet,
Text,
TouchableOpacity,
Linking,
View,
Input,
Item,
Button,
AnimationEffect,
ReadableStreamReader,
} from 'react-native';
import { Dimensions } from "react-native";
import QRCodeScanner from 'react-native-qrcode-scanner';
//const SCREEN_HEIGHT = Dimensions.get("window").height;
//const SCREEN_HEIGHT=40;
//const SCREEN_WIDTH=Dimensions.get("window").width;
//const SCREEN_WIDTH=130;
export default class OpenTicket extends Component {
onSuccess(e) {
// console.log(e.data);
this.props.navigation.navigate('OpenApplianceIssue', {
data: e.data,
} );
}
Nextpage() {
// console.log(e.data);
this.props.navigation.navigate('OpenApplianceIssue');
}
onClickListener = () => {
this.props.navigation.navigate('OpenApplianceIssue');
}
static navigationOptions = {
title: 'Open Ticket',
};
render() {
return (
<View style= {{paddingTop:30, paddingBottom:0}}>
// below code is for QRCode scanner
<QRCodeScanner
onRead={this.onSuccess.bind(this)}
cameraProps={{captureAudio: false}}
reactivate = {true}
cameraType={AnimationEffect}
style={ReadableStreamReader}
//cameraStyle={{ height: SCREEN_HEIGHT }}
cameraStyle={{ width: 200, alignSelf:'center'}}
bottomContent={
<Text style={styles.buttonText} onPress={() => this.onClickListener()}>SCAN ITEM{'n'}
</Text>
}
buttonText={
<Item style={{paddingBottom:10,alignSelf: 'center', justifyContent: 'center', alignItems: 'center'}}>
<Input placeholder='Enter serial number'/>
</Item>
}
/>
<Text>Hello Abhi</Text>
{/* <Item style={{paddingBottom:10,alignSelf: 'center', justifyContent: 'center', alignItems: 'center'}}>
<Input placeholder='Enter serial number'/>
</Item>
<Button full rounded light style={{backgroundColor: 'green', justifyContent: 'center', alignItems: 'center'}}
onPress={() => this.onClickListener()}>
<Text style={{color: 'white'}}>Go</Text>
</Button> */}
</View>
);
}
}
const styles = StyleSheet.create({
centerText: {
flex: 1,
fontSize: 18,
padding: 32,
color: '#777',
},
textBold: {
fontWeight: '500',
color: '#000',
},
buttonText: {
fontSize: 21,
color: 'rgb(0,122,255)',
},
buttonTouchable: {
padding: 16,
},
});
我会尝试这些用于 react-native-qrcode-scanner 的选项:
-
showMarker
(使用此选项可在相机扫描窗口上显示标记) -
customMarker
(传递 RN 元素/组件以将其用作自定义标记) -
markerStyle
(使用此选项将自定义样式添加到默认标记)
更新:例如,尝试将此属性添加到 <QRCodeScanner>
元素:
showMarker={true}