如何在二维码扫描仪中生成背景扫描线

时间:2019-01-21 11:45:10

标签: javascript reactjs react-native react-redux qr-code

下面是我的QRCode扫描器的完整代码

我的代码工作正常,但我想添加更多效果。

就像在扫描时要在背景中生成一条扫描移动线一样,就是将移动的绿线或红线上下移动。 我应该添加什么属性。

请帮助在qrcodescanner中添加更多属性。

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,
      },
    });

1 个答案:

答案 0 :(得分:0)

我会尝试react-native-qrcode-scanner的以下选项:

  • showMarker(用于在相机扫描窗口上显示标记)

  • customMarker(传递RN元素/组件以将其用作自定义标记)

  • markerStyle(使用它可以将自定义样式添加到默认标记)

更新: 例如,尝试将此属性添加到您的<QRCodeScanner>元素中:

showMarker={true}