1 | import { NativeModules, Platform } from 'react-native';
|
2 | export async function getBrightnessAsync() {
|
3 | return await NativeModules.ExponentBrightness.getBrightnessAsync();
|
4 | }
|
5 | export async function setBrightnessAsync(brightnessValue) {
|
6 | brightnessValue = Math.max(0, Math.min(brightnessValue, 1));
|
7 | return await NativeModules.ExponentBrightness.setBrightnessAsync(brightnessValue);
|
8 | }
|
9 | export async function getSystemBrightnessAsync() {
|
10 | if (Platform.OS !== 'android') {
|
11 | return await getBrightnessAsync();
|
12 | }
|
13 | return await NativeModules.ExponentBrightness.getSystemBrightnessAsync();
|
14 | }
|
15 | export async function setSystemBrightnessAsync(brightnessValue) {
|
16 | brightnessValue = Math.max(0, Math.min(brightnessValue, 1));
|
17 | if (Platform.OS !== 'android') {
|
18 | return await setBrightnessAsync(brightnessValue);
|
19 | }
|
20 | else {
|
21 | return await NativeModules.ExponentBrightness.setSystemBrightnessAsync(brightnessValue);
|
22 | }
|
23 | }
|
24 |
|
\ | No newline at end of file |