Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

react-native-awesome-pin

Package Overview
Dependencies
Maintainers
1
Versions
14
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-native-awesome-pin

A highly interactive and customisable PIN code screen for React Native.

  • 1.1.4
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
58
increased by163.64%
Maintainers
1
Weekly downloads
 
Created
Source

react-native-awesome-pin

npm npm licence npm downloads

A highly interactive and customizable PIN code screen for React Native.

  • Plug and play PIN screen with dozens of props (can be themed to suit your brand).

  • Keyboard and PIN components can be used independently for more fine-grained customization.

  • Animations and micro-feedback included to create a great user experience.

Install

To get started install via npm:

 npm install react-native-awesome-pin --save

Usage

PinScreen

The <PinScreen /> will take up the full view. It is a plug and play component... pass your logo, tagline, background colour, callback function and start verifying PINs.

Import:

 import { PinScreen } from 'react-native-awesome-pin';

Then add it to your code:

<PinScreen
    onRef={ ref => (this.pinScreen = ref) }
    tagline='Please enter your PIN'
    logo={ require('../../img/mylogohere.png') }
    containerStyle={{ backgroundColor: '#AAA' }}
    keyDown={ this.recievePin.bind(this) }
/>

// Callback function which receives the current PIN value
recievePin(pin){
   // Check if the PIN is correct here
}

You need to add a ref to your PinScreen, this allows you to throw an error from the parent component when a PIN is incorrect. Errors can be thrown using the throwError(message) method.

recievePin(pin){
   if(pin != '56771'){
       this.pinScreen.throwError('Your PIN is incorrect');
   }
}
PinKeyboard


The on-screen keyboard can be used separately if you do not want to use the plug and play <PinScreen /> component.

Import:

 import { PinKeyboard } from 'react-native-awesome-pin';

Then add it to your code:

<PinKeyboard
    onRef={ref => (this.keyboard = ref)}
    keyDown={this.keyDown.bind(this)}
/>

// Callback function which receives the key pressed
keyDown(key){
   // Key pressed
}

The <PinKeyboard /> also has a throwError(message) method. This will create a popup above the keyboard displaying the given error message. The style of the popup can be customized through props.

PinInput


The PIN input circles can be used separately if you do not want to use the plug and play <PinScreen /> component. They come with a shake animation and configurable device vibration.

Import:

 import { PinInput } from 'react-native-awesome-pin';

Then add it to your code:

<PinInput
    onRef={ref => (this.pins = ref)}
    numberOfPins={5}
    numberOfPinsActive={2}
/>

The <PinInput /> has a shake() method which can be called through the reference this.pins.shake(). This will perform a shake animation and vibration if enabled. A callback can be passed through props which will be fired when the animation is complete. See props below.

Props

PinScreen

The <PinScreen /> is a great plug and play solution for a PIN screen.

PropTypeOptionalDefaultDescription
onRefstringNoonRef allows you to call the throwError(message) method.
keyDownstringNoCallback function triggered when a key is pressed. Returns the current PIN value.
taglinestringYes'Enter your PIN'Tagline which sits above the PINS.
logoobjectYesLogo to place at top of screen.
numberOfPinsnumberYes5Number of pins to render.
vibrationboolYestrueShould vibration be enabled.
containerStyleobjectYesSee PinScreen.jsStyle applied to the container. Background colour can be set here.
logoStyleobjectYesStyle applied to your logo.
taglineStyleobjectYesSee PinScreen.jsStyle applied to the tagline.
pinContainerStyleobjectYesSee PinInput.jsStyle applied to PINS container.
pinStyleobjectYesSee PinInput.jsStyle applied to each circle PIN.
pinActiveStyleobjectYesSee PinInput.jsStyle applied to each circle PIN when it is active.
keyboardStyleobjectYesSee PinKeyboard.jsStyle applied to the keyboard.
keyboardDisabledStyleobjectYesSee PinKeyboard.jsStyle applied when the keyboard is disabled.
keyStyleobjectYesSee PinKeyboard.jsStyle applied to each key on the keyboard.
keyTextStyleobjectYesSee PinKeyboard.jsStyle applied to the text inside each key.
keyImageStyleobjectYesSee PinKeyboard.jsStyle applied to image in a key. If an image is passed.
errorStyleobjectYesSee PinKeyboard.jsStyle applied to popup error. Can set the background colour here.
errorTextStyleobjectYesSee PinKeyboard.jsStyle applied to the text inside the popup error.
PinKeyboard

The <PinKeyboard /> uses two arrays to allow you to set keys and define custom functions for each key. This is not the most fine-tune solution and will be upgraded in the future.

PropTypeOptionalDefaultDescription
onRefstringNoonRef allows you to call the throwError(message) method.
keyDownstringNoCallback function triggered when a key is pressed. Returns the key value.
keyboardarrayYesSee PinKeyboard.js4 x 3 matrix containing the value for each key. Image or text.
keyboardFuncarrayYesSee PinKeyboard.js4 x 3 matrix containing custom functions for each key. Pass null for no function.
keyboardStyleobjectYesSee PinKeyboard.jsStyle applied to the keyboard.
keyboardDisabledStyleobjectYesSee PinKeyboard.jsStyle applied when the keyboard is disabled.
keyStyleobjectYesSee PinKeyboard.jsStyle applied to each key on the keyboard.
keyTextStyleobjectYesSee PinKeyboard.jsStyle applied to the text inside each key.
keyImageStyleobjectYesSee PinKeyboard.jsStyle applied to image in a key. If an image is passed.
errorStyleobjectYesSee PinKeyboard.jsStyle applied to popup error. Can set the background colour here.
errorTextStyleobjectYesSee PinKeyboard.jsStyle applied to the text inside the popup error.
PinScreen
PropTypeOptionalDefaultDescription
onRefstringNoonRef allows you to call the throwError(message) method.
numberOfPinsnumberYes5Number of pins to render.
numberOfPinsActivenumberYes0Number of active pins. You can pass the pin.length here.
vibrationboolYestrueShould vibration be enabled.
animationShakeCallbackfuncYes4 x 3 matrix containing custom functions for each key. Pass null for no function.
containerStyleobjectYesSee PinInput.jsStyle applied to PINS container.
pinStyleobjectYesSee PinInput.jsStyle applied to each circle PIN.
pinActiveStyleobjectYesSee PinInput.jsStyle applied to each circle PIN when it is active.

Contributing

If you want to issue a PR, go ahead ;)

Authors

License

This project is licensed under the MIT License

Keywords

FAQs

Package last updated on 02 Aug 2018

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc