Files
PunchLog/ui/app.slint
T

192 lines
3.9 KiB
Plaintext

import { ScrollView } 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: 132px;
background: #f7f7f5;
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: 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";
Text {
x: 24px;
y: 16px;
text: "打卡";
font-size: 16px;
font-weight: 600;
color: #1a1a1a;
horizontal-alignment: left;
}
Text {
x: 72px;
y: 18px;
text: root.range;
font-size: 13px;
color: #8a8a8a;
horizontal-alignment: left;
}
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: right;
}
clicked => { root.refresh(); }
}
Rectangle {
x: 0px;
y: 51px;
width: parent.width;
height: 1px;
background: #e6e6e3;
}
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;
}
}
}
}