Files
Windows-Gotify-Client-Rust/ui/empty-state.slint
T
KennethCheng 11a122216b feat(ui): Phase 2 C2 — Mock 消息模型 + Message list + Empty state
- ui/message-card.slint: export enum Priority + struct MessageItem +
  MessageCard 组件(§7 优先级圆点 + 标题 + 应用·预览 + 相对时间 +
  URL 指示)
- ui/message-list.slint: VerticalLayout + for 渲染 MessageCard
  (避开 std-widgets 的 include_paths 配置需求)
- ui/empty-state.slint: §9 ✦ glyph(Path 自绘)+ "You're all caught up"
  + Test Notification 按钮
- ui/app.slint: messages.length 切换 list / empty-state;点击回
  调到 MainWindow 顶层 callback
- src/models.rs: mock_messages() 生成 12 条覆盖 4 个 priority 的
  假消息;format_relative() 输出 "2 min ago" / Yesterday 等
- src/lib.rs: ui.set_messages(mock_messages_model()) 装载;wire
  on_test_notification_clicked / on_message_card_clicked

避坑:
- Slint 1.18 不允许覆盖 Rectangle 内建 border-color,命名用 card-border
- ModelRc::from 需要 Rc<VecModel<T>> 不是裸 VecModel

验证:cargo build / build --release 都 exit 0,0 warning
- debug   26.55 MB, subsystem = WINDOWS_CUI
- release  7.94 MB, subsystem = WINDOWS_GUI
2026-09-19 04:39:24 +08:00

75 lines
2.2 KiB
Plaintext

// AGENTS.md §9 empty state.
//
// Uses Slint `Path` to draw the ✦ glyph — no external assets. C3 may wire the
// "Test Notification" button to a Phase 6 implementation that fires a real
// Windows toast; C2 just invokes the callback so the click path is verifiable.
export component EmptyState inherits Rectangle {
callback test-notification();
in property <color> glyph-color: #4ea1ff;
in property <color> text-primary-color: #e6e6e6;
in property <color> text-muted-color: #6a6a6a;
in property <color> button-bg: #2f3035;
in property <color> button-border: #3a3b40;
in property <color> button-text: #e6e6e6;
background: transparent;
VerticalLayout {
alignment: center;
spacing: 16px;
padding: 32px;
// §9 ✦ glyph — 4-point star drawn with Path.
Path {
width: 48px;
height: 48px;
fill: glyph-color;
commands: "M 24 0 L 28 20 L 48 24 L 28 28 L 24 48 L 20 28 L 0 24 L 20 20 Z";
}
Text {
text: "You're all caught up";
color: text-primary-color;
font-size: 18px;
font-weight: 600;
horizontal-alignment: center;
}
Text {
text: "New Gotify messages will\nappear here automatically.";
color: text-muted-color;
font-size: 13px;
horizontal-alignment: center;
wrap: word-wrap;
}
Rectangle { height: 8px; }
// "Test Notification" button — same visual language as NavItem.
Rectangle {
background: button-bg;
border-color: button-border;
border-width: 1px;
border-radius: 6px;
height: 36px;
width: 160px;
horizontal-stretch: 0;
Text {
x: (parent.width - self.width) / 2;
y: (parent.height - self.height) / 2;
text: "Test Notification";
color: button-text;
font-size: 13px;
}
TouchArea {
clicked => {
root.test-notification();
}
}
}
}
}