diff --git a/ArkUI/Component_Redundancy_Refresh_Optimization/entry/src/main/ets/segment/segment1.ets b/ArkUI/Component_Redundancy_Refresh_Optimization/entry/src/main/ets/segment/segment1.ets index 9b3c26bca072a24651ba4dea953e552d6e67360c..386160749164fc280e3d43499b18082b0d1cd426 100644 --- a/ArkUI/Component_Redundancy_Refresh_Optimization/entry/src/main/ets/segment/segment1.ets +++ b/ArkUI/Component_Redundancy_Refresh_Optimization/entry/src/main/ets/segment/segment1.ets @@ -24,39 +24,54 @@ struct ComponentA { Column() { // Components that use state variables SpecialImage({ specialImageUiStyle: this.uiStyle }) - Stack() { - Column() { - Image($r('app.media.startIcon')) - .height(78) - .width(78) - .scale({ - x: this.uiStyle.scaleX, - y: this.uiStyle.scaleY - }) - } - - Stack() { - Text('Hello World') - } + Column() { + // 需要替换为开发者所需的图像资源文件 + Image($r('app.media.startIcon')) + .height('150vp') + .width('150vp') + .scale({ + x: this.uiStyle.scaleX, + y: this.uiStyle.scaleY + }) + Text('Hello World') + .fontWeight(FontWeight.Bold) } .translate({ x: this.uiStyle.translateX, y: this.uiStyle.translateY }) - + .width('95%') + .height('200vp') + .margin({ + top: '10vp', + left: '15vp', + right: '15vp' + }) + .borderRadius('16vp') + .backgroundColor(Color.White) // Modify the value of a state variable via a button click callback, causing the corresponding component to refresh. Column() { Button('Move') + .width('80%') .onClick(() => { this.getUIContext().animateTo({ duration: animationDuration }, () => { this.uiStyle.translateY = (this.uiStyle.translateY + translateYChangeValue) % translateYChangeRange; }) }) Button('Scale') + .width('80%') .onClick(() => { this.uiStyle.scaleX = (this.uiStyle.scaleX + scaleXChangeValue) % scaleXChangeRange; }) + .margin({ + top: '10vp', + left: '15vp', + right: '15vp' + }) } + .height('35%') + .justifyContent(FlexAlign.End) + .width('100%') } } } @@ -74,15 +89,26 @@ struct SpecialImage { build() { Column() { + // 需要替换为开发者所需的图像资源文件 Image($r('app.media.startIcon')) - .size({ width: 200, height: 200 }) + .size({ width: 78, height: 78 }) .scale({ x: this.specialImageUiStyle.scaleX, y: this.specialImageUiStyle.scaleY }) .opacity(this.isRenderSpecialImage()) Text("SpecialImage") + .fontWeight(FontWeight.Bold) } + .width('95%') + .margin({ + top: '10vp', + left: '15vp', + right: '15vp' + }) + .borderRadius('16vp') + .height('200vp') + .backgroundColor(Color.White) } } @@ -100,6 +126,7 @@ struct DFXStateBeforeOptimization { } .width('100%') .height('100%') + .backgroundColor(0xDCDCDC) } } diff --git a/ArkUI/Component_Redundancy_Refresh_Optimization/entry/src/main/ets/segment/segment2.ets b/ArkUI/Component_Redundancy_Refresh_Optimization/entry/src/main/ets/segment/segment2.ets index c44e19606b9c18e7d6026f8a0f61d97a77e52290..1583092b1b7b8809a68ce07f5f4823c1ff29e04a 100644 --- a/ArkUI/Component_Redundancy_Refresh_Optimization/entry/src/main/ets/segment/segment2.ets +++ b/ArkUI/Component_Redundancy_Refresh_Optimization/entry/src/main/ets/segment/segment2.ets @@ -40,27 +40,36 @@ struct ComponentA { specialImageScaleStyle: this.scaleStyle }) // Other UI components - Stack() { Column() { + // 需要替换为开发者所需的图像资源文件 Image($r('app.media.startIcon')) + .height('150vp') + .width('150vp') .scale({ x: this.scaleStyle.scaleX, y: this.scaleStyle.scaleY }) - } - - Stack() { Text('Hello World') + .fontWeight(FontWeight.Bold) } - } + .translate({ x: this.translateStyle.translateX, y: this.translateStyle.translateY }) - + .width('95%') + .height('200vp') + .margin({ + top: '10vp', + left: '15vp', + right: '15vp' + }) + .borderRadius('16vp') + .backgroundColor(Color.White) // Modify the value of a state variable via a button click callback, causing the corresponding component to refresh. Column() { Button('Move') + .width('80%') .onClick(() => { this.getUIContext().animateTo({ duration: animationDuration }, () => { this.translateStyle.translateY = @@ -68,10 +77,19 @@ struct ComponentA { }) }) Button('Scale') + .width('80%') .onClick(() => { this.scaleStyle.scaleX = (this.scaleStyle.scaleX + scaleXChangeValue) % scaleXChangeRange; }) + .margin({ + top: '10vp', + left: '15vp', + right: '15vp' + }) } + .height('35%') + .justifyContent(FlexAlign.End) + .width('100%') } } } @@ -90,14 +108,26 @@ struct SpecialImage { build() { Column() { + // 需要替换为开发者所需的图像资源文件 Image($r('app.media.startIcon')) + .size({ width: 78, height: 78 }) .scale({ x: this.specialImageScaleStyle.scaleX, y: this.specialImageScaleStyle.scaleY }) .opacity(this.isRenderSpecialImage()) Text("SpecialImage") + .fontWeight(FontWeight.Bold) } + .width('95%') + .margin({ + top: '10vp', + left: '15vp', + right: '15vp' + }) + .borderRadius('16vp') + .height('200vp') + .backgroundColor(Color.White) } } @@ -113,6 +143,9 @@ struct DFXStateAfterOptimization { translateStyle: this.uiStyle.translateStyle, }) } + .width('100%') + .height('100%') + .backgroundColor(0xDCDCDC) } }