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