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 * Defines the MediaQuery event. 18 * @syscap SystemCapability.ArkUI.ArkUI.Full 19 * @since 3 20 */ 21export interface MediaQueryEvent { 22 /** 23 * The result of match result. 24 * @syscap SystemCapability.ArkUI.ArkUI.Full 25 * @since 3 26 */ 27 matches: boolean; 28} 29 30/** 31 * Defines the MediaQuery list info. 32 * @syscap SystemCapability.ArkUI.ArkUI.Full 33 * @since 3 34 */ 35export interface MediaQueryList { 36 /** 37 * Serialized media query condition. 38 * This parameter is read-only. 39 * @syscap SystemCapability.ArkUI.ArkUI.Full 40 * @since 3 41 */ 42 media?: string; 43 44 /** 45 * Whether the query is successful. True if the query condition is matched successfully, false otherwise. 46 * This parameter is read-only. 47 * @syscap SystemCapability.ArkUI.ArkUI.Full 48 * @since 3 49 */ 50 matches?: boolean; 51 52 /** 53 * Called when the matches value changes. 54 * @syscap SystemCapability.ArkUI.ArkUI.Full 55 * @since 3 56 */ 57 onchange?: (matches: boolean) => void; 58 59 /** 60 * Adds a listening function to MediaQueryList. 61 * The listening function must be added before onShow is called, that is, added to the onInit or onReady function. 62 * @syscap SystemCapability.ArkUI.ArkUI.Full 63 * @since 3 64 */ 65 addListener(callback: (event: MediaQueryEvent) => void): void; 66 67 /** 68 * Removes a listening function from MediaQueryList. 69 * @syscap SystemCapability.ArkUI.ArkUI.Full 70 * @since 3 71 */ 72 removeListener(callback: (event: MediaQueryEvent) => void): void; 73} 74 75/** 76 * Defines the mediaquery interface. 77 * @syscap SystemCapability.ArkUI.ArkUI.Full 78 * @since 3 79 */ 80export default class MediaQuery { 81 /** 82 * Queries a media item and returns a MediaQueryList object. 83 * @syscap SystemCapability.ArkUI.ArkUI.Full 84 * @since 3 85 */ 86 static matchMedia(condition: string): MediaQueryList; 87} 88