Hi -- I'd like to contribute to the installation guide.
I tried just adding the javascript code, and it didn't work, failing in the debugger with:
Cannot read property 'setBrightness' of undefined
So I'm guessing what to do here :-) based on various other react-native plugins.
So I've changed android/app/build.gradle
to have:
--- a/android/app/build.gradle
+++ b/android/app/build.gradle
@@ -131,4 +131,5 @@ dependencies {
compile fileTree(dir: "libs", include: ["*.jar"])
compile "com.android.support:appcompat-v7:23.0.1"
compile "com.facebook.react:react-native:0.20.+"
+ compile project(":react-native-screen-brightness")
}
Added:
import com.robinpowered.react.ScreenBrightness.ScreenBrightnessPackage;
to my MainActivity.java
file, which also has:
@@ -51,7 +53,8 @@ public class MainActivity extends ReactActivity {
@Override
protected List<ReactPackage> getPackages() {
return Arrays.<ReactPackage>asList(
- new MainReactPackage()
+ new MainReactPackage(),
+ new ScreenBrightnessPackage(this)
);
}
}
Added to android/settings.gradle
:
include ':react-native-screen-brightness'
project(':react-native-screen-brightness').projectDir = new File(settingsDir, '../node_modules/react-native-screen-brightness/android')
Finally, my index.android.js
file has:
import { NativeModules } from "react-native";
const { SystemBrightness } = NativeModules;
//...
SystemBrightness.setBrightness(0.75);
This all compiles fine, but I still get the Cannot read property 'setBrightness' of undefined
error.
Any help much appreciated!