1 |
|
2 |
|
3 | import { NativeModules, Platform } from 'react-native';
|
4 |
|
5 | export async function getBrightnessAsync(): Promise<number> {
|
6 | return await NativeModules.ExponentBrightness.getBrightnessAsync();
|
7 | }
|
8 |
|
9 | export async function setBrightnessAsync(brightnessValue: number): Promise<void> {
|
10 | brightnessValue = Math.max(0, Math.min(brightnessValue, 1));
|
11 | return await NativeModules.ExponentBrightness.setBrightnessAsync(brightnessValue);
|
12 | }
|
13 |
|
14 | export async function getSystemBrightnessAsync(): Promise<number> {
|
15 | if (Platform.OS !== 'android') {
|
16 | return await getBrightnessAsync();
|
17 | }
|
18 | return await NativeModules.ExponentBrightness.getSystemBrightnessAsync();
|
19 | }
|
20 |
|
21 | export async function setSystemBrightnessAsync(brightnessValue: number): Promise<void> {
|
22 | brightnessValue = Math.max(0, Math.min(brightnessValue, 1));
|
23 | if (Platform.OS !== 'android') {
|
24 | return await setBrightnessAsync(brightnessValue);
|
25 | } else {
|
26 | return await NativeModules.ExponentBrightness.setSystemBrightnessAsync(brightnessValue);
|
27 | }
|
28 | }
|