• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1/*
2 * Copyright (c) 2023 Huawei Device Co., Ltd.
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
6 *
7 *     http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
14 */
15
16/**
17 * @file
18 * @kit ArkUI
19 */
20
21import type { AsyncCallback } from './@ohos.base';
22
23/**
24 * Provide APIs to set system uiAppearance.
25 *
26 * @namespace uiAppearance
27 * @syscap SystemCapability.ArkUI.UiAppearance
28 * @systemapi hide this for inner system use
29 * @since 10
30 */
31declare namespace uiAppearance {
32  /**
33   * Enumerates dark-mode.
34   *
35   * @enum { number }
36   * @syscap SystemCapability.ArkUI.UiAppearance
37   * @systemapi hide this for inner system use
38   * @since 10
39   */
40  enum DarkMode {
41    /**
42     * Always display with dark mode.
43     *
44     * @syscap SystemCapability.ArkUI.UiAppearance
45     * @systemapi hide this for inner system use
46     * @since 10
47     */
48    ALWAYS_DARK = 0,
49
50    /**
51     * Always display with light mode.
52     *
53     * @syscap SystemCapability.ArkUI.UiAppearance
54     * @systemapi hide this for inner system use
55     * @since 10
56     */
57    ALWAYS_LIGHT = 1
58  }
59
60  /**
61   * Set the system dark-mode.
62   *
63   * @permission ohos.permission.UPDATE_CONFIGURATION
64   * @param { DarkMode } mode - indicates the dark-mode to set
65   * @param { AsyncCallback<void> } callback - the callback of setDarkMode
66   * @throws { BusinessError } 201 - Permission denied.
67   * @throws { BusinessError } 401 - Parameter error. Possible causes:
68   * <br> 1. Mandatory parameters are left unspecified.
69   * <br> 2. Incorrect parameters types.
70   * <br> 3. Parameter verification failed.
71   * @throws { BusinessError } 500001 - Internal error.
72   * @syscap SystemCapability.ArkUI.UiAppearance
73   * @systemapi hide this for inner system use
74   * @since 10
75   */
76  function setDarkMode(mode: DarkMode, callback: AsyncCallback<void>): void;
77
78  /**
79   * Set the system dark-mode.
80   *
81   * @permission ohos.permission.UPDATE_CONFIGURATION
82   * @param { DarkMode } mode - indicates the dark-mode to set
83   * @returns { Promise<void> } the promise returned by the function
84   * @throws { BusinessError } 201 - Permission denied.
85   * @throws { BusinessError } 401 - Parameter error. Possible causes:
86   * <br> 1. Mandatory parameters are left unspecified.
87   * <br> 2. Incorrect parameters types.
88   * <br> 3. Parameter verification failed.
89   * @throws { BusinessError } 500001 - Internal error.
90   * @syscap SystemCapability.ArkUI.UiAppearance
91   * @systemapi hide this for inner system use
92   * @since 10
93   */
94  function setDarkMode(mode: DarkMode): Promise<void>;
95
96  /**
97   * Acquire the current dark-mode.
98   *
99   * @permission ohos.permission.UPDATE_CONFIGURATION
100   * @returns { DarkMode } current dark-mode.
101   * @throws { BusinessError } 201 - Permission denied.
102   * @throws { BusinessError } 401 - Parameter error. Possible causes:
103   * <br> 1. Mandatory parameters are left unspecified.
104   * <br> 2. Incorrect parameters types.
105   * <br> 3. Parameter verification failed.
106   * @throws { BusinessError } 500001 - Internal error.
107   * @syscap SystemCapability.ArkUI.UiAppearance
108   * @systemapi hide this for inner system use
109   * @since 10
110   */
111  function getDarkMode(): DarkMode;
112
113  /**
114   * Set the system font-scale.
115   *
116   * @permission ohos.permission.UPDATE_CONFIGURATION
117   * @param { number } fontScale - indicates the font-scale to set
118   * @returns { Promise<void> } the promise returned by the function
119   * @throws { BusinessError } 201 - Permission denied.
120   * @throws { BusinessError } 202 - Permission verification failed. A non-system application calls a system API.
121   * @throws { BusinessError } 401 - Parameter error. Possible causes:
122   * <br> 1. Mandatory parameters are left unspecified.
123   * <br> 2. Incorrect parameters types.
124   * <br> 3. Parameter verification failed.
125   * @throws { BusinessError } 500001 - Internal error.
126   * @syscap SystemCapability.ArkUI.UiAppearance
127   * @systemapi hide this for inner system use
128   * @since 12
129   */
130  function setFontScale(fontScale: number): Promise<void>;
131
132  /**
133   * Acquire the current font-scale.
134   *
135   * @permission ohos.permission.UPDATE_CONFIGURATION
136   * @returns { number } current font-scale.
137   * @throws { BusinessError } 201 - Permission denied.
138   * @throws { BusinessError } 202 - Permission verification failed. A non-system application calls a system API.
139   * @throws { BusinessError } 401 - Parameter error. Possible causes:
140   * <br> 1. Mandatory parameters are left unspecified.
141   * <br> 2. Incorrect parameters types.
142   * <br> 3. Parameter verification failed.
143   * @throws { BusinessError } 500001 - Internal error.
144   * @syscap SystemCapability.ArkUI.UiAppearance
145   * @systemapi hide this for inner system use
146   * @since 12
147   */
148  function getFontScale(): number;
149
150  /**
151   * Set the system font-weight-scale.
152   *
153   * @permission ohos.permission.UPDATE_CONFIGURATION
154   * @param { number } fontWeightScale - indicates the font-weight-scale to set
155   * @returns { Promise<void> } the promise returned by the function
156   * @throws { BusinessError } 201 - Permission denied.
157   * @throws { BusinessError } 202 - Permission verification failed. A non-system application calls a system API.
158   * @throws { BusinessError } 401 - Parameter error. Possible causes:
159   * <br> 1. Mandatory parameters are left unspecified.
160   * <br> 2. Incorrect parameters types.
161   * <br> 3. Parameter verification failed.
162   * @throws { BusinessError } 500001 - Internal error.
163   * @syscap SystemCapability.ArkUI.UiAppearance
164   * @systemapi hide this for inner system use
165   * @since 12
166   */
167  function setFontWeightScale(fontWeightScale: number): Promise<void>;
168
169  /**
170   * Acquire the current font-weight-scale.
171   *
172   * @permission ohos.permission.UPDATE_CONFIGURATION
173   * @returns { number } current font-weight-scale.
174   * @throws { BusinessError } 201 - Permission denied.
175   * @throws { BusinessError } 202 - Permission verification failed. A non-system application calls a system API.
176   * @throws { BusinessError } 401 - Parameter error. Possible causes:
177   * <br> 1. Mandatory parameters are left unspecified.
178   * <br> 2. Incorrect parameters types.
179   * <br> 3. Parameter verification failed.
180   * @throws { BusinessError } 500001 - Internal error.
181   * @syscap SystemCapability.ArkUI.UiAppearance
182   * @systemapi hide this for inner system use
183   * @since 12
184   */
185  function getFontWeightScale(): number;
186}
187export default uiAppearance;
188