Add an icon size setting for the home grid and the app drawer
Slider (70-160%, step 5) with Small/Medium/Large presets and a live preview in the home menu. Icon, label and row height scale together; the home and drawer column counts reflow; the size is saved in localStorage; a corrupt saved value is logged and shown, not silently replaced. 100% is the original layout. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
3070db4fb4
commit
23317b949a
22 files changed
+901
-51
No files matched your search
+112
-2
@@ -170,7 +170,7 @@ fn Model::view_home(self : Model) -> Node[Msg] {
|
||||
el(
|
||||
"ul",
|
||||
classes=["slots", cls_if("dragging", self.lifted >= 0)],
|
||||
style="grid-template-columns:repeat(\{self.cols},minmax(0,1fr));grid-template-rows:repeat(\{rows},\{@grid.cell_px}px)",
|
||||
style="--s:\{@grid.css_factor(self.icon_pct)};grid-template-columns:repeat(\{self.cols},minmax(0,1fr));grid-template-rows:repeat(\{rows},\{self.cell_h()}px)",
|
||||
children=slots,
|
||||
),
|
||||
]
|
||||
@@ -266,7 +266,14 @@ fn Model::view_drawer(self : Model) -> Node[Msg] {
|
||||
]),
|
||||
)
|
||||
}
|
||||
children.push(el("ul", classes=["apps"], children=tiles))
|
||||
children.push(
|
||||
el(
|
||||
"ul",
|
||||
classes=["apps"],
|
||||
style="--s:\{@grid.css_factor(self.icon_pct)};grid-template-columns:repeat(\{self.drawer_cols},minmax(0,1fr))",
|
||||
children=tiles,
|
||||
),
|
||||
)
|
||||
if self.loading {
|
||||
children.push(
|
||||
el("p", classes=["empty"], children=[text("Loading apps…")]),
|
||||
@@ -296,6 +303,107 @@ fn sheet_title(label : String) -> Node[Msg] {
|
||||
el("h2", classes=["sheet-title"], children=[text(label)])
|
||||
}
|
||||
|
||||
///|
|
||||
fn preset_btn(label : String, pct : Int32, current : Int32) -> Node[Msg] {
|
||||
el(
|
||||
"button",
|
||||
classes=[
|
||||
"btn",
|
||||
if pct == current {
|
||||
"primary"
|
||||
} else {
|
||||
"outline"
|
||||
},
|
||||
"sm",
|
||||
cls_if("on", pct == current),
|
||||
],
|
||||
attrs=[("data-preset", pct.to_string())],
|
||||
handlers=tap(IconPreset(pct)),
|
||||
children=[text(label)],
|
||||
)
|
||||
}
|
||||
|
||||
///|
|
||||
/// The icon size sheet: a preview of a few real icons at the chosen size, the slider, the
|
||||
/// presets. The home grid behind the sheet changes with the slider as well.
|
||||
fn Model::view_icon_size(self : Model, items : Array[Node[Msg]]) -> Unit {
|
||||
let pct = self.icon_pct
|
||||
items.push(sheet_title("Icon size"))
|
||||
if self.icon_error != "" {
|
||||
items.push(
|
||||
el(
|
||||
"div",
|
||||
classes=["alert", "destructive", "icon-error"],
|
||||
attrs=[("role", "alert")],
|
||||
children=[
|
||||
el("div", classes=["alert-title"], children=[
|
||||
text("Icon size problem"),
|
||||
]),
|
||||
el("div", classes=["alert-description"], children=[
|
||||
text(self.icon_error),
|
||||
]),
|
||||
],
|
||||
),
|
||||
)
|
||||
}
|
||||
let sample : Array[Node[Msg]] = []
|
||||
for i in 0..<self.apps.length() {
|
||||
if sample.length() >= 4 {
|
||||
break
|
||||
}
|
||||
let a = self.apps[i]
|
||||
sample.push(
|
||||
el("li", key=i + 1, classes=["tile"], children=[
|
||||
icon(a.icon),
|
||||
el("span", classes=["name"], children=[text(a.label)]),
|
||||
]),
|
||||
)
|
||||
}
|
||||
items.push(
|
||||
el(
|
||||
"ul",
|
||||
classes=["icon-preview"],
|
||||
attrs=[("aria-label", "Preview")],
|
||||
style="--s:\{@grid.css_factor(pct)}",
|
||||
children=sample,
|
||||
),
|
||||
)
|
||||
items.push(
|
||||
el("div", classes=["icon-size-row"], children=[
|
||||
el(
|
||||
"input",
|
||||
classes=["icon-size-slider"],
|
||||
attrs=[
|
||||
("type", "range"),
|
||||
("min", @grid.scale_min.to_string()),
|
||||
("max", @grid.scale_max.to_string()),
|
||||
("step", @grid.scale_step.to_string()),
|
||||
("aria-label", "Icon size"),
|
||||
],
|
||||
props=[("value", pct.to_string())],
|
||||
handlers={ ..Handlers::none(), input: Some(fn(v) { SetIconSize(v) }), },
|
||||
),
|
||||
el("span", classes=["resize-size", "icon-size-value"], children=[
|
||||
text("\{pct}%"),
|
||||
]),
|
||||
]),
|
||||
)
|
||||
items.push(
|
||||
el("div", classes=["icon-presets"], children=[
|
||||
preset_btn("Small", @grid.scale_small, pct),
|
||||
preset_btn("Medium", @grid.scale_medium, pct),
|
||||
preset_btn("Large", @grid.scale_large, pct),
|
||||
]),
|
||||
)
|
||||
items.push(
|
||||
el("div", classes=["sheet-actions"], children=[
|
||||
el("button", classes=["btn", "ghost"], handlers=tap(CloseSheet), children=[
|
||||
text("Done"),
|
||||
]),
|
||||
]),
|
||||
)
|
||||
}
|
||||
|
||||
///|
|
||||
fn Model::view_sheet(self : Model) -> Array[Node[Msg]] {
|
||||
let items : Array[Node[Msg]] = []
|
||||
@@ -305,6 +413,7 @@ fn Model::view_sheet(self : Model) -> Array[Node[Msg]] {
|
||||
items.push(sheet_title("Home screen"))
|
||||
items.push(sheet_btn("Add apps", PickApps))
|
||||
items.push(sheet_btn("Add widget", PickWidget))
|
||||
items.push(sheet_btn("Icon size", IconSizeMenu))
|
||||
items.push(sheet_btn("Wallpaper", Wallpaper))
|
||||
items.push(sheet_btn("Settings", Settings))
|
||||
items.push(sheet_btn("Check for updates", CheckUpdates))
|
||||
@@ -407,6 +516,7 @@ fn Model::view_sheet(self : Model) -> Array[Node[Msg]] {
|
||||
)
|
||||
}
|
||||
}
|
||||
IconSize => self.view_icon_size(items)
|
||||
RecentsSetup => {
|
||||
items.push(sheet_title("Enable window list"))
|
||||
items.push(
|
||||
|
||||
Reference in new issue
Block a user