1.0.5 • Published 8 years ago

react-native-qrcode-logo v1.0.5

Weekly downloads
2
License
ISC
Repository
github
Last release
8 years ago

react-native-qrcode-logo

A react-native component to generate QRCode with logo, not only support English.

this module support iOS and Android

Installation

npm install react-native-qrcode-logo

Usage

'use strict';

var React = require('react-native');
var QRCode = require('react-native-qrcode-logo');
var {
    AppRegistry,
    StyleSheet,
    View,
    TextInput
} = React;

var helloworld = React.createClass({
    getInitialState: function() {
        return {
            text: 'https://www.baidu.com/',
            logo: 'http://pic2.ooopic.com/01/37/79/28b1OOOPIC30.jpg'
        };
    },
    render: function() {
        return (
            <View style={styles.container}>
                <TextInput
                    style={styles.input}
                    onChangeText={(text) => this.setState({text: text})}
                    value={this.state.text}
                />
                <TextInput
                    style={styles.input}
                    onChangeText={(text) => this.setState({logo: text})}
                    value={this.state.logo}
                />
                <QRCode className='qrcode' 
                  value={this.state.text}
                  size={300}
                  fgColor='black'
                  bgColor='white'
                  logo={this.state.logo}
                />
            </View>
        );
    }
});

var styles = StyleSheet.create({
    container: {
        flex: 1,
        backgroundColor: 'white',
        alignItems: 'center',
        justifyContent: 'center'
    },

    input: {
        height: 40,
        borderColor: 'gray',
        borderWidth: 1,
        margin: 10,
        borderRadius: 5,
        padding: 5,
    }
});

AppRegistry.registerComponent('helloworld', () => helloworld);

module.exports = helloworld;

Available Props

proptypedefault value
valuestringhttps://www.baidu.com/
logostringhttp://pic2.ooopic.com/01/37/79/28b1OOOPIC30.jpg
sizenumber128
bgColorstring (CSS color)"#FFFFFF"
fgColorstring (CSS color)"#000000"

##Logo can also be a base64 string, eg: