Code Monkey home page Code Monkey logo

react-native-pincode's Introduction

react-native-pincode

npm npm code style: prettier

A customizable PIN Code component for react native

Using:

Installation

npm install --save @haskkor/react-native-pincode

or

yarn add @haskkor/react-native-pincode

Please note that:

Async storage uses the react-native-async-storage library which has to be linked

react-native link @react-native-community/async-storage

If you wish to use the TouchID/FaceID authentication you will have to link the library:

react-native link react-native-touch-id

If you wish to use Keychain/Keystore to store the PIN code you will have to link the library:

react-native link react-native-keychain

If you wish to use FaceID you'll need to add the permission in your info.plist

<key>NSFaceIDUsageDescription</key>
<string>Enabling Face ID allows you quick and secure access to your account.</string>

Please note that you might have to link those libraries manually.

IMPORTANT: If you decide not to use Keychain/Keystore, you will have to provide a storePin property to the PINCode component.

The library uses the Vibration from React Native. Please note that on Android it requires the Vibrate permission as stated in the doc. (add to AndroidManifest.xml)

Demo

choose-confirm enter-locked

Usage

Basic usage requires choosing between the choose, enter and locked modes.

  • choose : requires the user to choose and to confirm a PIN code
  • enter : requires the user to enter the PIN code he previously chose
  • locked : prints a locked screen for a given time if the user failed to enter his/her PIN code too many times
import PINCode from '@haskkor/react-native-pincode'
<PINCode status={'choose'}/>

Package provides a promise to know if a PIN code has been set by the user. The serviceName parameter is optional. If provided, it should match the pinCodeKeychainName property.

import {hasUserSetPinCode} from '@haskkor/react-native-pincode'
await hasUserSetPinCode(serviceName)

One can also use a provided function to delete a PIN code previously set in the Keychain. The service name parameter is optional. If provided, it should match the pinCodeKeychainName property.

import {deleteUserPinCode} from '@haskkor/react-native-pincode'
await deleteUserPinCode(serviceName)

If needed, the internal states that record the number of attemps and time of last attempt can be reset in addition to user pin code deletion.

import {resetPinCodeInternalStates} from '@haskkor/react-native-pincode'
await resetPinCodeInternalStates()

Options

