rn-device-brightness
TypeScript icon, indicating that this package has built-in type declarations

0.4.0 • Public • Published

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

Package Sidebar

Install

npm i rn-device-brightness

Weekly Downloads

1

Version

0.4.0

License

MIT

Unpacked Size

30.4 kB

Total Files

20

Last publish

Collaborators

  • viethung232