0.4.1 • Published 1 year ago

react-native-secret-chamber v0.4.1

Weekly downloads
-
License
MIT
Repository
github
Last release
1 year ago

react-native-secret-chamber

This library is a small tool when you want a secret on your React-Native app. You might want to navigate to a hidden screen, display an alert or anything you want.

Installation

npm install react-native-secret-chamber

or

yarn add react-native-secret-chamber

Usage

Set the number of taps you want and encapsulate any ReactNode as a child. You can also set a password for it. If you do, you can also pass a alert title and message for the dialog

Note: The cadence of taps needs to be lower than 1.5 seconds, otherwise it will reset the tap counting.

import { SecretChamber } from 'react-native-secret-chamber';
import { Alert, StyleSheet, View, Text } from 'react-native';

export default function App() {
  const [secret, setSecret] = React.useState(false);

  return (
    <View style={styles.container}>
      <SecretChamber
        taps={10}
        password="123456"
        alertTitle="You should not be here!"
        alertMessage="Get out of my swamp!"
        onOpen={() => {
          Alert.alert('You entered', 'this gonna be our secret, okay? :)');
          setSecret(true);
        }}
      >
        <Text>There's nothing to see here</Text>
      </SecretChamber>
      {secret && <Text>Oops, you got me!</Text>}
    </View>
  );
}

Example

Props

Prop namerequireddefault valuetypedescription
tapsYesyou have to setnumberThe number of taps required to trigger the action
onOpenYesyou have to set() => voidThe function you want to trigger when the number of taps reached the required amount
passwordNoyou have to setstringAn optional password. It will trigger an alert prompt asking for the password.
alertTitleNo"Password"stringAn optional title for the alert in case you set a password
alertMessageNo-stringAn optional message for the alert in case you set a password

License

MIT


Made with create-react-native-library

0.4.1

1 year ago

0.4.0

1 year ago

0.3.0

1 year ago

0.2.1

1 year ago

0.2.0

1 year ago