!11936 无感监听添加tabContentState的API

Merge pull request !11936 from 徐钦锋/TabContentStateAPI
This commit is contained in:
openharmony_ci 2024-06-28 09:52:41 +00:00 committed by Gitee
commit 4996c6064e
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
2 changed files with 214 additions and 0 deletions

View File

@ -1701,6 +1701,60 @@ export class UIObserver {
* @since 12
*/
off(type: 'didClick', callback?: GestureEventListenerCallback): void;
/**
* Registers a callback function to be called when the tabContent is showed or hidden.
*
* @param { 'tabContentUpdate' } type - The type of event to listen for. Must be 'tabContentUpdate'.
* @param { observer.ObserverOptions } options - The options object.
* @param { Callback<observer.TabContentInfo> } callback - The callback function to be called
* when the tabContent show or hide.
* @syscap SystemCapability.ArkUI.ArkUI.Full
* @crossplatform
* @atomicservice
* @since 12
*/
on(type: 'tabContentUpdate', options: observer.ObserverOptions, callback: Callback<observer.TabContentInfo>): void;
/**
* Removes a callback function that was previously registered with `on()`.
*
* @param { 'tabContentUpdate' } type - The type of event to remove the listener for. Must be 'tabContentUpdate'.
* @param { observer.ObserverOptions } options - The options object.
* @param { Callback<observer.TabContentInfo> } callback - The callback function to remove. If not provided,
* all callbacks for the given event type and Tabs ID will be removed.
* @syscap SystemCapability.ArkUI.ArkUI.Full
* @crossplatform
* @atomicservice
* @since 12
*/
off(type: 'tabContentUpdate', options: observer.ObserverOptions, callback?: Callback<observer.TabContentInfo>): void;
/**
* Registers a callback function to be called when the tabContent is showed or hidden.
*
* @param { 'tabContentUpdate' } type - The type of event to listen for. Must be 'tabContentUpdate'.
* @param { Callback<observer.TabContentInfo> } callback - The callback function to be called
* when the tabContent is showed or hidden.
* @syscap SystemCapability.ArkUI.ArkUI.Full
* @crossplatform
* @atomicservice
* @since 12
*/
on(type: 'tabContentUpdate', callback: Callback<observer.TabContentInfo>): void;
/**
* Removes a callback function that was previously registered with `on()`.
*
* @param { 'tabContentUpdate'} type - The type of event to remove the listener for. Must be 'tabContentUpdate'.
* @param { Callback<observer.TabContentInfo> } callback - The callback function to remove. If not provided,
* all callbacks for the given event type and Tabs ID will be removed.
* @syscap SystemCapability.ArkUI.ArkUI.Full
* @crossplatform
* @atomicservice
* @since 12
*/
off(type: 'tabContentUpdate', callback?: Callback<observer.TabContentInfo>): void;
}
/**

View File

@ -311,6 +311,37 @@ declare namespace uiObserver {
SCROLL_STOP = 1
}
/**
* TabContent state.
*
* @enum { number }
* @syscap SystemCapability.ArkUI.ArkUI.Full
* @crossplatform
* @atomicservice
* @since 12
*/
export enum TabContentState {
/**
* When the TabContent hidden.
*
* @syscap SystemCapability.ArkUI.ArkUI.Full
* @crossplatform
* @atomicservice
* @since 12
*/
ON_SHOW = 0,
/**
* When the TabContent hidden.
*
* @syscap SystemCapability.ArkUI.ArkUI.Full
* @crossplatform
* @atomicservice
* @since 12
*/
ON_HIDE = 1
}
/**
* NavDestination info.
*
@ -508,6 +539,83 @@ declare namespace uiObserver {
offset: number
}
/**
* TabContent info.
*
* @typedef TabContentInfo
* @syscap SystemCapability.ArkUI.ArkUI.Full
* @crossplatform
* @atomicservice
* @since 12
*/
export interface TabContentInfo {
/**
* TabContent id.
*
* @type { string }
* @syscap SystemCapability.ArkUI.ArkUI.Full
* @crossplatform
* @atomicservice
* @since 12
*/
tabContentId: string,
/**
* TabContent uniqueId.
*
* @type { number }
* @syscap SystemCapability.ArkUI.ArkUI.Full
* @crossplatform
* @atomicservice
* @since 12
*/
tabContentUniqueId: number,
/**
* The state of TabContent.
*
* @type { TabContentState }
* @syscap SystemCapability.ArkUI.ArkUI.Full
* @crossplatform
* @atomicservice
* @since 12
*/
state: TabContentState,
/**
* The index of TabContent in Tabs.
*
* @type { number }
* @syscap SystemCapability.ArkUI.ArkUI.Full
* @crossplatform
* @atomicservice
* @since 12
*/
index: number,
/**
* Tabs id.
*
* @type { string }
* @syscap SystemCapability.ArkUI.ArkUI.Full
* @crossplatform
* @atomicservice
* @since 12
*/
id: string,
/**
* Tabs uniqueId.
*
* @type { number }
* @syscap SystemCapability.ArkUI.ArkUI.Full
* @crossplatform
* @atomicservice
* @since 12
*/
uniqueId: number
}
/**
* observer options.
*
@ -1035,6 +1143,58 @@ declare namespace uiObserver {
*/
export function off(type: 'didLayout', context: UIContext, callback?: Callback<void>): void;
/**
* Registers a callback function to be called when the tabContent is showed or hidden.
*
* @param { 'tabContentUpdate' } type - The type of event to listen for. Must be 'tabContentUpdate'.
* @param { ObserverOptions } options - The options object.
* @param { Callback<TabContentInfo> } callback - The callback function to be called when when the tabContent is showed or hidden.
* @syscap SystemCapability.ArkUI.ArkUI.Full
* @crossplatform
* @atomicservice
* @since 12
*/
export function on(type: 'tabContentUpdate', options: ObserverOptions, callback: Callback<TabContentInfo>): void;
/**
* Removes a callback function that was previously registered with `on()`.
*
* @param { 'tabContentUpdate' } type - The type of event to remove the listener for. Must be 'tabContentUpdate'.
* @param { ObserverOptions } options - The options object.
* @param { Callback<TabContentInfo> } callback - The callback function to remove. If not provided, all callbacks for the given event type and
* Tabs ID will be removed.
* @syscap SystemCapability.ArkUI.ArkUI.Full
* @crossplatform
* @atomicservice
* @since 12
*/
export function off(type: 'tabContentUpdate', options: ObserverOptions, callback?: Callback<TabContentInfo>): void;
/**
* Registers a callback function to be called when the tabContent is showed or hidden.
*
* @param { 'tabContentUpdate' } type - The type of event to listen for. Must be 'tabContentUpdate'.
* @param { Callback<TabContentInfo> } callback - The callback function to be called when the tabContent is showed or hidden.
* @syscap SystemCapability.ArkUI.ArkUI.Full
* @crossplatform
* @atomicservice
* @since 12
*/
export function on(type: 'tabContentUpdate', callback: Callback<TabContentInfo>): void;
/**
* Removes a callback function that was previously registered with `on()`.
*
* @param { 'tabContentUpdate'} type - The type of event to remove the listener for. Must be 'tabContentUpdate'.
* @param { Callback<TabContentInfo> } [callback] - The callback function to remove. If not provided, all callbacks for the given event type
* will be removed.
* @syscap SystemCapability.ArkUI.ArkUI.Full
* @crossplatform
* @atomicservice
* @since 12
*/
export function off(type: 'tabContentUpdate', callback?: Callback<TabContentInfo>): void;
/**
* Registers a callback function to be called when the navigation switched to a new navDestination.
*