Skip to content

Commit 22889a5

Browse files
authored
docs(brightness): update (#439)
1 parent 0b92dd2 commit 22889a5

File tree

1 file changed

+47
-21
lines changed

1 file changed

+47
-21
lines changed

packages/brightness/README.md

+47-21
Original file line numberDiff line numberDiff line change
@@ -1,54 +1,80 @@
11
# @nativescript/brightness
22

3+
A plugin that get and set the device's brightness level.
4+
5+
## Contents
6+
* [Installation](#installation)
7+
* [Required permissions for Android](#required-permissions-for-android)
8+
* [Use @nativescript/brightness](#use-nativescriptbrightness)
9+
* [Set the device brightness level](#set-the-device-brightness-level)
10+
* [Get the device brightness level](#get-the-device-brightness-level)
11+
* [API](#api)
12+
* [Brightness class](#brightness-class)
13+
* [BrightnessOptions interface](#brightnessoptions-interface)
14+
* [License](#license)
15+
16+
## Installation
17+
318
```cli
419
npm install @nativescript/brightness
520
```
621

7-
> **Note:** This plugin requires `<uses-permission android:name="android.permission.WRITE_SETTINGS"/>` to be added in the `AndroidManifest.xml`.
22+
## Required permissions for Android
823

9-
## Usage
24+
Add the following permission to the `App_Resources/src/main/AndroidManifest.xml` file:
25+
26+
- `<uses-permission android:name="android.permission.WRITE_SETTINGS"/>`
27+
28+
```xml
29+
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
30+
package="es.amplya.app_inventario">
31+
32+
<uses-permission android:name="android.permission.WRITE_SETTINGS"/>
33+
34+
<application android:name="com.tns.NativeScriptApplication">
35+
...
1036

11-
To use the plugin, you should first import it.
12-
```typescript
13-
// TypeScript
14-
import { Brightness } from '@nativescript/brightness';
1537
```
1638

17-
### Setting the device brightness level
18-
To set the brightness level of the device, call the `set()` method passing it the [BrightnessOptions](#brightnessoptions) object with the desired `intensity` value.
39+
## Use @nativescript/brightness
40+
41+
### Set the device brightness level
1942

20-
```js
21-
// TypeScript
43+
To set the device's brightness level, call the `set()` method on an instance of the [Brightness class](#brightness-class), passing it the [BrightnessOptions](#brightnessoptions) object with the desired `intensity` value.
44+
45+
```typescript
46+
47+
import { Brightness } from '@nativescript/brightness';
2248
const brightness = new Brightness();
2349

2450
brightness.set({
2551
intensity: 25,
2652
});
2753
```
2854

29-
The `intensity` value can range from `1` to `100`.
55+
### Get the device brightness level
56+
57+
To get the device's brightness level, call the `get()` method on an instance of the [Brightness class](#brightness-class).
3058

31-
### Getting the device brightness Level
32-
To get the device's brightness, call the `get()` method.
3359
```ts
3460
bightnessLevel : number = brightness.get()
3561
```
3662

3763
## API
3864

39-
### Methods
65+
### Brightness class
4066

41-
| Method | Description |
42-
| ------------------------------- | ------------------------------------------------------------------------------------------------------------------------------ |
43-
| `set(options: BrightnessOptions)` | Sets screen's brightness to the desired intensity |
44-
| `get()` | Returns current screen brightness value as a number between `0` and `100` |
45-
| `getNative() ` | returns current screen brightness value as returned from the native api: between` 0.0` and `1.0` for iOS and `0` and `255` for android |
67+
| Method | Returns | Description
68+
|:-------|:--------|:-----------
69+
| `set(options: BrightnessOptions)`| `void` | Sets screen's brightness level to the desired intensity |
70+
| `get()`| `number` | Returns current screen brightness value as a number between `0` and `100` |
71+
| `getNative() `| `number` | Returns current native screen brightness value. <br> iOS: a value between` 0.0` and `1.0`. <br> Android: `0` and `255` |
4672

47-
### BrightnessOptions
73+
### BrightnessOptions interface
4874

4975
| Property | Default | Description |
5076
| --------- | ------- | --------------------------------------------------------------------------------- |
51-
| intensity | 100 | defines the desired brightness value, which should be a number between 0 and 100. |
77+
| `intensity` | `100` | Defines the desired brightness value, which should be a number between `0` and `100`. |
5278

5379
## License
5480

0 commit comments

Comments
 (0)