@drakexorn/expo-torchstate
TypeScript icon, indicating that this package has built-in type declarations

0.1.2 • Public • Published

@drakexorn/expo-torchstate

A library to access the devices' flashlight.

Installation

In order to install this package, you need to have a project created with Expo. For bare React Native projects, you must ensure that you have installed and configured the expo package before continuing.

Once you have your project ready, you can install the package using the following command:

npm install @drakexorn/expo-torchstate

Usage

To be able to use the library, you need to import it in your file:

import {useTorch} from '@drakexorn/expo-torchstate';

Then, you can use the useTorch hook to access the flashlight. For example :

export default function SeeTorchState() {
  const [torchOn, setTorchStatus] = useTorch();

  return (
    <View style={styles.container}>
      <Text>Flashlight turned {torchOn ? "on" : "off"}</Text>
      <Pressable style={styles.button} onPress={() => setTorchStatus(currentState => !currentState)}>
        <Text>Toggle flashlight</Text>
      </Pressable>
    </View>
  );
}

The hook provides a boolean value representing the current state of the flashlight and a function to toggle it.

Contributing

Contributions are very welcome! Please refer to guidelines described in the contributing guide.

Authors

Thanks to the following people who have contributed to this project:

Acknowledgements

This project has been built using create-expo-module, thanks to the Expo team for providing this tool.

License

This project is licensed under the MIT License - see the LICENSE file for details.

Package Sidebar

Install

npm i @drakexorn/expo-torchstate

Weekly Downloads

5

Version

0.1.2

License

MIT

Unpacked Size

28.8 kB

Total Files

31

Last publish

Collaborators

  • drakexorn