1.0.6 • Published 8 years ago

ray-rn-qrcode v1.0.6

Weekly downloads
1
License
MIT
Repository
-
Last release
8 years ago

ray-rn-qrcode

author

ilex.h

NOTICED

This component ( AmosQrcodeScanner ) is dependent on react-native-camera@0.12.0,then make sure that you have installed android build-tools v 25.0.2, if not, you should use android studio sdk manager intall it.

由于用到 camera 此时需要给 android/app/src/main/AndroidManifest.xml中添加 <uses-permission android:name="android.permission.CAMERA"/>。可选步骤:react-native link or react-native link react-native-camera (如果 react-native-camera失败,则需要执行上述命令,用于加载native源码)。As for why you want to do this, please look up the information by yourself!

Install

# 第一步
npm install ray-rn-qrcode --save

# 第二步(react-native-camera 需要 link 后才能使用)
react-native link

# PS:如果 link 没有成功,会报错。如果没有自动 link,可以手动 link

feature

  • supported qrcode and barcode
  • suppored IOS and Android
  • based on react-native-camera
  • Easy custom interface
  • generate qrcode

Usage

import { ScannerView } from 'ray-rn-qrcode';
import { Text } from 'react-native';

export default class ScanDemo extends Component {

  barcodeReceived = (e) => {
    alert(`Type: ${e.type}\nData: ${e.data}`);
  }

  render() {
    const topBarView = (
      <Text style={styles.qrcodeView}>顶部标题区域</Text>
    );
    const bottomView = (
      <Text style={styles.qrcodeView}>底部菜单区域</Text>
    );

    const rnCameraProps = {
      // react-native-camera 属性
    };

    return (
      <Container>
        <ScannerView
          onScanResultReceived={this.barcodeReceived}
          topBarView={topBarView}
          bottomView={bottomView}
          rnCameraProps={rnCameraProps}
        />
      </Container>
    );
  }
}

props

nametypedefaultdescription
scanFrameColorstringrgba(0, 0, 0, 0.3)遮罩颜色
scanFrameHeightnumber200扫描框高度
scanFrameWidthnumber200扫描框宽度
isCornerOffsetboolfalse边角是否偏移
cornerOffsetSizenumber0边角偏移量
cornerColorstringwhite边角颜色
cornerBorderLengthnumber20边角长度
cornerBorderWidthnumber4边角宽度
borderWidthnumber0边框宽度
borderColorstringwhite边框颜色
loadingbooleanfalse显示loading
loadingColorstring--ActivityIndicator color
bottomViewHeightnumber0底部操作栏高度
scanBarMarginnumber6扫描线距扫描框边距
showScanBarbooltrue是否显示扫描条
scanBarImageanynull使用图片扫描线
scanBarColorstring#F90808扫描线颜色
scanBarHeightnumber1.5扫描线高度
scanBarAnimateTimenumber2500扫描线移动速度
hintTextPositionnumber130提示文字位置
hintTextStyleobject{ color: '#fff', fontSize: 14,backgroundColor:'transparent'}提示文字样式
hintTextstring将二维码/条码放入框内,即可自动扫描提示文本
------------------------
rnCameraPropsobject-react-native-camera 属性
onScanResultReceivedfunc-必选,扫描结果回调
topBarViewnode | element-必选,绘制顶部操作条组件
bottomViewnode | element-必选,绘制底部操作条组件
topExtraInfonode | element-顶部额外信息
bottomExtraInfonode | element-底部额外信息
showLightbooleanfalse是否显示手电筒图标
lightIconobject: {style: object, source: Image.propTypes.source }{}手电筒图标
cameraStyleobject{ flex: 1}camera样式

感谢

Generate

Use canvas and webview.

Use qr.js to generate qrcode data

Usage

import React, { Component } from 'react';
import {
  View,
  TextInput
} from 'react-native';
import { GenerateQRcode } from 'ray-rn-qrcode';

class GenerateDemo extends Component {
  state = {
    value: 'ray-rn-qrcode'
  };

  onTextChange = (value) => {
    this.setState({ value });
  }

  render() {
    const { value } = this.state;
    return (
      <View>
        <TextInput
          onChangeText={this.onTextChange}
          value={value}
        />
        <GenerateQRcode
          value={value}
          size={200}
          bgColor='black'
          fgColor='white'
        />
      </View>
    );
  }
}

export default GenerateDemo;

Props

proptypedefaultDescription
valuestringqrcodeqrcode value
sizenumber128area width and height
bgColorstring (CSS color)"#000"background color
fgColorstring (CSS color)"#FFF"front color
wrapperStyleobject--wrapper view style
innerStyleobject--inner style ,canvas and webview

License

MIT

1.0.6

8 years ago

1.0.5

8 years ago

1.0.4

8 years ago

1.0.3

8 years ago

1.0.2

8 years ago

1.0.1

8 years ago

1.0.0

8 years ago