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

This commit is contained in:
2026-11-19 16:01:18 +08:00
parent 5bffa0d87f
commit 6c7bc68cd6
+70 -54
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,84 +13,90 @@ 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 {
width: parent.width;
height: parent.height;
padding-left: 24px;
padding-right: 24px;
padding-top: 14px;
padding-bottom: 14px;
spacing: 8px;
alignment: start;
HorizontalLayout {
spacing: 16px;
alignment: start;
Text { Text {
text: day.date; x: 24px;
y: 14px;
width: 56px; width: 56px;
text: day.date;
font-size: 15px; font-size: 15px;
font-weight: 600; font-weight: 600;
color: #1a1a1a; color: #1a1a1a;
horizontal-alignment: left; horizontal-alignment: left;
} }
Text { Text {
x: 88px;
y: 16px;
width: 120px;
text: day.time; text: day.time;
width: 112px;
font-size: 13px; font-size: 13px;
color: #6a6a6a; color: #6a6a6a;
horizontal-alignment: left; horizontal-alignment: left;
} }
Text { Text {
x: 216px;
y: 16px;
width: 52px;
text: day.hours; text: day.hours;
width: 48px;
font-size: 13px; font-size: 13px;
color: #6a6a6a; color: #6a6a6a;
horizontal-alignment: left; horizontal-alignment: left;
} }
if day.mark != "": Text { if day.mark != "": Text {
x: 276px;
y: 16px;
text: day.mark; text: day.mark;
font-size: 13px; font-size: 13px;
color: #6a6a6a; color: #6a6a6a;
horizontal-alignment: left; horizontal-alignment: left;
} }
Rectangle { horizontal-stretch: 1; }
Text { Text {
x: parent.width - 24px - self.width;
y: 16px;
text: day.status; text: day.status;
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;
} }
}
if day.site != "": Text { Text {
x: 24px;
y: 42px;
width: parent.width - 48px;
height: 18px;
text: day.site; text: day.site;
wrap: word-wrap;
font-size: 12px; font-size: 12px;
color: #8a8a8a; color: #8a8a8a;
horizontal-alignment: left; horizontal-alignment: left;
overflow: elide;
} }
if day.memo != "": Text { Text {
x: 24px;
y: 64px;
width: parent.width - 48px;
height: 52px;
text: day.memo; text: day.memo;
wrap: word-wrap;
font-size: 14px; font-size: 14px;
color: #1a1a1a; color: #1a1a1a;
wrap: word-wrap;
horizontal-alignment: left; horizontal-alignment: left;
vertical-alignment: top;
} }
Rectangle { vertical-stretch: 1; }
Rectangle { Rectangle {
x: 0px;
y: parent.height - 1px;
width: parent.width;
height: 1px; height: 1px;
background: #e6e6e3; background: #e6e6e3;
} }
}
} }
export component MainWindow inherits Window { export component MainWindow inherits Window {
@@ -105,54 +111,54 @@ export component MainWindow inherits Window {
background: #f7f7f5; background: #f7f7f5;
default-font-family: "Segoe UI"; default-font-family: "Segoe UI";
VerticalLayout {
padding: 0px;
alignment: start;
Rectangle {
height: 52px;
background: #f7f7f5;
HorizontalLayout {
width: parent.width;
height: parent.height;
padding-left: 24px;
padding-right: 24px;
spacing: 16px;
alignment: start;
Text { Text {
x: 24px;
y: 16px;
text: "打卡"; text: "打卡";
font-size: 16px; font-size: 16px;
font-weight: 600; font-weight: 600;
color: #1a1a1a; color: #1a1a1a;
vertical-alignment: center;
horizontal-alignment: left; horizontal-alignment: left;
} }
Text { Text {
x: 72px;
y: 18px;
text: root.range; text: root.range;
font-size: 13px; font-size: 13px;
color: #8a8a8a; color: #8a8a8a;
vertical-alignment: center;
horizontal-alignment: left; horizontal-alignment: left;
} }
Rectangle { horizontal-stretch: 1; }
TouchArea {
x: parent.width - 72px;
y: 0px;
width: 72px;
height: 52px;
Text { Text {
x: 0px;
y: 18px;
width: parent.width;
text: "刷新"; text: "刷新";
font-size: 13px; font-size: 13px;
color: #1a1a1a; color: #1a1a1a;
vertical-alignment: center;
horizontal-alignment: right; horizontal-alignment: right;
TouchArea { clicked => { root.refresh(); } }
}
} }
clicked => { root.refresh(); }
} }
Rectangle { Rectangle {
x: 0px;
y: 51px;
width: parent.width;
height: 1px; height: 1px;
background: #e6e6e3; background: #e6e6e3;
} }
if root.error != "": Text { if root.error != "": Text {
x: 24px;
y: 68px;
width: parent.width - 48px;
text: root.error; text: root.error;
wrap: word-wrap; wrap: word-wrap;
font-size: 14px; font-size: 14px;
@@ -161,15 +167,25 @@ export component MainWindow inherits Window {
} }
if root.error == "" && root.days.length == 0: Text { if root.error == "" && root.days.length == 0: Text {
x: 24px;
y: 68px;
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: ScrollView {
vertical-stretch: 1; x: 0px;
for day in root.days: DayBlock { day: day; } y: 52px;
width: parent.width;
height: parent.height - 52px;
VerticalLayout {
alignment: start;
padding: 0px;
for day in root.days: DayBlock {
day: day;
}
} }
} }
} }