From aa3dded15c96968d556549490c04a61aebd7cc6c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BE=90=E5=8B=A4=E6=B0=91?= Date: Thu, 7 Nov 2024 15:28:14 +0800 Subject: [PATCH] =?UTF-8?q?feat(ywq):=20=E6=96=B0=E5=A2=9E=E5=9E=83?= =?UTF-8?q?=E5=9C=BE=E7=AE=B1=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 添加垃圾箱列表接口和相关数据模型 - 实现垃圾箱视图,包括列表展示和筛选功能 - 优化订单项组件,增加作废、删除等状态展示 - 更新路由配置,支持垃圾箱页面导航- 重构列表对话框组件,支持单选和取消功能 --- src/main/ets/pages/XWebview.ets | 2 +- src/main/ets/utils/ToolsHelper.ets | 112 ++++++++++++++++++++--------- 2 files changed, 78 insertions(+), 36 deletions(-) diff --git a/src/main/ets/pages/XWebview.ets b/src/main/ets/pages/XWebview.ets index e7e4d05..f4c6699 100644 --- a/src/main/ets/pages/XWebview.ets +++ b/src/main/ets/pages/XWebview.ets @@ -110,7 +110,7 @@ export struct XWebview { .justifyContent(FlexAlign.SpaceBetween) .padding({ left: 15, right: 15 }) - Divider().height(2).color(0xCCCCCC) + Row().backgroundColor('#CCCCCC').height(2).width('100%') Progress({ value: this.progress, type: ProgressType.Linear }) .visibility(this.progress > 95 || this.progress == 0 ? Visibility.None : Visibility.Visible) .width('100%') diff --git a/src/main/ets/utils/ToolsHelper.ets b/src/main/ets/utils/ToolsHelper.ets index 55e9957..e8fb500 100644 --- a/src/main/ets/utils/ToolsHelper.ets +++ b/src/main/ets/utils/ToolsHelper.ets @@ -28,6 +28,7 @@ export interface ConfirmOptions { export interface ListOptions { title?: string cancel?: Btn + index?: number alignment?: DialogAlignment values: Array onSelected: (index: number, value: T) => void @@ -43,22 +44,39 @@ function customDialogBuilder(option: ListOptions, dialogTag: string) { Column() { Text(option.title) - .fontSize(13) + .fontSize(16) + .fontColor('#00BE87') .textAlign(TextAlign.Center) - .width('60%') - .maxLines(2) - .ellipsisMode(EllipsisMode.END) - .textOverflow({ - overflow: TextOverflow.Ellipsis + .width('100%') + .height(60) + .backgroundColor('#F0FFFA') + .borderRadius({ + topLeft: 10, + topRight: 10 }) .visibility(option.title ? Visibility.Visible : Visibility.None) - List({ space: 20, initialIndex: 0 }) { - ForEach(option.values, (item: T, index: number) => { - ListItem() { - Text(typeof item === "string" ? item : (item as ListItem).content) + Column(){ + List() { + ForEach(option.values, (item: T, index: number) => { + ListItem() { + Row() { + Text(typeof item === "string" ? item : (item as ListItem).content) + .fontSize(option.index === index ? 16 : 14) + .fontWeight(option.index === index ? FontWeight.Bold : FontWeight.Normal) + .maxLines(1) + .width('70%') + .ellipsisMode(EllipsisMode.CENTER) + .textOverflow({ + overflow: TextOverflow.Ellipsis + }) + .textAlign(TextAlign.Center) + .align(Alignment.Center) + .fontColor('#11102C') + } + .alignItems(VerticalAlign.Center) + .justifyContent(FlexAlign.Center) + .height(60) .width('100%') - .fontSize(16) - .textAlign(TextAlign.Center) .onClick(() => { if (ToolsHelper.mapDialog.get(dialogTag)) { promptAction.closeCustomDialog(ToolsHelper.mapDialog.get(dialogTag)) @@ -66,29 +84,47 @@ function customDialogBuilder(option: ListOptions, dialogTag: string) { } option.onSelected(index, item) }) + } + }, (item: T) => typeof item === "string" ? item : (item as ListItem).content) + } + .listDirection(Axis.Vertical) // 排列方向 + .scrollBar(BarState.Off) + .friction(0.6) + .divider({ + strokeWidth: 1, + color: '#F6F6F6', + }) // 每行之间的分界线 + .edgeEffect(EdgeEffect.Spring) // 边缘效果设置为Spring + .width('100%') + .height(option.values === undefined ? '20%' :option.values.length < 5 ? option.values.length*60 : 300) + + if (option.cancel) { + Column() { + Text(option.cancel.text ?? '取消') + .fontSize(16) + .fontColor(option.cancel.color ?? '#777777') + .textAlign(TextAlign.Center) + .width(325) + .height(44) + .backgroundColor('white') + .borderRadius(22) + .borderWidth(1) + .borderColor('#D7D7D7') } - }, (item: string) => item) - } - .listDirection(Axis.Vertical) // 排列方向 - .scrollBar(BarState.Off) - .friction(0.6) - .divider({ - strokeWidth: 1, - color: 0xEEEEEE, - startMargin: 20, - endMargin: 20 - }) // 每行之间的分界线 - .edgeEffect(EdgeEffect.Spring) // 边缘效果设置为Spring - .width('100%') - .height(option.values.length < 8 ? `${option.values.length / 16 * 100}%` : '50%') - .margin({ top: 20 }) - } - .padding({ - top: 20, - bottom: 20, - left: 20, - right: 20 - }) + .onClick(() => { + if (ToolsHelper.mapDialog.get(dialogTag)) { + promptAction.closeCustomDialog(ToolsHelper.mapDialog.get(dialogTag)) + ToolsHelper.mapDialog.remove(dialogTag) + } + option.cancel?.onClick && option.cancel.onClick() + }) + .height(71) + .width('100%') + .alignItems(HorizontalAlign.Center) + .justifyContent(FlexAlign.Center) + } + }.justifyContent(FlexAlign.End) + }.justifyContent(FlexAlign.Start) } interface ThrottleInterface { @@ -236,8 +272,14 @@ export class ToolsHelper { } else { const dialogTag = ToolsHelper.getUuid() promptAction.openCustomDialog({ + cornerRadius: 0, + autoCancel: false, + width: '100%', + // height: options.values === undefined ? '20%' : + // options.values?.length < 8 ? `${options.values?.length / 16 * 100+10}%` : '50%', alignment: options.alignment ?? DialogAlignment.Bottom, - builder: customDialogBuilder.bind(p, options, dialogTag) + builder: customDialogBuilder.bind(p, options, dialogTag), + backgroundColor: 'white' }).then((dialogId: number) => { ToolsHelper.mapDialog.set(dialogTag, dialogId) })