npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

react-native-awesome-pin

v1.3.4

Published

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

Downloads

213

Readme

react-native-awesome-pin

All Contributors

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. Keyboard errors can be cleared using clearError()

recievePin(pin){
   // Clear error on interaction
   this.pinScreen.clearError();

   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.

| Prop | Type | Optional | Default | Description | | --------------------- | ------- | -------- | ------------------ | --------------------------------------------------------------------------------- | | onRef | string | No | | onRef allows you to call the throwError(message) method. | | keyDown | string | No | | Callback function triggered when a key is pressed. Returns the current PIN value. | | tagline | string | Yes | 'Enter your PIN' | Tagline which sits above the PINS. | | logo | object | Yes | | Logo to place at top of screen. | | numberOfPins | number | Yes | 5 | Number of pins to render. | | keyVibration | bool | Yes | true | Should vibration be enabled for key press. | | shakeVibration | bool | Yes | true | Should vibration be enabled for shake. | | headerBackgroundColor | string | Yes | #e2e2e2 | Header colour for the SafeAreaView. | | footerBackgroundColor | string | Yes | #fff | Footer colour for the SafeAreaView. | | ItemFooter | element | Yes | | A footer component to render below the PinScreen. | | containerStyle | object | Yes | See PinScreen.js | Style applied to the container. Background colour can be set here. | | logoStyle | object | Yes | | Style applied to your logo. | | taglineStyle | object | Yes | See PinScreen.js | Style applied to the tagline. | | pin | string | Yes | | The pin value. | | pinContainerStyle | object | Yes | See PinInput.js | Style applied to PINS container. | | pinStyle | object | Yes | See PinInput.js | Style applied to each circle PIN. | | pinActiveStyle | object | Yes | See PinInput.js | Style applied to each circle PIN when it is active. | | keyboard | array | Yes | See PinKeyboard.js | 4 x 3 matrix containing the value for each key. Image or text. | | keyboardStyle | object | Yes | See PinKeyboard.js | Style applied to the keyboard. | | keyboardDisabledStyle | object | Yes | See PinKeyboard.js | Style applied when the keyboard is disabled. | | disableRippleEffect | bool | Yes | false | Disables the ripple effect from the keys. | | keyStyle | object | Yes | See PinKeyboard.js | Style applied to each key on the keyboard. | | keyTextStyle | object | Yes | See PinKeyboard.js | Style applied to the text inside each key. | | keyImageStyle | object | Yes | See PinKeyboard.js | Style applied to image in a key. If an image is passed. | | errorStyle | object | Yes | See PinKeyboard.js | Style applied to popup error. Can set the background colour here. | | errorTextStyle | object | Yes | See PinKeyboard.js | Style 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.

| Prop | Type | Optional | Default | Description | | --------------------- | ------ | -------- | ------------------ | --------------------------------------------------------------------------------- | | onRef | string | No | | onRef allows you to call the throwError(message) method. | | keyDown | string | No | | Callback function triggered when a key is pressed. Returns the key value. | | keyboard | array | Yes | See PinKeyboard.js | 4 x 3 matrix containing the value for each key. Image or text. | | keyboardFunc | array | Yes | See PinKeyboard.js | 4 x 3 matrix containing custom functions for each key. Pass null for no function. | | keyboardStyle | object | Yes | See PinKeyboard.js | Style applied to the keyboard. | | keyboardDisabledStyle | object | Yes | See PinKeyboard.js | Style applied when the keyboard is disabled. | | disableRippleEffect | bool | Yes | false | Disables the ripple effect from the keys. | | keyStyle | object | Yes | See PinKeyboard.js | Style applied to each key on the keyboard. | | keyTextStyle | object | Yes | See PinKeyboard.js | Style applied to the text inside each key. | | keyImageStyle | object | Yes | See PinKeyboard.js | Style applied to image in a key. If an image is passed. | | errorStyle | object | Yes | See PinKeyboard.js | Style applied to popup error. Can set the background colour here. | | errorTextStyle | object | Yes | See PinKeyboard.js | Style applied to the text inside the popup error. |

PinInput

| Prop | Type | Optional | Default | Description | | ---------------------- | ------ | -------- | --------------- | --------------------------------------------------------------- | | onRef | any | No | | onRef allows you to call the shake() method. | | numberOfPins | number | Yes | 5 | Number of pins to render. | | numberOfPinsActive | number | Yes | 0 | Number of active pins. You can pass the pin.length here. | | vibration | bool | Yes | true | Should vibration be enabled on shake? | | animationShakeCallback | func | Yes | | A callback triggered when the pin shake animation has finished. | | containerStyle | object | Yes | See PinInput.js | Style applied to PINS container. | | pinStyle | object | Yes | See PinInput.js | Style applied to each circle PIN. | | pinActiveStyle | object | Yes | See PinInput.js | Style applied to each circle PIN when it is active. |

Contributing

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

License

This project is licensed under the MIT License

Contributors ✨

Thanks goes to these wonderful people (emoji key):

This project follows the all-contributors specification. Contributions of any kind welcome!