fix: 列表从第一条开始按固定行显示
This commit is contained in:
+151
-135
@@ -1,4 +1,4 @@
|
||||
import { ListView } from "std-widgets.slint";
|
||||
import { ScrollView } from "std-widgets.slint";
|
||||
|
||||
export struct DayRow {
|
||||
date: string,
|
||||
@@ -13,83 +13,89 @@ export struct DayRow {
|
||||
|
||||
component DayBlock inherits Rectangle {
|
||||
in property <DayRow> day;
|
||||
height: 168px;
|
||||
background: transparent;
|
||||
height: 132px;
|
||||
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;
|
||||
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: 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;
|
||||
}
|
||||
height: 1px;
|
||||
background: #e6e6e3;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -105,71 +111,81 @@ export component MainWindow inherits Window {
|
||||
background: #f7f7f5;
|
||||
default-font-family: "Segoe UI";
|
||||
|
||||
VerticalLayout {
|
||||
padding: 0px;
|
||||
alignment: start;
|
||||
Text {
|
||||
x: 24px;
|
||||
y: 16px;
|
||||
text: "打卡";
|
||||
font-size: 16px;
|
||||
font-weight: 600;
|
||||
color: #1a1a1a;
|
||||
horizontal-alignment: left;
|
||||
}
|
||||
|
||||
Rectangle {
|
||||
height: 52px;
|
||||
background: #f7f7f5;
|
||||
HorizontalLayout {
|
||||
width: parent.width;
|
||||
height: parent.height;
|
||||
padding-left: 24px;
|
||||
padding-right: 24px;
|
||||
spacing: 16px;
|
||||
alignment: start;
|
||||
Text {
|
||||
x: 72px;
|
||||
y: 18px;
|
||||
text: root.range;
|
||||
font-size: 13px;
|
||||
color: #8a8a8a;
|
||||
horizontal-alignment: left;
|
||||
}
|
||||
|
||||
Text {
|
||||
text: "打卡";
|
||||
font-size: 16px;
|
||||
font-weight: 600;
|
||||
color: #1a1a1a;
|
||||
vertical-alignment: center;
|
||||
horizontal-alignment: left;
|
||||
}
|
||||
Text {
|
||||
text: root.range;
|
||||
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;
|
||||
TouchArea {
|
||||
x: parent.width - 72px;
|
||||
y: 0px;
|
||||
width: 72px;
|
||||
height: 52px;
|
||||
Text {
|
||||
x: 0px;
|
||||
y: 18px;
|
||||
width: parent.width;
|
||||
text: "刷新";
|
||||
font-size: 13px;
|
||||
color: #1a1a1a;
|
||||
horizontal-alignment: left;
|
||||
horizontal-alignment: right;
|
||||
}
|
||||
clicked => { root.refresh(); }
|
||||
}
|
||||
|
||||
if root.error == "" && root.days.length == 0: Text {
|
||||
text: "这一周没有打卡记录。";
|
||||
font-size: 14px;
|
||||
color: #8a8a8a;
|
||||
horizontal-alignment: left;
|
||||
}
|
||||
Rectangle {
|
||||
x: 0px;
|
||||
y: 51px;
|
||||
width: parent.width;
|
||||
height: 1px;
|
||||
background: #e6e6e3;
|
||||
}
|
||||
|
||||
if root.error == "" && root.days.length > 0: ListView {
|
||||
vertical-stretch: 1;
|
||||
for day in root.days: DayBlock { day: day; }
|
||||
if root.error != "": Text {
|
||||
x: 24px;
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user