Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/capacitor-community/screen-brightness
https://github.com/capacitor-community/screen-brightness
Last synced: about 1 month ago
JSON representation
- Host: GitHub
- URL: https://github.com/capacitor-community/screen-brightness
- Owner: capacitor-community
- License: mit
- Created: 2021-01-26T15:54:33.000Z (almost 4 years ago)
- Default Branch: main
- Last Pushed: 2024-04-18T15:36:45.000Z (8 months ago)
- Last Synced: 2024-05-28T22:11:52.240Z (7 months ago)
- Language: Java
- Size: 273 KB
- Stars: 21
- Watchers: 2
- Forks: 7
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
Awesome Lists containing this project
- awesome-capacitorjs - @capacitor-community/screen-brightness - Capacitor community plugin for controlling screen brightness on iOS and Android devices. (Plugins / Community Plugins)
- awesome-capacitor - Screen brightness - Control screen brightness on iOS and android. (Community plugins)
README
Screen Brightness
@capacitor-community/screen-brightness
Capacitor community plugin for controlling screen brightness on iOS and Android devices.## Maintainers
| Maintainer | GitHub | Social |
| -----------| -------| -------|
| Ely Lucas | [elylucas](https://github.com/elylucas) | [@elylucas](https://twitter.com/elylucas) |## Versions
| Plugin | Capacitor | Documentation |
| ------ | --------- | --------------------------------------------------------------------------------- |
| 6.x | 6.x | [README](https://github.com/capacitor-community/screen-brightness/blob/main/README.md) |
| 5.x | 5.x | [README](https://github.com/capacitor-community/screen-brightness/blob/5.x/README.md) |
| 4.x | 4.x | [README](https://github.com/capacitor-community/screen-brightness/blob/4.x/README.md) |
| 1.x | 3.x | [README](https://github.com/capacitor-community/screen-brightness/blob/1.x/README.md) |## Installation
```bash
npm install @capacitor-community/screen-brightness
npx cap sync
```
## ConfigurationNo configuration required for this plugin
## Usage
```typescript
import { ScreenBrightness } from '@capacitor-community/screen-brightness';// Set the brightness:
const brightness = 0.5;
await ScreenBrightness.setBrightness({ brightness });// Get the current brightness:
const {brightness: currentBrightness} = await ScreenBrightness.getBrightness();
```## API
* [`setBrightness(...)`](#setbrightness)
* [`getBrightness()`](#getbrightness)
* [Interfaces](#interfaces)### setBrightness(...)
```typescript
setBrightness(options: SetBrightnessOptions) => Promise
```Sets the brightness level. On iOS, it sets the system level brightness, and on Android it sets the brightness for the current view.
| Param | Type | Description |
| ------------- | --------------------------------------------------------------------- | ------------------------- |
| **`options`** |SetBrightnessOptions
| Options to set brightness |**Since:** 1.0.0
--------------------
### getBrightness()
```typescript
getBrightness() => Promise
```Returns info than contains the current brightness level
* @since 1.0.0**Returns:**
Promise<GetBrightnessReturnValue>
--------------------
### Interfaces
#### SetBrightnessOptions
| Prop | Type | Description | Since |
| ---------------- | ------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----- |
| **`brightness`** |number
| The level to set the brightness to, from 0.0 (very dim) to 1.0 (full brightness) On Android, setting the value to -1 restores the user configured brightness. | 1.0.0 |#### GetBrightnessReturnValue
| Prop | Type | Description | Since |
| ---------------- | ------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------- | ----- |
| **`brightness`** |number
| The current brightness level, from 0.0 (very dim) to 1.0 (full brightness) On Android it returns -1 if the value has not been changed by the app. | 1.0.0 |