• Stars
    star
    548
  • Rank 81,119 (Top 2 %)
  • Language
    JavaScript
  • License
    MIT License
  • Created about 9 years ago
  • Updated over 4 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

A gesture password component for React Native. It supports both iOS and Android since it's written in pure JavaScript.

react-native-gesture-password

A gesture password component for React Native (web). It supports both iOS, Android and Web since it's written in pure JavaScript.

一个React Native的手势密码组件,纯JavaScript实现,因此同时支持iOS、安卓和Web平台。

image

Install

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

Properties

All properties bellow are optional.

message (string)

The message text you want to show. NOTE: If you leave this blank, no message appears for any state changes.

status (string)

Can be 'normal', 'right' or 'wrong'.

The gesture password don't validate your password. You should do that yourself, and tell the result by status.

style (string)

Styles for the gesture password view.

textStyle (string)

Style for the text element in the view.

normalColor (string)

Use this color to render the default circle color.

rightColor (string)

Use this color to render when status !== 'wrong'.

wrongColor (string)

Use this color to render when status === 'wrong'.

transparentLine (boolean)

True for transparent line.

interval (number)

The active circles will be reset automatically after you give an interval.

allowCross (boolean)

Allow cross the circles(eg: 1 -> 7 -> 4), default is false.

onStart (function)

Event raised when user touch a number circle.

onEnd (function)

Event raised when user finish input a password.

onReset (function)

Event raised after the reset interval has cleared circles. Can be used to reset message.

children

Other components that you want to display.

outerCircle and innerCircle (boolean)

Control whether to draw outer and inner circle, true default.

Examples

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

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

var Password1 = '';
var AppDemo = React.createClass({
    // Example for check password
    onEnd: function(password) {
        if (password == '123') {
            this.setState({
                status: 'right',
                message: 'Password is right, success.'
            });

            // your codes to close this view
        } else {
            this.setState({
                status: 'wrong',
                message: 'Password is wrong, try again.'
            });
        }
    },
    onStart: function() {
        this.setState({
            status: 'normal',
            message: 'Please input your password.'
        });
    },
    onReset: function() {
        this.setState({
            status: 'normal',
            message: 'Please input your password (again).'
        });
    },
    // Example for set password
    /*
    onEnd: function(password) {
        if ( Password1 === '' ) {
            // The first password
            Password1 = password;
            this.setState({
                status: 'normal',
                message: 'Please input your password secondly.'
            });
        } else {
            // The second password
            if ( password === Password1 ) {
                this.setState({
                    status: 'right',
                    message: 'Your password is set to ' + password
                });

                Password1 = '';
                // your codes to close this view
            } else {
                this.setState({
                    status: 'wrong',
                    message:  'Not the same, try again.'
                });
            }
        }
    },
    onStart: function() {
        if ( Password1 === '') {
            this.setState({
                message: 'Please input your password.'
            });
        } else {
            this.setState({
                message: 'Please input your password secondly.'
            });
        }
    },
    */

    getInitialState: function() {
        return {
            message: 'Please input your password.',
            status: 'normal'
        }
    },
    render: function() {
        return (
            <PasswordGesture
                ref='pg'
                status={this.state.status}
                message={this.state.message}
                onStart={() => this.onStart()}
                onEnd={(password) => this.onEnd(password)}
                />
        );
    }
});

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

Change Logs

0.4.0

  • Prettier: best practices for Format documents
  • Performance: Increase performance by using React hooks
  • Declaration
  • Readme: this package work with react-native-web well

(@hosseinmd)

v0.2.0

Rewrite with ES6 for [email protected]+ support

Add outerCircle and innerCircle properties

v0.1.5

TextStyle and onReset event. (@caledhwa)

v0.1.4

Manage the adaptation to landscape orientation. (@jujumoz)

v0.1.3

Add the allowCross property.

v0.1.2

Improve the performance for real device.

v0.1.0

Rewrite in pure javascript, for Android support.

Notes

This old version(<0.1.0) is at the branch native. I won't update that unless fix bugs.

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

More Repositories

1

react-native-phone-picker

React Native component for select phone number from address book.
Objective-C
68
star
2

vue-theme-switch-webpack-plugin

Vue主题切换插件。
CSS
16
star
3

vmc

VMC是一套针对移动端开发的组件库,分别适用于vue1和vue2。
CSS
14
star
4

NodeAsp

A JavaScript runtime built on classic asp. It works like NodeJS.
ASP
14
star
5

postcss-weex

postcss plugin for better weex style writting.
JavaScript
12
star
6

v-props

Vue directive for inheriting all defined props from parent component.
JavaScript
11
star
7

envirs-react-native-cli

A react native command tool build by Envirs Team.
JavaScript
8
star
8

quickjs-commonjs2

CommonJS2 Module for QuickJS, just for fun.
JavaScript
6
star
9

cmdu

A comfortable way to create your command line app by nodejs.
JavaScript
6
star
10

sync-sqlite

SQLite operation based on sql.js.
JavaScript
4
star
11

url2qrcode

Chrome插件,用于将当前页面的URL转为二维码。
JavaScript
4
star
12

folk

4
star
13

mobile-map-area

手机热点自适应。
JavaScript
4
star
14

smart-koa-router

smart-koa-router是一个复合型的Koa路由处理模块,支持Restful API、静态文件、文件上传、模板渲染,自动解析body参数,支持允许跨域请求,支持API参数校验和自动生成文档,支持应用启动时拦截等功能。
JavaScript
4
star
15

js-qrcode

web端基于纯js实现的二维码生成模块
JavaScript
3
star
16

siwa

根据swagger规格描述来解析成更易于js处理的对象。
JavaScript
2
star
17

web-apis-cli

JavaScript
2
star
18

cubb

cubb是一种命令行的文本标记语言, 用于输出更友好的命令行文本。
JavaScript
2
star
19

justshow

A pure html blog system based on nodejs cli.
JavaScript
1
star
20

node-database

JavaScript
1
star
21

cmdu-cli

CLI tool for using cmdu to create a new command line app.
JavaScript
1
star
22

open-path

Url path parser for OpenAPI.
JavaScript
1
star
23

ejs-lite

修改自ejs的模板引擎,使用更简单。
JavaScript
1
star