From 417bf1302a929d995db6502a154f52173c9112c9 Mon Sep 17 00:00:00 2001 From: c00471419 Date: Mon, 17 Jan 2022 09:52:13 +0800 Subject: [PATCH] add declare .d.ts for windowmanager Signed-off-by: c00471419 Change-Id: Icdc6a69ec4ad2f8c21eccbdc3c50ee705632ac89 Signed-off-by: c00471419 --- .../napi/window_runtime/api/@ohos.window.d.ts | 305 +++++++++++++++++- 1 file changed, 296 insertions(+), 9 deletions(-) diff --git a/interfaces/kits/napi/window_runtime/api/@ohos.window.d.ts b/interfaces/kits/napi/window_runtime/api/@ohos.window.d.ts index b486f75714..98bc1ed796 100644 --- a/interfaces/kits/napi/window_runtime/api/@ohos.window.d.ts +++ b/interfaces/kits/napi/window_runtime/api/@ohos.window.d.ts @@ -12,7 +12,8 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - +import { AsyncCallback, Callback } from './basic' ; +import { Context } from './app/context'; /** * Window manager. * @devices tv, phone, tablet, wearable. @@ -55,6 +56,28 @@ declare namespace windowmanager { SYSTEM_WINDOW_END = ABOVE_APP_SYSTEM_WINDOW_END, } + /** + * Describes the type of avoid area + * @devices tv, phone, tablet, wearable. + * @since 7 + */ + enum AvoidAreaType { + /** + * Default area of the system + */ + TYPE_SYSTEM, + + /** + * Notch + */ + TYPE_CUTOUT, + + /** + * area for system gesture + */ + TYPE_SYSTEM_GESTURE + } + enum WindowMode { /** * FullSCREEN. @@ -76,6 +99,7 @@ declare namespace windowmanager { */ WINDOW_MODE_PIP } + interface WindowManager { /** * Create a sub window with a specific id and type. @@ -85,6 +109,7 @@ declare namespace windowmanager { * @since 7 */ create(id: string, type: WindowType, callback: AsyncCallback): void; + /** * Create a sub window with a specific id and type. * @param id Indicates window id. @@ -93,20 +118,125 @@ declare namespace windowmanager { * @since 7 */ create(id: string, type: WindowType): Promise; + + /** + * Create a sub window with a specific id and type. + * @param ctx Indicates the context on which the window depends + * @param id Indicates window id. + * @param type Indicates window type. + * @permission ohos.permission.SYSTEM_FLOAT_WINDOW + * @since 8 + */ + create(ctx: Context, id: string, type: WindowType): Promise; + /** * Find the sub window by id. * @param id Indicates window id. * @since 7 */ find(id: string, callback: AsyncCallback): void; + /** * Find the sub window by id. * @param id Indicates window id. * @since 7 */ find(id: string): Promise; + } + + /** + * Properties of status bar and navigation bar, it couldn't update automatically + * @devices tv, phone, tablet, wearable, car + * @since 6 + */ + interface SystemBarProperties { + /** + * the color of the status bar. + * @since 6 + */ + statusBarColor?: string; + + /** + * the light icon of the status bar. + * @since 7 + */ + isStatusBarLightIcon?: boolean; + + /** + * the content color of the status bar + * @since 8 + */ + statusBarContentColor?: string; + + /** + * the color of the navigation bar. + * @since 6 + */ + navigationBarColor?: string; + + /** + * the light icon of the navigation bar. + * @since 7 + */ + isNavigationBarLightIcon?: boolean; + /** + * the content color of the navigation bar + * @since 8 + */ + navigationBarContentColor?: string; } + + /** + * system bar tint of region + * @devices tv, phone, tablet, wearable, car + * @systemapi Hide this for inner system use. + * @since 8 + */ + interface SystemBarRegionTint { + /** + * system bar type + */ + type: WindowType; + + /** + * the visibility of system bar + */ + isEnable?: boolean; + + /** + * the region of system bar + */ + region?: Rect; + + /** + * the background color of the system bar. + */ + backgroundColor?: string; + + /** + * the content color of the system bar. + */ + contentColor?: string + } + + /** + * system bar tint state for systemui + * @devices tv, phone, tablet, wearable, car + * @systemapi Hide this for inner system use. + * @since 8 + */ + interface SystemBarTintState { + /** + * id of display + */ + displayId: number; + /** + * region tint of systembar + */ + regionTint: Array; + } + /** * Rectangle * @devices tv, phone, tablet, wearable, car @@ -114,11 +244,41 @@ declare namespace windowmanager { */ interface Rect { left: number; + top: number; + width: number; + height: number; } + /** + * avoid area + * @devices tv, phone, tablet, wearable, car + * @since 7 + */ + interface AvoidArea { + /** + * Rectangle on the left of the screen + */ + leftRect: Rect; + + /** + * Rectangle on the top of the screen + */ + topRect: Rect; + + /** + * Rectangle on the right of the screen + */ + rightRect: Rect; + + /** + * Rectangle on the bottom of the screen + */ + bottomRect: Rect; + } + /** * window size * @devices tv, phone, tablet, wearable, car @@ -162,6 +322,7 @@ declare namespace windowmanager { * @since 7 */ hide (callback: AsyncCallback): void; + /** * hide sub window. * @systemapi Hide this for inner system use. @@ -174,53 +335,69 @@ declare namespace windowmanager { * @since 7 */ show(callback: AsyncCallback): void; + /** * show sub window. * @since 7 */ show(): Promise; + /** * Destroy the sub window. * @since 7 */ destroy(callback: AsyncCallback): void; + /** * Destroy the sub window. * @since 7 */ destroy(): Promise; + /** * Set the position of a window. * @param x Indicate the X-coordinate of the window. * @param y Indicate the Y-coordinate of the window. * @devices tv, phone, tablet, wearable, liteWearable. */ - moveTo(x:number, y:number): Promise; + moveTo(x: number, y: number): Promise; + /** * Set the size of a window . * @param width Indicates the width of the window. * @param height Indicates the height of the window. * @devices tv, phone, tablet, wearable, liteWearable. */ - resize(width:number, height:number): Promise; + resize(width: number, height: number): Promise; + /** - * Set the type of a window. - * @param windowType Indicate the type of a window. - * @devices tv, phone, tablet, wearable, liteWearable. + * Loads content to the subwindow + * @param path Path of the page to which the content will be loaded + * @since 7 */ - setWindowType(windowType: WindowType): Promise; + loadContent(path: string, callback: AsyncCallback): void; + + /** + * Loads content to the subwindow + * @param path Path of the page to which the content will be loaded + * @since 7 + */ + loadContent(path: string): Promise; + /** * Set the type of a window. - * @param windowMode Indicate the mode of a window. + * @param windowType Indicate the type of a window. * @devices tv, phone, tablet, wearable, liteWearable. */ - setWindowMode(windowMode: WindowMode): Promise; + setWindowType(windowType: WindowType): Promise; + /** * get the properties of current window * @devices tv, phone, tablet, wearable, car * @since 6 */ getProperties(callback: AsyncCallback): void; + /** * get the properties of current window * @devices tv, phone, tablet, wearable, car @@ -228,6 +405,82 @@ declare namespace windowmanager { */ getProperties(): Promise; + /** + * get the avoid area + * @param type Type of the area + */ + getAvoidArea(type: AvoidAreaType, callback: AsyncCallback): void; + + /** + * get the avoid area + * @param type Type of the area + */ + getAvoidArea(type: AvoidAreaType): Promise; + + /** + * set the flag of the window is shown full screen + * @param isFullScreen the flag of the window is shown full screen + * @devices tv, phone, tablet, wearable, car + * @since 6 + */ + setFullScreen(isFullScreen: boolean, callback: AsyncCallback): void; + + /** + * set the flag of the window is shown full screen + * @param isFullScreen the flag of the window is shown full screen + * @devices tv, phone, tablet, wearable, car + * @since 6 + */ + setFullScreen(isFullScreen: boolean): Promise; + + /** + * set the property of the window can layout in full screen + * @param isLayoutFullScreen the window can layout in full screen + * @devices tv, phone, tablet, wearable, car + * @since 7 + */ + setLayoutFullScreen(isLayoutFullScreen: boolean, callback: AsyncCallback): void; + + /** + * set the property of the window can layout in full screen + * @param isLayoutFullScreen the window can layout in full screen + * @devices tv, phone, tablet, wearable, car + * @since 7 + */ + setLayoutFullScreen(isLayoutFullScreen: boolean): Promise; + + /** + * set the system bar to have visible. + * @param names the set of system bar + * @devices tv, phone, tablet, wearable, car + * @since 7 + */ + setSystemBarEnable(names: Array<'status'|'navigation'>, callback: AsyncCallback): void; + + /** + * set the system bar to have visible. + * @param names the set of system bar + * @devices tv, phone, tablet, wearable, car + * @since 7 + */ + setSystemBarEnable(names: Array<'status'|'navigation'>): Promise; + + /** + * set the background color of statusbar + * @param color the background color of statusbar + * @devices tv, phone, tablet, wearable, car + * @since 6 + */ + setSystemBarProperties(systemBarProperties: SystemBarProperties, callback: AsyncCallback): void; + + /** + * set the background color of statusbar + * @param color the background color of statusbar + * @devices tv, phone, tablet, wearable, car + * @since 6 + */ + setSystemBarProperties(systemBarProperties: SystemBarProperties): Promise; + /** * register the callback of windowSizeChange * @param type: 'windowSizeChange' @@ -243,6 +496,40 @@ declare namespace windowmanager { * @since 7 */ off(type: 'windowSizeChange', callback?: Callback): void; + + /** + * register the callback of systemAvoidAreaChange + * @param type: 'systemAvoidAreaChange' + * @devices tv, phone, tablet, wearable, car + * @since 7 + */ + on(type: 'systemAvoidAreaChange', callback: Callback): void; + + /** + * unregister the callback of systemAvoidAreaChange + * @param type: 'systemAvoidAreaChange' + * @devices tv, phone, tablet, wearable, car + * @since 7 + */ + off(type: 'systemAvoidAreaChange', callback?: Callback): void; + + /** + * register the callback of systemBarTintChange + * @param type: 'systemBarTintChange' + * @devices tv, phone, tablet, wearable, car + * @systemapi Hide this for inner system use. + * @since 8 + */ + on(type: 'systemBarTintChange', callback: Callback): void; + + /** + * unregister the callback of systemBarTintChange + * @param type: 'systemBarTintChange' + * @devices tv, phone, tablet, wearable, car + * @systemapi Hide this for inner system use. + * @since 8 + */ + off(type: 'systemBarTintChange', callback?: Callback): void; } } -- Gitee