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 */ 47declare namespace mediaquery { 48 49 /** 50 * Defines the Result of mediaquery. 51 * 52 * @interface MediaQueryResult 53 * @syscap SystemCapability.ArkUI.ArkUI.Full 54 * @since 7 55 */ 56 /** 57 * Defines the Result of mediaquery. 58 * 59 * @interface MediaQueryResult 60 * @syscap SystemCapability.ArkUI.ArkUI.Full 61 * @crossplatform 62 * @since 10 63 */ 64 /** 65 * Defines the Result of mediaquery. 66 * 67 * @interface MediaQueryResult 68 * @syscap SystemCapability.ArkUI.ArkUI.Full 69 * @crossplatform 70 * @atomicservice 71 * @since 11 72 */ 73 interface MediaQueryResult { 74 /** 75 * Whether the match condition is met. 76 * This parameter is read-only. 77 * 78 * @type { boolean } 79 * @syscap SystemCapability.ArkUI.ArkUI.Full 80 * @since 7 81 */ 82 /** 83 * Whether the match condition is met. 84 * This parameter is read-only. 85 * 86 * @type { boolean } 87 * @syscap SystemCapability.ArkUI.ArkUI.Full 88 * @crossplatform 89 * @since 10 90 */ 91 /** 92 * Whether the match condition is met. 93 * This parameter is read-only. 94 * 95 * @type { boolean } 96 * @syscap SystemCapability.ArkUI.ArkUI.Full 97 * @crossplatform 98 * @atomicservice 99 * @since 11 100 */ 101 readonly matches: boolean; 102 103 /** 104 * Matching condition of a media event. 105 * This parameter is read-only. 106 * 107 * @type { string } 108 * @syscap SystemCapability.ArkUI.ArkUI.Full 109 * @since 7 110 */ 111 /** 112 * Matching condition of a media event. 113 * This parameter is read-only. 114 * 115 * @type { string } 116 * @syscap SystemCapability.ArkUI.ArkUI.Full 117 * @crossplatform 118 * @since 10 119 */ 120 /** 121 * Matching condition of a media event. 122 * This parameter is read-only. 123 * 124 * @type { string } 125 * @syscap SystemCapability.ArkUI.ArkUI.Full 126 * @crossplatform 127 * @atomicservice 128 * @since 11 129 */ 130 readonly media: string; 131 } 132 133 /** 134 * Defines the Listener of mediaquery. 135 * 136 * @interface MediaQueryListener 137 * @extends MediaQueryResult 138 * @syscap SystemCapability.ArkUI.ArkUI.Full 139 * @since 7 140 */ 141 /** 142 * Defines the Listener of mediaquery. 143 * 144 * @interface MediaQueryListener 145 * @extends MediaQueryResult 146 * @syscap SystemCapability.ArkUI.ArkUI.Full 147 * @crossplatform 148 * @since 10 149 */ 150 /** 151 * Defines the Listener of mediaquery. 152 * 153 * @interface MediaQueryListener 154 * @extends MediaQueryResult 155 * @syscap SystemCapability.ArkUI.ArkUI.Full 156 * @crossplatform 157 * @atomicservice 158 * @since 11 159 */ 160 interface MediaQueryListener extends MediaQueryResult { 161 /** 162 * Registers a callback with the corresponding query condition by using the handle. 163 * This callback is triggered when the media attributes change. 164 * 165 * @param { 'change' } type 166 * @param { Callback<MediaQueryResult> } callback 167 * @syscap SystemCapability.ArkUI.ArkUI.Full 168 * @since 7 169 */ 170 /** 171 * Registers a callback with the corresponding query condition by using the handle. 172 * This callback is triggered when the media attributes change. 173 * 174 * @param { 'change' } type 175 * @param { Callback<MediaQueryResult> } callback 176 * @syscap SystemCapability.ArkUI.ArkUI.Full 177 * @crossplatform 178 * @since 10 179 */ 180 /** 181 * Registers a callback with the corresponding query condition by using the handle. 182 * This callback is triggered when the media attributes change. 183 * 184 * @param { 'change' } type 185 * @param { Callback<MediaQueryResult> } callback 186 * @syscap SystemCapability.ArkUI.ArkUI.Full 187 * @crossplatform 188 * @atomicservice 189 * @since 11 190 */ 191 on(type: 'change', callback: Callback<MediaQueryResult>): void; 192 193 /** 194 * Deregisters a callback with the corresponding query condition by using the handle. 195 * This callback is not triggered when the media attributes chang. 196 * 197 * @param { 'change' } type 198 * @param { Callback<MediaQueryResult> } callback 199 * @syscap SystemCapability.ArkUI.ArkUI.Full 200 * @since 7 201 */ 202 /** 203 * Deregisters a callback with the corresponding query condition by using the handle. 204 * This callback is not triggered when the media attributes chang. 205 * 206 * @param { 'change' } type 207 * @param { Callback<MediaQueryResult> } callback 208 * @syscap SystemCapability.ArkUI.ArkUI.Full 209 * @crossplatform 210 * @since 10 211 */ 212 /** 213 * Deregisters a callback with the corresponding query condition by using the handle. 214 * This callback is not triggered when the media attributes chang. 215 * 216 * @param { 'change' } type 217 * @param { Callback<MediaQueryResult> } callback 218 * @syscap SystemCapability.ArkUI.ArkUI.Full 219 * @crossplatform 220 * @atomicservice 221 * @since 11 222 */ 223 off(type: 'change', callback?: Callback<MediaQueryResult>): void; 224 } 225 226 /** 227 * Sets the media query criteria and returns the corresponding listening handle 228 * 229 * @param { string } condition 230 * @returns { MediaQueryListener } 231 * @syscap SystemCapability.ArkUI.ArkUI.Full 232 * @since 7 233 */ 234 /** 235 * Sets the media query criteria and returns the corresponding listening handle 236 * 237 * @param { string } condition 238 * @returns { MediaQueryListener } 239 * @syscap SystemCapability.ArkUI.ArkUI.Full 240 * @crossplatform 241 * @since 10 242 */ 243 /** 244 * Sets the media query criteria and returns the corresponding listening handle 245 * 246 * @param { string } condition 247 * @returns { MediaQueryListener } 248 * @syscap SystemCapability.ArkUI.ArkUI.Full 249 * @crossplatform 250 * @atomicservice 251 * @since 11 252 */ 253 function matchMediaSync(condition: string): MediaQueryListener; 254} 255 256export default mediaquery; 257