GithubHelp home page GithubHelp logo

linecode / react-native-sms-verifycode Goto Github PK

View Code? Open in Web Editor NEW

This project forked from shixiaoquan/react-native-sms-verifycode

0.0 1.0 0.0 13.99 MB

一个用于填写短信验证码或密码的React Native组件, 适配android和iOS

JavaScript 100.00%

react-native-sms-verifycode's Introduction

Screen Capture

支持输入密码,兼容了 iOS 和 Android

android iOS Password
on Android on iOS use Password

在线Demo查看地址 Expo

Installation

$ npm install react-native-sms-verifycode --save

Usage

Basic Usage

设置输入完成时的回调函数,即可获取用户输入的内容

import SMSVerifyCode from 'react-native-sms-verifycode'
...
<SMSVerifyCode
  ref={ref => (this.verifycode = ref)}
  onInputCompleted={this.onInputCompleted}
/>

onInputCompleted = (text) => {
	Alert.alert(
	  text,
	  '本次输入的验证码',
	  [
	  	{
	      text: '确定',
	    },
	  ]
	)
}

reset = () => {
	this.verifycode.reset()
	this.setState({codeText: ''})
}
...        
android iOS all

Advanced Usage

设置验证码的个数

import SMSVerifyCode from 'react-native-sms-verifycode'
...
<SMSVerifyCode
  verifyCodeLength={4} // 根据需要设置任意数,类型必须时number
/>
android iOS iOS

设置Container样式

import SMSVerifyCode from 'react-native-sms-verifycode'
...
<SMSVerifyCode
  verifyCodeLength={5}
  containerPaddingVertical={10}
  containerPaddingHorizontal={50}
  containerBackgroundColor={'#8DC647'}
/>
...        
android android iOS

设置文本框的样式

import SMSVerifyCode from 'react-native-sms-verifycode'
...
<SMSVerifyCode
  verifyCodeLength={5}
  containerPaddingVertical={10}
  containerPaddingHorizontal={50}
  containerBackgroundColor={'#8DC647'}
  codeBorderColor={'#000000'}
  codeFocusedBorderColor={'#0000FF'}
  codeBorderWidth={3}
  // codeBorderRadius={26}
/>
...        
android iOS iOS

设置文本的样式

import SMSVerifyCode from 'react-native-sms-verifycode'
...
<SMSVerifyCode
  verifyCodeLength={5}
  codeFontSize={26}
  // codeFontColor={'#89C047'}
/>
...        
android iOS iOS

Properties

Prop PropType Default Value isRequired Description
verifyCodeLength number 6 NO 验证码的个数
containerPaddingVertical number 0 NO 外层容器的paddingVertical
containerPaddingHorizontal number 根据验证码个数自动计算 NO 外层容器的paddingHorizontal
containerBackgroundColor string #FDFFFD NO 外层容器的backgroundColor
codeBorderColor string grey NO 文本框的颜色
codeFocusedBorderColor string #1192F6 NO 当前获得焦点的文本框的颜色
codeViewWidth number 根据验证码个数自动计算 NO 文本框的宽度
codeBorderWidth number 1 NO 文本框的粗细
codeBorderRadius number 5 NO 文本框的圆角大小
codeFontSize number default NO 文本的大小
codeFontColor string #222222 NO 文本的颜色
secureTextEntry boolean false NO 默认为false,需要设置为true时,只要secureTextEntry即可,不需要secureTextEntry={true}

APIs

Name isRequired Description
onInputCompleted NO 输入完成时,回调的方法
reset NO 清空输入的内容,并将焦点设置在第一个输入框,使用ref调用
blur NO 隐藏键盘,使用ref调用
focus NO 显示键盘,使用ref调用

react-native-sms-verifycode's People

Contributors

shixiaoquan avatar

Watchers

 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.