yangchenggong1_wd

desc:关于 适配折叠屏

@@ -23,6 +23,6 @@ struct SettingAboutPage { @@ -23,6 +23,6 @@ struct SettingAboutPage {
23 build() { 23 build() {
24 Column(){ 24 Column(){
25 AboutPageUI() 25 AboutPageUI()
26 - } 26 + }.backgroundColor($r('app.color.white'))
27 } 27 }
28 } 28 }
@@ -4,14 +4,15 @@ import router from '@ohos.router' @@ -4,14 +4,15 @@ import router from '@ohos.router'
4 export struct CustomTitleUI { 4 export struct CustomTitleUI {
5 imgBack:boolean = true 5 imgBack:boolean = true
6 titleName:ResourceStr = "默认标题" 6 titleName:ResourceStr = "默认标题"
  7 + @Prop percent:number = 1
7 8
8 build() { 9 build() {
9 RelativeContainer() { 10 RelativeContainer() {
10 //标题栏目 11 //标题栏目
11 if(this.imgBack){ 12 if(this.imgBack){
12 Image($r('app.media.back_icon')) 13 Image($r('app.media.back_icon'))
13 - .width('46lpx')  
14 - .height('46lpx') 14 + .width(`${this.calcHeight(46)}lpx`)
  15 + .height(`${this.calcHeight(46)}lpx`)
15 .objectFit(ImageFit.Auto) 16 .objectFit(ImageFit.Auto)
16 .interpolation(ImageInterpolation.High) 17 .interpolation(ImageInterpolation.High)
17 .id("back_icon") 18 .id("back_icon")
@@ -19,7 +20,7 @@ export struct CustomTitleUI { @@ -19,7 +20,7 @@ export struct CustomTitleUI {
19 center: {anchor: "__container__", align: VerticalAlign.Center}, 20 center: {anchor: "__container__", align: VerticalAlign.Center},
20 left: {anchor: "__container__", align: HorizontalAlign.Start} 21 left: {anchor: "__container__", align: HorizontalAlign.Start}
21 }) 22 })
22 - .margin({left:'31lpx'}) 23 + .margin({left:`${this.calcHeight(31)}lpx`})
23 .onClick(()=>{ 24 .onClick(()=>{
24 router.back() 25 router.back()
25 }) 26 })
@@ -28,18 +29,22 @@ export struct CustomTitleUI { @@ -28,18 +29,22 @@ export struct CustomTitleUI {
28 Text(this.titleName) 29 Text(this.titleName)
29 .maxLines(1) 30 .maxLines(1)
30 .id("title") 31 .id("title")
31 - .fontSize('30lpx') 32 + .fontSize(`${this.calcHeight(30)}lpx`)
32 .fontWeight(400) 33 .fontWeight(400)
33 .fontColor($r('app.color.color_222222')) 34 .fontColor($r('app.color.color_222222'))
34 - .lineHeight('43lpx') 35 + .lineHeight(`${this.calcHeight(43)}lpx`)
35 .alignRules({ 36 .alignRules({
36 center: {anchor: "__container__", align: VerticalAlign.Center}, 37 center: {anchor: "__container__", align: VerticalAlign.Center},
37 middle: {anchor: "__container__", align: HorizontalAlign.Center} 38 middle: {anchor: "__container__", align: HorizontalAlign.Center}
38 }) 39 })
39 40
40 } 41 }
41 - .height('84lpx') 42 + .height(`${this.calcHeight(84)}lpx`)
42 .width('100%') 43 .width('100%')
43 .backgroundColor($r('app.color.white')) 44 .backgroundColor($r('app.color.white'))
44 } 45 }
  46 +
  47 + calcHeight(value:number): number{
  48 + return value * this.percent
  49 + }
45 } 50 }
1 import { Params } from 'wdBean'; 1 import { Params } from 'wdBean';
2 -import { AppUtils, StringUtils } from 'wdKit/Index'; 2 +import { AppUtils, BreakpointSystem, StringUtils } from 'wdKit/Index';
3 import { WDRouterPage, WDRouterRule } from 'wdRouter'; 3 import { WDRouterPage, WDRouterRule } from 'wdRouter';
4 import { TrackingButton, TrackConstants } from 'wdTracking/Index'; 4 import { TrackingButton, TrackConstants } from 'wdTracking/Index';
5 import { CustomTitleUI } from '../reusable/CustomTitleUI'; 5 import { CustomTitleUI } from '../reusable/CustomTitleUI';
@@ -24,11 +24,25 @@ export struct AboutPageUI { @@ -24,11 +24,25 @@ export struct AboutPageUI {
24 alignment: DialogAlignment.Center 24 alignment: DialogAlignment.Center
25 }) 25 })
26 26
  27 + @StorageProp('currentBreakpoint') @Watch("currentChanged")currentBreakpoint: string = 'sm';
  28 + private breakpointSystem = new BreakpointSystem();
  29 + @State percent:number = 1
  30 +
  31 + currentChanged(){
  32 + if(this.currentBreakpoint == "md" || this.currentBreakpoint == "lg"){
  33 + this.percent = 0.7
  34 + }else {
  35 + this.percent = 1
  36 + }
  37 + }
  38 +
