89 lines
5.8 KiB
Text
89 lines
5.8 KiB
Text
import { Theme, ActionButton } from "theme.slint";
|
||
|
||
export struct BookmarkItem { name: string, address: string }
|
||
|
||
export component ConnectScreen inherits Rectangle {
|
||
in-out property <[BookmarkItem]> bookmarks;
|
||
in-out property <string> address-input;
|
||
in-out property <string> status-text;
|
||
in-out property <bool> connecting;
|
||
in-out property <bool> auto-reconnect;
|
||
in-out property <string> node-name;
|
||
callback address-edited(string);
|
||
callback auto-reconnect-changed(bool);
|
||
callback connect(string);
|
||
callback disconnect();
|
||
callback remove-bookmark(string);
|
||
callback add-bookmark(string);
|
||
callback open-settings();
|
||
background: Theme.bg-base;
|
||
VerticalLayout {
|
||
padding: 32px; spacing: 22px;
|
||
HorizontalLayout {
|
||
Image { source: @image-url("assets/vnox-mark.svg"); width: 32px; height: 32px; image-fit: contain; }
|
||
Text { text: "Vnox"; color: Theme.text-primary; font-size: Math.max(11px, Theme.font-size * 1.1875); font-weight: 700; }
|
||
Rectangle { horizontal-stretch: 1; }
|
||
ActionButton { text: @tr("Settings"); quiet: true; clicked => { root.open-settings(); } }
|
||
}
|
||
Rectangle { vertical-stretch: 1; }
|
||
HorizontalLayout {
|
||
Rectangle { horizontal-stretch: 1; }
|
||
Rectangle {
|
||
width: 540px;
|
||
height: card.preferred-height;
|
||
background: Theme.bg-surface; border-radius: 14px;
|
||
card := VerticalLayout {
|
||
padding: 28px; spacing: 15px; alignment: start;
|
||
Text { text: @tr("Connect to a server"); color: Theme.text-primary; font-size: Math.max(11px, Theme.font-size * 1.5); font-weight: 600; }
|
||
Text { text: @tr("Enter your server address or choose a saved server."); color: Theme.text-secondary; font-size: Math.max(11px, Theme.font-size * 0.8125); wrap: word-wrap; }
|
||
Text { text: @tr("Server address"); color: Theme.text-secondary; font-size: Math.max(11px, Theme.font-size * 0.75); }
|
||
HorizontalLayout {
|
||
spacing: 9px;
|
||
Rectangle {
|
||
height: 40px; background: Theme.bg-interactive; border-radius: 7px;
|
||
border-width: 1px; border-color: Theme.border;
|
||
HorizontalLayout {
|
||
padding: 10px;
|
||
TextInput {
|
||
text <=> root.address-input;
|
||
single-line: true; color: Theme.text-primary; font-size: Math.max(11px, Theme.font-size * 0.875);
|
||
edited => { root.address-edited(self.text); }
|
||
accepted => { if !root.connecting { root.connect(root.address-input); } }
|
||
}
|
||
}
|
||
}
|
||
if !root.connecting : ActionButton { text: @tr("Connect"); height: 40px; clicked => { root.connect(root.address-input); } }
|
||
if root.connecting : ActionButton { text: @tr("Cancel"); height: 40px; clicked => { root.disconnect(); } }
|
||
}
|
||
HorizontalLayout {
|
||
ActionButton { text: root.auto-reconnect ? "✓" : "○"; width: 30px; quiet: true; clicked => { root.auto-reconnect = !root.auto-reconnect; root.auto-reconnect-changed(root.auto-reconnect); } }
|
||
Text { text: @tr("Reconnect automatically"); color: Theme.text-secondary; font-size: Math.max(11px, Theme.font-size * 0.75); }
|
||
Rectangle { horizontal-stretch: 1; }
|
||
}
|
||
if root.connecting : Text { text: @tr("Connecting…"); color: Theme.accent; font-size: Math.max(11px, Theme.font-size * 0.8125); }
|
||
if root.status-text != "" : Text { text: root.status-text; color: Theme.text-secondary; font-size: Math.max(11px, Theme.font-size * 0.8125); wrap: word-wrap; }
|
||
Rectangle { height: 1px; background: Theme.border; }
|
||
HorizontalLayout {
|
||
Text { text: @tr("Saved servers"); color: Theme.text-primary; font-size: Math.max(11px, Theme.font-size * 0.875); font-weight: 600; }
|
||
Rectangle { horizontal-stretch: 1; }
|
||
ActionButton { text: @tr("+ Save address"); quiet: true; clicked => { root.add-bookmark(root.address-input); } }
|
||
}
|
||
if root.bookmarks.length == 0 : Text { text: @tr("No saved servers yet."); color: Theme.text-muted; font-size: Math.max(11px, Theme.font-size * 0.75); }
|
||
for server in root.bookmarks: HorizontalLayout {
|
||
height: 48px; spacing: 8px;
|
||
VerticalLayout {
|
||
spacing: 2px; horizontal-stretch: 1;
|
||
Text { text: server.name; color: Theme.text-primary; font-size: Math.max(11px, Theme.font-size * 0.875); overflow: elide; }
|
||
Text { text: server.address; color: Theme.text-muted; font-size: Math.max(11px, Theme.font-size * 0.6875); overflow: elide; }
|
||
}
|
||
ActionButton { text: @tr("Join"); quiet: true; clicked => { if !root.connecting { root.connect(server.address); } } }
|
||
ActionButton { text: "×"; width: 28px; quiet: true; clicked => { root.remove-bookmark(server.address); } }
|
||
}
|
||
}
|
||
}
|
||
Rectangle { horizontal-stretch: 1; }
|
||
}
|
||
Rectangle { vertical-stretch: 1; }
|
||
Text { text: @tr("Your server. Your community."); color: Theme.text-disabled; font-size: Math.max(11px, Theme.font-size * 0.75); horizontal-alignment: center; }
|
||
}
|
||
}
|