133 lines
4.0 KiB
Plaintext
133 lines
4.0 KiB
Plaintext
// Sign-in (server address, user name, password) on a modal glass pane with
|
|
// the on-screen keyboard, and a plain message screen (loading, errors).
|
|
|
|
import { Tv, GlassRect, GlassPane, GlassButton, Keyboard, Spinner, Title, Label, Caption, Icon } from "@sf-ui/sf-ui.slint";
|
|
|
|
export component SignInScreen inherits Rectangle {
|
|
in property <float> alpha: 1;
|
|
in property <string> title: "Bejelentkezés";
|
|
in property <string> subtitle;
|
|
in property <string> placeholder;
|
|
in property <bool> secret;
|
|
in property <string> submit-label: "Tovább";
|
|
in property <int> min-length: 1;
|
|
in property <string> footer;
|
|
in property <bool> busy;
|
|
in-out property <string> text;
|
|
in-out property <string> error;
|
|
callback submitted(string);
|
|
callback cancelled();
|
|
|
|
public function key(event: KeyEvent) -> EventResult {
|
|
if root.busy {
|
|
return accept;
|
|
}
|
|
kb.key(event)
|
|
}
|
|
|
|
public function reset() {
|
|
kb.reset();
|
|
}
|
|
|
|
pane := GlassPane {
|
|
x: (root.width - self.width) / 2;
|
|
y: (root.height - self.height) / 2 - 24 * Tv.u;
|
|
width: 1720 * Tv.u;
|
|
height: 720 * Tv.u;
|
|
radius: 56 * Tv.u;
|
|
frost: 3.8;
|
|
tint: Tv.smoke.with-alpha(0.48);
|
|
glow: #e50914;
|
|
alpha: root.alpha;
|
|
kb := Keyboard {
|
|
x: 0;
|
|
y: 72 * Tv.u;
|
|
width: parent.width;
|
|
title: root.title;
|
|
subtitle: root.subtitle;
|
|
placeholder: root.placeholder;
|
|
secret: root.secret;
|
|
submit-label: root.submit-label;
|
|
min-length: root.min-length;
|
|
max-length: 200;
|
|
alpha: root.alpha * (root.busy ? 0.4 : 1);
|
|
active: !root.busy;
|
|
text <=> root.text;
|
|
error <=> root.error;
|
|
submitted(t) => { root.submitted(t); }
|
|
cancelled => { root.cancelled(); }
|
|
}
|
|
}
|
|
HorizontalLayout {
|
|
x: pane.x;
|
|
y: pane.y + pane.height + 28 * Tv.u;
|
|
width: pane.width;
|
|
height: 48 * Tv.u;
|
|
alignment: center;
|
|
spacing: 16 * Tv.u;
|
|
opacity: root.alpha;
|
|
if root.busy: Spinner { size: 40 * Tv.u; }
|
|
Caption {
|
|
vertical-alignment: center;
|
|
text: root.footer;
|
|
}
|
|
}
|
|
|
|
out property <[GlassRect]> glass: [pane.glass];
|
|
out property <[GlassRect]> glass-keyboard: kb.glass;
|
|
}
|
|
|
|
// Loading and errors, with up to two buttons.
|
|
export component MessageScreen inherits Rectangle {
|
|
in property <float> alpha: 1;
|
|
in property <bool> busy;
|
|
in property <string> title;
|
|
in property <string> text;
|
|
in property <string> action-a;
|
|
in property <string> action-b;
|
|
in property <int> action;
|
|
|
|
VerticalLayout {
|
|
x: Tv.safe-x;
|
|
width: root.width - 2 * Tv.safe-x;
|
|
y: 320 * Tv.u;
|
|
height: 440 * Tv.u;
|
|
spacing: 24 * Tv.u;
|
|
alignment: start;
|
|
opacity: root.alpha;
|
|
HorizontalLayout {
|
|
alignment: center;
|
|
if root.busy: Spinner { size: 72 * Tv.u; }
|
|
if !root.busy: Icon { name: "warning"; size: 64 * Tv.u; ink: Tv.warn-ink; }
|
|
}
|
|
Title {
|
|
horizontal-alignment: center;
|
|
text: root.title;
|
|
}
|
|
Label {
|
|
horizontal-alignment: center;
|
|
text: root.text;
|
|
wrap: word-wrap;
|
|
}
|
|
HorizontalLayout {
|
|
alignment: center;
|
|
spacing: 24 * Tv.u;
|
|
padding-top: 24 * Tv.u;
|
|
a := GlassButton {
|
|
text: root.action-a;
|
|
focused: root.action == 0;
|
|
alpha: root.action-a != "" ? root.alpha : 0;
|
|
visible: root.action-a != "";
|
|
}
|
|
b := GlassButton {
|
|
text: root.action-b;
|
|
focused: root.action == 1;
|
|
alpha: root.action-b != "" ? root.alpha : 0;
|
|
visible: root.action-b != "";
|
|
}
|
|
}
|
|
}
|
|
|
|
out property <[GlassRect]> glass: [a.glass, b.glass];
|
|
}
|