2.3.2 • Published 5 years ago

xiurobert-ac-qrcode-rn v2.3.2

Weekly downloads
13
License
Apache-2.0
Repository
github
Last release
5 years ago

xiurobert-ac-qrcode-rn

Features and Changes

  • Supports QR Codes ONLY
  • Supports both Android and iOS
  • Based on react-native-camera
  • Simple to use scanning boundary
  • Supports enabling and disabling torchlight via a prop

Installation

$ yarn add xiurobert-ac-qrcode-rn
$ yarn add react-native-camera
$ react-native link react-native-camera

Basic usage

import React,{Component} from 'react'
import { Text, StyleSheet } from 'react-native'
import { QRScannerView } from 'ac-qrcode-rn'
import { Toast } from 'antd-mobile-rn'

class DefaultScreen extends Component {
  constructor(props) {
    super(props)
  }

  componentDidMount() {}
  
  onScanResultReceived = ({ data, type }) => {
    console.log(`Type: ${type}\nData: ${data}`)
    // do anything
  }

  renderTopBarView() {
    return (
      <Text style={styles.text}>Insert your top menu here</Text>
    )
  }

  renderBottomMenuView() {
    return (
      <Text style={styles.text}>Insert your bottom menu here</Text>
    )
  }

  render() {
    return (
      <QRScannerView
        onScanResultReceived={this.onScanResultReceived}
        renderTopBarView={this.renderTopBarView}
        renderBottomMenuView={this.renderBottomMenuView}
      />
    )
  }
}

const styles = StyleSheet.create({
  text: {
    color: 'white',
    textAlignVertical: 'center',
    textAlign: 'center',
    fontSize: 20,
    padding: 12,
  },
})

export default DefaultScreen

Props

npm.io

PropTypeDefault ValueOptionalExplanation
maskColorstring#0000004DtrueMask colour
borderColorstring#000000trueBorder colour
cornerColorstring#000000trueCorner colour
borderWidthnumber0trueBorder width
cornerBorderWidthnumber4trueCorner width
cornerBorderLengthnumber20trueCorner height
rectHeightnumber200trueScanning rectangle height
rectWidthnumber200trueScanning rectangle height
isCornerOffsetboolfalsetrueWhether the corners are offset
cornerOffsetSizenumber0trueCorner offset size
bottomMenuHeightnumber0trueHeight of the bottom menu
scanBarAnimateTimenumber2500trueTime for the scan bar to move down fully
scanBarColorstring#22ff00trueColour of the animated scan bar
scanBarImageanynulltrueImage to be used for the scan bar
scanBarHeightnumber1.5trueHeight of the scan bar
scanBarMarginnumber6trueMargins of the scan bar
hintTextstringAlign the QR code within the viewfindertrueHint
hintTextStyleobject{ color: '#fff', fontSize: 14,backgroundColor:'transparent'}trueHint text style
hintTextPositionnumber130trueAbsolute position of the hint text
isShowScanBarbooltruetrueShould show scan bar?
bottomMenuStyleobject-trueBottom menu style
renderTopBarViewfunc-falseFunction to render the top menu view
renderBottomMenuViewfunc-falseFunction to render the bottom menu view
onScanResultReceivedfunc-falseFunction to call when QR code is scanned
torchEnabledboolfalsetrueWhether the torchlight is enabled

Credits