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

react-native-patternlock-authentication

Package Overview
Dependencies
Maintainers
1
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-native-patternlock-authentication

Pattern Lock Security for both Android and IOS

  • 1.3.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
12
increased by33.33%
Maintainers
1
Weekly downloads
 
Created
Source

react-native-patternlock-authentication

Pattern Lock Security for both Android and IOS using react native svg.

Set New Pattern Change Pattern Confirm Pattern

General Pattern Working Gif

General Pattern

Installation

Note: To use this Authentication, ensure that you have react-native-svg and its dependencies (follow this guide).

npm install react-native-patternlock-authentication

Usage

There are two types of PatternLock Available in this Package.

  1. GeneralPatternLock
  2. FeaturedPatternLock

GeneralPatternLock

import { Dimensions } from 'react-native';

// ....

import { GeneralPatternLock } from 'react-native-patternlock-authentication'; // Import Package

const { width, height } = Dimensions.get('window');
const PATTERN_CONTAINER_HEIGHT = height / 2; //you can change it as per your need
const PATTERN_CONTAINER_WIDTH = width; //you can change it as per your need
const PATTERN_DIMENSION = 3; //you can change it as per your need
const CORRECT_UNLOCK_PATTERN = '0123'; //Correct Pattern

// ...

export const App = () => {
  const onPatternMatch = () => {
    // Do your Functionalities
  };

  const onWrongPattern = () => {
    // Do your Functionalities
  };

  const onPatternMatchAfterDelay = () => {
    // Do your Functionalities
  };

  const onWrongPatternAfterDelay = () => {
    // Do your Functionalities
  };

  return (
    //...

    <GeneralPatternLock
      containerDimension={PATTERN_DIMENSION}
      containerWidth={PATTERN_CONTAINER_WIDTH}
      containerHeight={PATTERN_CONTAINER_HEIGHT}
      correctPattern={CORRECT_UNLOCK_PATTERN}
      dotsAndLineColor="blue"
      defaultDotRadius={10}
      snapDotRadius={15}
      snapDuration={100}
      lineStrokeWidth={5}
      wrongPatternColor="red"
      matchedPatternColor="green"
      onPatternMatch={onPatternMatch}
      onWrongPatternAfterDelay={onWrongPatternAfterDelay}
      onPatternMatchAfterDelay={onPatternMatchAfterDelay}
      onWrongPattern={onWrongPattern}

      // ...Use Remaining Props as per your convenience
    />

    //...
  );
};

Props

PropsTypeRequiredDefaultDescription
containerDimensionNumberNo3It Refers the Dimension of the Pattern Dots Array (eg.). 3 means 3 x 3, 4 means 4 x 4.
containerWidthNumberNoDimensions.get('window').width
containerHeightNumberNo(Dimensions.get('window').height)/2
correctPatternStringYes
wrongPatternDelayTimeNumber (MilliSeconds)No1000Pattern draw event disable duration after the Wrong Pattern.
correctPatternDelayTimeNumberNo0Pattern draw event disable duration after the Correct Pattern.
dotsAndLineColorStringNoblue
wrongPatternColorStringNored
lineStrokeWidthNumberNo5Thickness of Line
defaultDotRadiusNumberNo6
snapDotRadiusNumberNo10Snaping radius of Dots When Connecting the Dots.
snapDurationNumberNo100Snaping duration of Dots When Connecting the Dots.
enableHintBooleanNofalse
hintStringNo
hintContainerStyleViewStyleNo
hintTextStyleTextStyleNo{ color: '#000000' }
matchedPatternColorStringNogreen

Methods

onPatternMatch

It will call, when the Pattern is Matched with Correct Pattern.

TypeRequired
functionYes

onWrongPattern

It will call, when the Pattern is Matched with Wrong Pattern.

TypeRequired
functionNo

onPatternMatchAfterDelay

It will call, when the Pattern is Matched with Correct Pattern after the correctPatternDelayTime which is passed as prop by you.

TypeRequired
functionNo

onWrongPatternAfterDelay

It will call, when the Pattern is Matched with Wrong Pattern after the wrongPatternDelayTime which is passed as prop by you.

TypeRequired
functionNo

FeaturedPatternLock

It includes all Pattern Authentication Process like,

  1. Confirm Your Pattern,
  2. Change Pattern
  3. Set New Pattern
import { Dimensions } from 'react-native';

// ....

import {
  FeaturedPatternLock,
  PatternProcess,
} from 'react-native-patternlock-authentication'; // Import Package

const { width, height } = Dimensions.get('window');
const PATTERN_CONTAINER_HEIGHT = height / 2; //you can change it as per your need
const PATTERN_CONTAINER_WIDTH = width; //you can change it as per your need
const PATTERN_DIMENSION = 3; //you can change it as per your need

// ...

