rn-device-brightness
v0.4.0
Published
A native module for React Native to control the screen brightness.
Downloads
4
Readme
rn-device-brightness
A native module for React Native to control the screen brightness.
Installation
npm install rn-device-brightness
or
yarn add rn-device-brightness
iOS
cd ios && pod install && cd ..
or npx pod-install
Permission
Android
- Remember add the following uses-permission to your
AndroidManifest.xml
(usually found at: android/src/main/)
<uses-permission android:name="android.permission.WRITE_SETTINGS" />
Running the example project
cd example && yarn install
npx pod-install && yarn ios
or yarn android
Functions
getBrightness: support Android and iOS, get brightness level
getSystemBrightness: support Android only, get brightness level
setBrightness: support Android and iOS, set brightness
setBrightnessAnimation: support Android and iOS, set brightness with animation
setSystemBrightness: support Android, set system brightness
Usage
import { Platform } from 'react-native';
import { getBrightness, setBrightness, setSystemBrightnness } from 'rn-device-brightness';
// ...
const level = await getBrightness();
if (Platform.OS === 'android') {
setSystemBrightnness(0.75);
} else {
setBrightness(0.75);
}
Contributing
See the contributing guide to learn how to contribute to the repository and the development workflow.
License
MIT
Made with create-react-native-library