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 interface MediaQueryResult { 94 /** 95 * Whether the match condition is met. 96 * This parameter is read-only. 97 * 98 * @type { boolean } 99 * @readonly 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 * @readonly 109 * @syscap SystemCapability.ArkUI.ArkUI.Full 110 * @crossplatform 111 * @since 10 112 */ 113 /** 114 * Whether the match condition is met. 115 * This parameter is read-only. 116 * 117 * @type { boolean } 118 * @readonly 119 * @syscap SystemCapability.ArkUI.ArkUI.Full 120 * @crossplatform 121 * @atomicservice 122 * @since 11 123 */ 124 /** 125 * Whether the match condition is met. 126 * This parameter is read-only. 127 * 128 * @type { boolean } 129 * @readonly 130 * @syscap SystemCapability.ArkUI.ArkUI.Full 131 * @crossplatform 132 * @form 133 * @atomicservice 134 * @since 12 135 */ 136 readonly matches: boolean; 137 138 /** 139 * Matching condition of a media event. 140 * This parameter is read-only. 141 * 142 * @type { string } 143 * @readonly 144 * @syscap SystemCapability.ArkUI.ArkUI.Full 145 * @since 7 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 * @crossplatform 155 * @since 10 156 */ 157 /** 158 * Matching condition of a media event. 159 * This parameter is read-only. 160 * 161 * @type { string } 162 * @readonly 163 * @syscap SystemCapability.ArkUI.ArkUI.Full 164 * @crossplatform 165 * @atomicservice 166 * @since 11 167 */ 168 /** 169 * Matching condition of a media event. 170 * This parameter is read-only. 171 * 172 * @type { string } 173 * @readonly 174 * @syscap SystemCapability.ArkUI.ArkUI.Full 175 * @crossplatform 176 * @form 177 * @atomicservice 178 * @since 12 179 */ 180 readonly media: string; 181 } 182 183 /** 184 * Defines the Listener of mediaquery. 185 * 186 * @extends MediaQueryResult 187 * @interface MediaQueryListener 188 * @syscap SystemCapability.ArkUI.ArkUI.Full 189 * @since 7 190 */ 191 /** 192 * Defines the Listener of mediaquery. 193 * 194 * @extends MediaQueryResult 195 * @interface MediaQueryListener 196 * @syscap SystemCapability.ArkUI.ArkUI.Full 197 * @crossplatform 198 * @since 10 199 */ 200 /** 201 * Defines the Listener of mediaquery. 202 * 203 * @extends MediaQueryResult 204 * @interface MediaQueryListener 205 * @syscap SystemCapability.ArkUI.ArkUI.Full 206 * @crossplatform 207 * @atomicservice 208 * @since 11 209 */ 210 /** 211 * Defines the Listener of mediaquery. 212 * 213 * @extends MediaQueryResult 214 * @interface MediaQueryListener 215 * @syscap SystemCapability.ArkUI.ArkUI.Full 216 * @crossplatform 217 * @form 218 * @atomicservice 219 * @since 12 220 */ 221 interface MediaQueryListener extends MediaQueryResult { 222 /** 223 * Registers a callback with the corresponding query condition by using the handle. 224 * This callback is triggered when the media attributes change. 225 * 226 * @param { 'change' } type 227 * @param { Callback<MediaQueryResult> } callback 228 * @syscap SystemCapability.ArkUI.ArkUI.Full 229 * @since 7 230 */ 231 /** 232 * Registers a callback with the corresponding query condition by using the handle. 233 * This callback is triggered when the media attributes change. 234 * 235 * @param { 'change' } type 236 * @param { Callback<MediaQueryResult> } callback 237 * @syscap SystemCapability.ArkUI.ArkUI.Full 238 * @crossplatform 239 * @since 10 240 */ 241 /** 242 * Registers a callback with the corresponding query condition by using the handle. 243 * This callback is triggered when the media attributes change. 244 * 245 * @param { 'change' } type 246 * @param { Callback<MediaQueryResult> } callback 247 * @syscap SystemCapability.ArkUI.ArkUI.Full 248 * @crossplatform 249 * @atomicservice 250 * @since 11 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 * @form 261 * @atomicservice 262 * @since 12 263 */ 264 on(type: 'change', callback: Callback<MediaQueryResult>): void; 265 266 /** 267 * Deregisters a callback with the corresponding query condition by using the handle. 268 * This callback is not triggered when the media attributes chang. 269 * 270 * @param { 'change' } type 271 * @param { Callback<MediaQueryResult> } callback 272 * @syscap SystemCapability.ArkUI.ArkUI.Full 273 * @since 7 274 */ 275 /** 276 * Deregisters a callback with the corresponding query condition by using the handle. 277 * This callback is not triggered when the media attributes chang. 278 * 279 * @param { 'change' } type 280 * @param { Callback<MediaQueryResult> } callback 281 * @syscap SystemCapability.ArkUI.ArkUI.Full 282 * @crossplatform 283 * @since 10 284 */ 285 /** 286 * Deregisters a callback with the corresponding query condition by using the handle. 287 * This callback is not triggered when the media attributes chang. 288 * 289 * @param { 'change' } type 290 * @param { Callback<MediaQueryResult> } callback 291 * @syscap SystemCapability.ArkUI.ArkUI.Full 292 * @crossplatform 293 * @atomicservice 294 * @since 11 295 */ 296 /** 297 * Deregisters a callback with the corresponding query condition by using the handle. 298 * This callback is not triggered when the media attributes chang. 299 * 300 * @param { 'change' } type 301 * @param { Callback<MediaQueryResult> } callback 302 * @syscap SystemCapability.ArkUI.ArkUI.Full 303 * @crossplatform 304 * @form 305 * @atomicservice 306 * @since 12 307 */ 308 off(type: 'change', callback?: Callback<MediaQueryResult>): void; 309 } 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 * @since 7 318 */ 319 /** 320 * Sets the media query criteria and returns the corresponding listening handle 321 * 322 * @param { string } condition 323 * @returns { MediaQueryListener } 324 * @syscap SystemCapability.ArkUI.ArkUI.Full 325 * @crossplatform 326 * @since 10 327 */ 328 /** 329 * Sets the media query criteria and returns the corresponding listening handle 330 * 331 * @param { string } condition 332 * @returns { MediaQueryListener } 333 * @syscap SystemCapability.ArkUI.ArkUI.Full 334 * @crossplatform 335 * @atomicservice 336 * @since 11 337 */ 338 /** 339 * Sets the media query criteria and returns the corresponding listening handle 340 * 341 * @param { string } condition 342 * @returns { MediaQueryListener } 343 * @syscap SystemCapability.ArkUI.ArkUI.Full 344 * @crossplatform 345 * @form 346 * @atomicservice 347 * @since 12 348 * @deprecated since 18 349 * @useinstead ohos.arkui.UIContext.MediaQuery#matchMediaSync 350 */ 351 function matchMediaSync(condition: string): MediaQueryListener; 352} 353 354export default mediaquery; 355