This package has been deprecated

Author message:

Package no longer supported. Contact Support at https://www.npmjs.com/support for more info.

react-native-dimmer

1.0.1 • Public • Published

react-native-dimmer

A plugin that allows you to enable (eventually lock the device) and disable the screen dim in your React Native app. Works in both iOS and Android.

github home github issues npm version npm downloads npm license


Installation

$ npm install react-native-dimmer --save

iOS

In the XCode's "Project navigator", right click on your project's "Libraries" folder ➜ Add Files to <...>. Go to node_modulesreact-native-dimmer ➜ select the contents of ios folder. Make sure RNDimmer.m is listed under "Compile Sources" in your project's "Build Phases" tab.

Android

Add react-native-dimmer to your ./android/settings.gradle file as follows:

include ':react-native-dimmer'
project(':react-native-dimmer').projectDir = new File(settingsDir, '../node_modules/react-native-dimmer/android')

Include it as dependency in ./android/app/build.gradle file:

dependencies {
    ...
    compile project(':react-native-dimmer')
}

Finally, you need to add the package within the ReactInstanceManager of your MainActivity (./android/app/src/main/java/your/bundle/MainActivity.java):

import social.yadi.rndimmer.ReactNativeDimmerPackage;  // <---- import this one 
...
@Override
protected List<ReactPackage> getPackages() {
    return Arrays.<ReactPackage>asList(
        new MainReactPackage(),
        new ReactNativeDimmerPackage(this)  // <---- add this line 
    );
}

After that, you will need to recompile your project with react-native run-android.

Usage

import React, { Component } from 'react-native';
import RNDimmer from 'react-native-dimmer';
...
class Application extends Component {
    ...
    componentWillMount() {
        // Enable dimmer
        this.applyDimmer();
    }
    componentWillUnmount() {
        // Disable dimmer
        this.applyDimmer( false );
    }
    async applyDimmer( disabled = true ) {
        try {
            await RNDimmer.set( disabled );
            console.log( disabled ? 'Enabled' : 'Disabled' );
        } catch ( e ) {
            console.error( e );
        }
    }
    ...
}

License

The MIT License

Package Sidebar

Install

npm i react-native-dimmer

Weekly Downloads

1

Version

1.0.1

License

MIT

Last publish

Collaborators

  • khadorkin