1.0.26 • Published 4 years ago

react-native-barcode-zxing v1.0.26

Weekly downloads
31
License
MIT
Repository
-
Last release
4 years ago

react-native-barcode

Getting started

$ npm install react-native-barcode-zxing --save

Mostly automatic installation

$ react-native link react-native-barcode-zxing

Manual installation

iOS

  1. please update rn to 0.60.* and use autolink

Android

  1. please update rn to 0.60.* and use autolink

Windows

Read it! :D

  1. In Visual Studio add the RNBarcode.sln in node_modules/react-native-barcode/windows/RNBarcode.sln folder to their solution, reference from their app.
  2. Open up your MainPage.cs app
  • Add using Barcode.RNBarcode; to the usings at the top of the file
  • Add new RNBarcodePackage() to the List<IReactPackage> returned by the Packages method

Usage Encode

import React, { Component } from 'react';
import { StyleSheet, View, Picker, Button, Image } from 'react-native';
import RNBarcode from 'react-native-barcode-zxing';

export default class EncodeApp extends Component {

  constructor(props) {
    super(props);
    
    this.onEncodePress = this.onEncodePress.bind(this);

    this.state = {
      imagesrc: ""
    }
  }

  onEncodePress() {
    const self = this;
    const options = {
      'type' : 'pdf417', // types
      'code' : '12345',
      'width' : 200,
      'height' : 200
    } 
    RNBarcode.encode(options, (error, blob) => {
      if (error) {
        console.error(error);
      } else {
        let baseImg = `data:image/png;base64,${blob}`;
        self.setState({
          imagesrc: baseImg
        })
      }
    })
  }

  render() {
    return (
      <View style={styles.container}>
        <Button
          title="Encode"
          onPress={this.onEncodePress}
          color="#841584"></Button>
        <Image style={styles.barcode} ref='barcode' source={{ uri: this.state.imagesrc }}></Image>
      </View>
    );
  }
}

const styles = StyleSheet.create({
  container: {
    flex: 1,
    justifyContent: 'center',
    alignItems: 'center',
    backgroundColor: '#F5FCFF',
  },
  barcode: {
    width: 200,
    height: 200,
    backgroundColor: '#FF0000',
  }
});

Usage BarcodeView

import { BarcodeView } from 'react-native-barcode-zxing';

export default class BarcodeComponent extends Component {

    render() {
        return (
            <View>
                <BarcodeView text="This is a Data Matrix by TEC-IT"
                    format="DATA_MATRIX"
                    style={{ height: 200, width: 200 }} />
            </View>
        )
    }
}

Support Types

  • qrcode
  • code39
  • isbn10
  • code128
  • upca
  • upce
  • ean13
  • ean8
  • itf
  • databar
  • databarexp
  • isbn13
  • pdf417
  • codabar
  • aztec

1.0.26

4 years ago

1.0.25

4 years ago

1.0.24

4 years ago

1.0.23

4 years ago

1.0.22

4 years ago

1.0.21

4 years ago

1.0.19

4 years ago

1.0.20

4 years ago

1.0.18

4 years ago

1.0.17

5 years ago

1.0.16

5 years ago

1.0.15

5 years ago

1.0.14

5 years ago

1.0.13

5 years ago

1.0.12

5 years ago

1.0.11

5 years ago

1.0.10

5 years ago

1.0.9

5 years ago

1.0.8

5 years ago

1.0.7

5 years ago

1.0.6

5 years ago

1.0.5

5 years ago

1.0.4

5 years ago

1.0.3

5 years ago

1.0.2

5 years ago

1.0.1

5 years ago

1.0.0

5 years ago