react-native-brightness
v1.0.3
Published
React Native bridge controls device screen brightness
Downloads
160
Readme
react-native-brightness
Getting started
$ npm install react-native-brightness --save
Mostly automatic installation
$ react-native link react-native-brightness
Manual installation
iOS
- In XCode, in the project navigator, right click
Libraries
➜Add Files to [your project's name]
- Go to
node_modules
➜react-native-brightness
and addBrightness.xcodeproj
- In XCode, in the project navigator, select your project. Add
libBrightness.a
to your project'sBuild Phases
➜Link Binary With Libraries
- Run your project (
Cmd+R
)<
Android
- Open up
android/app/src/main/java/[...]/MainApplication.java
- Add
import com.cca6286pro.reactlibrary.brightness.BrightnessPackage;
to the imports at the top of the file - Add
new BrightnessPackage()
to the list returned by thegetPackages()
method
- Append the following lines to
android/settings.gradle
:include ':react-native-brightness' project(':react-native-brightness').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-brightness/android')
- Insert the following lines inside the dependencies block in
android/app/build.gradle
:compile project(':react-native-brightness')
Usage
import Brightness from "react-native-brightness";
Brightness.getBrightness((brightnessLevel) => {
// brightnessLevel is a float (0 - 1)
});
Brightness.setBrightness(0.7);