From 46694aa97d4de83970fb2f44ca0b3f1b80a247ef Mon Sep 17 00:00:00 2001 From: yangfan229 Date: Wed, 30 Jul 2025 10:53:35 +0800 Subject: [PATCH] observer add tab content change Signed-off-by: yangfan229 Change-Id: Ib440aaacaea978d13c716ff66948c8821c6a6cd2 --- api/@ohos.arkui.observer.d.ts | 70 ++++++++++++++++++++++++++++++++++- 1 file changed, 69 insertions(+), 1 deletion(-) diff --git a/api/@ohos.arkui.observer.d.ts b/api/@ohos.arkui.observer.d.ts index dcc34ce776..e2c0e5bdbd 100644 --- a/api/@ohos.arkui.observer.d.ts +++ b/api/@ohos.arkui.observer.d.ts @@ -717,7 +717,19 @@ declare namespace uiObserver { * @since arkts {'1.1':'12','1.2':'20'} * @arkts 1.1&1.2 */ - 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, + } /** @@ -1309,6 +1321,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. * -- Gitee