UNPKG

4.99 kBTypeScriptView Raw
1import { PermissionExpiration, PermissionHookOptions, PermissionResponse, PermissionStatus } from 'expo-modules-core';
2export declare enum BrightnessMode {
3 /**
4 * Means that the current brightness mode cannot be determined.
5 */
6 UNKNOWN = 0,
7 /**
8 * Mode in which the device OS will automatically adjust the screen brightness depending on the
9 * ambient light.
10 */
11 AUTOMATIC = 1,
12 /**
13 * Mode in which the screen brightness will remain constant and will not be adjusted by the OS.
14 */
15 MANUAL = 2
16}
17export { PermissionExpiration, PermissionHookOptions, PermissionResponse, PermissionStatus };
18/**
19 * Returns whether the Brightness API is enabled on the current device. This does not check the app
20 * permissions.
21 * @return Async `boolean`, indicating whether the Brightness API is available on the current device.
22 * Currently this resolves `true` on iOS and Android only.
23 */
24export declare function isAvailableAsync(): Promise<boolean>;
25/**
26 * Gets the current brightness level of the device's main screen.
27 * @return A `Promise` that fulfils with a number between `0` and `1`, inclusive, representing the
28 * current screen brightness.
29 */
30export declare function getBrightnessAsync(): Promise<number>;
31/**
32 * Sets the current screen brightness. On iOS, this setting will persist until the device is locked,
33 * after which the screen brightness will revert to the user's default setting. On Android, this
34 * setting only applies to the current activity; it will override the system brightness value
35 * whenever your app is in the foreground.
36 * @param brightnessValue A number between `0` and `1`, inclusive, representing the desired screen
37 * brightness.
38 * @return A `Promise` that fulfils when the brightness has been successfully set.
39 */
40export declare function setBrightnessAsync(brightnessValue: number): Promise<void>;
41/**
42 * __Android only.__ Gets the global system screen brightness.
43 * @return A `Promise` that is resolved with a number between `0` and `1`, inclusive, representing
44 * the current system screen brightness.
45 */
46export declare function getSystemBrightnessAsync(): Promise<number>;
47/**
48 * > __WARNING:__ This method is experimental.
49 *
50 * __Android only.__ Sets the global system screen brightness and changes the brightness mode to
51 * `MANUAL`. Requires `SYSTEM_BRIGHTNESS` permissions.
52 * @param brightnessValue A number between `0` and `1`, inclusive, representing the desired screen
53 * brightness.
54 * @return A `Promise` that fulfils when the brightness has been successfully set.
55 */
56export declare function setSystemBrightnessAsync(brightnessValue: number): Promise<void>;
57/**
58 * __Android only.__ Resets the brightness setting of the current activity to use the system-wide
59 * brightness value rather than overriding it.
60 * @return A `Promise` that fulfils when the setting has been successfully changed.
61 */
62export declare function useSystemBrightnessAsync(): Promise<void>;
63/**
64 * __Android only.__ Returns a boolean specifying whether or not the current activity is using the
65 * system-wide brightness value.
66 * @return A `Promise` that fulfils with `true` when the current activity is using the system-wide
67 * brightness value, and `false` otherwise.
68 */
69export declare function isUsingSystemBrightnessAsync(): Promise<boolean>;
70/**
71 * __Android only.__ Gets the system brightness mode (e.g. whether or not the OS will automatically
72 * adjust the screen brightness depending on ambient light).
73 * @return A `Promise` that fulfils with a [`BrightnessMode`](#brightnessmode). Requires
74 * `SYSTEM_BRIGHTNESS` permissions.
75 */
76export declare function getSystemBrightnessModeAsync(): Promise<BrightnessMode>;
77/**
78 * __Android only.__ Sets the system brightness mode.
79 * @param brightnessMode One of `BrightnessMode.MANUAL` or `BrightnessMode.AUTOMATIC`. The system
80 * brightness mode cannot be set to `BrightnessMode.UNKNOWN`.
81 */
82export declare function setSystemBrightnessModeAsync(brightnessMode: BrightnessMode): Promise<void>;
83/**
84 * Checks user's permissions for accessing system brightness.
85 * @return A promise that fulfils with an object of type [PermissionResponse](#permissionrespons).
86 */
87export declare function getPermissionsAsync(): Promise<PermissionResponse>;
88/**
89 * Asks the user to grant permissions for accessing system brightness.
90 * @return A promise that fulfils with an object of type [PermissionResponse](#permissionrespons).
91 */
92export declare function requestPermissionsAsync(): Promise<PermissionResponse>;
93/**
94 * Check or request permissions to modify the system brightness.
95 * This uses both `requestPermissionAsync` and `getPermissionsAsync` to interact with the permissions.
96 *
97 * @example
98 * ```ts
99 * const [status, requestPermission] = Brightness.usePermissions();
100 * ```
101 */
102export declare const usePermissions: (options?: PermissionHookOptions<object> | undefined) => [PermissionResponse | null, () => Promise<PermissionResponse>, () => Promise<PermissionResponse>];