• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1/*
2 * Copyright (c) 2021-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 { Callback } from './@ohos.base';
22
23/**
24 * Used to do mediaquery operations.
25 *
26 * @namespace mediaquery
27 * @syscap SystemCapability.ArkUI.ArkUI.Full
28 * @since 7
29 */
30/**
31 * Used to do mediaquery operations.
32 *
33 * @namespace mediaquery
34 * @syscap SystemCapability.ArkUI.ArkUI.Full
35 * @crossplatform
36 * @since 10
37 */
38/**
39 * Used to do mediaquery operations.
40 *
41 * @namespace mediaquery
42 * @syscap SystemCapability.ArkUI.ArkUI.Full
43 * @crossplatform
44 * @atomicservice
45 * @since 11
46 */
47/**
48 * Used to do mediaquery operations.
49 *
50 * @namespace mediaquery
51 * @syscap SystemCapability.ArkUI.ArkUI.Full
52 * @crossplatform
53 * @form
54 * @atomicservice
55 * @since 12
56 */
57declare namespace mediaquery {
58
59  /**
60   * Defines the Result of mediaquery.
61   *
62   * @interface MediaQueryResult
63   * @syscap SystemCapability.ArkUI.ArkUI.Full
64   * @since 7
65   */
66  /**
67   * Defines the Result of mediaquery.
68   *
69   * @interface MediaQueryResult
70   * @syscap SystemCapability.ArkUI.ArkUI.Full
71   * @crossplatform
72   * @since 10
73   */
74  /**
75   * Defines the Result of mediaquery.
76   *
77   * @interface MediaQueryResult
78   * @syscap SystemCapability.ArkUI.ArkUI.Full
79   * @crossplatform
80   * @atomicservice
81   * @since 11
82   */
83  /**
84   * Defines the Result of mediaquery.
85   *
86   * @interface MediaQueryResult
87   * @syscap SystemCapability.ArkUI.ArkUI.Full
88   * @crossplatform
89   * @form
90   * @atomicservice
91   * @since 12
92   */
93  export interface MediaQueryResult {
94    /**
95     * Whether the match condition is met.
96     * This parameter is read-only.
97     *
98     * @type { boolean }
99     * @syscap SystemCapability.ArkUI.ArkUI.Full
100     * @since 7
101     */
102    /**
103     * Whether the match condition is met.
104     * This parameter is read-only.
105     *
106     * @type { boolean }
107     * @syscap SystemCapability.ArkUI.ArkUI.Full
108     * @crossplatform
109     * @since 10
110     */
111    /**
112     * Whether the match condition is met.
113     * This parameter is read-only.
114     *
115     * @type { boolean }
116     * @syscap SystemCapability.ArkUI.ArkUI.Full
117     * @crossplatform
118     * @atomicservice
119     * @since 11
120     */
121    /**
122     * Whether the match condition is met.
123     * This parameter is read-only.
124     *
125     * @type { boolean }
126     * @syscap SystemCapability.ArkUI.ArkUI.Full
127     * @crossplatform
128     * @form
129     * @atomicservice
130     * @since 12
131     */
132    readonly matches: boolean;
133
134    /**
135     * Matching condition of a media event.
136     * This parameter is read-only.
137     *
138     * @type { string }
139     * @syscap SystemCapability.ArkUI.ArkUI.Full
140     * @since 7
141     */
142    /**
143     * Matching condition of a media event.
144     * This parameter is read-only.
145     *
146     * @type { string }
147     * @syscap SystemCapability.ArkUI.ArkUI.Full
148     * @crossplatform
149     * @since 10
150     */
151    /**
152     * Matching condition of a media event.
153     * This parameter is read-only.
154     *
155     * @type { string }
156     * @syscap SystemCapability.ArkUI.ArkUI.Full
157     * @crossplatform
158     * @atomicservice
159     * @since 11
160     */
161    /**
162     * Matching condition of a media event.
163     * This parameter is read-only.
164     *
165     * @type { string }
166     * @syscap SystemCapability.ArkUI.ArkUI.Full
167     * @crossplatform
168     * @form
169     * @atomicservice
170     * @since 12
171     */
172    readonly media: string;
173  }
174
175  /**
176   * Defines the Listener of mediaquery.
177   *
178   * @interface MediaQueryListener
179   * @extends MediaQueryResult
180   * @syscap SystemCapability.ArkUI.ArkUI.Full
181   * @since 7
182   */
183  /**
184   * Defines the Listener of mediaquery.
185   *
186   * @interface MediaQueryListener
187   * @extends MediaQueryResult
188   * @syscap SystemCapability.ArkUI.ArkUI.Full
189   * @crossplatform
190   * @since 10
191   */
192  /**
193   * Defines the Listener of mediaquery.
194   *
195   * @interface MediaQueryListener
196   * @extends MediaQueryResult
197   * @syscap SystemCapability.ArkUI.ArkUI.Full
198   * @crossplatform
199   * @atomicservice
200   * @since 11
201   */
202  /**
203   * Defines the Listener of mediaquery.
204   *
205   * @interface MediaQueryListener
206   * @extends MediaQueryResult
207   * @syscap SystemCapability.ArkUI.ArkUI.Full
208   * @crossplatform
209   * @form
210   * @atomicservice
211   * @since 12
212   */
213  export interface MediaQueryListener extends MediaQueryResult {
214    /**
215     * Registers a callback with the corresponding query condition by using the handle.
216     * This callback is triggered when the media attributes change.
217     *
218     * @param { 'change' } type
219     * @param { Callback<MediaQueryResult> } callback
220     * @syscap SystemCapability.ArkUI.ArkUI.Full
221     * @since 7
222     */
223    /**
224     * Registers a callback with the corresponding query condition by using the handle.
225     * This callback is triggered when the media attributes change.
226     *
227     * @param { 'change' } type
228     * @param { Callback<MediaQueryResult> } callback
229     * @syscap SystemCapability.ArkUI.ArkUI.Full
230     * @crossplatform
231     * @since 10
232     */
233    /**
234     * Registers a callback with the corresponding query condition by using the handle.
235     * This callback is triggered when the media attributes change.
236     *
237     * @param { 'change' } type
238     * @param { Callback<MediaQueryResult> } callback
239     * @syscap SystemCapability.ArkUI.ArkUI.Full
240     * @crossplatform
241     * @atomicservice
242     * @since 11
243     */
244    /**
245     * Registers a callback with the corresponding query condition by using the handle.
246     * This callback is triggered when the media attributes change.
247     *
248     * @param { 'change' } type
249     * @param { Callback<MediaQueryResult> } callback
250     * @syscap SystemCapability.ArkUI.ArkUI.Full
251     * @crossplatform
252     * @form
253     * @atomicservice
254     * @since 12
255     */
256    on(type: 'change', callback: Callback<MediaQueryResult>): void;
257
258    /**
259     * Deregisters a callback with the corresponding query condition by using the handle.
260     * This callback is not triggered when the media attributes chang.
261     *
262     * @param { 'change' } type
263     * @param { Callback<MediaQueryResult> } callback
264     * @syscap SystemCapability.ArkUI.ArkUI.Full
265     * @since 7
266     */
267    /**
268     * Deregisters a callback with the corresponding query condition by using the handle.
269     * This callback is not triggered when the media attributes chang.
270     *
271     * @param { 'change' } type
272     * @param { Callback<MediaQueryResult> } callback
273     * @syscap SystemCapability.ArkUI.ArkUI.Full
274     * @crossplatform
275     * @since 10
276     */
277    /**
278     * Deregisters a callback with the corresponding query condition by using the handle.
279     * This callback is not triggered when the media attributes chang.
280     *
281     * @param { 'change' } type
282     * @param { Callback<MediaQueryResult> } callback
283     * @syscap SystemCapability.ArkUI.ArkUI.Full
284     * @crossplatform
285     * @atomicservice
286     * @since 11
287     */
288    /**
289     * Deregisters a callback with the corresponding query condition by using the handle.
290     * This callback is not triggered when the media attributes chang.
291     *
292     * @param { 'change' } type
293     * @param { Callback<MediaQueryResult> } callback
294     * @syscap SystemCapability.ArkUI.ArkUI.Full
295     * @crossplatform
296     * @form
297     * @atomicservice
298     * @since 12
299     */
300    off(type: 'change', callback?: Callback<MediaQueryResult>): void;
301  }
302
303  /**
304   * Sets the media query criteria and returns the corresponding listening handle
305   *
306   * @param { string } condition
307   * @returns { MediaQueryListener }
308   * @syscap SystemCapability.ArkUI.ArkUI.Full
309   * @since 7
310   */
311  /**
312   * Sets the media query criteria and returns the corresponding listening handle
313   *
314   * @param { string } condition
315   * @returns { MediaQueryListener }
316   * @syscap SystemCapability.ArkUI.ArkUI.Full
317   * @crossplatform
318   * @since 10
319   */
320  /**
321   * Sets the media query criteria and returns the corresponding listening handle
322   *
323   * @param { string } condition
324   * @returns { MediaQueryListener }
325   * @syscap SystemCapability.ArkUI.ArkUI.Full
326   * @crossplatform
327   * @atomicservice
328   * @since 11
329   */
330  /**
331   * Sets the media query criteria and returns the corresponding listening handle
332   *
333   * @param { string } condition
334   * @returns { MediaQueryListener }
335   * @syscap SystemCapability.ArkUI.ArkUI.Full
336   * @crossplatform
337   * @form
338   * @atomicservice
339   * @since 12
340   */
341  export function matchMediaSync(condition: string): MediaQueryListener;
342}
343
344export default mediaquery;