Files
PunchLog/ui/app.slint
T

176 lines
4.5 KiB
Plaintext

import { ListView } from "std-widgets.slint";
export struct DayRow {
date: string,
mark: string,
time: string,
hours: string,
status: string,
site: string,
memo: string,
problem: bool,
}
component DayBlock inherits Rectangle {
in property <DayRow> day;
height: 168px;
background: transparent;
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: 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;
}
}
}
export component MainWindow inherits Window {
in property <[DayRow]> days;
in property <string> range;
in property <string> error;
callback refresh();
title: "打卡";
preferred-width: 880px;
preferred-height: 720px;
background: #f7f7f5;
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: "打卡";
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;
color: #1a1a1a;
horizontal-alignment: left;
}
if root.error == "" && root.days.length == 0: Text {
text: "这一周没有打卡记录。";
font-size: 14px;
color: #8a8a8a;
horizontal-alignment: left;
}
if root.error == "" && root.days.length > 0: ListView {
vertical-stretch: 1;
for day in root.days: DayBlock { day: day; }
}
}
}