-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(brightness): add brightness plugin (#4454)
* feat(brightness): add brightness plugin * doc(brightness): update usage doc
- Loading branch information
1 parent
7fe3ad1
commit f02bc78
Showing
1 changed file
with
62 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
import { Injectable } from '@angular/core'; | ||
import { Plugin, Cordova, AwesomeCordovaNativePlugin } from '@awesome-cordova-plugins/core'; | ||
|
||
/** | ||
* @name Brightness | ||
* @description | ||
* The Brightness plugin let you control the display brightness of your device. | ||
* | ||
* Requires Cordova plugin: `cordova-plugin-brightness`. For more info, please see the [Brightness plugin docs](https://github.com/mgcrea/cordova-plugin-brightness). | ||
* | ||
* @usage | ||
* ```typescript | ||
* import { Brightness } from '@awesome-cordova-plugins/brightness/ngx'; | ||
* | ||
* | ||
* constructor(private brightness: Brightness) { } | ||
* | ||
* ... | ||
* | ||
* | ||
* let brightnessValue = 0.8; | ||
* this.brightness.setBrightness(brightnessValue); | ||
* ``` | ||
*/ | ||
@Plugin({ | ||
pluginName: 'Brightness', | ||
plugin: 'cordova-plugin-brightness', | ||
pluginRef: 'cordova.plugins.brightness', | ||
repo: 'https://github.com/mgcrea/cordova-plugin-brightness', | ||
platforms: ['Android', 'iOS'], | ||
}) | ||
@Injectable() | ||
export class Brightness extends AwesomeCordovaNativePlugin { | ||
/** | ||
* Sets the brightness of the display. | ||
* @param value {number} Floating number between 0 and 1 in which case 1 means 100% brightness and 0 means 0% brightness. | ||
* @returns {Promise<any>} Returns a Promise that resolves if setting brightness was successful. | ||
*/ | ||
@Cordova() | ||
setBrightness(value: number): Promise<any> { | ||
return; | ||
} | ||
|
||
/** | ||
* Reads the current brightness of the device display. | ||
* @returns {Promise<any>} Returns a Promise that resolves with the | ||
* brightness value of the device display (floating number between 0 and 1). | ||
*/ | ||
@Cordova() | ||
getBrightness(): Promise<any> { | ||
return; | ||
} | ||
|
||
/** | ||
* Keeps the screen on. Prevents the device from setting the screen to sleep. | ||
* @param {boolean} value | ||
*/ | ||
@Cordova() | ||
setKeepScreenOn(value: boolean): void { | ||
return; | ||
} | ||
} |