Showing
3 changed files
with
120 additions
and
62 deletions
| 1 | -import { DateTimeUtils, PermissionUtil } from 'wdKit' | 1 | +import { BreakpointSystem, DateTimeUtils, PermissionUtil } from 'wdKit' |
| 2 | import { PrivacySettingModel } from '../../model/PrivacySettingModel' | 2 | import { PrivacySettingModel } from '../../model/PrivacySettingModel' |
| 3 | import { Params } from 'wdBean'; | 3 | import { Params } from 'wdBean'; |
| 4 | import { WDRouterPage, WDRouterRule } from 'wdRouter'; | 4 | import { WDRouterPage, WDRouterRule } from 'wdRouter'; |
| 5 | import { HttpUtils } from 'wdNetwork/Index'; | 5 | import { HttpUtils } from 'wdNetwork/Index'; |
| 6 | import { TrackingPageBrowse, TrackConstants, TrackingButton } from 'wdTracking/Index'; | 6 | import { TrackingPageBrowse, TrackConstants, TrackingButton } from 'wdTracking/Index'; |
| 7 | +import { TitleBackComponent } from '../setting/TitleBackComponent'; | ||
| 7 | 8 | ||
| 8 | const TAG = 'PrivacySettingPage'; | 9 | const TAG = 'PrivacySettingPage'; |
| 9 | const DiyString = '开启个性化推荐' | 10 | const DiyString = '开启个性化推荐' |
| @@ -18,6 +19,17 @@ export struct PrivacySettingPage { | @@ -18,6 +19,17 @@ export struct PrivacySettingPage { | ||
| 18 | tipsEnd = '中相应权限使用规则' | 19 | tipsEnd = '中相应权限使用规则' |
| 19 | pageShowTime:number = 0; | 20 | pageShowTime:number = 0; |
| 20 | pageHideTime:number = 0; | 21 | pageHideTime:number = 0; |
| 22 | + @StorageProp('currentBreakpoint') @Watch("currentChanged")currentBreakpoint: string = 'sm'; | ||
| 23 | + private breakpointSystem = new BreakpointSystem(); | ||
| 24 | + @State percent:number = 1 | ||
| 25 | + | ||
| 26 | + currentChanged(){ | ||
| 27 | + if(this.currentBreakpoint == "md" || this.currentBreakpoint == "lg"){ | ||
| 28 | + this.percent = 0.7 | ||
| 29 | + }else { | ||
| 30 | + this.percent = 1 | ||
| 31 | + } | ||
| 32 | + } | ||
| 21 | 33 | ||
| 22 | onPageShow(): void { | 34 | onPageShow(): void { |
| 23 | this.getPermissionStatus(); | 35 | this.getPermissionStatus(); |
| @@ -32,6 +44,8 @@ export struct PrivacySettingPage { | @@ -32,6 +44,8 @@ export struct PrivacySettingPage { | ||
| 32 | } | 44 | } |
| 33 | 45 | ||
| 34 | aboutToAppear() { | 46 | aboutToAppear() { |
| 47 | + this.breakpointSystem.register(); | ||
| 48 | + this.currentChanged() | ||
| 35 | if (!HttpUtils.getUserId()) { | 49 | if (!HttpUtils.getUserId()) { |
| 36 | this.listData.splice(0, 1); | 50 | this.listData.splice(0, 1); |
| 37 | } | 51 | } |
| @@ -43,6 +57,10 @@ export struct PrivacySettingPage { | @@ -43,6 +57,10 @@ export struct PrivacySettingPage { | ||
| 43 | 57 | ||
| 44 | } | 58 | } |
| 45 | 59 | ||
| 60 | + aboutToDisappear(): void { | ||
| 61 | + this.breakpointSystem.unregister(); | ||
| 62 | + } | ||
| 63 | + | ||
| 46 | async getPermissionStatus() { | 64 | async getPermissionStatus() { |
| 47 | const permissionUtil = new PermissionUtil(); | 65 | const permissionUtil = new PermissionUtil(); |
| 48 | for (const element of this.listData) { | 66 | for (const element of this.listData) { |
| @@ -57,25 +75,27 @@ export struct PrivacySettingPage { | @@ -57,25 +75,27 @@ export struct PrivacySettingPage { | ||
| 57 | } | 75 | } |
| 58 | 76 | ||
| 59 | build() { | 77 | build() { |
| 60 | - Navigation() { | 78 | + Column(){ |
| 79 | + TitleBackComponent({title:"隐私设置"}) | ||
| 80 | + | ||
| 61 | //滑动区域 | 81 | //滑动区域 |
| 62 | this.PrivacySettingComponentsUI() | 82 | this.PrivacySettingComponentsUI() |
| 83 | + }.backgroundColor('#F8F8F8') | ||
| 84 | + .width("100%") | ||
| 85 | + .height("100%") | ||
| 63 | 86 | ||
| 64 | - }.titleMode(NavigationTitleMode.Mini) | ||
| 65 | - .title('隐私设置') | ||
| 66 | - .backgroundColor('#F8F8F8') | ||
| 67 | } | 87 | } |
| 68 | 88 | ||
| 69 | @Builder PrivacySettingComponentsUI() { | 89 | @Builder PrivacySettingComponentsUI() { |
| 70 | Column() { | 90 | Column() { |
| 71 | 91 | ||
| 72 | - List({ space: '23lpx' }) { | 92 | + List({ space: `${this.calcHeight(23)}lpx` }) { |
| 73 | ForEach(this.listData, (item: PrivacySettingModel, index:number) => { | 93 | ForEach(this.listData, (item: PrivacySettingModel, index:number) => { |
| 74 | ListItem() { | 94 | ListItem() { |
| 75 | if (item.privacyName == DiyString) { | 95 | if (item.privacyName == DiyString) { |
| 76 | - getTuiJianCell({ item:item, index:index }); | 96 | + getTuiJianCell({ item:item, index:index ,percent:$percent}); |
| 77 | } else { | 97 | } else { |
| 78 | - getArrowCell({ item:item, index:index }); | 98 | + getArrowCell({ item:item, index:index ,percent:$percent}); |
| 79 | } | 99 | } |
| 80 | }.onClick(() => { | 100 | }.onClick(() => { |
| 81 | if (item.privacyName == DiyString) { | 101 | if (item.privacyName == DiyString) { |
| @@ -103,32 +123,33 @@ export struct PrivacySettingPage { | @@ -103,32 +123,33 @@ export struct PrivacySettingPage { | ||
| 103 | } | 123 | } |
| 104 | }) | 124 | }) |
| 105 | }) | 125 | }) |
| 106 | - } | ||
| 107 | - .padding({ left: '29lpx', right: '29lpx' }) | ||
| 108 | - .margin({ top: '38lpx' }) | 126 | + }.width('100%') |
| 127 | + .padding({ left: `${this.calcHeight(29)}lpx`, right: `${this.calcHeight(29)}lpx` }) | ||
| 128 | + .margin({ top: `${this.calcHeight(38)}lpx` }) | ||
| 129 | + | ||
| 109 | 130 | ||
| 110 | Row() { | 131 | Row() { |
| 111 | Text(this.tips) | 132 | Text(this.tips) |
| 112 | - .fontSize('25lpx') | 133 | + .fontSize(`${this.calcHeight(25)}lpx`) |
| 113 | .textAlign(TextAlign.Start) | 134 | .textAlign(TextAlign.Start) |
| 114 | .fontColor($r("app.color.color_666666")) | 135 | .fontColor($r("app.color.color_666666")) |
| 115 | - .margin({ left: '29lpx', top: '46lpx' }) | 136 | + .margin({ left: `${this.calcHeight(29)}lpx`, top: `${this.calcHeight(46)}lpx` }) |
| 116 | // .backgroundColor(Color.Orange) | 137 | // .backgroundColor(Color.Orange) |
| 117 | Text(this.privacyTips) | 138 | Text(this.privacyTips) |
| 118 | - .fontSize('25lpx') | 139 | + .fontSize(`${this.calcHeight(25)}lpx`) |
| 119 | .textAlign(TextAlign.Start) | 140 | .textAlign(TextAlign.Start) |
| 120 | .fontColor('#ED2800') | 141 | .fontColor('#ED2800') |
| 121 | - .margin({ top: '46lpx' }) | 142 | + .margin({ top: `${this.calcHeight(46)}lpx` }) |
| 122 | .onClick(() => { | 143 | .onClick(() => { |
| 123 | //跳转隐私政策 | 144 | //跳转隐私政策 |
| 124 | let bean={contentID:"2",pageID:""} as Params | 145 | let bean={contentID:"2",pageID:""} as Params |
| 125 | WDRouterRule.jumpWithPage(WDRouterPage.loginProtocolPage,bean) | 146 | WDRouterRule.jumpWithPage(WDRouterPage.loginProtocolPage,bean) |
| 126 | }) | 147 | }) |
| 127 | Text(this.tipsEnd) | 148 | Text(this.tipsEnd) |
| 128 | - .fontSize('25lpx') | 149 | + .fontSize(`${this.calcHeight(25)}lpx`) |
| 129 | .textAlign(TextAlign.Start) | 150 | .textAlign(TextAlign.Start) |
| 130 | .fontColor($r("app.color.color_666666")) | 151 | .fontColor($r("app.color.color_666666")) |
| 131 | - .margin({ top: '46lpx' }) | 152 | + .margin({ top: `${this.calcHeight(46)}lpx` }) |
| 132 | } | 153 | } |
| 133 | 154 | ||
| 134 | } | 155 | } |
| @@ -137,6 +158,10 @@ export struct PrivacySettingPage { | @@ -137,6 +158,10 @@ export struct PrivacySettingPage { | ||
| 137 | .backgroundColor('#F8F8F8') | 158 | .backgroundColor('#F8F8F8') |
| 138 | .alignItems(HorizontalAlign.Start) | 159 | .alignItems(HorizontalAlign.Start) |
| 139 | } | 160 | } |
| 161 | + | ||
| 162 | + calcHeight(value:number): number{ | ||
| 163 | + return value * this.percent | ||
| 164 | + } | ||
| 140 | } | 165 | } |
| 141 | 166 | ||
| 142 | 167 | ||
| @@ -144,6 +169,7 @@ export struct PrivacySettingPage { | @@ -144,6 +169,7 @@ export struct PrivacySettingPage { | ||
| 144 | struct getArrowCell { | 169 | struct getArrowCell { |
| 145 | @ObjectLink item: PrivacySettingModel; | 170 | @ObjectLink item: PrivacySettingModel; |
| 146 | index:number = 0; | 171 | index:number = 0; |
| 172 | + @Link percent:number | ||
| 147 | // 右文字+箭头cell | 173 | // 右文字+箭头cell |
| 148 | // @Builder getArrowCell(item:PrivacySettingModel, index) { | 174 | // @Builder getArrowCell(item:PrivacySettingModel, index) { |
| 149 | build() { | 175 | build() { |
| @@ -151,28 +177,32 @@ struct getArrowCell { | @@ -151,28 +177,32 @@ struct getArrowCell { | ||
| 151 | // 左侧标题 | 177 | // 左侧标题 |
| 152 | Text(this.item.privacyName) | 178 | Text(this.item.privacyName) |
| 153 | .fontColor('#666666') | 179 | .fontColor('#666666') |
| 154 | - .fontSize('31lpx') | 180 | + .fontSize(`${this.calcHeight(31)}lpx`) |
| 155 | 181 | ||
| 156 | Row() { | 182 | Row() { |
| 157 | Text(this.item.permission ? '已开启' : '去设置') | 183 | Text(this.item.permission ? '已开启' : '去设置') |
| 158 | .fontColor(this.item.permission ? '#666666' : '#CCCCCC') | 184 | .fontColor(this.item.permission ? '#666666' : '#CCCCCC') |
| 159 | - .fontSize('31lpx') | ||
| 160 | - .margin({ right: '8lpx' }) | 185 | + .fontSize(`${this.calcHeight(31)}lpx`) |
| 186 | + .margin({ right: `${this.calcHeight(8)}lpx` }) | ||
| 161 | 187 | ||
| 162 | Image($r('app.media.mine_user_arrow')) | 188 | Image($r('app.media.mine_user_arrow')) |
| 163 | - .width('27lpx') | ||
| 164 | - .height('27lpx') | 189 | + .width(`${this.calcHeight(27)}lpx`) |
| 190 | + .height(`${this.calcHeight(27)}lpx`) | ||
| 165 | .objectFit(ImageFit.Auto) | 191 | .objectFit(ImageFit.Auto) |
| 166 | } | 192 | } |
| 167 | 193 | ||
| 168 | } | 194 | } |
| 169 | .alignItems(VerticalAlign.Center) | 195 | .alignItems(VerticalAlign.Center) |
| 170 | .justifyContent(FlexAlign.SpaceBetween) | 196 | .justifyContent(FlexAlign.SpaceBetween) |
| 171 | - .height('97lpx') | 197 | + .height(`${this.calcHeight(97)}lpx`) |
| 172 | .width('100%') | 198 | .width('100%') |
| 173 | - .padding({ left: '29lpx', right: '29lpx' }) | 199 | + .padding({ left: `${this.calcHeight(29)}lpx`, right: `${this.calcHeight(29)}lpx` }) |
| 174 | .backgroundColor('#FFFFFF') | 200 | .backgroundColor('#FFFFFF') |
| 175 | - .borderRadius('8lpx') | 201 | + .borderRadius(`${this.calcHeight(8)}lpx`) |
| 202 | + } | ||
| 203 | + | ||
| 204 | + calcHeight(value:number): number{ | ||
| 205 | + return value * this.percent | ||
| 176 | } | 206 | } |
| 177 | } | 207 | } |
| 178 | 208 | ||
| @@ -180,6 +210,7 @@ struct getArrowCell { | @@ -180,6 +210,7 @@ struct getArrowCell { | ||
| 180 | struct getTuiJianCell { | 210 | struct getTuiJianCell { |
| 181 | @ObjectLink item: PrivacySettingModel; | 211 | @ObjectLink item: PrivacySettingModel; |
| 182 | index:number = 0; | 212 | index:number = 0; |
| 213 | + @Link percent:number | ||
| 183 | build() { | 214 | build() { |
| 184 | Column() { | 215 | Column() { |
| 185 | 216 | ||
| @@ -187,12 +218,12 @@ struct getTuiJianCell { | @@ -187,12 +218,12 @@ struct getTuiJianCell { | ||
| 187 | // 左侧标题 | 218 | // 左侧标题 |
| 188 | Text(this.item.privacyName) | 219 | Text(this.item.privacyName) |
| 189 | .fontColor('#666666') | 220 | .fontColor('#666666') |
| 190 | - .fontSize('31lpx') | 221 | + .fontSize(`${this.calcHeight(31)}lpx`) |
| 191 | 222 | ||
| 192 | Row() { | 223 | Row() { |
| 193 | Toggle({ type: ToggleType.Switch, isOn: this.item.permission }) | 224 | Toggle({ type: ToggleType.Switch, isOn: this.item.permission }) |
| 194 | - .height('58lpx') | ||
| 195 | - .width('96lpx') | 225 | + .height(`${this.calcHeight(58)}lpx`) |
| 226 | + .width(`${this.calcHeight(96)}lpx`) | ||
| 196 | .selectedColor('#ED2700') | 227 | .selectedColor('#ED2700') |
| 197 | .onChange((isOn: boolean) => { | 228 | .onChange((isOn: boolean) => { |
| 198 | // this.privacySwitch = isOn; | 229 | // this.privacySwitch = isOn; |
| @@ -203,25 +234,29 @@ struct getTuiJianCell { | @@ -203,25 +234,29 @@ struct getTuiJianCell { | ||
| 203 | } | 234 | } |
| 204 | .alignItems(VerticalAlign.Center) | 235 | .alignItems(VerticalAlign.Center) |
| 205 | .justifyContent(FlexAlign.SpaceBetween) | 236 | .justifyContent(FlexAlign.SpaceBetween) |
| 206 | - .height('97lpx') | 237 | + .height(`${this.calcHeight(97)}lpx`) |
| 207 | .width('100%') | 238 | .width('100%') |
| 208 | 239 | ||
| 209 | 240 | ||
| 210 | Blank() | 241 | Blank() |
| 211 | .backgroundColor('#EDEDED') | 242 | .backgroundColor('#EDEDED') |
| 212 | - .height('1lpx') | 243 | + .height(`${this.calcHeight(1)}lpx`) |
| 213 | 244 | ||
| 214 | Text(DiyCloseTipsString) | 245 | Text(DiyCloseTipsString) |
| 215 | .fontColor('#999999') | 246 | .fontColor('#999999') |
| 216 | - .fontSize('23lpx') | ||
| 217 | - .margin({ right: '8lpx' }) | ||
| 218 | - .height('69lpx') | 247 | + .fontSize(`${this.calcHeight(23)}lpx`) |
| 248 | + .margin({ right: `${this.calcHeight(8)}lpx` }) | ||
| 249 | + .height(`${this.calcHeight(69)}lpx`) | ||
| 219 | 250 | ||
| 220 | - } | 251 | + }.width('100%') |
| 221 | .alignItems(HorizontalAlign.Start) | 252 | .alignItems(HorizontalAlign.Start) |
| 222 | .backgroundColor('#FFFFFF') | 253 | .backgroundColor('#FFFFFF') |
| 223 | - .borderRadius('8lpx') | ||
| 224 | - .padding({ left: '29lpx', right: '29lpx' }) | 254 | + .borderRadius(`${this.calcHeight(8)}lpx`) |
| 255 | + .padding({ left: `${this.calcHeight(29)}lpx`, right: `${this.calcHeight(29)}lpx` }) | ||
| 256 | + } | ||
| 257 | + | ||
| 258 | + calcHeight(value:number): number{ | ||
| 259 | + return value * this.percent | ||
| 225 | } | 260 | } |
| 226 | } | 261 | } |
| 227 | 262 |
| @@ -2,7 +2,7 @@ import { MineSettingComponent } from '../setting/MineSettingComponent'; | @@ -2,7 +2,7 @@ import { MineSettingComponent } from '../setting/MineSettingComponent'; | ||
| 2 | import { AccountAndSecurityLayout } from '../setting/AccountAndSecurityLayout'; | 2 | import { AccountAndSecurityLayout } from '../setting/AccountAndSecurityLayout'; |
| 3 | import router from '@ohos.router'; | 3 | import router from '@ohos.router'; |
| 4 | import { Params } from 'wdBean'; | 4 | import { Params } from 'wdBean'; |
| 5 | -import { DateTimeUtils } from 'wdKit/Index'; | 5 | +import { BreakpointSystem, DateTimeUtils } from 'wdKit/Index'; |
| 6 | import { TrackingPageBrowse, TrackConstants } from 'wdTracking/Index'; | 6 | import { TrackingPageBrowse, TrackConstants } from 'wdTracking/Index'; |
| 7 | 7 | ||
| 8 | @Entry | 8 | @Entry |
| @@ -51,6 +51,7 @@ struct SettingPage { | @@ -51,6 +51,7 @@ struct SettingPage { | ||
| 51 | AccountAndSecurityLayout({enterActivityTime:this.enterActivityTime}) | 51 | AccountAndSecurityLayout({enterActivityTime:this.enterActivityTime}) |
| 52 | } | 52 | } |
| 53 | }.setFullWidth() | 53 | }.setFullWidth() |
| 54 | + .backgroundColor($r("app.color.white")) | ||
| 54 | } | 55 | } |
| 55 | 56 | ||
| 56 | // 私有方法 | 57 | // 私有方法 |
| 1 | import { BottomNavi, CommonConstants, SpConstants } from 'wdConstant'; | 1 | import { BottomNavi, CommonConstants, SpConstants } from 'wdConstant'; |
| 2 | -import { Logger, SPHelper, StringUtils } from 'wdKit'; | 2 | +import { BreakpointSystem, Logger, SPHelper, StringUtils } from 'wdKit'; |
| 3 | import PageViewModel from '../../viewmodel/PageViewModel'; | 3 | import PageViewModel from '../../viewmodel/PageViewModel'; |
| 4 | import storageStatistics from "@ohos.file.storageStatistics"; | 4 | import storageStatistics from "@ohos.file.storageStatistics"; |
| 5 | import { BusinessError } from '@ohos.base'; | 5 | import { BusinessError } from '@ohos.base'; |
| @@ -25,6 +25,17 @@ export struct MineSettingComponent { | @@ -25,6 +25,17 @@ export struct MineSettingComponent { | ||
| 25 | @State cacheSize: number = 0 | 25 | @State cacheSize: number = 0 |
| 26 | @State accountState:boolean=false | 26 | @State accountState:boolean=false |
| 27 | preferences: dataPreferences.Preferences | null = null; | 27 | preferences: dataPreferences.Preferences | null = null; |
| 28 | + @StorageProp('currentBreakpoint') @Watch("currentChanged")currentBreakpoint: string = 'sm'; | ||
| 29 | + private breakpointSystem = new BreakpointSystem(); | ||
| 30 | + @State percent:number = 1 | ||
| 31 | + | ||
| 32 | + currentChanged(){ | ||
| 33 | + if(this.currentBreakpoint == "md" || this.currentBreakpoint == "lg"){ | ||
| 34 | + this.percent = 0.7 | ||
| 35 | + }else { | ||
| 36 | + this.percent = 1 | ||
| 37 | + } | ||
| 38 | + } | ||
| 28 | 39 | ||
| 29 | dialogController: CustomDialogController = new CustomDialogController({ | 40 | dialogController: CustomDialogController = new CustomDialogController({ |
| 30 | builder: MyCustomDialog({ | 41 | builder: MyCustomDialog({ |
| @@ -43,6 +54,8 @@ export struct MineSettingComponent { | @@ -43,6 +54,8 @@ export struct MineSettingComponent { | ||
| 43 | customStyle: true | 54 | customStyle: true |
| 44 | }) | 55 | }) |
| 45 | aboutToAppear() { | 56 | aboutToAppear() { |
| 57 | + this.breakpointSystem.register(); | ||
| 58 | + this.currentChanged() | ||
| 46 | // 获取设置页面数据 | 59 | // 获取设置页面数据 |
| 47 | this.getSettingPageData() | 60 | this.getSettingPageData() |
| 48 | 61 | ||
| @@ -54,6 +67,10 @@ export struct MineSettingComponent { | @@ -54,6 +67,10 @@ export struct MineSettingComponent { | ||
| 54 | 67 | ||
| 55 | } | 68 | } |
| 56 | 69 | ||
| 70 | + aboutToDisappear(): void { | ||
| 71 | + this.breakpointSystem.unregister(); | ||
| 72 | + } | ||
| 73 | + | ||
| 57 | async getAccountState(){ | 74 | async getAccountState(){ |
| 58 | let userId=await SPHelper.default.get(SpConstants.USER_ID,'') as string | 75 | let userId=await SPHelper.default.get(SpConstants.USER_ID,'') as string |
| 59 | if(userId==''){ | 76 | if(userId==''){ |
| @@ -91,13 +108,13 @@ export struct MineSettingComponent { | @@ -91,13 +108,13 @@ export struct MineSettingComponent { | ||
| 91 | if (item.type == 0) { | 108 | if (item.type == 0) { |
| 92 | Column() { | 109 | Column() { |
| 93 | this.getArrowCell(item,index) | 110 | this.getArrowCell(item,index) |
| 94 | - }.padding({ left: '27lpx' }).height('117lpx').justifyContent(FlexAlign.Center) | 111 | + }.padding({ left: `${this.calcHeight(27)}lpx` }).height(`${this.calcHeight(117)}lpx`).justifyContent(FlexAlign.Center) |
| 95 | } else if (item.type == 1) { | 112 | } else if (item.type == 1) { |
| 96 | Column() { | 113 | Column() { |
| 97 | this.getSwitchCell(item,index) | 114 | this.getSwitchCell(item,index) |
| 98 | - }.padding({ left: '27lpx' }).height('117lpx').justifyContent(FlexAlign.Center) | 115 | + }.padding({ left: `${this.calcHeight(27)}lpx` }).height(`${this.calcHeight(117)}lpx`).justifyContent(FlexAlign.Center) |
| 99 | } else { | 116 | } else { |
| 100 | - Column().width('100%').height('15lpx').backgroundColor(0xf0f0f0) | 117 | + Column().width('100%').height(`${this.calcHeight(15)}lpx`).backgroundColor(0xf0f0f0) |
| 101 | } | 118 | } |
| 102 | } | 119 | } |
| 103 | }) | 120 | }) |
| @@ -112,7 +129,7 @@ export struct MineSettingComponent { | @@ -112,7 +129,7 @@ export struct MineSettingComponent { | ||
| 112 | @Builder itemHead(text: string) { | 129 | @Builder itemHead(text: string) { |
| 113 | // 列表分组的头部组件,对应联系人分组A、B等位置的组件 | 130 | // 列表分组的头部组件,对应联系人分组A、B等位置的组件 |
| 114 | if (text.length > 0) { | 131 | if (text.length > 0) { |
| 115 | - Row().width('100%').height('20lpx').backgroundColor(0xf0f0f0) | 132 | + Row().width('100%').height(`${this.calcHeight(20)}lpx`).backgroundColor(0xf0f0f0) |
| 116 | } | 133 | } |
| 117 | } | 134 | } |
| 118 | 135 | ||
| @@ -125,28 +142,29 @@ export struct MineSettingComponent { | @@ -125,28 +142,29 @@ export struct MineSettingComponent { | ||
| 125 | // 判断有没有图片 | 142 | // 判断有没有图片 |
| 126 | if (0) { | 143 | if (0) { |
| 127 | Image('https://pic.rmb.bdstatic.com/e182cf67c341d1128d2a6cc05886bf62.jpeg@s_0,h_2000') | 144 | Image('https://pic.rmb.bdstatic.com/e182cf67c341d1128d2a6cc05886bf62.jpeg@s_0,h_2000') |
| 128 | - .height('38lpx') | ||
| 129 | - .margin({ right: '5lpx' }) | 145 | + .height(`${this.calcHeight(38)}lpx`) |
| 146 | + .margin({ right: `${this.calcHeight(5)}lpx` }) | ||
| 130 | 147 | ||
| 131 | Text(`${item.title}`) | 148 | Text(`${item.title}`) |
| 132 | - .margin({ top: '8lpx' }) | ||
| 133 | - .height('38lpx') | 149 | + .margin({ top: `${this.calcHeight(8)}lpx` }) |
| 150 | + .height(`${this.calcHeight(38)}lpx`) | ||
| 134 | .fontColor('#333333') | 151 | .fontColor('#333333') |
| 135 | - .fontSize('29lpx') | 152 | + .fontSize(`${this.calcHeight(29)}lpx`) |
| 136 | } else { | 153 | } else { |
| 137 | Text(`${item.title}`) | 154 | Text(`${item.title}`) |
| 138 | - .margin({ top: '8lpx' }) | ||
| 139 | - .height('38lpx') | 155 | + .margin({ top: `${this.calcHeight(8)}lpx` }) |
| 156 | + .height(`${this.calcHeight(38)}lpx`) | ||
| 140 | .fontColor('#333333') | 157 | .fontColor('#333333') |
| 141 | - .fontSize('29lpx') | 158 | + .fontSize(`${this.calcHeight(29)}lpx`) |
| 142 | } | 159 | } |
| 143 | }.width('60%') | 160 | }.width('60%') |
| 144 | 161 | ||
| 145 | // 右侧文案和右箭头 | 162 | // 右侧文案和右箭头 |
| 146 | Row() { | 163 | Row() { |
| 147 | Toggle({ type: ToggleType.Switch, isOn: item.switchState }) | 164 | Toggle({ type: ToggleType.Switch, isOn: item.switchState }) |
| 148 | - .height('50lpx') | ||
| 149 | - .margin({ left: '81lpx', right: '29lpx' }) | 165 | + .height(`${this.calcHeight(50)}lpx`) |
| 166 | + .width(`${this.calcHeight(96)}lpx`) | ||
| 167 | + .margin({ left: `${this.calcHeight(81)}lpx`, right: `${this.calcHeight(29)}lpx` }) | ||
| 150 | .selectedColor("#ED2800") | 168 | .selectedColor("#ED2800") |
| 151 | .onChange((isOn: boolean) => { | 169 | .onChange((isOn: boolean) => { |
| 152 | if(item.itemType=='push_switch'){ | 170 | if(item.itemType=='push_switch'){ |
| @@ -168,13 +186,13 @@ export struct MineSettingComponent { | @@ -168,13 +186,13 @@ export struct MineSettingComponent { | ||
| 168 | } | 186 | } |
| 169 | }) | 187 | }) |
| 170 | }.width('40%') | 188 | }.width('40%') |
| 171 | - .margin({ right: '29lpx' }) | 189 | + .margin({ right: `${this.calcHeight(29)}lpx` }) |
| 172 | .justifyContent(FlexAlign.End) | 190 | .justifyContent(FlexAlign.End) |
| 173 | 191 | ||
| 174 | } | 192 | } |
| 175 | .alignItems(VerticalAlign.Center) | 193 | .alignItems(VerticalAlign.Center) |
| 176 | .justifyContent(FlexAlign.SpaceBetween) | 194 | .justifyContent(FlexAlign.SpaceBetween) |
| 177 | - }.height('54lpx') | 195 | + }.height(`${this.calcHeight(54)}lpx`) |
| 178 | } | 196 | } |
| 179 | 197 | ||
| 180 | // 右文字+箭头cell | 198 | // 右文字+箭头cell |
| @@ -185,10 +203,10 @@ export struct MineSettingComponent { | @@ -185,10 +203,10 @@ export struct MineSettingComponent { | ||
| 185 | // 左侧logo和标题 | 203 | // 左侧logo和标题 |
| 186 | Row() { | 204 | Row() { |
| 187 | Text(`${item.title}`) | 205 | Text(`${item.title}`) |
| 188 | - .margin({ top: '8lpx' }) | ||
| 189 | - .height('38lpx') | 206 | + .margin({ top: `${this.calcHeight(8)}lpx` }) |
| 207 | + .height(`${this.calcHeight(38)}lpx`) | ||
| 190 | .fontColor('#333333') | 208 | .fontColor('#333333') |
| 191 | - .fontSize('29lpx') | 209 | + .fontSize(`${this.calcHeight(29)}lpx`) |
| 192 | }.width('60%') | 210 | }.width('60%') |
| 193 | 211 | ||
| 194 | // 右侧文案和右箭头 | 212 | // 右侧文案和右箭头 |
| @@ -197,13 +215,13 @@ export struct MineSettingComponent { | @@ -197,13 +215,13 @@ export struct MineSettingComponent { | ||
| 197 | .fontColor('#999999') | 215 | .fontColor('#999999') |
| 198 | .maxLines(1) | 216 | .maxLines(1) |
| 199 | Image($r('app.media.mine_user_arrow_2')) | 217 | Image($r('app.media.mine_user_arrow_2')) |
| 200 | - .width('27lpx') | ||
| 201 | - .height('27lpx') | 218 | + .width(`${this.calcHeight(27)}lpx`) |
| 219 | + .height(`${this.calcHeight(27)}lpx`) | ||
| 202 | .objectFit(ImageFit.Auto) | 220 | .objectFit(ImageFit.Auto) |
| 203 | .interpolation(ImageInterpolation.High) | 221 | .interpolation(ImageInterpolation.High) |
| 204 | - Column().width('29lpx') | 222 | + Column().width(`${this.calcHeight(29)}lpx`) |
| 205 | }.width('40%') | 223 | }.width('40%') |
| 206 | - .margin({ right: '29lpx' }) | 224 | + .margin({ right: `${this.calcHeight(29)}lpx` }) |
| 207 | .justifyContent(FlexAlign.End) | 225 | .justifyContent(FlexAlign.End) |
| 208 | 226 | ||
| 209 | } | 227 | } |
| @@ -211,7 +229,7 @@ export struct MineSettingComponent { | @@ -211,7 +229,7 @@ export struct MineSettingComponent { | ||
| 211 | .justifyContent(FlexAlign.SpaceBetween) | 229 | .justifyContent(FlexAlign.SpaceBetween) |
| 212 | 230 | ||
| 213 | } | 231 | } |
| 214 | - .height('54lpx') | 232 | + .height(`${this.calcHeight(54)}lpx`) |
| 215 | .onClick(() => { | 233 | .onClick(() => { |
| 216 | if (item.itemType == 'account') { | 234 | if (item.itemType == 'account') { |
| 217 | trackButtonClick("settingPageAccountManagement") | 235 | trackButtonClick("settingPageAccountManagement") |
| @@ -266,6 +284,10 @@ export struct MineSettingComponent { | @@ -266,6 +284,10 @@ export struct MineSettingComponent { | ||
| 266 | } | 284 | } |
| 267 | this.preferences.on('change', observer); | 285 | this.preferences.on('change', observer); |
| 268 | } | 286 | } |
| 287 | + | ||
| 288 | + calcHeight(value:number): number{ | ||
| 289 | + return value * this.percent | ||
| 290 | + } | ||
| 269 | } | 291 | } |
| 270 | 292 | ||
| 271 | function trackButtonClick(buttonName: string){ | 293 | function trackButtonClick(buttonName: string){ |
-
Please register or login to post a comment