diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-remotewindow.md b/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-remotewindow.md index a378f85c11918c041547ec2067becc5f7e45c0b9..beacd7a07259e135732dc7922f7a5159c307ab09 100644 --- a/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-remotewindow.md +++ b/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-remotewindow.md @@ -56,20 +56,120 @@ RemoteWindow(target: WindowAnimationTarget) 支持[通用事件](ts-universal-events-click.md)。 ## 示例 +RemoteWindow需要接收由[windowAnimationManager](../apis/js-apis-windowAnimationManager.md)设置的WindowAnimationController对象传入对应窗口WindowAnimationTarget对象,可以创建一个RemoteWindowExample.ets作为示例组件将RemoteWindow组件和传入的WindowAnimationTarget对象关联封装起来。 +由于RemoteWindow只能用于系统应用程序Launcher中,可以将RemoteWindowExample组件放置于Launcher的EntryView.ets页面的build函数中,编译Launcher, 然后推送Launcher安装包到设备系统中运行。 ```ts -// xxx.ets +// WindowAnimationControllerImpl.ets 文件 +import windowAnimationManager from '@ohos.animation.windowAnimationManager'; + +export default class WindowAnimationControllerImpl implements windowAnimationManager.WindowAnimationController { + onStartAppFromLauncher(startingWindowTarget: windowAnimationManager.WindowAnimationTarget, + finishedCallback: windowAnimationManager.WindowAnimationFinishedCallback): void + { + console.log(`remote window animaion onStartAppFromLauncher`); + finishedCallback.onAnimationFinish(); + } + + onStartAppFromRecent(startingWindowTarget: windowAnimationManager.WindowAnimationTarget, + finishedCallback: windowAnimationManager.WindowAnimationFinishedCallback): void { + console.log(`remote window animaion onStartAppFromRecent`); + finishedCallback.onAnimationFinish(); + } + + onStartAppFromOther(startingWindowTarget: windowAnimationManager.WindowAnimationTarget, + finishedCallback: windowAnimationManager.WindowAnimationFinishedCallback): void { + console.log(`remote window animaion onStartAppFromOther`); + finishedCallback.onAnimationFinish(); + } + + onAppTransition(fromWindowTarget: windowAnimationManager.WindowAnimationTarget, + toWindowTarget: windowAnimationManager.WindowAnimationTarget, + finishedCallback: windowAnimationManager.WindowAnimationFinishedCallback): void{ + console.log(`remote window animaion onAppTransition`); + finishedCallback.onAnimationFinish(); + } + + onMinimizeWindow(minimizingWindowTarget: windowAnimationManager.WindowAnimationTarget, + finishedCallback: windowAnimationManager.WindowAnimationFinishedCallback): void { + console.log(`remote window animaion onMinimizeWindow`); + finishedCallback.onAnimationFinish(); + } + + onCloseWindow(closingWindowTarget: windowAnimationManager.WindowAnimationTarget, + finishedCallback: windowAnimationManager.WindowAnimationFinishedCallback): void { + console.log(`remote window animaion onCloseWindow`); + finishedCallback.onAnimationFinish(); + } + + onScreenUnlock(finishedCallback: windowAnimationManager.WindowAnimationFinishedCallback): void { + console.log(`remote window animaion onScreenUnlock`); + finishedCallback.onAnimationFinish(); + } + + onWindowAnimationTargetsUpdate(fullScreenWindowTarget: windowAnimationManager.WindowAnimationTarget, + floatingWindowTargets: Array): void { + console.log('onWindowAnimationTargetsUpdate, the fullScreenWindowTarget is: ' + fullScreenWindowTarget); + console.log('onWindowAnimationTargetsUpdate, the floatingWindowTargets are: ' + floatingWindowTargets); + } +} +``` + +```ts +// RemoteWindowExample.ets 文件 +import windowAnimationManager from '@ohos.animation.windowAnimationManager'; +import WindowAnimationControllerImpl from '../animation/remoteanimation/WindowAnimationControllerImpl'; + @Entry @Component -struct RemoteWindowExample { +export default struct RemoteWindowExample { @State target: WindowAnimationTarget = undefined // 通过windowAnimationManager获取 + aboutToAppear(): void { + let controller = new WindowAnimationControllerImpl(); + windowAnimationManager.setController(controller); + + controller.onStartAppFromLauncher = (startingWindowTarget, finishedCallback) => { + console.log(`RemoteWindowExample: remote window animaion onStartAppFromLauncher`); + this.target = startingWindowTarget; + finishedCallback.onAnimationFinish(); + } + + controller.onStartAppFromRecent = (startingWindowTarget, finishedCallback) => { + console.log(`RemoteWindowExample: remote window animaion onStartAppFromRecent`); + this.target = startingWindowTarget; + finishedCallback.onAnimationFinish(); + } + + controller.onStartAppFromOther = (startingWindowTarget, finishedCallback) => { + console.log(`RemoteWindowExample: remote window animaion onStartAppFromOther`); + this.target = startingWindowTarget; + finishedCallback.onAnimationFinish(); + } + + controller.onAppTransition = (fromWindowTarget, toWindowTarget, finishedCallback) => { + console.log(`RemoteWindowExample: remote window animaion onAppTransition`); + this.target = toWindowTarget; + finishedCallback.onAnimationFinish(); + } + + controller.onMinimizeWindow = (minimizingWindowTarget, finishedCallback) => { + console.log(`RemoteWindowExample: remote window animaion onMinimizeWindow`); + this.target = minimizingWindowTarget; + finishedCallback.onAnimationFinish(); + } + + controller.onCloseWindow = (closingWindowTarget, finishedCallback) => { + console.log(`RemoteWindowExample: remote window animaion onCloseWindow`); + this.target = closingWindowTarget; + finishedCallback.onAnimationFinish(); + } + } + build() { Column() { RemoteWindow(this.target) - .translate({ x: 100, y: 200 }) - .scale({ x: 0.5, y: 0.5 }) - .opacity(0.8) + .scale({ x: 0.5, y: 0.5 }) // 仅用于可见效果的演示目的,正常使用须 .scale({ x: 1, y: 1 }) .position({ x: px2vp(this.target?.windowBounds.left), y: px2vp(this.target?.windowBounds.top) }) .width(px2vp(this.target?.windowBounds.width)) .height(px2vp(this.target?.windowBounds.height))