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 arkts { '1.1':'11','1.2':'20' } 35 * @arkts 1.1&1.2 36 */ 37export interface MediaQueryEvent { 38 /** 39 * The result of match result. 40 * 41 * @type { boolean } 42 * @syscap SystemCapability.ArkUI.ArkUI.Full 43 * @since 3 44 */ 45 /** 46 * The result of match result. 47 * 48 * @type { boolean } 49 * @syscap SystemCapability.ArkUI.ArkUI.Full 50 * @atomicservice 51 * @since arkts { '1.1':'11','1.2':'20' } 52 * @arkts 1.1&1.2 53 */ 54 matches: boolean; 55} 56 57/** 58 * Defines the MediaQuery list info. 59 * 60 * @interface MediaQueryList 61 * @syscap SystemCapability.ArkUI.ArkUI.Full 62 * @since 3 63 */ 64/** 65 * Defines the MediaQuery list info. 66 * 67 * @interface MediaQueryList 68 * @syscap SystemCapability.ArkUI.ArkUI.Full 69 * @atomicservice 70 * @since arkts { '1.1':'11','1.2':'20' } 71 * @arkts 1.1&1.2 72 */ 73export interface MediaQueryList { 74 /** 75 * Serialized media query condition. 76 * This parameter is read-only. 77 * 78 * @type { ?string } 79 * @syscap SystemCapability.ArkUI.ArkUI.Full 80 * @since 3 81 */ 82 /** 83 * Serialized media query condition. 84 * This parameter is read-only. 85 * 86 * @type { ?string } 87 * @syscap SystemCapability.ArkUI.ArkUI.Full 88 * @atomicservice 89 * @since arkts { '1.1':'11','1.2':'20' } 90 * @arkts 1.1&1.2 91 */ 92 media?: string; 93 94 /** 95 * Whether the query is successful. True if the query condition is matched successfully, false otherwise. 96 * This parameter is read-only. 97 * 98 * @type { ?boolean } 99 * @syscap SystemCapability.ArkUI.ArkUI.Full 100 * @since 3 101 */ 102 /** 103 * Whether the query is successful. True if the query condition is matched successfully, false otherwise. 104 * This parameter is read-only. 105 * 106 * @type { ?boolean } 107 * @syscap SystemCapability.ArkUI.ArkUI.Full 108 * @atomicservice 109 * @since arkts { '1.1':'11','1.2':'20' } 110 * @arkts 1.1&1.2 111 */ 112 matches?: boolean; 113 114 /** 115 * Called when the matches value changes. 116 * 117 * @type { ?function } 118 * @syscap SystemCapability.ArkUI.ArkUI.Full 119 * @since 3 120 */ 121 /** 122 * Called when the matches value changes. 123 * 124 * @type { ?function } 125 * @syscap SystemCapability.ArkUI.ArkUI.Full 126 * @atomicservice 127 * @since arkts { '1.1':'11','1.2':'20' } 128 * @arkts 1.1&1.2 129 */ 130 onchange?: (matches: boolean) => void; 131 132 /** 133 * Adds a listening function to MediaQueryList. 134 * The listening function must be added before onShow is called, that is, added to the onInit or onReady function. 135 * 136 * @param { function } callback 137 * @syscap SystemCapability.ArkUI.ArkUI.Full 138 * @since 3 139 */ 140 /** 141 * Adds a listening function to MediaQueryList. 142 * The listening function must be added before onShow is called, that is, added to the onInit or onReady function. 143 * 144 * @param { function } callback 145 * @syscap SystemCapability.ArkUI.ArkUI.Full 146 * @atomicservice 147 * @since arkts { '1.1':'11','1.2':'20' } 148 * @arkts 1.1&1.2 149 */ 150 addListener(callback: (event: MediaQueryEvent) => void): void; 151 152 /** 153 * Removes a listening function from MediaQueryList. 154 * 155 * @param { function } callback 156 * @syscap SystemCapability.ArkUI.ArkUI.Full 157 * @since 3 158 */ 159 /** 160 * Removes a listening function from MediaQueryList. 161 * 162 * @param { function } callback 163 * @syscap SystemCapability.ArkUI.ArkUI.Full 164 * @atomicservice 165 * @since arkts { '1.1':'11','1.2':'20' } 166 * @arkts 1.1&1.2 167 */ 168 removeListener(callback: (event: MediaQueryEvent) => void): void; 169} 170 171/** 172 * Defines the mediaquery interface. 173 * 174 * @syscap SystemCapability.ArkUI.ArkUI.Full 175 * @since 3 176 */ 177/** 178 * Defines the mediaquery interface. 179 * 180 * @syscap SystemCapability.ArkUI.ArkUI.Full 181 * @atomicservice 182 * @since 11 183 */ 184export default class MediaQuery { 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 * @since 3 192 */ 193 /** 194 * Queries a media item and returns a MediaQueryList object. 195 * 196 * @param { string } condition 197 * @returns { MediaQueryList } 198 * @syscap SystemCapability.ArkUI.ArkUI.Full 199 * @atomicservice 200 * @since 11 201 */ 202 static matchMedia(condition: string): MediaQueryList; 203} 204 205/** 206 * Defines the mediaquery interface. 207 * 208 * @syscap SystemCapability.ArkUI.ArkUI.Full 209 * @atomicservice 210 * @since 20 211 * @arkts 1.2 212 */ 213declare class MediaQuery { 214 /** 215 * Queries a media item and returns a MediaQueryList object. 216 * 217 * @param { string } condition 218 * @returns { MediaQueryList } 219 * @syscap SystemCapability.ArkUI.ArkUI.Full 220 * @atomicservice 221 * @since 20 222 * @arkts 1.2 223 */ 224 static matchMedia(condition: string): MediaQueryList; 225} 226 227/*** if arkts 1.2 */ 228export default MediaQuery; 229/*** endif */