mediaquery支持form

Signed-off-by: wangyuhang <wangyuhang26@huawei.com>
This commit is contained in:
wangyuhang 2024-02-18 11:10:33 +08:00
parent d2ed51bed5
commit 2aa31ca5bd
2 changed files with 106 additions and 0 deletions

18
api/@ohos.base.d.ts vendored
View File

@ -39,6 +39,15 @@
* @atomicservice
* @since 11
*/
/**
* Defines the basic callback.
* @typedef Callback
* @syscap SystemCapability.Base
* @crossplatform
* @form
* @atomicservice
* @since 12
*/
export interface Callback<T> {
/**
* Defines the callback info.
@ -61,6 +70,15 @@ export interface Callback<T> {
* @atomicservice
* @since 11
*/
/**
* Defines the callback info.
* @param { T } data
* @syscap SystemCapability.Base
* @crossplatform
* @form
* @atomicservice
* @since 12
*/
(data: T): void;
}

View File

@ -44,6 +44,16 @@ import { Callback } from './@ohos.base';
* @atomicservice
* @since 11
*/
/**
* Used to do mediaquery operations.
*
* @namespace mediaquery
* @syscap SystemCapability.ArkUI.ArkUI.Full
* @crossplatform
* @form
* @atomicservice
* @since 12
*/
declare namespace mediaquery {
/**
@ -70,6 +80,16 @@ declare namespace mediaquery {
* @atomicservice
* @since 11
*/
/**
* Defines the Result of mediaquery.
*
* @interface MediaQueryResult
* @syscap SystemCapability.ArkUI.ArkUI.Full
* @crossplatform
* @form
* @atomicservice
* @since 12
*/
interface MediaQueryResult {
/**
* Whether the match condition is met.
@ -98,6 +118,17 @@ declare namespace mediaquery {
* @atomicservice
* @since 11
*/
/**
* Whether the match condition is met.
* This parameter is read-only.
*
* @type { boolean }
* @syscap SystemCapability.ArkUI.ArkUI.Full
* @crossplatform
* @form
* @atomicservice
* @since 12
*/
readonly matches: boolean;
/**
@ -127,6 +158,17 @@ declare namespace mediaquery {
* @atomicservice
* @since 11
*/
/**
* Matching condition of a media event.
* This parameter is read-only.
*
* @type { string }
* @syscap SystemCapability.ArkUI.ArkUI.Full
* @crossplatform
* @form
* @atomicservice
* @since 12
*/
readonly media: string;
}
@ -157,6 +199,17 @@ declare namespace mediaquery {
* @atomicservice
* @since 11
*/
/**
* Defines the Listener of mediaquery.
*
* @interface MediaQueryListener
* @extends MediaQueryResult
* @syscap SystemCapability.ArkUI.ArkUI.Full
* @crossplatform
* @form
* @atomicservice
* @since 12
*/
interface MediaQueryListener extends MediaQueryResult {
/**
* Registers a callback with the corresponding query condition by using the handle.
@ -188,6 +241,18 @@ declare namespace mediaquery {
* @atomicservice
* @since 11
*/
/**
* Registers a callback with the corresponding query condition by using the handle.
* This callback is triggered when the media attributes change.
*
* @param { 'change' } type
* @param { Callback<MediaQueryResult> } callback
* @syscap SystemCapability.ArkUI.ArkUI.Full
* @crossplatform
* @form
* @atomicservice
* @since 12
*/
on(type: 'change', callback: Callback<MediaQueryResult>): void;
/**
@ -220,6 +285,18 @@ declare namespace mediaquery {
* @atomicservice
* @since 11
*/
/**
* Deregisters a callback with the corresponding query condition by using the handle.
* This callback is not triggered when the media attributes chang.
*
* @param { 'change' } type
* @param { Callback<MediaQueryResult> } callback
* @syscap SystemCapability.ArkUI.ArkUI.Full
* @crossplatform
* @form
* @atomicservice
* @since 12
*/
off(type: 'change', callback?: Callback<MediaQueryResult>): void;
}
@ -250,6 +327,17 @@ declare namespace mediaquery {
* @atomicservice
* @since 11
*/
/**
* Sets the media query criteria and returns the corresponding listening handle
*
* @param { string } condition
* @returns { MediaQueryListener }
* @syscap SystemCapability.ArkUI.ArkUI.Full
* @crossplatform
* @form
* @atomicservice
* @since 12
*/
function matchMediaSync(condition: string): MediaQueryListener;
}