Key Description Default Required Type
alphabetCharsVisible Boolean to hide/show English alphabet on PIN panel false false boolean
bottomLeftComponent Component to replace the empty space at the bottom left of the numpad Empty space false any
buttonComponentLockedPage Button component to be used at the bottom of the page on the locked application page TouchableOpacity exit button killing the application false any
buttonDeleteComponent Button component to be used at the bottom right of the PIN panel to delete a previous entry TouchableHighlight button with a delete text and the backspace material icon false any
buttonDeleteText Text of the of the button used to delete a previous entry on the PIN panel delete false string
buttonNumberComponent Button component to be used on the PIN panel to select a character for the PIN TouchableHighlight button with a number text false any
callbackErrorTouchId Callback to be used when the TouchID authenticate method throws an error console.log('TouchID error', e) false (error: Error) => void
customBackSpaceIcon Function, that returns custom backspace component to be used to replace the default backspace one on the PIN screen Function
disableLockScreen Boolean to disable the lock screen false false boolean
endProcessFunction Function to handle the end of the process None false (pinCode: string) => void
finishProcess Function to be used when the user enters the right PIN code Removes the values in AsyncStorage and set the status to success false (pinCode?: string) => void
getCurrentPinLength Function returning the length of the current PIN code None false (length: number) => void
handleResultEnterPin Function to be used to handle the PIN code entered by the user. Can be used for external-custom pin validation, return boolean to override internal pin validation undefined false (pinCode?: string) => bool or undefined
iconComponentLockedPage View component to be used between the timer and the text on the locked application page A circular red View using the lock material icon false any
iconButtonDeleteDisabled Boolean to remove the icon on the delete button of the PIN panel false false boolean
launchTouchID Function to manually trigger the touchID undefined false () => void
lockedIconComponent Component to replace the locked icon on the locked application page Material lock icon false any
lockedPage View component used as a locked page if the user fails to provide the correct PIN code maxAttempts times A application locked page with a timer indicating to the user the remaining time locked and a button closing the application false any
maxAttempts Number of attempts the user is given before locking the application 3 false number
onClickButtonLockedPage Function to be used when the user taps the button on the locked application page Kills the app by throwing Quit application false any
onFail Function to be used when the user enters the wrong PIN code Returns number of failed attempts false any
passwordComponent Component to be used to indicate to the user how many characters he/she typed. To be used with the getCurrentPinLength prop Dots growing or shrinking when the user adds or removes a character in the PIN code false any
passwordLength Length of the password the user has to enter 4 false number
pinAttemptsAsyncStorageName String to be used as a key in AsyncStorage to store the number of attempts the user already made pinAttemptsRNPin false string
pinCodeKeychainName String to be used as a key to store the PIN code in Keychain/Keystore reactNativePinCode false string
pinCodeVisible Boolean to show/hide the PIN code typed by the user None false boolean
pinStatus Status coming back to the PIN component after the handleResultEnterPin function. The status type is a value of the PinResultStatus enum (initial, success, failure, locked) None false PinResultStatus enum
status Indicates the mode that should be used (see Usage section for the different modes available) None true choose or enter or locked
storedPin The PIN code previously stored with the storePin function The PIN Code previously stored in the Keychain/Keystore false string
storePin Function that will be used to store the PIN (pin is given as a string argument) Stores the PIN in Keychain/Keystore false any
subtitleChoose String used as a subtitle on the PIN code choose page to keep your information secure false string
subtitleComponent Component to be used as a subtitle on all the PIN code pages Light grey Text component false any
subtitleConfirm String used as a subtitle on the PIN code confirmation page None false string
subtitleEnter String used as a subtitle on the PIN code enter page None false string
subtitleError String used as a subtitle on the PIN code pages when an error occurs (wrong PIN code used for enter or confirm modes) Please try again false string
textButtonLockedPage String to be used as text on the button in the locked application page Quit false string
textCancelButtonTouchID String to be used as text on the cancel button of the touchID popup. Only for Android Cancel false string
textDescriptionLockedPage String to be used as a description on the locked application page To protect your information, access has been locked for {timeLocked} minutes. false string
textSubDescriptionLockedPage String to be used as a subtitle on the locked application page Come back later and try again. false string
textPasswordVisibleFamily Font to be used for the PIN code numbers when pinCodeVisible is true system font false string
textPasswordVisibleSize Size of the font used for the PIN code numbers when pinCodeVisible is true 22 false number
textTitleLockedPage String to be used as a title on the locked application page Maximum attempts reached false string
timeLocked Number of milliseconds where the application should be locked after maxAttempts failed attempts from the user 300000 (5 minutes) false number
timePinLockedAsyncStorageName String to be used as a key in AsyncStorage to store the time when the user locks the application timePinLockedRNPin false string
timerComponentLockedPage Component to be used on the application locked page to indicates the remaining locked time to the user A Text component displaying a timer with the remaining locked time on the application locked page false any
titleAttemptFailed String used as a title on the PIN enter page when the user enters a wrong PIN code Incorrect PIN Code false string
titleChoose String used as a title on the PIN choose page 1 - Enter a PIN Code false string
titleComponent Component to be used as a title on all the PIN code pages Light grey Text component false any
titleComponentLockedPage Component to be used as a title on the application locked page Light grey Text component false any
titleConfirm String used as a title on the PIN confirm page 2 - Confirm your PIN Code false string
titleConfirmFailed String used as a title on the PIN confirm page when the user enters a wrong PIN code Your entries did not match false string
titleEnter String used as a title on the PIN enter page Enter your PIN Code false string
titleValidationFailed String used as a title on the PIN choose page when the PIN code entered by the user does not match the provided RegExp (use with validationRegex property PIN code unsafe false string
touchIDDisabled Boolean disabling the TouchID/FaceID on the PIN code enter page false false boolean
touchIDSentence String to be used in the TouchID/FaceID popup To unlock your application false string
touchIDTitle ANDROID ONLY. String to be used in the TouchID/FaceID popup title. Authentication Required false string
validationRegex Regex to be used to validate the PIN code entered by the user on choose mode None false RegExp
vibrationEnabled Boolean enabling vibration feedback when an incorrect PIN is entered true false boolean
delayBetweenAttempts Delay when an incorrect PIN is entered 3000 false number

Styles

Key Description Default Type
colorCircleButtons Color of the circle buttons rgb(242, 245, 251) string
colorPassword Color of the dots used for the password component turquoise string
colorPasswordEmpty Color of the dots used for the password component when small turquoise string
colorPasswordError Color of the dots used for the password component on error state #9DAFC8 string
numbersButtonOverlayColor Color of the PIN panel buttons when highlighted turquoise string
styleAlphabet Text of English letters on PIN panel. (First, set alphabetCharsVisible={true}) fontSize: grid.unit/2, fontWeight: "300" StyleProp<TextStyle>
styleMainContainer Main container of index file flex: 1, justifyContent: 'center', alignItems: 'center' StyleProp<ViewStyle>
stylePinCodeChooseContainer Main container of PinCodeChoose file flex: 1, justifyContent: 'center', alignItems: 'center' StyleProp<ViewStyle>
stylePinCodeEnterContainer Main container of PinCodeEnter file flex: 1, justifyContent: 'center', alignItems: 'center' StyleProp<ViewStyle>
styleLockScreenButton Button of the lock screen backgroundColor: colors.turquoise, borderRadius: grid.border, paddingLeft: grid.unit * 2, paddingRight: grid.unit * 2, paddingBottom: grid.unit, paddingTop: grid.unit StyleProp<ViewStyle>
styleLockScreenColorIcon Color of the icon on the lock screen white string
styleLockScreenMainContainer Main container of the lock screen position: 'absolute', top: 0, backgroundColor: colors.background, flexBasis: 0, left: 0, height: '100%', width: '100%', alignItems: 'center', flex: 1, justifyContent: 'center' StyleProp<ViewStyle>
styleLockScreenNameIcon Name of the material icon to be used on the lock screen lock string
styleLockScreenSizeIcon Size of the icon on the lock screen 24 number
styleLockScreenText Text on the lock screen (Come back..., To protect...) fontSize: grid.unit, color: colors.base, lineHeight: grid.unit * grid.lineHeight, textAlign: 'center' StyleProp<TextStyle>
styleLockScreenTextButton Text of the button of the lock screen color: colors.white, fontWeight: 'bold', fontSize: 14 StyleProp<TextStyle>
styleLockScreenTextTimer Text of the timer of the lock screen fontFamily: Platform.OS === 'ios' ? 'Courier' : 'monospace', fontSize: 20, color: colors.base StyleProp<TextStyle>
styleLockScreenTitle Title of the lock screen fontSize: grid.navIcon, color: colors.base, opacity: grid.mediumOpacity, fontWeight: '200', marginBottom: grid.unit * 4 StyleProp<TextStyle>
styleLockScreenViewCloseButton View of the button close of the lock screen alignItems: 'center', opacity: grid.mediumOpacity, justifyContent: 'center', marginTop: grid.unit * 2 StyleProp<ViewStyle>
styleLockScreenViewIcon View containing the icon of the lock screen width: grid.unit * 4, justifyContent: 'center', alignItems: 'center', height: grid.unit * 4, borderRadius: grid.unit * 2, opacity: grid.mediumOpacity, backgroundColor: colors.alert, overflow: 'hidden', marginBottom: grid.unit * 4 StyleProp<ViewStyle>
styleLockScreenViewTextLock View containing all the text of the lock screen justifyContent: 'center', alignItems: 'center', paddingLeft: grid.unit * 3, paddingRight: grid.unit * 3, flex: 3 StyleProp<ViewStyle>
styleLockScreenViewTimer View of the timer of the lock screen paddingLeft: 30, paddingRight: 30, paddingBottom: 10, paddingTop: 10, borderRadius: 4, borderWidth: 2, borderColor: 'rgb(230, 231, 233)', marginBottom: grid.unit * 4 StyleProp<ViewStyle>
stylePinCodeButtonCircle Circle button TouchableHighlight of the PinCode file alignItems: 'center', justifyContent: 'center', width: grid.unit * 4, height: grid.unit * 4, backgroundColor: 'rgb(242, 245, 251)', borderRadius: grid.unit * 2 StyleProp<ViewStyle>
stylePinCodeButtonNumber Color of the number buttons on the Pin code page 'white' string
stylePinCodeButtonNumberPressed Color of the number buttons on the Pin code page when pressed #9DAFC8 string
stylePinCodeCircle Style of the pinCode dots left, height, width, opacity, borderRadius, marginLeft, marginRight, and backgroundColor inherited from the animation StyleProp<ViewStyle>
stylePinCodeColorSubtitle Color of the PinCode page subtitle in normal state #9DAFC8 string
stylePinCodeColorSubtitleError Color of the the PinCode page subtitle in error state #FC4349 string
stylePinCodeColorTitle Color of the the PinCode page title in normal state #9DAFC8 string
stylePinCodeColorTitleError Color of the the PinCode page title in error state #9DAFC8 string
stylePinCodeColumnButtons Column of buttons of the PinCode file alignItems: 'center', width: 'auto' StyleProp<ViewStyle>
stylePinCodeColumnDeleteButton Column of the delete button of the PinCode file width: grid.unit * 4, height: grid.unit * 4, marginLeft: grid.unit / 2, marginRight: grid.unit / 2, justifyContent: 'center', alignItems: 'center', flexDirection: 'column' StyleProp<ViewStyle>
stylePinCodeDeleteButtonColorHideUnderlay Color of the delete button when underlay is hidden of the PinCode file rgb(211, 213, 218) string
stylePinCodeDeleteButtonColorShowUnderlay Color of the delete button when underlay is shown of the PinCode file colors.turquoise string
stylePinCodeDeleteButtonIcon Name of the icon of the delete button of the PinCode file backspace string
stylePinCodeDeleteButtonSize Size of the icon of the delete button of the PinCode file 30 number
stylePinCodeDeleteButtonText Text of the delete button of the PinCode file fontWeight: '200', marginTop: 5 StyleProp<TextStyle>
stylePinCodeEmptyColumn Empty column of the last line of buttons of the PinCode file width: grid.unit * 4, height: grid.unit * 4 StyleProp<ViewStyle>
stylePinCodeHiddenPasswordCircle Circle representing the hidden password of the PinCode file flexDirection: 'row', height: 'auto', justifyContent: 'center', alignItems: 'center' StyleProp<ViewStyle>
stylePinCodeHiddenPasswordSizeEmpty Size of the circle representing the hidden password of the PinCode file when empty 4 number
stylePinCodeHiddenPasswordSizeFull Size of the circle representing the hidden password of the PinCode file when full 8 number
stylePinCodeMainContainer Main container of the PinCode file flex: 1, justifyContent: 'center', alignItems: 'center' StyleProp<ViewStyle>
stylePinCodeRowButtons Row of buttons of the PinCode file justifyContent: 'center', alignItems: 'center', width: '100%', height: grid.unit * 5.5 StyleProp<ViewStyle>
stylePinCodeTextButtonCircle Text of circle button TouchableHighlight of the PinCode file fontSize: grid.unit * 2, fontWeight: '200' StyleProp<TextStyle>
stylePinCodeTextSubtitle Title of the PinCode file fontSize: 20, fontWeight: '200', lineHeight: grid.unit * 2.5 StyleProp<TextStyle>
stylePinCodeTextTitle Subtitle of the PinCode file fontSize: grid.unit, fontWeight: '200', textAlign: 'center' StyleProp<TextStyle>
stylePinCodeViewTitle View of the title of the PinCode file flexDirection: 'column', justifyContent: 'center', alignItems: 'center', minHeight: grid.unit * 4 StyleProp<TextStyle>

Contributing

Pull requests are welcome.

react-native-pincode's People

Contributors

beinlife avatar dependabot[bot] avatar dimon70007 avatar emmastead avatar galimpian avatar jeremy-farnault avatar juliengatt avatar leo-maidea avatar marla-singer avatar mikecann avatar netpumi2 avatar oli-laban avatar omorkved avatar panda-ref avatar shuchenliu avatar szlezak avatar tim-cdl avatar tombaki avatar tskorupka avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

react-native-pincode's Issues

Unhandled Promise Rejection: setGenericPasswordForOptions

Hey,

Firstly awesome component mate, very good work.

I am testing it in the simulator and it works great except for the final part once the key is confirmed I get an exception:

Possible Unhandled Promise Rejection (id: 0):
TypeError: Cannot read property 'setGenericPasswordForOptions' of undefined
TypeError: Cannot read property 'setGenericPasswordForOptions' of undefined
    at Object.setGenericPassword (blob:http://localhost:8081/1f2ec60d-926f-43e9-b4a3-564cdc3a4f6e:203342:30)
    at PinCodeChoose._callee$ (blob:http://localhost:8081/1f2ec60d-926f-43e
...

I suspect it is to do with https://github.com/oblador/react-native-keychain but cant for the life of me work out why its not working.

Does one have to install react-native-keychain explicitly or is just react-native-pincode's dependency on it good enough?

Provide pin code to finishProcess

If we're using enter mode, we can use endProcessFunction to get the entered pin code:

<PINCode
    status={'enter'}
    endProcessFunction={(pin) => console.log('Got pin: ' + pin)}}
/>

However, if we're using choose mode, I'm not seeing a simple way to get the correct pin code. We can use finishProcess to indicate when the correct pin has been entered, but this doesn't provide the pin code.

I could use storePin and then store the pin myself, but it would be a bit nicer if finishProcess could come with the pin :)

Hopefully I'm not overlooking a simple way to do this.

Thanks for the great library!

Remove pin option?

Hi!

I was wondering what can you do, once you set the pin code and want to remove it later. I used Keychain.resetGenericPassword, but the hasUserSetPinCode still returned with true, even though the pin code i set no longer worked :/

Would it be possible to one more option to pinSatus ('reset') ?
I will try yo look into it in the meantime

Copyright and Usage Example

First, thanks for your great PinCode component, it looks fantastic ๐Ÿ‘.
However, owing to the lack of a copyright statement, it makes me stop the pace to use it in a potential commercial product.
If that not be a problem, would you please give a simple Example of how to use this component? Suppose using this component in a single screen, combined with react-navigation, how could I navigate to another screen after successfully PIN CODE input?

Request service for hasUserSetPinCode and deleteUserPinCode

I using PINcode to secure my token, but in my app, I also using keychain to storage some other values by storage with other service. But if I save any item to keychain, and then call the method hasUserSetPinCode, it always return true, whether PINCode I have not set anywhere. Please provide a params for hasUserSetPinCode() like service to get value that they are not in my service.

Can set pinStatus to failure only once inside handleResultEnterPin

import PINCode, { PinResultStatus } from '@haskkor/react-native-pincode'

<PINCode
 status={'enter'}
 pinStatus={this.state.pinStatus}
 handleResultEnterPin={this.handleResultEnterPin}
 onFail={this.onFail}
/>

I have simple pin code component then, inside handleResultEnterPin Im setting pin status to failure
this.setState({ pinStatus: PinResultStatus.failure })

And after first entry I can retype pin, but then component just stuck on second entry last digit and onFail is not being fired

Expected behaviour: I should be able to retype pin code as many times as I want and handle this inside onFail method that is being fired after state being changed to failure

Delete button stylePinCodeDeleteButtonColorHideUnderlay property

This property is not applied until the Delete button is pressed once.

The problem appears to be in PinCode.js, line 223, where the state is set to the default colorDelete: 'rgb(211, 213, 218)' instead of checking if the property styleDeleteButtonColorHideUnderlay has been supplied, as it does for example in onHideUnderlay.

Cleanup dependencies

First of all, thanks for sharing a nice library.
Can you please cleanup the dependencies and devDependencies?
Especially, react-navigation. Actually, this library doesn't depend on the navigation lib.
So while we are using another navigation lib, it becomes to be spam package.
I hope you to cleanup the dependencies to install only necessary packages.
Thanks in advance.

How to use custom passwordcomponent

This is my code , please help me

`
import React, {Component} from 'react';
import {Platform, StyleSheet, Text, View} from 'react-native';
import Pincode from './react-native-pincode';
import Password from './src/pincode/index';

type Props = {};
export default class App extends Component {
renderPassword(){
return(

)
}
render() {
return (
<Pincode
status={'choose'}
passwordComponent={this.renderPassword()}
passwordLength={4}
/>
);
}
}

const styles = StyleSheet.create({
container: {
flex: 1,
justifyContent: 'center',
alignItems: 'center',
backgroundColor: '#F5FCFF',
},

});
`

Title and subtitle colors

Hello @Haskkor

Can't find a way to change title and subtitle colors.

screen shot 2018-07-05 at 6 24 24 pm

Could you please add this to props?

Has pincode?

I was just wondering how you would go about detecting if the user has actually set the pincode or not.

For for the following example:

  1. User logs into the app and sets Pincode for quick access next time
  2. User exits app
  3. User enters app again. App needs to now determine if the user has set a pincode yet, in which case they should be directed to the "EnterPincode" screen, otherwise the user should be directed to the "LoginAndSetPincode" screen.

So the problem is around step 3, how does the app know which screen to send the user to? Obviously we could use localstorage to store if the user has set a pincode for the device but that means that react-native-pincode and the app are using two different stores for the same value so they could go out of sync?

I guess one way to do it would be to use the "storePin" and "storedPin" properties to proxy access to react-native-keychain but this seems somehow wasteful?

Thoughts?

Touch id/Face id

how can i disable Touch id/Face id ? status={"enter"} always ask me to use touch id

PIN validation

Hi,

I wondered if you'd thought of adding pluggable validation rules when choosing a PIN, such as non-sequential numbers, and non-repeating numbers.

Or perhaps just a couple of new parameters that allow restricting the use of sequential numbers and all repeating numbers?

If not, would you accept a pull request?

Thanks.

Callback when pin has been chosen?

Maybe im missing something obvious but I cant seem to work out how I am supposed to get an event / callback when the user has chosen a pin (status is "choose").

The "finishProcess" callback seems to only be triggered after the user has entered the pin when the status is "enter".

how to use guide example ?

status: choose or enter has a function related ?
Want to make an example of how to use status: choose or enter?

Animation freezes in android

I am using Android with USB debugging.
And animation, for example, of wrong pin are really laggy and have low fps. In builded app it's a little better, but still.
Can you please optimize animation for better perfomance?

Deprecated React Lifecycle Methods

Hi,

Do you plan to migrate away from the deprecated React methods such as:
componentWillReceiveProps
componentWillUpdate

Thanks,
Justin

Clear Pin Code after account was locked

Steps for reproduce

  1. Try to login and enter PIN Code incorrectly some times so access is locked
  2. Wait until the time is over and Enter your PIN Code step is shown again
  3. See pict. Note that the 4 PIN Code dots are filled/completed. The user has to manually deleted them before entering the 4 digits again

image

  1. It would be nice to show the 4 dots cleared as when first requested

image

Solution

I've made the dirty hack to fix it and I'm using that
https://github.com/marla-singer/react-native-pincode/blob/2a39d1bff9d560c9d860b1aa05fc9458ec063fb3/src/PinCode.tsx#L137

If it's okay for you then I can prepare PR. If it isn't then I'm looking forward to see your changes and a new version of the library :)

Feature request: hidden password circle size

Hi,
Thanks for a great library.
Could you please expose a property to adjust password hidden circle sizes (pre and post entry).
If you'd prefer, I could submit a pull request.
Many thanks,
Justin

iOS: hasUserSetPinCode defaults to true

Hi!

For some time now, hasUserSetPinCode() on iOS always returns true when I open the app. If I then call deleteUserPinCode, it returns with false. I thought it was just a simulator issue, but it returns true for fresh install on new devices. Am I missing something with the react-native-keychain stuff? I tried the latest update with pinCodeKeychainName and serviceName no results. If i test it with some faceroll hasUserSetPinCode(hjvhgkvjhhjkvj) , it still returns true.

Can you elaborate how pinCodeKeychainName works btw? if I set it to unique is, it should save it under that name, right?

Crash on Iphone X version 12.1

It is crashing on real device Iphone X with version above 11, I couldn't get any logs yet...
It worked on older real devices.
It worked on Iphone X simulator.

any one tested it on Iphone X ?

Font styles not being applied (or, I'm doing it wrong :D)

Hey there, thank you for this awesome library! We are using it and it's great.

I'm having one issue though, while trying to change the fontFamily of the text portions of the <PINCode />:

const primaryFont = 'Avenir-Book';
const fontWeight = '400';

<PINCode
  colorPassword={CommonUtils.uiColors.success}
  numbersButtonOverlayColor={CommonUtils.uiColors.success}
  styleMainContainer={{
    backgroundColor: 'white',
    flex: 1,
    justifyContent: 'center',
    alignItems: 'center'
  }}
  styleLockScreenText={{
    fontFamily: primaryFont,
    fontWeight: fontWeight
  }}
  styleLockScreenTextButton={{
    fontFamily: primaryFont,
    fontWeight: fontWeight
  }}
  styleLockScreenTextTimer={{
    fontFamily: primaryFont,
    fontWeight: fontWeight
  }}
  stylePinCodeViewTitle={{
    fontFamily: primaryFont,
    fontWeight: fontWeight
  }}
  stylePinCodeTextButtonCircle={{
    fontFamily: primaryFont,
    fontWeight: fontWeight
  }}
  stylePinCodeTextTitle={{
    fontFamily: primaryFont,
    fontWeight: fontWeight
  }}
  stylePinCodeTextSubtitle={{
    fontFamily: primaryFont,
    fontWeight: fontWeight
  }}
  storedPin={this.props.pin}
  maxAttempts={3}
  textButtonLockedPage="Log In with email/password"
/>

None of these seem to be taking effect, am I doing this incorrectly? Thank you!

Show PIN code

Hi,
Another suggestion we have is to have a configuration option to show the PIN code as the user types. This would be useful when entering an MFA code, as opposed to a PIN.
Best regards,
Justin

pinStatus

after Locked screen goes away, password not resetted and have unlimited length.

I dont use handler, only required props.

iPhone X simulator.

by the way, why so bad customization? awesome component :)

Tests fails on App Center CI

Hey,

We are trying to use react-native-pincode on AppCenter and are running into an issue. If you setup a simple project that uses react-native-pincode then write a Unit test such as:

it('renders without crashing', () => {
   const rendered = renderer.create(<SetPinCodeScreen
     setPinCode={ store }
      />).toJSON();
  expect(rendered).toBeTruthy();
});

Then you get the following error:

FAIL src/views/set-pin-code/SetPinCodeScreen.test.tsx
  โ— Test suite failed to run

    /Users/vsts/agent/2.136.1/work/1/s/node_modules/@haskkor/react-native-pincode/dist/index.js:37
        async componentWillMount() {
              ^^^^^^^^^^^^^^^^^^

    SyntaxError: Unexpected identifier

      1 | import * as React from 'react';
      2 | import PINCode, { IProps } from '@haskkor/react-native-pincode'
    > 3 | import { StyleSheet } from "react-native";
        |                         ^
      4 | 
      5 | interface Props extends IProps {
      6 |   id?: string

      at ScriptTransformer._transformAndBuildScript (node_modules/jest-runtime/build/script_transformer.js:403:17)
      at Object.<anonymous> (src/views/set-pin-code/SetPinCodeScreen.tsx:6:17)

I looked into that method:

async componentWillMount() {
    await AsyncStorage.getItem(this.props.timePinLockedAsyncStorageName || timePinLockedAsyncStorageNameDefault).then((val) => {
      this.setState({pinLocked: !!val})
    })
  }

I think maybe AsyncStorage is hanging?

Any thoughts, are you running this on a CI?

Delete button text

How i can change delete button text only ?
I want to change delete button text, and keep same Icon.

pinStatus property no longer being used!

Hi,

The fix for #48 in commit e26fb9d now means that when we set pinStatus on PINCode this value is now overwritten in the method endProcess. We need a way to be able to replace the method endProcess(pinCode) with our own handler completly. Just to be clear we are not using the storedPin approach, and instead manage the pinStatus property ourselves.

setState touchIDDisabled prop not reloading pin to achieve faceId.

During creating new PIN view and setting touchIDDisabled prop by setState it does not re render and ask for face id, tried to do so on iphone X.

@haskkor/[email protected]
[email protected]

import React from 'react';
import {View} from 'react-native';
import PINCode, {hasUserSetPinCode} from '@haskkor/react-native-pincode';
import TouchID from 'react-native-touch-id';

export interface Props {

}

export interface State {
    status: "choose" | "enter" | "locked";
    isTouchIdSupported: boolean;
}

class AuthPinScreen extends React.Component<Props, State> {
    constructor(props: Props) {
        super(props);

        this.state = {
            status: 'choose',
        };
    }

    componentWillMount(): void {
        hasUserSetPinCode(Config.pin.codeKeychainName)
            .then((a) => {
                if (a) {
                    this.setState({status: 'enter'});
                }
            })
            .catch(() => this.setState({status: 'locked'}));

        TouchID.isSupported()
            .then(() => {
                this.setState({isTouchIdSupported: true}, () => {
                    this.forceUpdate();
                });
            })
            .catch((e: any) => console.log(e));
    }

    render(): React.ReactNode {
        return <View>
            <PINCode
                status={this.state.status}
                touchIDDisabled={!this.state.isTouchIdSupported}
            />
        </View>;
    }
}

export default AuthPinScreen;

Android ApplicationLocked screen positioning issue

Original ApplicationLocked render function is:

  render() {
    return (
      <View>
        {this.renderErrorLocked()}
      </View>
    )
  }

Here we apply container styles on top View component of renderErrorLocked, on Android it still remains hidden despite absolute positioning and you see PinCodeEnter.

Moving container styles here solves the issue for me:

  render() {
    return (
      <View style={styles.container}>
        {this.renderErrorLocked()}
      </View>
    )
  }

Feature request: custom left bottom button component

Hi. First of all thanks for library, I like many possibilities for customization. But now I am missing one.

Could you please add property where I can define custom component, which will be rendered in the left bottom corner of numpad (now there is nothing rendered) ?
So it would be something like
buttonLeftBottomComponent={() => <MyCustomButton title={...} onPress={...} />}.
I could really use that button for some actions.

Add option to disable locked screen

Hello, I would love to handle on my own failed attempts, could you add property to disable locked screen? (But still need failed attempts to be counted and passed to onFail method)

how to use handleResultEnterPin

please , tell me how to get my enter code .

<PINCode
status={'choose'}
finishProcess={()=>console.log('pin enters')}
handleResultEnterPin={(code)=>{
console.log(code);
}}
onFail={(attempt)=>{
console.log(attempt+'fail');
}}
/>

passwordLength issue

hi,

i dont know if it is bug or not, if i set passwordLength to 6, i can type over 6 char. it means if user typed to 8 char accidentally, user need to backspace 2 more extra. Sorry for my bad english, i hope you understand what i mean.

and so, which options can i use to run function if user already type 6 chars, so user cant typed 7th and 8th char.

thanks

pincode component is very slow in my android device

In my android device react-native-pincode component is very slow tell me what can i do to make this fast. when i click number button it responds very late peroformance very slow.
please help , i am stuck with it,

My Code

<PINCode
status={'enter'}
finishProcess={()=>this.finishProcess()}
colorPassword={'#7E7EEF'}
numbersButtonOverlayColor={'#7E7EEF'}
touchIDDisabled={true}
pinCodeKeychainName={'pincode'}
onClickButtonLockedPage={this.quitApplication}
/>

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.