From 29737596352ca6fc6f35af273de9879705a61daa Mon Sep 17 00:00:00 2001 From: wangweiyuan2 Date: Thu, 11 Sep 2025 11:25:57 +0800 Subject: [PATCH] WinSizeLayoutBreakpoint Signed-off-by: wangweiyuan2 --- api/@ohos.arkui.UIContext.d.ts | 70 ++++++++++++++++++++++++++++++++++ 1 file changed, 70 insertions(+) diff --git a/api/@ohos.arkui.UIContext.d.ts b/api/@ohos.arkui.UIContext.d.ts index 9278165b5b..6d8fc8eef3 100644 --- a/api/@ohos.arkui.UIContext.d.ts +++ b/api/@ohos.arkui.UIContext.d.ts @@ -1746,6 +1746,41 @@ export interface OverlayManagerOptions { enableBackPressedEvent?: boolean; } +/** + * Defines the window size layout breakpoint information. + * This interface provides the current breakpoint classification of the window's width and height + * based on the configured breakpoint thresholds. + * + * @syscap SystemCapability.ArkUI.ArkUI.Full + * @atomicservice + * @since 22 + */ +export interface WindowSizeLayoutBreakPointInfo { + /** + * The width breakpoint classification of the current window. + * This value indicates which width category the window currently falls into based on + * the configured width breakpoint thresholds. + * + * @type { WidthBreakpoint } + * @syscap SystemCapability.ArkUI.ArkUI.Full + * @atomicservice + * @since 22 + */ + widthBreakpoint: WidthBreakpoint; + + /** + * The height breakpoint classification of the current window. + * This value indicates which height category the window currently falls into based on + * the configured height breakpoint thresholds and aspect ratio. + * + * @type { HeightBreakpoint } + * @syscap SystemCapability.ArkUI.ArkUI.Full + * @atomicservice + * @since 22 + */ + heightBreakpoint: HeightBreakpoint; +} + /** * Register callbacks to observe ArkUI behavior. * In the following API examples, you must first use getUIObserver() in UIContext to obtain a UIObserver instance, and @@ -2533,6 +2568,41 @@ export declare class UIObserver { */ off(type: 'nodeRenderState', nodeIdentity: NodeIdentity, callback?: NodeRenderStateChangeCallback): void; + /** + * Registers a callback function to be called when the window size layout breakpoint changes. + * This method allows observing changes in window size breakpoints which can be used to + * adapt UI layouts responsively based on window dimensions. + * + * @param { 'windowSizeLayoutBreakPointChange' } type - The type of event to listen for. + * Must be 'windowSizeLayoutBreakPointChange'. + * @param { UIContext } context - The UIContext instance that specifies the scope of observation. + * This parameter is used to determine which window/instance to observe. + * @param { Callback } callback - The callback function to be + * called when the window size layout breakpoint changes. The callback receives a + * {@link WindowSizeLayoutBreakPointInfo} object containing the current width and height + * breakpoint classifications. + * @syscap SystemCapability.ArkUI.ArkUI.Full + * @atomicservice + * @since 22 + */ +on(type: 'windowSizeLayoutBreakPointChange', context: UIContext, callback: Callback): void; + +/** + * Removes a previously registered callback function for window size layout breakpoint changes. + * If no callback is provided, all callbacks for the specified context will be removed. + * + * @param { 'windowSizeLayoutBreakPointChange' } type - The type of event to remove the listener for. + * Must be 'windowSizeLayoutBreakPointChange'. + * @param { UIContext } context - The UIContext instance that was used during registration. + * This parameter specifies which context's listeners to remove. + * @param { Callback } [callback] - The specific callback function to remove. + * If not provided, all callbacks for the given event type and context will be removed. + * @syscap SystemCapability.ArkUI.ArkUI.Full + * @atomicservice + * @since 22 + */ +off(type: 'windowSizeLayoutBreakPointChange', context: UIContext, callback?: Callback): void; + /** * Registers a callback to monitor the gesture trigger information. * -- Gitee