feat(client): redesign native UI, themes, settings and avatars

Separate conversation drafts and voice view state, add native settings and restricted CSS themes, implement validated avatar cropping, and refresh dependencies with documented desktop compatibility backports.
This commit is contained in:
Loki 2026-10-24 14:23:48 +02:00
parent 44d284a568
commit 8e5ab56611
Signed by: boba
GPG key ID: 253067914055423B
276 changed files with 53546 additions and 3399 deletions

View file

@ -0,0 +1,121 @@
import { Theme, ActionButton } from "theme.slint";
import { AudioSlider } from "controls.slint";
export component AvatarCropper inherits Rectangle {
in property <image> avatar-source;
in property <float> source-width: 1;
in property <float> source-height: 1;
in property <float> offset-x;
in property <float> offset-y;
in-out property <float> zoom: 1;
in property <string> error;
callback crop-moved(float, float);
callback zoom-changed(float);
callback confirm();
callback cancel();
private property <length> frame-size: Math.min(320px, Math.max(220px, root.height - 350px));
private property <float> cover-scale: Math.max(root.frame-size / 1px / Math.max(root.source-width, 1), root.frame-size / 1px / Math.max(root.source-height, 1)) * root.zoom;
background: Theme.overlay;
TouchArea { }
keyboard := FocusScope {
init => { self.focus(); }
key-pressed(event) => {
if event.text == Key.Escape { root.cancel(); return accept; }
if event.text == "+" || event.text == "=" { root.set-zoom(root.zoom + 0.1); return accept; }
if event.text == "-" { root.set-zoom(root.zoom - 0.1); return accept; }
return reject;
}
Rectangle {
width: 440px;
height: Math.min(620px, root.height - 24px);
x: (root.width - self.width) / 2;
y: (root.height - self.height) / 2;
background: Theme.bg-surface;
border-radius: 12px;
border-width: 1px;
border-color: Theme.border;
VerticalLayout {
padding: 18px; spacing: 8px; alignment: start;
HorizontalLayout {
Text { text: "Выбрать область фото"; color: Theme.text-primary; font-size: Theme.font-size + 5px; font-weight: 600; horizontal-stretch: 1; vertical-alignment: center; }
ActionButton { text: "×"; width: 30px; quiet: true; clicked => { root.cancel(); } }
}
Text { text: "Перетащи фото и выбери масштаб."; color: Theme.text-muted; font-size: Math.max(Theme.font-size - 3px, 11px); }
Rectangle { height: 4px; }
HorizontalLayout {
Rectangle { horizontal-stretch: 1; }
frame := Rectangle {
width: root.frame-size; height: root.frame-size;
clip: true; background: Theme.bg-surface;
accessible-role: image;
accessible-label: "Область фото. Перетаскивай изображение, чтобы изменить кадрирование.";
Image {
source: root.avatar-source;
width: root.source-width * root.cover-scale * 1px;
height: root.source-height * root.cover-scale * 1px;
x: (frame.width - self.width) / 2 + root.offset-x * frame.width;
y: (frame.height - self.height) / 2 + root.offset-y * frame.height;
image-fit: fill;
}
// The mask makes the final circular avatar explicit, independently
// of renderer support for rounded clipping of bitmap images.
Path {
width: parent.width; height: parent.height;
viewbox-width: 320; viewbox-height: 320;
fill: Theme.bg-surface;
fill-rule: evenodd;
commands: "M0 0H320V320H0Z M320 160 A160 160 0 1 0 0 160 A160 160 0 1 0 320 160Z";
}
Rectangle {
width: parent.width; height: parent.height;
border-radius: parent.width / 2;
border-width: 1px; border-color: Theme.border;
background: transparent;
}
drag := TouchArea {
property <float> start-x;
property <float> start-y;
pointer-event(event) => {
if event.button == PointerEventButton.left && event.kind == PointerEventKind.down {
self.start-x = root.offset-x;
self.start-y = root.offset-y;
keyboard.focus();
}
}
moved => {
if self.pressed {
root.crop-moved(self.start-x + (self.mouse-x - self.pressed-x) / frame.width,
self.start-y + (self.mouse-y - self.pressed-y) / frame.height);
}
}
}
}
Rectangle { horizontal-stretch: 1; }
}
Rectangle { height: 2px; }
HorizontalLayout {
spacing: 10px;
ActionButton { text: "−"; width: 32px; clicked => { root.set-zoom(root.zoom - 0.1); } }
AudioSlider { minimum: 1; maximum: 3; value <=> root.zoom; changed(value) => { root.zoom-changed(value); } }
ActionButton { text: "+"; width: 32px; clicked => { root.set-zoom(root.zoom + 0.1); } }
}
HorizontalLayout {
Text { text: "Масштаб " + Math.round(root.zoom * 100) + "%"; color: Theme.text-muted; font-size: Math.max(Theme.font-size - 4px, 11px); vertical-alignment: center; horizontal-stretch: 1; }
ActionButton { text: "Сбросить кадр"; quiet: true; clicked => { root.crop-moved(0,0); root.set-zoom(1); } }
}
if root.error != "" : Text { text: root.error; color: Theme.danger; font-size: Math.max(Theme.font-size - 3px, 11px); wrap: word-wrap; }
Rectangle { vertical-stretch: 1; }
HorizontalLayout {
spacing: 9px;
ActionButton { text: "Отмена"; quiet: true; clicked => { root.cancel(); } }
Rectangle { horizontal-stretch: 1; }
ActionButton { text: "Использовать фото"; active: true; clicked => { root.confirm(); } }
}
}
}
}
function set-zoom(value: float) {
root.zoom = Math.clamp(value, 1, 3);
root.zoom-changed(root.zoom);
}
}