27 build() { 39 build() {
28 this.aboutUi() 40 this.aboutUi()
29 } 41 }
30 42
31 aboutToAppear() { 43 aboutToAppear() {
  44 + this.breakpointSystem.register();
  45 + this.currentChanged()
32 let context = getContext(); 46 let context = getContext();
33 context.getApplicationContext(); 47 context.getApplicationContext();
34 let appVerion = AppUtils.getAppVersionName() 48 let appVerion = AppUtils.getAppVersionName()
@@ -37,15 +51,19 @@ export struct AboutPageUI { @@ -37,15 +51,19 @@ export struct AboutPageUI {
37 } 51 }
38 } 52 }
39 53
  54 + aboutToDisappear(): void {
  55 + this.breakpointSystem.unregister();
  56 + }
  57 +
40 @Builder 58 @Builder
41 aboutUi() { 59 aboutUi() {
42 Column() { 60 Column() {
43 - CustomTitleUI({titleName:'关于'}) 61 + CustomTitleUI({titleName:'关于',percent:this.percent})
44 62
45 Image($r('app.media.setting_about_logo')) 63 Image($r('app.media.setting_about_logo'))
46 - .width('278lpx')  
47 - .height('154lpx')  
48 - .margin({ top: '173lpx', bottom: '154lpx' }) 64 + .width(`${this.calcHeight(278)}lpx`)
  65 + .height(`${this.calcHeight(154)}lpx`)
  66 + .margin({ top: `${this.calcHeight2(173)}lpx`, bottom: `${this.calcHeight2(154)}lpx` })
49 .gesture( 67 .gesture(
50 TapGesture({ count: 2 }) 68 TapGesture({ count: 2 })
51 .onAction((event: GestureEvent) => { 69 .onAction((event: GestureEvent) => {
@@ -77,28 +95,28 @@ export struct AboutPageUI { @@ -77,28 +95,28 @@ export struct AboutPageUI {
77 }) 95 })
78 }.divider({ 96 }.divider({
79 strokeWidth: 1, 97 strokeWidth: 1,
80 - startMargin: '29lpx',  
81 - endMargin: '29lpx', 98 + startMargin: `${this.calcHeight(29)}lpx`,
  99 + endMargin: `${this.calcHeight(29)}lpx`,
82 color: '#EDEDED' 100 color: '#EDEDED'
83 }) 101 })
84 102
85 Blank() 103 Blank()
86 104
87 Image($r('app.media.about_us_code')) 105 Image($r('app.media.about_us_code'))
88 - .width('192lpx')  
89 - .height('192lpx') 106 + .width(`${this.calcHeight(192)}lpx`)
  107 + .height(`${this.calcHeight(192)}lpx`)
90 108
91 Text(this.version) 109 Text(this.version)
92 - .fontSize('25lpx') 110 + .fontSize(`${this.calcHeight(25)}lpx`)
93 .textAlign(TextAlign.Center) 111 .textAlign(TextAlign.Center)
94 .fontColor($r("app.color.color_666666")) 112 .fontColor($r("app.color.color_666666"))
95 - .margin({ bottom: '31lpx' }) 113 + .margin({ bottom: `${this.calcHeight(31)}lpx` })
96 114
97 Text(this.message) 115 Text(this.message)
98 - .fontSize('19lpx') 116 + .fontSize(`${this.calcHeight(19)}lpx`)
99 .textAlign(TextAlign.Center) 117 .textAlign(TextAlign.Center)
100 .fontColor($r("app.color.color_999999")) 118 .fontColor($r("app.color.color_999999"))
101 - .margin({ bottom: '35lpx' }) 119 + .margin({ bottom: `${this.calcHeight(35)}lpx` })
102 } 120 }
103 .width('100%') 121 .width('100%')
104 .height('100%') 122 .height('100%')
@@ -112,18 +130,30 @@ export struct AboutPageUI { @@ -112,18 +130,30 @@ export struct AboutPageUI {
112 // 左侧标题 130 // 左侧标题
113 Text(`${item}`) 131 Text(`${item}`)
114 .fontColor('#666666') 132 .fontColor('#666666')
115 - .fontSize('31lpx') 133 + .fontSize(`${this.calcHeight(31)}lpx`)
116 134
117 Image($r('app.media.mine_user_arrow')) 135 Image($r('app.media.mine_user_arrow'))
118 - .width('27lpx')  
119 - .height('27lpx') 136 + .width(`${this.calcHeight(27)}lpx`)
  137 + .height(`${this.calcHeight(27)}lpx`)
120 .objectFit(ImageFit.Auto) 138 .objectFit(ImageFit.Auto)
121 } 139 }
122 .alignItems(VerticalAlign.Center) 140 .alignItems(VerticalAlign.Center)
123 .justifyContent(FlexAlign.SpaceBetween) 141 .justifyContent(FlexAlign.SpaceBetween)
124 - .height('97lpx') 142 + .height(`${this.calcHeight(97)}lpx`)
125 .width('100%') 143 .width('100%')
126 - .padding({ left: '29lpx', right: '29lpx' }) 144 + .padding({ left:`${this.calcHeight(29)}lpx`, right: `${this.calcHeight(29)}lpx` })
  145 + }
  146 +
  147 + calcHeight(value:number): number{
  148 + return value * this.percent
  149 + }
  150 +
  151 + calcHeight2(value:number): number{
  152 + if(this.percent < 1){
  153 + return value * 0.3
  154 + }else{
  155 + return value * 1
  156 + }
127 } 157 }
128 } 158 }
129 159