diff --git a/api/@ohos.arkui.observer.d.ts b/api/@ohos.arkui.observer.d.ts index 6ba74fa4c2501f3198e94f8911ef3925be5339c0..01ff62eef39c81b8112851e9e3fcf808fc681198 100644 --- a/api/@ohos.arkui.observer.d.ts +++ b/api/@ohos.arkui.observer.d.ts @@ -662,7 +662,19 @@ declare namespace uiObserver { * @atomicservice * @since 12 */ - uniqueId: number + uniqueId: number, + + /** + * The last focus index of TabContent in Tabs. + * + * @type { ?number } + * @syscap SystemCapability.ArkUI.ArkUI.Full + * @crossplatform + * @atomicservice + * @since 22 + */ + lastIndex?: number, + } /** @@ -1191,6 +1203,62 @@ declare namespace uiObserver { */ export function off(type: 'didLayout', context: UIContext, callback?: Callback): void; + /** + * Registers a callback function to be called when the tabContent is showed or hidden. + * Include the cases when the first tab content shows and when the tab changes current index. + * + * @param { 'tabChange' } type - The type of event to listen for. Must be 'tabChange'. + * @param { ObserverOptions } config - The options object. Includes the observed component id. + * @param { Callback } callback - The callback function to be called + * when when the tabContent is showed or hidden. + * @syscap SystemCapability.ArkUI.ArkUI.Full + * @crossplatform + * @atomicservice + * @since 22 + */ + export function on(type: 'tabChange', config: ObserverOptions, callback: Callback): void; + + /** + * Removes a callback function that was previously registered with `on()`. + * + * @param { 'tabChange' } type - The type of event to remove the listener for. Must be 'tabChange'. + * @param { ObserverOptions } config - The config object. Includes the observed component id. + * @param { Callback } [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 22 + */ + export function off(type: 'tabChange', config: ObserverOptions, callback?: Callback): void; + + /** + * Registers a callback function to be called when the tabContent is showed or hidden. + * Include the cases when the first tab content shows and when the tab changes current index. + * + * @param { 'tabChange' } type - The type of event to listen for. Must be 'tabChange'. + * @param { Callback } callback - The callback function to be called + * when the tabContent is showed or hidden. + * @syscap SystemCapability.ArkUI.ArkUI.Full + * @crossplatform + * @atomicservice + * @since 22 + */ + export function on(type: 'tabChange', callback: Callback): void; + + /** + * Removes a callback function that was previously registered with `on()`. + * + * @param { 'tabChange' } type - The type of event to remove the listener for. Must be 'tabChange'. + * @param { Callback } [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 22 + */ + export function off(type: 'tabChange', callback?: Callback): void; + /** * Registers a callback function to be called when the tabContent is showed or hidden. * diff --git a/api/@ohos.arkui.observer.static.d.ets b/api/@ohos.arkui.observer.static.d.ets index 810edd9da5f1e4f16e0c9d28de1b7d96e7383fca..9110fb0fbc1c221f6f8c9bb4144d3440cac7a259 100644 --- a/api/@ohos.arkui.observer.static.d.ets +++ b/api/@ohos.arkui.observer.static.d.ets @@ -428,6 +428,15 @@ declare namespace uiObserver { * @since 20 */ uniqueId: number; + + /** + * The last focus index of TabContent in Tabs. + * + * @type { ?int } + * @syscap SystemCapability.ArkUI.ArkUI.Full + * @since 22 + */ + lastIndex?: int; } /** * observer options. @@ -892,5 +901,51 @@ declare namespace uiObserver { observerOptions: NavDestinationSwitchObserverOptions, callback?: Callback ): void; + + /** + * Registers a callback function to be called when the tabContent is showed or hidden. + * + * @param { 'tabChange' } type - The type of event to listen for. Must be 'tabChange'. + * @param { ObserverOptions } config - The options object. + * @param { Callback } callback - The callback function to be called when when the tabContent is + * showed or hidden. + * @syscap SystemCapability.ArkUI.ArkUI.Full + * @since 22 + */ + export function on(type: 'tabChange', config: ObserverOptions, callback: Callback): void; + + /** + * Removes a callback function that was previously registered with `on()`. + * + * @param { 'tabChange' } type - The type of event to remove the listener for. Must be 'tabChange'. + * @param { ObserverOptions } config - The options object. + * @param { Callback } [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 + * @since 22 + */ + export function off(type: 'tabChange', config: ObserverOptions, callback?: Callback): void; + + /** + * Registers a callback function to be called when the tabContent is showed or hidden. + * + * @param { 'tabChange' } type - The type of event to listen for. Must be 'tabChange'. + * @param { Callback } callback - The callback function to be called when the tabContent is + * showed or hidden. + * @syscap SystemCapability.ArkUI.ArkUI.Full + * @since 22 + */ + export function on(type: 'tabChange', callback: Callback): void; + + /** + * Removes a callback function that was previously registered with `on()`. + * + * @param { 'tabChange' } type - The type of event to remove the listener for. Must be 'tabChange'. + * @param { Callback } [callback] - The callback function to remove. If not provided, all callbacks + * for the given event type will be removed. + * @syscap SystemCapability.ArkUI.ArkUI.Full + * @since 22 + */ + export function off(type: 'tabChange', callback?: Callback): void; } export default uiObserver;