Git Product home page Git Product logo

react-native-gesture-password's Introduction

react-native-gesture-password

A gesture password component for React Native

一个React Native的手势密码组件

image

Usage

npm install react-native-gesture-password --save

In XCode, in the project navigator, right click Libraries ➜ Add Files to [your project's name], Go to node_modules ➜ react-native-gesture-password and add the RNGesturePassword.xcodeproj file

In XCode, in the project navigator, select your project. Add the lib*.a from the RNGesturePassword project to your project's Build Phases ➜ Link Binary With Libraries Click RNGesturePassword.xcodeproj file you added before in the project navigator and go the Build Settings tab. Make sure 'All' is toggled on (instead of 'Basic'). Look for Header Search Paths and make sure it contains both $(SRCROOT)/../react-native/React and $(SRCROOT)/../../React - mark both as recursive.

Run your project (Cmd+R)

Examples

var React = require('react-native');
var {
    AppRegistry,
} = React;

var PasswordGesture = require('react-native-gesture-password');

var Password1 = '';
var AppDemo = React.createClass({
    // Example for check password
    onEnd: function(password) {
        if (password == '012') {
            this.refs.pg.setNativeProps({
                gestureError: false,
                inputTipText: 'Password is right, success.'
            })
            
            // your codes to close this view
        } else {
            this.refs.pg.setNativeProps({
                gestureError: true,
                inputTipText: 'Password is wrong, try again.'
            });
        }
    },
    onStart: function() {
        this.refs.pg.setNativeProps({
            inputDefault: 'Please input your password.'
        })
    },
    /*
    // Example for set password
    onEnd: function(password) {
        if ( Password1 === '' ) {
            if (password !== '') {
                Password1 = password;
                this.refs.pg.setNativeProps({
                    gestureError: false,
                    inputDefault: 'Please input your password secondly.'
                })
            }
        } else {
            if ( password === Password1 ) {
                this.refs.pg.setNativeProps({
                    gestureError: false,
                    inputTipText: 'Your password is set to ' + password
                });

                // your codes to close this view
            } else {
                this.refs.pg.setNativeProps({
                    gestureError: true,
                    inputTipText: 'Not the same, try again.'
                })
            }
        }
    },
    onStart: function() {
        if ( Password1 === '') {
            this.refs.pg.setNativeProps({
                inputDefault: 'Please input your password.'
            })
        } else {
            this.refs.pg.setNativeProps({
                inputDefault: 'Please input your password secondly.'
            })
        }
    },
     */
    render: function() {
        return (
            <PasswordGesture
                ref='pg'
                inputDefault='Please input your password.'
                onStart={() => this.onStart()}
                onEnd={(password) => this.onEnd(password)}
                />
        );
    }
});

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

Credits

This project is inspired by GesturePasswordView.

If you have suggestions or bug reports, feel free to send pull request or create new issue.

react-native-gesture-password's People

Contributors

spikef 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.