export const App = () => {
  const onPatternMatch = () => {
    // Do your Functionalities
  };

  const onWrongPattern = () => {
    // Do your Functionalities
  };

  const onPatternMatchAfterDelay = () => {
    // Do your Functionalities
  };

  const onWrongPatternAfterDelay = () => {
    // Do your Functionalities
  };

  return (
    //...

    <FeaturedPatternLock
      onPatternMatch={onPatternMatch}
      onWrongPattern={onWrongPattern}
      isChangePattern={false}
      processName={PatternProcess.NEW_PATTERN}

      // ...Use Remaining Props as per your convenience
    />

    //...
  );
};

Props

PropsTypeRequiredDefaultDescription
containerDimensionNumberNo3It Refers the Dimension of the Pattern Dots Array (eg.). 3 means 3 x 3, 4 means 4 x 4.
containerWidthNumberNoDimensions.get('window').width
containerHeightNumberNo(Dimensions.get('window').height)/2
correctPatternStringYes - when processName is PatternProcess.CONFIRM_PATTERN. No - when processName is PatternProcess.NEW_PATTERN.
processNameStringNoPatternProcess.NEW_PATTERNPatternProcess Contains two processes. NEW_PATTERN and CONFIRM_PATTERN. processName must be CONFIRM_PATTERN for Change Pattern Process
isChangePatternbooleanNofalseIf the Pattern is working as Change Pattern then change it to true
showHintMessageBooleanNofalse
dotRadiusNumberNo10
dotsColorStringNored
movingLineColorStringNoblue
snapDotRadiusNumberNo15Snaping radius of Dots When Connecting the Dots.
lineStrokeWidthStringNo6
activeLineColorStringNoblue
wrongPatternColorStringNored
snapDurationNumberNo100 (milli seconds)Snaping duration of Dots When Connecting the Dots.
connectedDotsColorStringNoblue
correctPatternColorNumberNogreen
minPatternLengthNumberNo3
newPatternConfirmationMessageStringNoEmpty String
wrongPatternDelayTimeNumberNo1000 (milli seconds)
correctPatternMessageStringNoEmpty String
correctPatternDelayTimeNumberNo1000 (milli seconds)
correctPatternDelayDurationMessageStringNoEmpty String
iswrongPatternCountLimitedBooleanNofalseIf there is maximum limit of Wrong Pattern then change it to true
totalWrongPatternCountNumberNo0If iswrongPatternCountLimited is true then give maximum limit of Wrong Pattern
wrongPatternDelayDurationMessageStringNoEmpty String
minPatternLengthErrorMessageStringNoEmpty String
wrongPatternMessageStringNoEmpty String
changePatternFirstMessageStringNoEmpty String
changePatternDelayTimeNumberNo1000 (milli seconds)
changePatternSecondMessageStringNoEmpty String
isEnableHeadingTextBooleanNofalse
enableDotsJoinVirationBooleanNofalseIf it is true, then the mobile will be vibrate whenever the Pattern Dots Connects (Add Vibration Permissions). Refer React Native Vibration for Permissions.
vibrationPatternArrayNo[0, 200]Pattern of Vibration for connecting Dots. If enableDotsJoinViration is true then the Mobile Vibrates in this Pattern Refer React Native Vibration
headingTextStringNoEmpty String
enablePatternNotSameConditionBooleanNotrueIf It is true, then the previous Pattern is not allowed for new Pattern when the time of Change Pattern Process. Change it to false, if the Previous Pattern is also allowed for New Pattern
patternTotalCountReachedErrorMessageStringNoEmpty String
newPatternDelayDurationMessageStringNoEmpty String
newPatternMatchedMessageStringNoEmpty String
newPatternDelayTimeNumberNo1000 (milli seconds)
patternCountLimitedErrorMessageStringNoEmpty String
samePatternMatchedMessageStringNoEmpty String
hintTextStyleTextStyleNo{ color: 'blue' }
headingTextStyleTextStyleNo{ color: 'blue' }
hintTextContainerStyleViewStyleNo{ alignItems: 'center' }

Methods

onPatternMatch

It will call, when the Pattern is Matched with Correct Pattern. It will also called after the Confirm Pattern of Set Pattern Process. It returns pattern as callback Parameters.

TypeRequired
functionYes

onWrongPattern

It will call, whenever the Pattern is Matched with Wrong Pattern. It returns pattern and wrongPatternRemainingCount ( if enable iswrongPatternCountLimited ) as callback Parameters.

TypeRequired
functionNo

onPatternMatchAfterDelay

It will call, when the Pattern is Matched with Correct Pattern after the correctPatternDelayTime which is passed as prop by you. It will also called after the Confirm Pattern of Set Pattern Process. It returns pattern as callback Parameters.

TypeRequired
functionNo

onWrongPatternAfterDelay

It will call, when the Pattern is Matched with Wrong Pattern after the wrongPatternDelayTime which is passed as prop by you. It returns pattern and wrongPatternRemainingCount ( if enable iswrongPatternCountLimited ) as callback Parameters.

TypeRequired
functionNo

License

MIT

Would you like to support me?

Buy Me A Coffee

Keywords

FAQs

Package last updated on 12 Jan 2024

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