2.0.0 • Published 11 months ago

@flyskywhy/react-native-qrcode-local-image v2.0.0

Weekly downloads
-
License
MIT
Repository
github
Last release
11 months ago

@flyskywhy/react-native-qrcode-local-image

npm version npm downloads npm licence Platform

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

Installation

yarn add @flyskywhy/react-native-qrcode-local-image

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('@flyskywhy/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