2021-08-30 12:39:49 +00:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2020 Huawei Device Co., Ltd.
|
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
* you may not use this file except in compliance with the License.
|
|
|
|
* You may obtain a copy of the License at
|
|
|
|
*
|
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
*
|
|
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
* See the License for the specific language governing permissions and
|
|
|
|
* limitations under the License.
|
|
|
|
*/
|
|
|
|
|
2023-12-11 09:08:03 +00:00
|
|
|
/**
|
|
|
|
* @file
|
|
|
|
* @kit ArkUI
|
|
|
|
*/
|
|
|
|
|
2021-08-30 12:39:49 +00:00
|
|
|
/**
|
2022-03-04 09:08:22 +00:00
|
|
|
* Defines the MediaQuery event.
|
2023-07-06 09:26:10 +00:00
|
|
|
*
|
|
|
|
* @interface MediaQueryEvent
|
2022-03-02 11:32:45 +00:00
|
|
|
* @syscap SystemCapability.ArkUI.ArkUI.Full
|
2022-03-04 09:08:22 +00:00
|
|
|
* @since 3
|
2021-08-30 12:39:49 +00:00
|
|
|
*/
|
2023-11-22 07:19:57 +00:00
|
|
|
/**
|
|
|
|
* Defines the MediaQuery event.
|
|
|
|
*
|
|
|
|
* @interface MediaQueryEvent
|
|
|
|
* @syscap SystemCapability.ArkUI.ArkUI.Full
|
|
|
|
* @atomicservice
|
|
|
|
* @since 11
|
|
|
|
*/
|
2021-08-30 12:39:49 +00:00
|
|
|
export interface MediaQueryEvent {
|
|
|
|
/**
|
2022-03-04 09:08:22 +00:00
|
|
|
* The result of match result.
|
2023-07-06 09:26:10 +00:00
|
|
|
*
|
|
|
|
* @type { boolean }
|
2022-03-02 11:32:45 +00:00
|
|
|
* @syscap SystemCapability.ArkUI.ArkUI.Full
|
2021-08-30 12:39:49 +00:00
|
|
|
* @since 3
|
|
|
|
*/
|
2023-11-22 07:19:57 +00:00
|
|
|
/**
|
|
|
|
* The result of match result.
|
|
|
|
*
|
|
|
|
* @type { boolean }
|
|
|
|
* @syscap SystemCapability.ArkUI.ArkUI.Full
|
|
|
|
* @atomicservice
|
|
|
|
* @since 11
|
|
|
|
*/
|
2021-08-30 12:39:49 +00:00
|
|
|
matches: boolean;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2022-03-04 09:08:22 +00:00
|
|
|
* Defines the MediaQuery list info.
|
2023-07-06 09:26:10 +00:00
|
|
|
*
|
|
|
|
* @interface MediaQueryList
|
2022-03-02 11:32:45 +00:00
|
|
|
* @syscap SystemCapability.ArkUI.ArkUI.Full
|
2022-03-04 09:08:22 +00:00
|
|
|
* @since 3
|
2021-08-30 12:39:49 +00:00
|
|
|
*/
|
2023-11-22 07:19:57 +00:00
|
|
|
/**
|
|
|
|
* Defines the MediaQuery list info.
|
|
|
|
*
|
|
|
|
* @interface MediaQueryList
|
|
|
|
* @syscap SystemCapability.ArkUI.ArkUI.Full
|
|
|
|
* @atomicservice
|
|
|
|
* @since 11
|
|
|
|
*/
|
2021-08-30 12:39:49 +00:00
|
|
|
export interface MediaQueryList {
|
|
|
|
/**
|
|
|
|
* Serialized media query condition.
|
|
|
|
* This parameter is read-only.
|
2023-07-06 09:26:10 +00:00
|
|
|
*
|
|
|
|
* @type { ?string }
|
2022-03-02 11:32:45 +00:00
|
|
|
* @syscap SystemCapability.ArkUI.ArkUI.Full
|
2021-08-30 12:39:49 +00:00
|
|
|
* @since 3
|
|
|
|
*/
|
2023-11-22 07:19:57 +00:00
|
|
|
/**
|
|
|
|
* Serialized media query condition.
|
|
|
|
* This parameter is read-only.
|
|
|
|
*
|
|
|
|
* @type { ?string }
|
|
|
|
* @syscap SystemCapability.ArkUI.ArkUI.Full
|
|
|
|
* @atomicservice
|
|
|
|
* @since 11
|
|
|
|
*/
|
2021-08-30 12:39:49 +00:00
|
|
|
media?: string;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Whether the query is successful. True if the query condition is matched successfully, false otherwise.
|
|
|
|
* This parameter is read-only.
|
2023-07-06 09:26:10 +00:00
|
|
|
*
|
|
|
|
* @type { ?boolean }
|
2022-03-02 11:32:45 +00:00
|
|
|
* @syscap SystemCapability.ArkUI.ArkUI.Full
|
2021-08-30 12:39:49 +00:00
|
|
|
* @since 3
|
|
|
|
*/
|
2023-11-22 07:19:57 +00:00
|
|
|
/**
|
|
|
|
* Whether the query is successful. True if the query condition is matched successfully, false otherwise.
|
|
|
|
* This parameter is read-only.
|
|
|
|
*
|
|
|
|
* @type { ?boolean }
|
|
|
|
* @syscap SystemCapability.ArkUI.ArkUI.Full
|
|
|
|
* @atomicservice
|
|
|
|
* @since 11
|
|
|
|
*/
|
2021-08-30 12:39:49 +00:00
|
|
|
matches?: boolean;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Called when the matches value changes.
|
2023-07-06 09:26:10 +00:00
|
|
|
*
|
2023-07-19 11:30:32 +00:00
|
|
|
* @type { ?function }
|
2022-03-02 11:32:45 +00:00
|
|
|
* @syscap SystemCapability.ArkUI.ArkUI.Full
|
2021-08-30 12:39:49 +00:00
|
|
|
* @since 3
|
|
|
|
*/
|
2023-11-22 07:19:57 +00:00
|
|
|
/**
|
|
|
|
* Called when the matches value changes.
|
|
|
|
*
|
|
|
|
* @type { ?function }
|
|
|
|
* @syscap SystemCapability.ArkUI.ArkUI.Full
|
|
|
|
* @atomicservice
|
|
|
|
* @since 11
|
|
|
|
*/
|
2021-08-30 12:39:49 +00:00
|
|
|
onchange?: (matches: boolean) => void;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Adds a listening function to MediaQueryList.
|
|
|
|
* The listening function must be added before onShow is called, that is, added to the onInit or onReady function.
|
2023-07-06 09:26:10 +00:00
|
|
|
*
|
2023-07-19 11:30:32 +00:00
|
|
|
* @param { function } callback
|
2022-03-02 11:32:45 +00:00
|
|
|
* @syscap SystemCapability.ArkUI.ArkUI.Full
|
2021-08-30 12:39:49 +00:00
|
|
|
* @since 3
|
|
|
|
*/
|
2023-11-22 07:19:57 +00:00
|
|
|
/**
|
|
|
|
* Adds a listening function to MediaQueryList.
|
|
|
|
* The listening function must be added before onShow is called, that is, added to the onInit or onReady function.
|
|
|
|
*
|
|
|
|
* @param { function } callback
|
|
|
|
* @syscap SystemCapability.ArkUI.ArkUI.Full
|
|
|
|
* @atomicservice
|
|
|
|
* @since 11
|
|
|
|
*/
|
2021-08-30 12:39:49 +00:00
|
|
|
addListener(callback: (event: MediaQueryEvent) => void): void;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Removes a listening function from MediaQueryList.
|
2023-07-06 09:26:10 +00:00
|
|
|
*
|
2023-07-19 11:30:32 +00:00
|
|
|
* @param { function } callback
|
2022-03-02 11:32:45 +00:00
|
|
|
* @syscap SystemCapability.ArkUI.ArkUI.Full
|
2021-08-30 12:39:49 +00:00
|
|
|
* @since 3
|
|
|
|
*/
|
2023-11-22 07:19:57 +00:00
|
|
|
/**
|
|
|
|
* Removes a listening function from MediaQueryList.
|
|
|
|
*
|
|
|
|
* @param { function } callback
|
|
|
|
* @syscap SystemCapability.ArkUI.ArkUI.Full
|
|
|
|
* @atomicservice
|
|
|
|
* @since 11
|
|
|
|
*/
|
2021-08-30 12:39:49 +00:00
|
|
|
removeListener(callback: (event: MediaQueryEvent) => void): void;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2022-11-18 06:38:45 +00:00
|
|
|
* Defines the mediaquery interface.
|
2023-07-06 09:26:10 +00:00
|
|
|
*
|
2022-03-02 11:32:45 +00:00
|
|
|
* @syscap SystemCapability.ArkUI.ArkUI.Full
|
2022-03-04 09:08:22 +00:00
|
|
|
* @since 3
|
2021-08-30 12:39:49 +00:00
|
|
|
*/
|
2023-11-22 07:19:57 +00:00
|
|
|
/**
|
|
|
|
* Defines the mediaquery interface.
|
|
|
|
*
|
|
|
|
* @syscap SystemCapability.ArkUI.ArkUI.Full
|
|
|
|
* @atomicservice
|
|
|
|
* @since 11
|
|
|
|
*/
|
2021-08-30 12:39:49 +00:00
|
|
|
export default class MediaQuery {
|
|
|
|
/**
|
|
|
|
* Queries a media item and returns a MediaQueryList object.
|
2023-07-06 09:26:10 +00:00
|
|
|
*
|
|
|
|
* @param { string } condition
|
|
|
|
* @returns { MediaQueryList }
|
2022-03-02 11:32:45 +00:00
|
|
|
* @syscap SystemCapability.ArkUI.ArkUI.Full
|
2022-03-04 09:08:22 +00:00
|
|
|
* @since 3
|
2021-08-30 12:39:49 +00:00
|
|
|
*/
|
2023-11-22 07:19:57 +00:00
|
|
|
/**
|
|
|
|
* Queries a media item and returns a MediaQueryList object.
|
|
|
|
*
|
|
|
|
* @param { string } condition
|
|
|
|
* @returns { MediaQueryList }
|
|
|
|
* @syscap SystemCapability.ArkUI.ArkUI.Full
|
|
|
|
* @atomicservice
|
|
|
|
* @since 11
|
|
|
|
*/
|
2021-08-30 12:39:49 +00:00
|
|
|
static matchMedia(condition: string): MediaQueryList;
|
|
|
|
}
|