Implement Android Room UI and customizable palette
android-ci / android-arm64 (push) Successful in 17m10s

This commit is contained in:
bit9992 committed 2026-11-15 12:32:59 +03:00
1 parent 057bfae87c
commit 87265a3e75
26 files changed
+825 -135

No files matched your search

+114 -19
View File
@@ -1,6 +1,6 @@
import { ScrollView, ListView, AboutSlint } from "std-widgets.slint";
import { ScrollView, ListView, AboutSlint, Slider } from "std-widgets.slint";
import { Theme } from "theme.slint";
import { ActionButton, TextField, Toggle, Choice } from "controls.slint";
import { ActionButton, TextField, Toggle, Choice, RoomIcon, RoomIconButton } from "controls.slint";
import { RichDocument, ChatVisual } from "chat.slint";
export struct SettingsRow {
@@ -8,10 +8,14 @@ export struct SettingsRow {
checked: bool, value: string, options: [string], selected: int,
enabled: bool, destructive: bool, inset: bool, error: string,
meter: float, decrease: string, increase: string, rich: [ChatVisual],
swatch: color, red: float, green: float, blue: float,
}
export global SettingsBridge {
in-out property <[string]> categories;
in-out property <[string]> category-groups;
in-out property <[string]> category-subtitles;
in-out property <string> profile-name;
in-out property <string> profile-label;
in-out property <[SettingsRow]> rows;
in-out property <int> category;
in-out property <string> title;
@@ -33,16 +37,18 @@ export global SettingsBridge {
callback commit(string, string);
callback step(string, int);
callback capture-lost();
callback color-channel(string, int, float);
}
component SettingCell inherits Rectangle {
in property <SettingsRow> setting;
in property <bool> compact;
private property <string> secret-draft;
private property <bool> color-expanded;
private property <string> secret-owner: setting.stable-id;
changed secret-owner => { root.secret-draft = ""; }
callback field-focused(bool);
background: setting.kind == 0 ? transparent : Theme.header;
background: Theme.android || setting.kind == 0 ? transparent : Theme.header;
min-height: Theme.android ? content.preferred-height : (setting.kind == 0 ? 48px : content.preferred-height + 16px);
preferred-height: self.min-height;
vertical-stretch: Theme.android ? 0 : 1;
@@ -83,12 +89,19 @@ component SettingCell inherits Rectangle {
font-family: Theme.font-family; font-size: Theme.font-size - 1px;
accessible-role: text; accessible-label: self.text;
}
if root.setting.kind == 3: Choice {
if root.setting.kind == 3 && root.setting.stable-id != "palette-presets": Choice {
values: root.setting.options; current-index: root.setting.selected;
enabled: root.setting.enabled; label: root.setting.title;
min-height: max(48px, Theme.touch-target);
selected(index) => { self.current-index = root.setting.selected; SettingsBridge.choice-value(root.setting.token, index); }
}
if root.setting.kind == 3 && root.setting.stable-id == "palette-presets": HorizontalLayout {
spacing: 8px;
for preset[index] in root.setting.options: ActionButton {
text: preset; min-width: 0px; enabled: root.setting.enabled;
clicked => { SettingsBridge.choice-value(root.setting.token, index); }
}
}
if root.setting.kind == 4 || root.setting.kind == 5 || root.setting.kind == 8: VerticalLayout {
spacing: 4px;
field := TextField {
@@ -124,8 +137,42 @@ component SettingCell inherits Rectangle {
}
}
}
if root.setting.kind == 10: VerticalLayout {
spacing: 8px;
HorizontalLayout {
spacing: 8px;
TextField {
text: root.setting.value; placeholder: "#RRGGBB"; label: root.setting.title + " · #RRGGBB";
enabled: root.setting.enabled; min-width: 0px; horizontal-stretch: 1;
changed has-focus => { root.field-focused(self.has-focus); }
edited(value) => { SettingsBridge.draft(root.setting.token, value); }
accepted => { SettingsBridge.commit(root.setting.token, self.text); }
}
Rectangle {
width: 48px; height: 48px; background: root.setting.swatch; border-radius: 8px;
border-width: 1px; border-color: Theme.outline;
RoomIconButton { icon: "palette"; label: root.setting.title; enabled: root.setting.enabled;
accessible-expandable: true; accessible-expanded: root.color-expanded;
clicked => { root.color-expanded = !root.color-expanded; }
}
}
}
if root.color-expanded: VerticalLayout {
spacing: 8px;
for channel[index] in [root.setting.red, root.setting.green, root.setting.blue]: HorizontalLayout {
spacing: 8px;
Text { text: index == 0 ? "R" : index == 1 ? "G" : "B"; color: Theme.fg;
font-family: Theme.font-family; font-size: Theme.font-size; width: 24px; vertical-alignment: center; }
Slider { minimum: 0; maximum: 255; value: channel; enabled: root.setting.enabled; min-height: 48px;
accessible-label: root.setting.title + (index == 0 ? " · R" : index == 1 ? " · G" : " · B");
changed(value) => { SettingsBridge.color-channel(root.setting.token, index, value); }
}
Text { text: "\{round(channel)}"; color: Theme.fg; font-family: Theme.font-family; font-size: Theme.font-size; width: 36px; vertical-alignment: center; }
}
}
}
if root.setting.kind == 6: ActionButton {
text: root.setting.title; enabled: root.setting.enabled; destructive: root.setting.destructive;
text: root.setting.title; enabled: root.setting.enabled; destructive: root.setting.destructive; primary: Theme.android && root.setting.stable-id == "palette-save";
min-height: max(48px, Theme.touch-target);
clicked => { SettingsBridge.invoke(root.setting.token); }
}
@@ -141,6 +188,30 @@ component SettingCell inherits Rectangle {
}
}
component RoomSettingsRow inherits Rectangle {
in property <int> category;
min-height: max(72px, row-content.preferred-height); vertical-stretch: 0;
background: row-touch.pressed ? Theme.bg : transparent;
accessible-role: button;
accessible-label: SettingsBridge.categories[category] + ". " + SettingsBridge.category-subtitles[category];
accessible-action-default => { SettingsBridge.category-chosen(root.category); }
border-width: row-focus.has-focus ? 2px : 0px; border-color: Theme.tint-text;
row-content := HorizontalLayout {
padding-left: 0px; padding-right: 0px; padding-top: 12px; padding-bottom: 12px; spacing: 16px;
RoomIcon { name: root.category == 3 ? "headphones" : root.category == 8 ? "bell" : root.category == 2 ? "palette" : root.category == 0 ? "user" : root.category == 1 ? "shield" : root.category == 4 ? "screen" : root.category == 6 ? "chat" : root.category == 7 ? "users" : root.category == 11 ? "info" : "settings"; ink: Theme.muted; width: 20px; height: 24px; }
VerticalLayout { spacing: 4px; alignment: center;
Text { text: SettingsBridge.categories[root.category]; color: Theme.fg; font-family: Theme.font-family; font-size: Theme.font-size; font-weight: 600; wrap: word-wrap; }
Text { text: SettingsBridge.category-subtitles[root.category]; color: Theme.muted; font-family: Theme.font-family; font-size: Theme.font-size * 0.85; wrap: word-wrap; }
}
RoomIcon { name: "chevron"; ink: Theme.muted; width: 20px; height: 24px; }
}
Rectangle { y: parent.height - 1px; height: 1px; width: parent.width; background: Theme.outline; }
row-focus := FocusScope { key-pressed(event) => {
if event.text == Key.Return || event.text == " " { SettingsBridge.category-chosen(root.category); return accept; }return reject;
} }
row-touch := TouchArea { clicked => { row-focus.focus(); SettingsBridge.category-chosen(root.category); } }
}
export component SettingsScreen inherits Rectangle {
background: Theme.shaded;
min-width: 0px; min-height: 0px;
@@ -148,6 +219,8 @@ export component SettingsScreen inherits Rectangle {
private property <bool> compact: self.width < 600px;
private property <length> focused-row-y: -1px;
private property <string> focused-row;
private property <string> content-title: SettingsBridge.title;
changed content-title => { root.focused-row = ""; root.focused-row-y = -1px; }
forward-focus: keyboard;
keyboard := FocusScope {
key-pressed(event) => {
@@ -211,23 +284,36 @@ export component SettingsScreen inherits Rectangle {
}
}
if Theme.android: VerticalLayout {
padding: 8px; spacing: 0px; min-width: 0px;
padding: 20px; spacing: 0px; min-width: 0px;
if !SettingsBridge.panel-open: ScrollView {
min-height: 0px; min-width: 0px; vertical-stretch: 1;
VerticalLayout {
spacing: 4px; alignment: start; min-width: 0px; preferred-width: 0px;
for category[index] in SettingsBridge.categories: VerticalLayout {
spacing: 4px; vertical-stretch: 0; min-width: 0px; preferred-width: 0px;
if index == 0 || index == 2 || index == 11: Text {
spacing: 0px; alignment: start; min-width: 0px; preferred-width: 0px;
Rectangle {
min-height: max(104px, profile-content.preferred-height); vertical-stretch: 0;
accessible-role: button; accessible-label: SettingsBridge.profile-label + ". " + SettingsBridge.profile-name;
accessible-action-default => { SettingsBridge.category-chosen(0); }
border-width: profile-focus.has-focus ? 2px : 0px; border-color: Theme.tint-text;
profile-content := HorizontalLayout { spacing: 14px; padding-top: 12px; padding-bottom: 12px;
Rectangle { width: 64px; height: 64px; background: Theme.bg; border-radius: 32px;
RoomIcon { name: "user"; ink: Theme.tint-text; x: 16px; y: 16px; width: 32px; height: 32px; }
}
VerticalLayout { spacing: 4px; alignment: center;
Text { text: SettingsBridge.profile-name; color: Theme.fg; font-family: Theme.font-family; font-size: Theme.font-size * 1.25; font-weight: 700; wrap: word-wrap; }
Text { text: SettingsBridge.profile-label; color: Theme.muted; font-family: Theme.font-family; font-size: Theme.font-size * 0.85; wrap: word-wrap; }
}
}
profile-focus := FocusScope { key-pressed(event) => { if event.text == Key.Return || event.text == " " { SettingsBridge.category-chosen(0); return accept; }return reject; } }
TouchArea { clicked => { profile-focus.focus(); SettingsBridge.category-chosen(0); } }
}
for category[index] in [3, 8, 2, 0, 1, 4, 5, 6, 7, 9, 10, 11]: VerticalLayout {
spacing: 0px; vertical-stretch: 0; min-width: 0px; preferred-width: 0px;
if index == 0 || index == 2 || index == 5: Text {
text: SettingsBridge.category-groups[index == 0 ? 0 : index == 2 ? 1 : 2];
color: Theme.muted; font-family: Theme.font-family; font-size: Theme.font-size - 1px;
min-height: 32px; vertical-alignment: center; wrap: word-wrap;
}
ActionButton {
text: category; primary: index == SettingsBridge.category;
min-width: 0px; vertical-stretch: 0;
clicked => { SettingsBridge.category-chosen(index); }
color: Theme.muted; font-family: Theme.font-family; font-size: Theme.font-size * 0.85;
font-weight: 600; min-height: 48px; vertical-alignment: center; wrap: word-wrap;
}
RoomSettingsRow { category: category; min-width: 0px; }
}
}
}
@@ -248,7 +334,7 @@ export component SettingsScreen inherits Rectangle {
font-family: Theme.font-family; font-size: Theme.font-size;
accessible-role: text; accessible-label: self.text;
}
for row in SettingsBridge.rows: phone-row := VerticalLayout {
for row[index] in SettingsBridge.rows: phone-row := VerticalLayout {
spacing: 0px; vertical-stretch: 0; min-width: 0px; preferred-width: 0px;
changed y => {
if root.focused-row == row.stable-id {
@@ -256,7 +342,16 @@ export component SettingsScreen inherits Rectangle {
phone-list.content-y = clamp(-self.y, min(0px, phone-list.visible-height - phone-list.content-height), 0px);
}
}
if row.kind != 0 || row.title != SettingsBridge.title: SettingCell {
if row.stable-id == "palette-cancel": HorizontalLayout {
spacing: 8px;
ActionButton { text: row.title; enabled: row.enabled;
clicked => { SettingsBridge.invoke(row.token); }
}
ActionButton { text: SettingsBridge.rows[index + 1].title; primary: true; enabled: SettingsBridge.rows[index + 1].enabled;
clicked => { SettingsBridge.invoke(SettingsBridge.rows[index + 1].token); }
}
}
if (row.kind != 0 || row.title != SettingsBridge.title) && row.stable-id != "palette-cancel" && row.stable-id != "palette-save": SettingCell {
setting: row; compact: true;
min-width: 0px; preferred-width: 0px; vertical-stretch: 0;
field-focused(focused) => {