fix: 列表从第一条开始按固定行显示

This commit is contained in:
2026-11-19 16:01:18 +08:00
parent 5bffa0d87f
commit 6c7bc68cd6
+151 -135
View File
@@ -1,4 +1,4 @@
import { ListView } from "std-widgets.slint"; import { ScrollView } from "std-widgets.slint";
export struct DayRow { export struct DayRow {
date: string, date: string,
@@ -13,83 +13,89 @@ export struct DayRow {
component DayBlock inherits Rectangle { component DayBlock inherits Rectangle {
in property <DayRow> day; in property <DayRow> day;
height: 168px; height: 132px;
background: transparent; background: #f7f7f5;
VerticalLayout { Text {
x: 24px;
y: 14px;
width: 56px;
text: day.date;
font-size: 15px;
font-weight: 600;
color: #1a1a1a;
horizontal-alignment: left;
}
Text {
x: 88px;
y: 16px;
width: 120px;
text: day.time;
font-size: 13px;
color: #6a6a6a;
horizontal-alignment: left;
}
Text {
x: 216px;
y: 16px;
width: 52px;
text: day.hours;
font-size: 13px;
color: #6a6a6a;
horizontal-alignment: left;
}
if day.mark != "": Text {
x: 276px;
y: 16px;
text: day.mark;
font-size: 13px;
color: #6a6a6a;
horizontal-alignment: left;
}
Text {
x: parent.width - 24px - self.width;
y: 16px;
text: day.status;
font-size: 13px;
color: day.problem ? #1a1a1a : #6a6a6a;
horizontal-alignment: right;
}
Text {
x: 24px;
y: 42px;
width: parent.width - 48px;
height: 18px;
text: day.site;
font-size: 12px;
color: #8a8a8a;
horizontal-alignment: left;
overflow: elide;
}
Text {
x: 24px;
y: 64px;
width: parent.width - 48px;
height: 52px;
text: day.memo;
font-size: 14px;
color: #1a1a1a;
wrap: word-wrap;
horizontal-alignment: left;
vertical-alignment: top;
}
Rectangle {
x: 0px;
y: parent.height - 1px;
width: parent.width; width: parent.width;
height: parent.height; height: 1px;
padding-left: 24px; background: #e6e6e3;
padding-right: 24px;
padding-top: 14px;
padding-bottom: 14px;
spacing: 8px;
alignment: start;
HorizontalLayout {
spacing: 16px;
alignment: start;
Text {
text: day.date;
width: 56px;
font-size: 15px;
font-weight: 600;
color: #1a1a1a;
horizontal-alignment: left;
}
Text {
text: day.time;
width: 112px;
font-size: 13px;
color: #6a6a6a;
horizontal-alignment: left;
}
Text {
text: day.hours;
width: 48px;
font-size: 13px;
color: #6a6a6a;
horizontal-alignment: left;
}
if day.mark != "": Text {
text: day.mark;
font-size: 13px;
color: #6a6a6a;
horizontal-alignment: left;
}
Rectangle { horizontal-stretch: 1; }
Text {
text: day.status;
min-width: 96px;
font-size: 13px;
color: day.problem ? #1a1a1a : #6a6a6a;
horizontal-alignment: right;
}
}
if day.site != "": Text {
text: day.site;
wrap: word-wrap;
font-size: 12px;
color: #8a8a8a;
horizontal-alignment: left;
}
if day.memo != "": Text {
text: day.memo;
wrap: word-wrap;
font-size: 14px;
color: #1a1a1a;
horizontal-alignment: left;
}
Rectangle { vertical-stretch: 1; }
Rectangle {
height: 1px;
background: #e6e6e3;
}
} }
} }
@@ -105,71 +111,81 @@ export component MainWindow inherits Window {
background: #f7f7f5; background: #f7f7f5;
default-font-family: "Segoe UI"; default-font-family: "Segoe UI";
VerticalLayout { Text {
padding: 0px; x: 24px;
alignment: start; y: 16px;
text: "打卡";
font-size: 16px;
font-weight: 600;
color: #1a1a1a;
horizontal-alignment: left;
}
Rectangle { Text {
height: 52px; x: 72px;
background: #f7f7f5; y: 18px;
HorizontalLayout { text: root.range;
width: parent.width; font-size: 13px;
height: parent.height; color: #8a8a8a;
padding-left: 24px; horizontal-alignment: left;
padding-right: 24px; }
spacing: 16px;
alignment: start;
Text { TouchArea {
text: "打卡"; x: parent.width - 72px;
font-size: 16px; y: 0px;
font-weight: 600; width: 72px;
color: #1a1a1a; height: 52px;
vertical-alignment: center; Text {
horizontal-alignment: left; x: 0px;
} y: 18px;
Text { width: parent.width;
text: root.range; text: "刷新";
font-size: 13px; font-size: 13px;
color: #8a8a8a;
vertical-alignment: center;
horizontal-alignment: left;
}
Rectangle { horizontal-stretch: 1; }
Text {
text: "刷新";
font-size: 13px;
color: #1a1a1a;
vertical-alignment: center;
horizontal-alignment: right;
TouchArea { clicked => { root.refresh(); } }
}
}
}
Rectangle {
height: 1px;
background: #e6e6e3;
}
if root.error != "": Text {
text: root.error;
wrap: word-wrap;
font-size: 14px;
color: #1a1a1a; color: #1a1a1a;
horizontal-alignment: left; horizontal-alignment: right;
} }
clicked => { root.refresh(); }
}
if root.error == "" && root.days.length == 0: Text { Rectangle {
text: "这一周没有打卡记录。"; x: 0px;
font-size: 14px; y: 51px;
color: #8a8a8a; width: parent.width;
horizontal-alignment: left; height: 1px;
} background: #e6e6e3;
}
if root.error == "" && root.days.length > 0: ListView { if root.error != "": Text {
vertical-stretch: 1; x: 24px;
for day in root.days: DayBlock { day: day; } y: 68px;
width: parent.width - 48px;
text: root.error;
wrap: word-wrap;
font-size: 14px;
color: #1a1a1a;
horizontal-alignment: left;
}
if root.error == "" && root.days.length == 0: Text {
x: 24px;
y: 68px;
text: "这一周没有打卡记录。";
font-size: 14px;
color: #8a8a8a;
horizontal-alignment: left;
}
if root.error == "" && root.days.length > 0: ScrollView {
x: 0px;
y: 52px;
width: parent.width;
height: parent.height - 52px;
VerticalLayout {
alignment: start;
padding: 0px;
for day in root.days: DayBlock {
day: day;
}
} }
} }
} }