diff --git a/build-profile.json5 b/build-profile.json5 index c033ce4278fb0641d84107c3c134047ac487368e..e8de1a3cb6ba71c60762653ebac9cfdc1cfa0132 100644 --- a/build-profile.json5 +++ b/build-profile.json5 @@ -5,7 +5,7 @@ { "name": "default", "signingConfig": "default", - "compatibleSdkVersion": "5.0.0(12)", + "compatibleSdkVersion": "5.0.4(16)", "runtimeOS": "HarmonyOS", } ], diff --git a/entry/src/main/ets/pages/Index.ets b/entry/src/main/ets/pages/Index.ets index d4bc752f97b8443c7218f2b6b889f75a51d246a7..c2eac4f6199682658cce5767d4b004b598656cae 100644 --- a/entry/src/main/ets/pages/Index.ets +++ b/entry/src/main/ets/pages/Index.ets @@ -34,7 +34,7 @@ struct Index { Column({ space: 12 }) { ForEach(this.dataArr, (item: CardListItemData, index: number) => { DataItemView({ itemData: item }) - .margin({ bottom: index === this.dataArr.length - 1 ? px2vp(this.bottomHeight) : 0 }) + .margin({ bottom: index === this.dataArr.length - 1 ? this.getUIContext().px2vp(this.bottomHeight) : 0 }) }, (item: CardListItemData, index: number) => index + JSON.stringify(item)) } } @@ -51,9 +51,7 @@ struct Index { .width('100%') .expandSafeArea([SafeAreaType.SYSTEM], [SafeAreaEdge.TOP, SafeAreaEdge.BOTTOM]) .backgroundColor('#F1F3F5') - .padding({ - top: px2vp(this.topHeight) - }) + .padding({ top: this.getUIContext().px2vp(this.topHeight) }) } } @@ -105,8 +103,8 @@ struct DataItemView { } .onClick(() => { let util = PreferencesUtil.getInstance(); - let preferences = util.getPreferences(getContext(this)); - this.statusArr[this.itemData.id] = !this.statusArr[this.itemData.id] + let preferences = util.getPreferences(this.getUIContext().getHostContext()!); + this.statusArr[this.itemData.id] = !this.statusArr[this.itemData.id]; this.itemData.favour = this.statusArr[this.itemData.id!]; util.preferencesPut(preferences, 'statusArr', this.statusArr)