Skip to content

DrakeXorn/expo-torchstate

Repository files navigation

@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.

About

A library to access the devices' flashlight

Resources

License

Code of conduct

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published