Files
os/crates/sf-launcher/ui/settings.slint
2026-10-24 09:06:06 +02:00

211 lines
7.3 KiB
Plaintext
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
// Settings screen: categories on the left, rows on the right.
//
// Only text and icons are drawn here. The glass (pane, rows, chips) comes from
// `settings_screen::glass` in Rust, which mirrors the geometry below: keep the
// row/nav formulas (position, focus `f`, visibility `vis`) in sync with it.
import { WifiIcon, BluetoothIcon, InfoIcon, DisplayIcon, PowerIcon, SignalIcon, LockIcon } from "icons.slint";
export struct SettingRow {
title: string,
value: string,
detail: string,
// info | choice | device | action | danger | option | network
kind: string,
// network rows: signal bars (1-4) and a lock for protected networks
level: int,
lock: bool,
}
component NavIcon inherits Rectangle {
in property <int> index;
in property <color> ink;
if root.index == 0: DisplayIcon { width: 100%; height: 100%; ink: root.ink; }
if root.index == 1: BluetoothIcon { width: 100%; height: 100%; ink: root.ink; }
if root.index == 2: WifiIcon { width: 100%; height: 100%; ink: root.ink; }
if root.index == 3: PowerIcon { width: 100%; height: 100%; ink: root.ink; }
if root.index == 4: InfoIcon { width: 100%; height: 100%; ink: root.ink; }
}
export component SettingsView inherits Rectangle {
in property <length> u;
in property <length> pane-x;
in property <length> pane-y;
in property <length> pane-h;
in property <length> nav-x;
in property <length> nav-y;
in property <length> nav-w;
in property <length> nav-h;
in property <length> nav-step;
in property <length> rows-x;
in property <length> rows-y;
in property <length> rows-w;
in property <length> row-h;
in property <length> row-step;
in property <length> rows-view-h;
in property <length> rows-scroll;
in property <float> nav-pos;
in property <float> nav-active;
in property <float> row-pos;
in property <float> content-active;
in property <string> title;
in property <string> subtitle;
in property <[SettingRow]> rows;
in property <[string]> categories;
// ---- left column ----------------------------------------------------
Text {
x: root.nav-x + 8 * root.u;
y: root.pane-y + 50 * root.u;
text: "Beállítások";
font-family: "Inter Display";
font-weight: 800;
font-size: 50 * root.u;
letter-spacing: -1.5 * root.u;
color: #ffffff;
}
for name[i] in root.categories: Rectangle {
property <float> f: max(0, 1 - abs(root.nav-pos - i)) * root.nav-active;
property <float> sel: max(0, 1 - abs(root.nav-pos - i));
property <color> ink: self.f > 0.5 ? #121317 : #ffffff.with-alpha(0.72 + 0.28 * self.sel);
x: root.nav-x;
y: root.nav-y + i * root.nav-step;
width: root.nav-w;
height: root.nav-h;
NavIcon {
x: 28 * root.u;
y: (parent.height - self.height) / 2;
width: 34 * root.u;
height: 34 * root.u;
index: i;
ink: parent.ink;
}
Text {
x: 82 * root.u;
width: parent.width - 100 * root.u;
height: parent.height;
vertical-alignment: center;
text: name;
font-size: 26 * root.u;
font-weight: 600;
color: parent.ink;
overflow: elide;
}
}
Text {
x: root.nav-x;
y: root.pane-y + root.pane-h - 92 * root.u;
width: 300 * root.u;
height: 56 * root.u;
horizontal-alignment: center;
vertical-alignment: center;
text: "‹ Vissza · Esc";
font-size: 21 * root.u;
font-weight: 500;
color: #ffffffc0;
}
// ---- right column ---------------------------------------------------
Text {
x: root.rows-x + 8 * root.u;
y: root.pane-y + 44 * root.u;
width: root.rows-w - 16 * root.u;
text: root.title;
font-family: "Inter Display";
font-weight: 800;
font-size: 40 * root.u;
letter-spacing: -1 * root.u;
color: #ffffff;
overflow: elide;
}
Text {
x: root.rows-x + 8 * root.u;
y: root.pane-y + 102 * root.u;
width: root.rows-w - 16 * root.u;
height: 64 * root.u;
text: root.subtitle;
wrap: word-wrap;
overflow: elide;
font-size: 21 * root.u;
color: #ffffffa8;
}
for row[j] in root.rows: r := Rectangle {
property <float> f: max(0, 1 - abs(root.row-pos - j)) * root.content-active;
property <length> top: root.rows-y + j * root.row-step - root.rows-scroll;
property <float> over: max(root.rows-y - self.top, self.top + root.row-h - (root.rows-y + root.rows-view-h)) / root.row-h;
property <float> vis: clamp(1 - self.over, 0, 1);
property <bool> hot: self.f > 0.5;
property <bool> danger: row.kind == "danger";
property <color> ink: self.hot ? (self.danger ? #ffffff : #121317) : (self.danger ? #ff8278 : #ffffff);
property <color> ink-dim: self.hot ? (self.danger ? #ffffffd0 : #121317b0) : #ffffff99;
property <bool> chevron: row.kind == "choice" || row.kind == "device";
property <bool> network: row.kind == "network";
x: root.rows-x;
y: self.top;
width: root.rows-w;
height: root.row-h;
opacity: self.vis;
visible: self.vis > 0.01;
Text {
x: 30 * root.u;
y: row.detail == "" ? (parent.height - self.height) / 2 : 15 * root.u;
width: parent.width * 0.55;
text: row.title;
font-size: 26 * root.u;
font-weight: 600;
color: r.ink;
overflow: elide;
}
if row.detail != "": Text {
x: 30 * root.u;
y: 51 * root.u;
width: parent.width * 0.55;
text: row.detail;
font-size: 19 * root.u;
color: r.ink-dim;
overflow: elide;
}
Text {
x: parent.width * 0.4;
width: parent.width * 0.6 - (r.network ? 124 : r.chevron ? 64 : 32) * root.u;
height: parent.height;
horizontal-alignment: right;
vertical-alignment: center;
text: row.value;
font-size: row.kind == "option" ? 30 * root.u : 23 * root.u;
font-weight: row.kind == "option" ? 700 : 400;
color: row.kind == "option" ? (r.hot ? #121317 : #ff9a5c) : r.ink-dim;
overflow: elide;
}
if r.chevron: Text {
x: parent.width - 50 * root.u;
width: 24 * root.u;
height: parent.height;
vertical-alignment: center;
text: "›";
font-size: 36 * root.u;
color: r.ink-dim;
}
// Wi-Fi network: lock (protected) and signal strength on the right.
if r.network && row.lock: LockIcon {
x: parent.width - 104 * root.u;
y: (parent.height - self.height) / 2;
width: 24 * root.u;
height: 24 * root.u;
ink: r.ink-dim;
}
if r.network: SignalIcon {
x: parent.width - 66 * root.u;
y: (parent.height - self.height) / 2;
width: 34 * root.u;
height: 34 * root.u;
level: row.level;
ink: r.ink;
}
}
}