diff --git a/entry/src/main/ets/pages/Index.ets b/entry/src/main/ets/pages/Index.ets index 0203d1e6d23134d6ae24514c9c9f7b282f3412bd..ab86d21d4aae04e843a846cb350fc6f207494c60 100644 --- a/entry/src/main/ets/pages/Index.ets +++ b/entry/src/main/ets/pages/Index.ets @@ -19,6 +19,7 @@ import { image } from '@kit.ImageKit'; import { effectKit } from '@kit.ArkGraphics2D'; import CommonConstants from '../constants/CommonContants'; import { BusinessError } from '@kit.BasicServicesKit'; +import { common } from '@kit.AbilityKit'; @Entry @Component @@ -39,13 +40,14 @@ struct Index { private swiperInterval: number = CommonConstants.SWIPER_INTERVAL; private swiperDuration: number = CommonConstants.SWIPER_DURATION; private swiperItemSpace: number = CommonConstants.SWIPER_ITEM_SPACE; + private context = this.getUIContext().getHostContext() as common.UIAbilityContext; async aboutToAppear() { - let windowHeight: window.Window = await window.getLastWindow(getContext(this)); + let windowHeight: window.Window = await window.getLastWindow(this.context); await windowHeight.setWindowLayoutFullScreen(true); - this.topSafeHeight = px2vp(windowHeight.getWindowAvoidArea(window.AvoidAreaType.TYPE_SYSTEM).topRect.height) + this.topSafeHeight = this.getUIContext().px2vp(windowHeight.getWindowAvoidArea(window.AvoidAreaType.TYPE_SYSTEM).topRect.height) - const context = getContext(this); + const context = this.context; const resourceMgr: resourceManager.ResourceManager = context.resourceManager; const fileData: Uint8Array = await resourceMgr.getMediaContent(this.imgData[0]); const buffer = fileData.buffer as ArrayBuffer; @@ -78,7 +80,7 @@ struct Index { .indicator(false) .onAnimationStart(async (index, targetIndex) => { try { - const context = getContext(this); + const context = this.context; const resourceMgr: resourceManager.ResourceManager = context.resourceManager; const fileData: Uint8Array = await resourceMgr.getMediaContent(this.imgData[targetIndex]); const buffer = fileData.buffer as ArrayBuffer; @@ -87,7 +89,7 @@ struct Index { effectKit.createColorPicker(pixelMap, (err, colorPicker) => { let color = colorPicker.getMainColorSync(); - animateTo({ + this.getUIContext().animateTo({ duration: CommonConstants.ANIMATION_DURATION, curve: Curve.Linear, iterations: CommonConstants.ANIMATION_ITERATIONS