221 lines
8.3 KiB
Plaintext
221 lines
8.3 KiB
Plaintext
// Settings screen: categories on the left, the selected page's rows on one
|
|
// grouped platter on the right.
|
|
//
|
|
// Only text and icons are drawn here. The glass (platter, focus pills) 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, AudioIcon, PowerIcon, SignalIcon, LockIcon, ChevronIcon, StoreIcon, CheckIcon, LinkIcon } 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: AudioIcon { width: 100%; height: 100%; ink: root.ink; }
|
|
if root.index == 3: WifiIcon { width: 100%; height: 100%; ink: root.ink; }
|
|
if root.index == 4: PowerIcon { width: 100%; height: 100%; ink: root.ink; }
|
|
if root.index == 5: InfoIcon { width: 100%; height: 100%; ink: root.ink; }
|
|
// App Store mode: Felfedezés, Telepítve, Források.
|
|
if root.index == 6: StoreIcon { width: 100%; height: 100%; ink: root.ink; }
|
|
if root.index == 7: CheckIcon { width: 100%; height: 100%; ink: root.ink; }
|
|
if root.index == 8: LinkIcon { 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;
|
|
// The same pane serves the App Store (app.slint set-mode).
|
|
in property <string> heading: "Beállítások";
|
|
in property <int> icon-base: 0;
|
|
|
|
// Row text is inset from the platter edge by the focus pill's margin.
|
|
property <length> inset: 8 * root.u;
|
|
property <length> pad: 28 * root.u;
|
|
|
|
// ---- left column ----------------------------------------------------
|
|
Text {
|
|
x: root.nav-x;
|
|
y: root.pane-y;
|
|
width: root.nav-w;
|
|
height: 88 * root.u;
|
|
vertical-alignment: center;
|
|
text: root.heading;
|
|
font-weight: 700;
|
|
font-size: 56 * root.u;
|
|
letter-spacing: -1 * 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.62 + 0.38 * self.sel);
|
|
x: root.nav-x;
|
|
y: root.nav-y + i * root.nav-step;
|
|
width: root.nav-w;
|
|
height: root.nav-h;
|
|
NavIcon {
|
|
x: 24 * root.u;
|
|
y: (parent.height - self.height) / 2;
|
|
width: 32 * root.u;
|
|
height: 32 * root.u;
|
|
index: i + root.icon-base;
|
|
ink: parent.ink;
|
|
}
|
|
Text {
|
|
x: 76 * root.u;
|
|
width: parent.width - 96 * root.u;
|
|
height: parent.height;
|
|
vertical-alignment: center;
|
|
text: name;
|
|
font-size: 26 * root.u;
|
|
font-weight: 600;
|
|
color: parent.ink;
|
|
overflow: elide;
|
|
}
|
|
}
|
|
|
|
// ---- right column ---------------------------------------------------
|
|
Text {
|
|
x: root.rows-x + root.inset + root.pad;
|
|
y: root.nav-y;
|
|
width: root.rows-w - 2 * (root.inset + root.pad);
|
|
height: root.nav-h;
|
|
vertical-alignment: center;
|
|
text: root.title;
|
|
font-weight: 700;
|
|
font-size: 40 * root.u;
|
|
color: #ffffff;
|
|
overflow: elide;
|
|
}
|
|
Text {
|
|
x: root.rows-x + root.inset + root.pad;
|
|
y: root.nav-y + root.nav-h;
|
|
width: root.rows-w - 2 * (root.inset + root.pad);
|
|
height: root.rows-y - root.nav-y - root.nav-h - 24 * root.u;
|
|
text: root.subtitle;
|
|
wrap: word-wrap;
|
|
overflow: elide;
|
|
font-size: 24 * 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;
|
|
// Focus on this row or the one above hides the hairline between them.
|
|
property <float> f-above: max(0, 1 - abs(root.row-pos - (j - 1))) * 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 + root.inset;
|
|
y: self.top;
|
|
width: root.rows-w - 2 * root.inset;
|
|
height: root.row-h;
|
|
opacity: self.vis;
|
|
visible: self.vis > 0.01;
|
|
|
|
if j > 0: Rectangle {
|
|
x: root.pad;
|
|
y: 0;
|
|
width: parent.width - 2 * root.pad;
|
|
height: 1.5 * root.u;
|
|
background: #ffffff1f;
|
|
opacity: 1 - clamp(max(r.f, r.f-above) * 2, 0, 1);
|
|
}
|
|
Text {
|
|
x: root.pad;
|
|
y: row.detail == "" ? (parent.height - self.height) / 2 : 14 * root.u;
|
|
width: parent.width * 0.56;
|
|
text: row.title;
|
|
font-size: 26 * root.u;
|
|
font-weight: 600;
|
|
color: r.ink;
|
|
overflow: elide;
|
|
}
|
|
if row.detail != "": Text {
|
|
x: root.pad;
|
|
y: 50 * root.u;
|
|
width: parent.width * 0.56;
|
|
text: row.detail;
|
|
font-size: 21 * root.u;
|
|
color: r.ink-dim;
|
|
overflow: elide;
|
|
}
|
|
Text {
|
|
x: parent.width * 0.4;
|
|
width: parent.width * 0.6 - (r.network ? 120 : r.chevron ? 64 : root.pad / root.u) * root.u;
|
|
height: parent.height;
|
|
horizontal-alignment: right;
|
|
vertical-alignment: center;
|
|
text: row.value;
|
|
font-size: row.kind == "option" ? 28 * root.u : 24 * 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: ChevronIcon {
|
|
x: parent.width - root.pad - self.width + 4 * root.u;
|
|
y: (parent.height - self.height) / 2;
|
|
width: 24 * root.u;
|
|
height: 24 * root.u;
|
|
ink: r.ink-dim;
|
|
}
|
|
// Wi-Fi network: lock (protected) and signal strength on the right.
|
|
if r.network && row.lock: LockIcon {
|
|
x: parent.width - root.pad - 34 * root.u - 16 * root.u - self.width;
|
|
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 - root.pad - self.width;
|
|
y: (parent.height - self.height) / 2;
|
|
width: 34 * root.u;
|
|
height: 34 * root.u;
|
|
level: row.level;
|
|
ink: r.ink;
|
|
}
|
|
}
|
|
}
|