Giter VIP home page Giter VIP logo

react-native-qrcode-local-image's Introduction

React Native QRCodeLocalImage (remobile)

A local qrcode image parse for react-native, support for ios and android

Installation

npm install @remobile/react-native-qrcode-local-image --save

Installation (iOS)

  • Drag RCTQRCodeLocalImage.xcodeproj to your project on Xcode.
  • Click on your main project file (the one that represents the .xcodeproj) select Build Phases and drag libRCTQRCodeLocalImage.a from the Products folder inside the RCTQRCodeLocalImage.xcodeproj.
  • Look for Header Search Paths and make sure it contains $(SRCROOT)/../../../react-native/React as recursive.

Installation (Android)

...
include ':react-native-qrcode-local-image'
project(':react-native-qrcode-local-image').projectDir = new File(settingsDir, '../node_modules/@remobile/react-native-qrcode-local-image/android')
  • In android/app/build.gradle
...
dependencies {
    ...
    compile project(':react-native-qrcode-local-image')
}
  • register module (in MainApplication.java)
......
import com.remobile.qrcodeLocalImage.RCTQRCodeLocalImagePackage;  // <--- import

......

@Override
protected List<ReactPackage> getPackages() {
   ......
   new RCTQRCodeLocalImagePackage()              // <------ add here
   ......
}

Usage

Example

'use strict';

var React = require('react');
var ReactNative = require('react-native');
var {
    StyleSheet,
    View,
    Text,
} = ReactNative;

var Button = require('@remobile/react-native-simple-button');
var QRCode = require('@remobile/react-native-qrcode-local-image');


module.exports = React.createClass({
    getInitialState() {
        return {text: ''}
    },
    onPress() {
        QRCode.decode(!app.isandroid?'/Users/fang/Desktop/qr.png':'/sdcard/qr.png', (error, result)=>{
            this.setState({text: JSON.stringify({error, result})});
        });
    },
    render() {
        return (
            <View style={styles.container}>
                <Button onPress={this.onPress}>测试</Button>
                <Text>
                    {this.state.text}
                </Text>
            </View>
        );
    }
});


var styles = StyleSheet.create({
    container: {
        flex: 1,
        backgroundColor: 'transparent',
        justifyContent: 'space-around',
        paddingVertical: 150,
    },
});

method

  • decode(path, callback) path canbe local image or url

see detail use

react-native-qrcode-local-image's People

Contributors

sky42550564 avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.