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