• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1/*
2 * Copyright (c) 2020 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/**
22 * Defines the MediaQuery event.
23 *
24 * @interface MediaQueryEvent
25 * @syscap SystemCapability.ArkUI.ArkUI.Full
26 * @since 3
27 */
28/**
29 * Defines the MediaQuery event.
30 *
31 * @interface MediaQueryEvent
32 * @syscap SystemCapability.ArkUI.ArkUI.Full
33 * @atomicservice
34 * @since 11
35 */
36export interface MediaQueryEvent {
37  /**
38   * The result of match result.
39   *
40   * @type { boolean }
41   * @syscap SystemCapability.ArkUI.ArkUI.Full
42   * @since 3
43   */
44  /**
45   * The result of match result.
46   *
47   * @type { boolean }
48   * @syscap SystemCapability.ArkUI.ArkUI.Full
49   * @atomicservice
50   * @since 11
51   */
52  matches: boolean;
53}
54
55/**
56 * Defines the MediaQuery list info.
57 *
58 * @interface MediaQueryList
59 * @syscap SystemCapability.ArkUI.ArkUI.Full
60 * @since 3
61 */
62/**
63 * Defines the MediaQuery list info.
64 *
65 * @interface MediaQueryList
66 * @syscap SystemCapability.ArkUI.ArkUI.Full
67 * @atomicservice
68 * @since 11
69 */
70export interface MediaQueryList {
71  /**
72   * Serialized media query condition.
73   * This parameter is read-only.
74   *
75   * @type { ?string }
76   * @syscap SystemCapability.ArkUI.ArkUI.Full
77   * @since 3
78   */
79  /**
80   * Serialized media query condition.
81   * This parameter is read-only.
82   *
83   * @type { ?string }
84   * @syscap SystemCapability.ArkUI.ArkUI.Full
85   * @atomicservice
86   * @since 11
87   */
88  media?: string;
89
90  /**
91   * Whether the query is successful. True if the query condition is matched successfully, false otherwise.
92   * This parameter is read-only.
93   *
94   * @type { ?boolean }
95   * @syscap SystemCapability.ArkUI.ArkUI.Full
96   * @since 3
97   */
98  /**
99   * Whether the query is successful. True if the query condition is matched successfully, false otherwise.
100   * This parameter is read-only.
101   *
102   * @type { ?boolean }
103   * @syscap SystemCapability.ArkUI.ArkUI.Full
104   * @atomicservice
105   * @since 11
106   */
107  matches?: boolean;
108
109  /**
110   * Called when the matches value changes.
111   *
112   * @type { ?function }
113   * @syscap SystemCapability.ArkUI.ArkUI.Full
114   * @since 3
115   */
116  /**
117   * Called when the matches value changes.
118   *
119   * @type { ?function }
120   * @syscap SystemCapability.ArkUI.ArkUI.Full
121   * @atomicservice
122   * @since 11
123   */
124  onchange?: (matches: boolean) => void;
125
126  /**
127   * Adds a listening function to MediaQueryList.
128   * The listening function must be added before onShow is called, that is, added to the onInit or onReady function.
129   *
130   * @param { function } callback
131   * @syscap SystemCapability.ArkUI.ArkUI.Full
132   * @since 3
133   */
134  /**
135   * Adds a listening function to MediaQueryList.
136   * The listening function must be added before onShow is called, that is, added to the onInit or onReady function.
137   *
138   * @param { function } callback
139   * @syscap SystemCapability.ArkUI.ArkUI.Full
140   * @atomicservice
141   * @since 11
142   */
143  addListener(callback: (event: MediaQueryEvent) => void): void;
144
145  /**
146   * Removes a listening function from MediaQueryList.
147   *
148   * @param { function } callback
149   * @syscap SystemCapability.ArkUI.ArkUI.Full
150   * @since 3
151   */
152  /**
153   * Removes a listening function from MediaQueryList.
154   *
155   * @param { function } callback
156   * @syscap SystemCapability.ArkUI.ArkUI.Full
157   * @atomicservice
158   * @since 11
159   */
160  removeListener(callback: (event: MediaQueryEvent) => void): void;
161}
162
163/**
164 * Defines the mediaquery interface.
165 *
166 * @syscap SystemCapability.ArkUI.ArkUI.Full
167 * @since 3
168 */
169/**
170 * Defines the mediaquery interface.
171 *
172 * @syscap SystemCapability.ArkUI.ArkUI.Full
173 * @atomicservice
174 * @since 11
175 */
176declare class MediaQuery {
177  /**
178   * Queries a media item and returns a MediaQueryList object.
179   *
180   * @param { string } condition
181   * @returns { MediaQueryList }
182   * @syscap SystemCapability.ArkUI.ArkUI.Full
183   * @since 3
184   */
185  /**
186   * Queries a media item and returns a MediaQueryList object.
187   *
188   * @param { string } condition
189   * @returns { MediaQueryList }
190   * @syscap SystemCapability.ArkUI.ArkUI.Full
191   * @atomicservice
192   * @since 11
193   */
194  static matchMedia(condition: string): MediaQueryList;
195}
196export default MediaQuery