|
| 1 | +import { Injectable } from '@angular/core'; |
| 2 | +import { Plugin, Cordova, AwesomeCordovaNativePlugin } from '@awesome-cordova-plugins/core'; |
| 3 | + |
| 4 | +/** |
| 5 | + * @name Brightness |
| 6 | + * @description |
| 7 | + * The Brightness plugin let you control the display brightness of your device. |
| 8 | + * |
| 9 | + * Requires Cordova plugin: `cordova-plugin-brightness`. For more info, please see the [Brightness plugin docs](https://github.com/mgcrea/cordova-plugin-brightness). |
| 10 | + * |
| 11 | + * @usage |
| 12 | + * ```typescript |
| 13 | + * import { Brightness } from '@awesome-cordova-plugins/brightness/ngx'; |
| 14 | + * |
| 15 | + * |
| 16 | + * constructor(private brightness: Brightness) { } |
| 17 | + * |
| 18 | + * ... |
| 19 | + * |
| 20 | + * |
| 21 | + * let brightnessValue = 0.8; |
| 22 | + * this.brightness.setBrightness(brightnessValue); |
| 23 | + * ``` |
| 24 | + */ |
| 25 | +@Plugin({ |
| 26 | + pluginName: 'Brightness', |
| 27 | + plugin: 'cordova-plugin-brightness', |
| 28 | + pluginRef: 'cordova.plugins.brightness', |
| 29 | + repo: 'https://github.com/mgcrea/cordova-plugin-brightness', |
| 30 | + platforms: ['Android', 'iOS'], |
| 31 | +}) |
| 32 | +@Injectable() |
| 33 | +export class Brightness extends AwesomeCordovaNativePlugin { |
| 34 | + /** |
| 35 | + * Sets the brightness of the display. |
| 36 | + * @param value {number} Floating number between 0 and 1 in which case 1 means 100% brightness and 0 means 0% brightness. |
| 37 | + * @returns {Promise<any>} Returns a Promise that resolves if setting brightness was successful. |
| 38 | + */ |
| 39 | + @Cordova() |
| 40 | + setBrightness(value: number): Promise<any> { |
| 41 | + return; |
| 42 | + } |
| 43 | + |
| 44 | + /** |
| 45 | + * Reads the current brightness of the device display. |
| 46 | + * @returns {Promise<any>} Returns a Promise that resolves with the |
| 47 | + * brightness value of the device display (floating number between 0 and 1). |
| 48 | + */ |
| 49 | + @Cordova() |
| 50 | + getBrightness(): Promise<any> { |
| 51 | + return; |
| 52 | + } |
| 53 | + |
| 54 | + /** |
| 55 | + * Keeps the screen on. Prevents the device from setting the screen to sleep. |
| 56 | + * @param {boolean} value |
| 57 | + */ |
| 58 | + @Cordova() |
| 59 | + setKeepScreenOn(value: boolean): void { |
| 60 | + return; |
| 61 | + } |
| 62 | +} |
0 commit comments