Files
Unlucky-Launcher/crates/app-iced/src/pages/instances/data.rs
T
AskaEth 2c442585b1 feat(app-iced): M84 页面骨架与布局系统(断点 / 行宽上限 / 三种版面)
视觉复审在 M68 的判词是不能把「全宽单卡」当页面模板(1180 宽下正文单行 712px ≈ 118 字符)。
本 mission 把它落成一套**布局系统**,四个页面只是它的用例:

- `pages/layout.rs`:官方 600 / 840 两个档位 → 三种版面(单列 / supporting-pane / list-detail),
  阈值由列宽和算出(设置 240+24+320 → 720;实例 336+24+320 → 816 ≤ 840),行宽硬上限
  14 × 0.5em × 72 = **504px**,全部是纯函数,`pages/layout/tests.rs` 用绝对值和边界表钉死。
- `pages/frame.rs`:页头(56 / 两行 84)+ 内容列(≤504)+ 两列骨架 + 空态位;
  `pages/frame/pieces.rs` 是占位控件(卡片 / 分隔线 / 文本按钮 / 图标),令牌驱动、无完整状态机,
  待 M75 的 components 家族合入后替换。
- 四页:实例(list-detail,列表列 336 独立滚动,窄窗退化成整页切换)、
  设置(supporting-pane,240 分组导航 + ≤504 表单列)、下载 / 日志(单列,两行页头)。
- `pages/harness.rs` + `examples/pages_demo.rs`:自带 `--screen/--width/--screenshot-theme`,
  不碰 `cli.rs` / `app.rs`(M75 在改)。

偏离与说明:
- 布局用「页边距 16/24」而非 16/24/32,官方 expanded 也是 24(少一条偏离登记);
- 实例空详情态一屏会有 5 档字号(22/16/24/12 + 14 的操作按钮),未截图的状态,已知并登记;
- `lib.rs` 只加一行 `pub mod pages;`。
2026-11-01 23:27:28 +08:00

137 lines
4.1 KiB
Rust

//! 实例页的**演示数据**(骨架期没有业务状态机,也没有业务数据)。
//!
//! 12 条,**故意比可视区高**:列表列的独立滚动条要能在截图里看见(单测钉住这条)。
//! 文案是英文基线:i18n 是后续 mission,干净 CI 上没有中文字体,写中文会变豆腐块。
/// 演示条目(骨架期没有业务数据;文案是英文基线,i18n 是后续 mission)。
pub(crate) struct Entry {
pub(crate) name: &'static str,
pub(crate) version: &'static str,
pub(crate) loader: &'static str,
pub(crate) memory: &'static str,
pub(crate) java: &'static str,
pub(crate) mods: &'static str,
pub(crate) last_played: &'static str,
}
/// 12 条演示数据:**比可视区高**,这样列表列的独立滚动条在截图里能看见。
pub(crate) const DEMO: [Entry; 12] = [
Entry {
name: "Fabulous World",
version: "1.20.4",
loader: "Fabric 0.15.7",
memory: "4 GiB",
java: "Temurin 21",
mods: "148 mods",
last_played: "2 hours ago",
},
Entry {
name: "Skyblock Origins",
version: "1.21.1",
loader: "NeoForge 21.1.72",
memory: "6 GiB",
java: "Temurin 21",
mods: "86 mods",
last_played: "yesterday",
},
Entry {
name: "Vanilla Survival",
version: "1.21.4",
loader: "Vanilla",
memory: "2 GiB",
java: "Temurin 21",
mods: "0 mods",
last_played: "3 days ago",
},
Entry {
name: "Create: Above and Beyond",
version: "1.18.2",
loader: "Forge 40.2.0",
memory: "8 GiB",
java: "Temurin 17",
mods: "312 mods",
last_played: "last week",
},
Entry {
name: "All the Mods 9",
version: "1.20.1",
loader: "NeoForge 20.4.237",
memory: "8 GiB",
java: "Temurin 17",
mods: "412 mods",
last_played: "2 weeks ago",
},
Entry {
name: "Better MC",
version: "1.20.1",
loader: "Fabric 0.14.24",
memory: "6 GiB",
java: "Temurin 17",
mods: "264 mods",
last_played: "last month",
},
Entry {
name: "RLCraft",
version: "1.12.2",
loader: "Forge 14.23.5",
memory: "4 GiB",
java: "Zulu 8",
mods: "184 mods",
last_played: "2 months ago",
},
Entry {
name: "Origins SMP",
version: "1.20.4",
loader: "Quilt 0.24.0",
memory: "4 GiB",
java: "Temurin 21",
mods: "57 mods",
last_played: "3 months ago",
},
Entry {
name: "Redstone Lab",
version: "1.19.4",
loader: "Fabric 0.15.2",
memory: "3 GiB",
java: "Temurin 17",
mods: "34 mods",
last_played: "April 12",
},
Entry {
name: "Pixelmon Reforged",
version: "1.16.5",
loader: "Forge 36.2.34",
memory: "6 GiB",
java: "Temurin 8",
mods: "121 mods",
last_played: "March 3",
},
Entry {
name: "Techopolis 2",
version: "1.20.1",
loader: "Forge 47.2.20",
memory: "8 GiB",
java: "Temurin 17",
mods: "198 mods",
last_played: "January 28",
},
Entry {
name: "Cobblemon",
version: "1.21.1",
loader: "Fabric 0.16.9",
memory: "5 GiB",
java: "Temurin 21",
mods: "74 mods",
last_played: "January 9",
},
];
/// 演示选中的条目(第一条)。
pub(crate) const SELECTED: usize = 0;
/// 详情正文(**故意写长**:这是行宽上限的视觉证据——1180 宽窗口下也只断在 ~72 字符)。
pub(crate) const NOTE: &str = "This instance keeps its own mods, configs and saves. The launcher resolves the version chain \
(instance → mod loader → vanilla) at launch time, verifies every jar it downloaded against the mirror \
manifest, and streams progress back as structured events so the UI never has to guess. Nothing on this \
page is wired to real data yet: the layout is, the numbers are.";