fix: ListView 每行固定高度,避免记录叠在一起

This commit is contained in:
2026-11-19 15:57:43 +08:00
parent 0ceb334988
commit 5bffa0d87f
+36 -51
View File
@@ -11,23 +11,22 @@ export struct DayRow {
problem: bool, problem: bool,
} }
component Hairline inherits Rectangle { component DayBlock inherits Rectangle {
height: 1px;
background: #e6e6e3;
}
component DayBlock inherits VerticalLayout {
in property <DayRow> day; in property <DayRow> day;
width: 100%; height: 168px;
background: transparent;
VerticalLayout {
width: parent.width;
height: parent.height;
padding-left: 24px; padding-left: 24px;
padding-right: 24px; padding-right: 24px;
padding-top: 16px; padding-top: 14px;
padding-bottom: 16px; padding-bottom: 14px;
spacing: 8px; spacing: 8px;
alignment: start; alignment: start;
HorizontalLayout { HorizontalLayout {
width: 100%;
spacing: 16px; spacing: 16px;
alignment: start; alignment: start;
@@ -38,7 +37,6 @@ component DayBlock inherits VerticalLayout {
font-weight: 600; font-weight: 600;
color: #1a1a1a; color: #1a1a1a;
horizontal-alignment: left; horizontal-alignment: left;
vertical-alignment: center;
} }
Text { Text {
text: day.time; text: day.time;
@@ -46,7 +44,6 @@ component DayBlock inherits VerticalLayout {
font-size: 13px; font-size: 13px;
color: #6a6a6a; color: #6a6a6a;
horizontal-alignment: left; horizontal-alignment: left;
vertical-alignment: center;
} }
Text { Text {
text: day.hours; text: day.hours;
@@ -54,32 +51,25 @@ component DayBlock inherits VerticalLayout {
font-size: 13px; font-size: 13px;
color: #6a6a6a; color: #6a6a6a;
horizontal-alignment: left; horizontal-alignment: left;
vertical-alignment: center;
} }
if day.mark != "": Text { if day.mark != "": Text {
text: day.mark; text: day.mark;
font-size: 13px; font-size: 13px;
color: #6a6a6a; color: #6a6a6a;
horizontal-alignment: left; horizontal-alignment: left;
vertical-alignment: center;
}
Rectangle {
horizontal-stretch: 1;
min-width: 0px;
} }
Rectangle { horizontal-stretch: 1; }
Text { Text {
text: day.status; text: day.status;
min-width: 96px; min-width: 96px;
font-size: 13px; font-size: 13px;
color: day.problem ? #1a1a1a : #6a6a6a; color: day.problem ? #1a1a1a : #6a6a6a;
horizontal-alignment: right; horizontal-alignment: right;
vertical-alignment: center;
} }
} }
if day.site != "": Text { if day.site != "": Text {
text: day.site; text: day.site;
width: 100%;
wrap: word-wrap; wrap: word-wrap;
font-size: 12px; font-size: 12px;
color: #8a8a8a; color: #8a8a8a;
@@ -88,12 +78,19 @@ component DayBlock inherits VerticalLayout {
if day.memo != "": Text { if day.memo != "": Text {
text: day.memo; text: day.memo;
width: 100%;
wrap: word-wrap; wrap: word-wrap;
font-size: 14px; font-size: 14px;
color: #1a1a1a; color: #1a1a1a;
horizontal-alignment: left; horizontal-alignment: left;
} }
Rectangle { vertical-stretch: 1; }
Rectangle {
height: 1px;
background: #e6e6e3;
}
}
} }
export component MainWindow inherits Window { export component MainWindow inherits Window {
@@ -109,13 +106,15 @@ export component MainWindow inherits Window {
default-font-family: "Segoe UI"; default-font-family: "Segoe UI";
VerticalLayout { VerticalLayout {
width: 100%; padding: 0px;
height: 100%;
alignment: start; alignment: start;
HorizontalLayout { Rectangle {
width: 100%;
height: 52px; height: 52px;
background: #f7f7f5;
HorizontalLayout {
width: parent.width;
height: parent.height;
padding-left: 24px; padding-left: 24px;
padding-right: 24px; padding-right: 24px;
spacing: 16px; spacing: 16px;
@@ -126,65 +125,51 @@ export component MainWindow inherits Window {
font-size: 16px; font-size: 16px;
font-weight: 600; font-weight: 600;
color: #1a1a1a; color: #1a1a1a;
horizontal-alignment: left;
vertical-alignment: center; vertical-alignment: center;
horizontal-alignment: left;
} }
Text { Text {
text: root.range; text: root.range;
font-size: 13px; font-size: 13px;
color: #8a8a8a; color: #8a8a8a;
horizontal-alignment: left;
vertical-alignment: center; vertical-alignment: center;
horizontal-alignment: left;
} }
Rectangle { Rectangle { horizontal-stretch: 1; }
horizontal-stretch: 1;
min-width: 0px;
}
Text { Text {
text: "刷新"; text: "刷新";
font-size: 13px; font-size: 13px;
color: #1a1a1a; color: #1a1a1a;
horizontal-alignment: right;
vertical-alignment: center; vertical-alignment: center;
horizontal-alignment: right;
TouchArea { clicked => { root.refresh(); } } TouchArea { clicked => { root.refresh(); } }
} }
} }
}
Hairline {} Rectangle {
height: 1px;
background: #e6e6e3;
}
if root.error != "": VerticalLayout { if root.error != "": Text {
width: 100%;
padding: 24px;
alignment: start;
Text {
text: root.error; text: root.error;
width: 100%;
wrap: word-wrap; wrap: word-wrap;
font-size: 14px; font-size: 14px;
color: #1a1a1a; color: #1a1a1a;
horizontal-alignment: left; horizontal-alignment: left;
} }
}
if root.error == "" && root.days.length == 0: VerticalLayout { if root.error == "" && root.days.length == 0: Text {
width: 100%;
padding: 24px;
alignment: start;
Text {
text: "这一周没有打卡记录。"; text: "这一周没有打卡记录。";
font-size: 14px; font-size: 14px;
color: #8a8a8a; color: #8a8a8a;
horizontal-alignment: left; horizontal-alignment: left;
} }
}
if root.error == "" && root.days.length > 0: ListView { if root.error == "" && root.days.length > 0: ListView {
vertical-stretch: 1; vertical-stretch: 1;
for day in root.days: VerticalLayout { for day in root.days: DayBlock { day: day; }
alignment: start;
DayBlock { day: day; }
Hairline {}
}
} }
} }
} }