From 33053cb39324e1138dec2a3a4f14ca2ca61e8adf Mon Sep 17 00:00:00 2001 From: wcmzllx Date: Wed, 22 May 2024 19:09:14 +0800 Subject: [PATCH] =?UTF-8?q?=E9=87=8D=E6=9E=84=E6=88=91=E7=9A=84=E4=B8=AD?= =?UTF-8?q?=E5=BF=83=E6=A0=87=E9=A2=98=E6=A0=8F=EF=BC=8C=E8=87=AA=E9=80=82?= =?UTF-8?q?=E5=BA=94=E5=B1=85=E4=B8=AD=EF=BC=8C=E8=8F=9C=E5=8D=95=E5=92=8C?= =?UTF-8?q?=E7=BC=96=E8=BE=91=E6=8C=89=E9=92=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ets/componets/myCenter/MyCenterTitle.ets | 72 +++++++++++++++++++ .../ets/componets/myCenter/myCenterTitle.ets | 24 ------- .../ets/pages/view/myCenter/clearCache.ets | 4 +- .../ets/pages/view/myCenter/cloudDisk.ets | 4 +- .../main/ets/pages/view/myCenter/diskSet.ets | 4 +- .../resources/base/media/more_vertical.svg | 5 ++ 6 files changed, 83 insertions(+), 30 deletions(-) create mode 100644 entry/src/main/ets/componets/myCenter/MyCenterTitle.ets delete mode 100644 entry/src/main/ets/componets/myCenter/myCenterTitle.ets create mode 100644 entry/src/main/resources/base/media/more_vertical.svg diff --git a/entry/src/main/ets/componets/myCenter/MyCenterTitle.ets b/entry/src/main/ets/componets/myCenter/MyCenterTitle.ets new file mode 100644 index 00000000..fe0a5acc --- /dev/null +++ b/entry/src/main/ets/componets/myCenter/MyCenterTitle.ets @@ -0,0 +1,72 @@ +import { router } from '@kit.ArkUI' +import CommonConstants from '../../common/constants/CommonConstants' + +@Component +export struct MyCenterTitle{ + + @Prop title:string + + // 是否显示编辑按钮 + isShowEdit?:boolean = false + // 是否显示菜单 + isShowMore?:boolean = false + + // 编辑标题按钮事件 + onEditClickEvent?: (event: ClickEvent) => void + // 更多菜单按钮 + onMoreClickEvent?: (event: ClickEvent) => void + + @StorageProp('topRectHeight') topRectHeight: number = 0 + + // 重构 我的中心标题栏 + build() { + Column(){ + // 如果同步状态栏高度不成功,默认40 + Blank(this.topRectHeight == 0 ? 40 : this.topRectHeight) + + Row(){ + Image($r("app.media.return_left")) + .size({width:CommonConstants.TITLE_IMG_SIZE,height:CommonConstants.TITLE_IMG_SIZE}) + .onClick(()=>{ + router.back() + }) + + Row(){ + Row(){ + if (this.isShowEdit){ + // 左占位 + Blank(CommonConstants.TITLE_IMG_SIZE) + .margin({right: 8}) + } + + // 标题 + Text(this.title).fontSize(16).fontWeight(600).lineHeight(24) + .textAlign(TextAlign.Center) + + // 修改标题的 笔图标 + if (this.isShowEdit){ + Image($r("app.media.ic_public_edit")) + .size({width:CommonConstants.TITLE_IMG_SIZE,height:CommonConstants.TITLE_IMG_SIZE}) + .margin({left: 8}) + .onClick(this.onEditClickEvent) + } + } + } + .justifyContent(FlexAlign.Center) + .layoutWeight(1) // 占满剩余空间 + + // 修改标题的 菜单标 + if (this.isShowMore){ + Image($r("app.media.more_vertical")) + .size({width:CommonConstants.TITLE_IMG_SIZE,height:CommonConstants.TITLE_IMG_SIZE}) + .onClick(this.onMoreClickEvent) + }else { // 占位,保持标题居中 + Blank(CommonConstants.TITLE_IMG_SIZE) + } + } + // 固定高度不能适配所有设备,应该100%,主轴居中显示 + .width("100%").justifyContent(FlexAlign.Center).padding({top:12,bottom:12}) + //.width(320).justifyContent(FlexAlign.Start).padding({top:12,bottom:12}) + } + } +} \ No newline at end of file diff --git a/entry/src/main/ets/componets/myCenter/myCenterTitle.ets b/entry/src/main/ets/componets/myCenter/myCenterTitle.ets deleted file mode 100644 index c704e06c..00000000 --- a/entry/src/main/ets/componets/myCenter/myCenterTitle.ets +++ /dev/null @@ -1,24 +0,0 @@ -import { router } from '@kit.ArkUI' -import CommonConstants from '../../common/constants/CommonConstants' - -@Component -export struct myCenterTitle{ - - @Prop title:string - - build() { - Column(){ - Blank(40) - Row(){ - Row(){ - Image($r("app.media.return_left")) - .size({width:CommonConstants.TITLE_IMG_SIZE,height:CommonConstants.TITLE_IMG_SIZE}) - .onClick(()=>{ - router.back() - }) - }.width("40%") - Text(this.title).fontSize(16).fontWeight(600).lineHeight(24) - }.width(320).justifyContent(FlexAlign.Start).padding({top:12,bottom:12}) - } - } -} \ No newline at end of file diff --git a/entry/src/main/ets/pages/view/myCenter/clearCache.ets b/entry/src/main/ets/pages/view/myCenter/clearCache.ets index 13b029f0..bb98c60a 100644 --- a/entry/src/main/ets/pages/view/myCenter/clearCache.ets +++ b/entry/src/main/ets/pages/view/myCenter/clearCache.ets @@ -1,5 +1,5 @@ import { dataItem } from '../../../componets/dataList/dataItem' -import { myCenterTitle } from '../../../componets/myCenter/myCenterTitle' +import { MyCenterTitle } from '../../../componets/myCenter/MyCenterTitle' import { serviceDialog } from '../../../componets/webDavService/serviceDialog' @Entry @@ -17,7 +17,7 @@ struct clearCache{ build() { Column({space:12}){ //标题栏 - myCenterTitle({title:"清理缓存"}) + MyCenterTitle({title:"清理缓存"}) Column(){ ForEach(this.clearList,(item:dataItem,index:number)=>{ Row({space:10}){ diff --git a/entry/src/main/ets/pages/view/myCenter/cloudDisk.ets b/entry/src/main/ets/pages/view/myCenter/cloudDisk.ets index a597585b..44517b4c 100644 --- a/entry/src/main/ets/pages/view/myCenter/cloudDisk.ets +++ b/entry/src/main/ets/pages/view/myCenter/cloudDisk.ets @@ -1,6 +1,6 @@ import { promptAction, router } from '@kit.ArkUI'; import { dataItem } from '../../../componets/dataList/dataItem'; -import { myCenterTitle } from '../../../componets/myCenter/myCenterTitle'; +import { MyCenterTitle } from '../../../componets/myCenter/MyCenterTitle'; import { cloudDisKBindSheetComponet } from '../../../componets/myCenter/cloudDisKBindSheetComponet'; @Entry @@ -147,7 +147,7 @@ struct CloudDisk { Column() { //标题栏 - myCenterTitle({title:"云备份"}) + MyCenterTitle({title:"云备份"}) //备份图片及按钮 Column(){ Column(){ diff --git a/entry/src/main/ets/pages/view/myCenter/diskSet.ets b/entry/src/main/ets/pages/view/myCenter/diskSet.ets index 1974c67e..0f5f19c3 100644 --- a/entry/src/main/ets/pages/view/myCenter/diskSet.ets +++ b/entry/src/main/ets/pages/view/myCenter/diskSet.ets @@ -1,7 +1,7 @@ import { ColumnModifier } from '../../../common/utils/ComponetModifier'; import { dataItem } from '../../../componets/dataList/dataItem'; -import { myCenterTitle } from '../../../componets/myCenter/myCenterTitle'; +import { MyCenterTitle } from '../../../componets/myCenter/MyCenterTitle'; import { diskComponet } from '../../../componets/myCenter/diskComponet'; @@ -83,7 +83,7 @@ struct DiskSet { build() { Column() { //标题栏 - myCenterTitle({title:"备份设置"}) + MyCenterTitle({title:"备份设置"}) Column(){ diskComponet({ diff --git a/entry/src/main/resources/base/media/more_vertical.svg b/entry/src/main/resources/base/media/more_vertical.svg new file mode 100644 index 00000000..9fcb40df --- /dev/null +++ b/entry/src/main/resources/base/media/more_vertical.svg @@ -0,0 +1,5 @@ + + + + +