Spotify for Fennec OS: native TV client
All checks were successful
release / release (push) Successful in 12m14s
All checks were successful
release / release (push) Successful in 12m14s
Rust + Slint on sf-ui's Liquid Glass, with the page engine of Netflex TV. librespot plays (GStreamer on the TV) and makes the TV a Spotify Connect device; the Web API (token from the session) feeds the pages. - Sign-in with the phone: a pairing code / QR code (spotify.com/pair, OAuth device flow) or picking the TV in the Spotify app (zeroconf). - Home, search, library, playlist / album / liked songs / podcast pages, artist pages, settings; the user's picture top right. - Now playing: seek, shuffle, repeat, like, synced lyrics, queue. - package.sh builds x86-64 and aarch64 (Raspberry Pi); the Gitea CI releases both on a tag. - tools/mock_server.py and SPOTIFY_MOCK for work without an account. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
195
ui/app.slint
Normal file
195
ui/app.slint
Normal file
@@ -0,0 +1,195 @@
|
||||
// Spotify for Fennec OS: the root window.
|
||||
//
|
||||
// Screens: "message" (start-up, errors), "signin" (QR code / Spotify app),
|
||||
// "page" (every browsing screen: a LinePage built by src/page.rs),
|
||||
// "nowplaying". Over them: the text input, the picker, the toast.
|
||||
//
|
||||
// Rust owns state and focus: every key goes to the `key` callback, except
|
||||
// while a keyboard has the focus (the input overlay, the search keyboard).
|
||||
|
||||
import { TvWindow, Tv, SfText, GlassRect, MenuItem } from "@sf-ui/sf-ui.slint";
|
||||
import { Line, Chip, Card, Check, QueueItem } from "types.slint";
|
||||
import { LinePage } from "page.slint";
|
||||
import { NowPlayingScreen } from "nowplaying.slint";
|
||||
import { ConnectScreen, InputScreen, MessageScreen } from "signin.slint";
|
||||
import { SelectOverlay, Toast } from "overlays.slint";
|
||||
|
||||
export { Tv, SfText, MenuItem, Line, Chip, Card, Check, QueueItem }
|
||||
|
||||
export component App inherits TvWindow {
|
||||
title: "Spotify";
|
||||
forward-focus: keys;
|
||||
|
||||
// "message", "signin", "page", "nowplaying"
|
||||
in property <string> screen: "message";
|
||||
// The key text (Slint's Key codes) and whether it repeats; true = handled.
|
||||
callback key(string, bool) -> bool;
|
||||
|
||||
out property <float> message-t: self.screen == "message" ? 1 : 0;
|
||||
animate message-t { duration: 420ms; easing: cubic-bezier(0.22, 1, 0.36, 1); }
|
||||
out property <float> signin-t: self.screen == "signin" ? 1 : 0;
|
||||
animate signin-t { duration: 420ms; easing: cubic-bezier(0.22, 1, 0.36, 1); }
|
||||
out property <float> page-t: self.screen == "page" ? 1 : 0;
|
||||
animate page-t { duration: 420ms; easing: cubic-bezier(0.22, 1, 0.36, 1); }
|
||||
out property <float> np-t: self.screen == "nowplaying" ? 1 : 0;
|
||||
animate np-t { duration: 420ms; easing: cubic-bezier(0.22, 1, 0.36, 1); }
|
||||
out property <float> input-t: self.input-open ? 1 : 0;
|
||||
animate input-t { duration: 420ms; easing: cubic-bezier(0.22, 1, 0.36, 1); }
|
||||
out property <float> select-t: self.select-open ? 1 : 0;
|
||||
animate select-t { duration: 300ms; easing: cubic-bezier(0.3, 1.18, 0.4, 1); }
|
||||
// Whatever an overlay would cover goes away first.
|
||||
property <float> under: max(0, 1 - 1.6 * max(self.input-t, self.select-t));
|
||||
// The outgoing screen goes first, the incoming one follows.
|
||||
function vis(t: float) -> float {
|
||||
clamp(t * 2 - 1, 0, 1)
|
||||
}
|
||||
|
||||
keys := FocusScope {
|
||||
key-pressed(event) => {
|
||||
if root.input-open {
|
||||
return input.key(event);
|
||||
}
|
||||
if root.screen == "page" && root.page-kb-focused && !root.select-open {
|
||||
return page.kb-key(event);
|
||||
}
|
||||
if root.key(event.text, event.repeat) {
|
||||
return accept;
|
||||
}
|
||||
reject
|
||||
}
|
||||
}
|
||||
|
||||
// ---- message ----
|
||||
in property <bool> message-busy <=> message.busy;
|
||||
in property <string> message-title <=> message.title;
|
||||
in property <string> message-text <=> message.text;
|
||||
message := MessageScreen {
|
||||
alpha: root.vis(root.message-t);
|
||||
visible: self.alpha > 0.001;
|
||||
}
|
||||
|
||||
// ---- sign-in ----
|
||||
in property <string> signin-device <=> signin.device;
|
||||
in property <string> signin-code <=> signin.code;
|
||||
in property <image> signin-qr <=> signin.qr;
|
||||
in property <bool> signin-busy <=> signin.busy;
|
||||
in property <string> signin-error <=> signin.error;
|
||||
signin := ConnectScreen {
|
||||
alpha: root.vis(root.signin-t);
|
||||
visible: self.alpha > 0.001;
|
||||
}
|
||||
|
||||
// ---- page ----
|
||||
in property <[Line]> page-lines <=> page.lines;
|
||||
in property <int> page-focus <=> page.focus-line;
|
||||
in property <float> page-scroll <=> page.scroll;
|
||||
in property <bool> page-show-nav <=> page.show-nav;
|
||||
in property <[string]> page-nav-items <=> page.nav-items;
|
||||
in property <int> page-nav-index <=> page.nav-index;
|
||||
in property <bool> page-nav-focused <=> page.nav-focused;
|
||||
in property <string> page-np-title <=> page.np-title;
|
||||
in property <string> page-np-artist <=> page.np-artist;
|
||||
in property <bool> page-np-playing <=> page.np-playing;
|
||||
in property <bool> page-np-focused <=> page.np-focused;
|
||||
in property <image> page-user-image <=> page.user-image;
|
||||
in property <string> page-user-initial <=> page.user-initial;
|
||||
in property <float> page-kb-y <=> page.kb-y;
|
||||
in property <bool> page-kb-focused <=> page.kb-focused;
|
||||
in property <string> page-kb-placeholder <=> page.kb-placeholder;
|
||||
in-out property <string> page-query <=> page.query;
|
||||
callback search-submitted(string);
|
||||
callback search-changed(string);
|
||||
changed page-query => {
|
||||
root.search-changed(self.page-query);
|
||||
}
|
||||
callback search-exit-down();
|
||||
callback search-exit-up();
|
||||
callback search-cancelled();
|
||||
public function page-kb-reset() {
|
||||
page.kb-reset();
|
||||
}
|
||||
page := LinePage {
|
||||
alpha: root.vis(root.page-t) * root.under;
|
||||
visible: root.page-t > 0.001;
|
||||
search-submitted(t) => { root.search-submitted(t); }
|
||||
search-exit-down => { root.search-exit-down(); }
|
||||
search-exit-up => { root.search-exit-up(); }
|
||||
search-cancelled => { root.search-cancelled(); }
|
||||
}
|
||||
|
||||
// ---- now playing ----
|
||||
in property <string> np-title <=> np.title;
|
||||
in property <string> np-artist <=> np.artist;
|
||||
in property <string> np-album <=> np.album;
|
||||
in property <image> np-cover <=> np.art;
|
||||
in property <bool> np-explicit <=> np.explicit;
|
||||
in property <bool> np-episode <=> np.episode;
|
||||
in property <bool> np-playing <=> np.playing;
|
||||
in property <bool> np-loading <=> np.loading;
|
||||
in property <float> np-progress <=> np.progress;
|
||||
in property <string> np-time <=> np.time;
|
||||
in property <string> np-duration <=> np.duration;
|
||||
in property <bool> np-shuffle <=> np.shuffle;
|
||||
in property <int> np-repeat <=> np.repeat;
|
||||
in property <int> np-liked <=> np.liked;
|
||||
in property <int> np-focus <=> np.button;
|
||||
in property <int> np-area <=> np.area;
|
||||
in property <int> np-panel <=> np.panel;
|
||||
in property <[string]> np-lyrics <=> np.lyrics;
|
||||
in property <int> np-lyric-line <=> np.lyric-line;
|
||||
in property <bool> np-lyrics-synced <=> np.lyrics-synced;
|
||||
in property <string> np-lyrics-note <=> np.lyrics-note;
|
||||
in property <[QueueItem]> np-queue <=> np.queue;
|
||||
in property <string> np-queue-note <=> np.queue-note;
|
||||
in property <string> np-device <=> np.device;
|
||||
np := NowPlayingScreen {
|
||||
alpha: root.vis(root.np-t) * root.under;
|
||||
visible: root.np-t > 0.001;
|
||||
}
|
||||
|
||||
// ---- text input ----
|
||||
in property <bool> input-open;
|
||||
in property <string> input-title <=> input.title;
|
||||
in property <string> input-subtitle <=> input.subtitle;
|
||||
in property <string> input-placeholder <=> input.placeholder;
|
||||
in property <string> input-submit-label <=> input.submit-label;
|
||||
in property <int> input-min-length <=> input.min-length;
|
||||
in-out property <string> input-text <=> input.text;
|
||||
in-out property <string> input-error <=> input.error;
|
||||
callback input-submitted(string);
|
||||
callback input-cancelled();
|
||||
public function input-reset() {
|
||||
input.reset();
|
||||
}
|
||||
input := InputScreen {
|
||||
alpha: root.vis(root.input-t);
|
||||
visible: root.input-t > 0.001;
|
||||
submitted(t) => { root.input-submitted(t); }
|
||||
cancelled => { root.input-cancelled(); }
|
||||
}
|
||||
|
||||
// ---- picker ----
|
||||
in property <bool> select-open;
|
||||
in property <string> select-title <=> select.title;
|
||||
in property <[MenuItem]> select-items <=> select.items;
|
||||
in property <int> select-focus <=> select.focus-index;
|
||||
select := SelectOverlay {
|
||||
alpha: root.select-t;
|
||||
visible: root.select-t > 0.001;
|
||||
}
|
||||
|
||||
// ---- toast ----
|
||||
in property <string> toast-text <=> toast.text;
|
||||
in property <bool> toast-bad <=> toast.bad;
|
||||
toast := Toast { }
|
||||
|
||||
// ---- glass, in drawing order (listed by src/main.rs) ----
|
||||
out property <[GlassRect]> glass-signin: signin.glass;
|
||||
out property <[GlassRect]> glass-page: page.glass;
|
||||
out property <[GlassRect]> glass-page-keyboard: page.glass-keyboard;
|
||||
out property <[GlassRect]> glass-np: np.glass;
|
||||
out property <[GlassRect]> glass-input: input.glass;
|
||||
out property <[GlassRect]> glass-input-keyboard: input.glass-keyboard;
|
||||
out property <[GlassRect]> glass-select: select.glass;
|
||||
out property <[GlassRect]> glass-toast: toast.glass;
|
||||
}
|
||||
37
ui/icons.slint
Normal file
37
ui/icons.slint
Normal file
@@ -0,0 +1,37 @@
|
||||
// Icons sf-ui does not have (shuffle, repeat, heart, lyrics, queue), drawn
|
||||
// the same way: strokes on a 32 grid. Any other name goes to sf-ui's Icon.
|
||||
|
||||
import { Tv, Icon } from "@sf-ui/sf-ui.slint";
|
||||
|
||||
export component SpIcon inherits Rectangle {
|
||||
in property <string> name;
|
||||
in property <color> ink: Tv.text;
|
||||
in property <length> size: 32 * Tv.u;
|
||||
width: self.size;
|
||||
height: self.size;
|
||||
property <bool> own: self.name == "shuffle" || self.name == "repeat" || self.name == "repeat-one" || self.name == "heart"
|
||||
|| self.name == "heart-filled" || self.name == "lyrics" || self.name == "queue" || self.name == "devices";
|
||||
property <bool> filled: self.name == "heart-filled";
|
||||
if !root.own: Icon {
|
||||
name: root.name;
|
||||
ink: root.ink;
|
||||
size: root.size;
|
||||
}
|
||||
if root.own: Path {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
viewbox-width: 32;
|
||||
viewbox-height: 32;
|
||||
stroke: root.ink;
|
||||
stroke-width: root.size * 2.4 / 32;
|
||||
fill: root.filled ? root.ink : transparent;
|
||||
commands: root.name == "shuffle" ? "M 4 9 L 9 9 C 15 9 17 23 23 23 L 28 23 M 24.5 19.5 L 28 23 L 24.5 26.5 M 4 23 L 9 23 C 11.5 23 13 21 14.5 18 M 17.5 14 C 19 11 20.5 9 23 9 L 28 9 M 24.5 5.5 L 28 9 L 24.5 12.5"
|
||||
: root.name == "repeat" ? "M 6 16 L 6 12.5 C 6 10 7.5 8.5 10 8.5 L 26 8.5 M 22.5 5 L 26 8.5 L 22.5 12 M 26 16 L 26 19.5 C 26 22 24.5 23.5 22 23.5 L 6 23.5 M 9.5 27 L 6 23.5 L 9.5 20"
|
||||
: root.name == "repeat-one" ? "M 6 16 L 6 12.5 C 6 10 7.5 8.5 10 8.5 L 26 8.5 M 22.5 5 L 26 8.5 L 22.5 12 M 26 16 L 26 19.5 C 26 22 24.5 23.5 22 23.5 L 6 23.5 M 9.5 27 L 6 23.5 L 9.5 20 M 14.5 14 L 16.5 12.8 L 16.5 19.5"
|
||||
: root.name == "heart" || root.name == "heart-filled" ? "M 16 26.5 L 6.2 16.8 C 3.2 13.8 3.6 9 7.4 7.4 C 10.4 6.1 13.8 7.3 16 10.2 C 18.2 7.3 21.6 6.1 24.6 7.4 C 28.4 9 28.8 13.8 25.8 16.8 Z"
|
||||
: root.name == "lyrics" ? "M 16 4 C 18.5 4 20.5 6 20.5 8.5 L 20.5 15 C 20.5 17.5 18.5 19.5 16 19.5 C 13.5 19.5 11.5 17.5 11.5 15 L 11.5 8.5 C 11.5 6 13.5 4 16 4 Z M 7.5 14.5 C 7.5 19.5 11.3 23.5 16 23.5 C 20.7 23.5 24.5 19.5 24.5 14.5 M 16 23.5 L 16 28 M 11 28 L 21 28"
|
||||
: root.name == "queue" ? "M 5 8 L 22 8 M 5 14 L 22 14 M 5 20 L 13 20 M 18 18.5 L 18 27.5 L 26 23 Z"
|
||||
: root.name == "devices" ? "M 4 7 L 22 7 L 22 20 L 4 20 Z M 9 25 L 17 25 M 25 11 L 29 11 L 29 26 L 25 26 Z"
|
||||
: "";
|
||||
}
|
||||
}
|
||||
405
ui/nowplaying.slint
Normal file
405
ui/nowplaying.slint
Normal file
@@ -0,0 +1,405 @@
|
||||
// Most szól: the cover, the title, the progress and the controls. With the
|
||||
// lyrics or the queue open, the cover and the texts move to the left and a
|
||||
// glass panel holds the lyrics / the queue on the right.
|
||||
//
|
||||
// Rust owns the focus: `button` is the focused button (0..7), `area` 1 means
|
||||
// the progress bar (left/right seek there).
|
||||
|
||||
import { Tv, GlassRect, GlassPane, Spinner, Caption } from "@sf-ui/sf-ui.slint";
|
||||
import { QueueItem } from "types.slint";
|
||||
import { SpIcon } from "icons.slint";
|
||||
import { Accent, Equalizer } from "page.slint";
|
||||
|
||||
// A round glass control. `on`: a toggle that is on (green icon and dot).
|
||||
component NpButton inherits Rectangle {
|
||||
in property <string> icon;
|
||||
in property <bool> focused;
|
||||
in property <bool> on;
|
||||
in property <bool> primary;
|
||||
in property <float> alpha: 1;
|
||||
in property <length> size: 80 * Tv.u;
|
||||
out property <float> f: self.focused ? 1 : 0;
|
||||
animate f { duration: 220ms; easing: cubic-bezier(0.22, 1, 0.36, 1); }
|
||||
property <float> s: 1 + 0.08 * self.f;
|
||||
width: self.size;
|
||||
height: self.size;
|
||||
SpIcon {
|
||||
name: root.icon;
|
||||
size: root.size * (root.primary ? 0.46 : 0.42);
|
||||
ink: root.focused ? Tv.ink : root.primary ? #121317 : root.on ? Accent.green : Tv.text;
|
||||
opacity: root.alpha;
|
||||
}
|
||||
if root.on: Rectangle {
|
||||
x: (parent.width - self.width) / 2;
|
||||
y: parent.height - 14 * Tv.u;
|
||||
width: 7 * Tv.u;
|
||||
height: 7 * Tv.u;
|
||||
border-radius: self.width / 2;
|
||||
background: root.focused ? Tv.ink : Accent.green;
|
||||
opacity: root.alpha;
|
||||
}
|
||||
out property <GlassRect> glass: {
|
||||
x: self.absolute-position.x - self.width * (self.s - 1) / 2,
|
||||
y: self.absolute-position.y - self.height * (self.s - 1) / 2,
|
||||
w: self.width * self.s,
|
||||
h: self.height * self.s,
|
||||
r: self.height * self.s / 2,
|
||||
focus: self.f,
|
||||
alpha: self.alpha,
|
||||
blur: 1.4,
|
||||
glow: self.primary ? Accent.green : #ffffff,
|
||||
tint: self.primary ? (self.focused ? #ffffff.with-alpha(0.9) : Accent.green.with-alpha(0.92)) : #ffffff.with-alpha(0.06 + 0.82 * self.f),
|
||||
group: 0,
|
||||
};
|
||||
}
|
||||
|
||||
export component NowPlayingScreen inherits Rectangle {
|
||||
in property <float> alpha: 1;
|
||||
in property <string> title;
|
||||
in property <string> artist;
|
||||
in property <string> album;
|
||||
in property <image> art;
|
||||
in property <bool> explicit;
|
||||
in property <bool> episode;
|
||||
in property <bool> playing;
|
||||
in property <bool> loading;
|
||||
in property <float> progress;
|
||||
in property <string> time;
|
||||
in property <string> duration;
|
||||
in property <bool> shuffle;
|
||||
// 0 off, 1 the list, 2 this track
|
||||
in property <int> repeat;
|
||||
// -1 unknown, 0 no, 1 yes
|
||||
in property <int> liked: -1;
|
||||
in property <int> button: 2;
|
||||
in property <int> area;
|
||||
// 0 none, 1 lyrics, 2 queue
|
||||
in property <int> panel;
|
||||
in property <[string]> lyrics;
|
||||
in property <int> lyric-line: -1;
|
||||
in property <bool> lyrics-synced;
|
||||
in property <string> lyrics-note;
|
||||
in property <[QueueItem]> queue;
|
||||
in property <string> queue-note;
|
||||
in property <string> device;
|
||||
|
||||
// 0: the big layout, 1: side by side with the panel.
|
||||
out property <float> t: self.panel != 0 ? 1 : 0;
|
||||
animate t { duration: 520ms; easing: cubic-bezier(0.22, 1, 0.36, 1); }
|
||||
pure function mix(a: float, b: float) -> length {
|
||||
(a + (b - a) * root.t) * Tv.u
|
||||
}
|
||||
|
||||
// ---- cover ----
|
||||
property <length> cover-size: root.mix(600, 360);
|
||||
Rectangle {
|
||||
x: root.mix(170, 120);
|
||||
y: root.mix(190, 120);
|
||||
width: root.cover-size;
|
||||
height: root.cover-size;
|
||||
opacity: root.alpha;
|
||||
Rectangle {
|
||||
border-radius: 20 * Tv.u;
|
||||
background: #1b1d24;
|
||||
drop-shadow-blur: 60 * Tv.u;
|
||||
drop-shadow-offset-y: 24 * Tv.u;
|
||||
drop-shadow-color: #000000b0;
|
||||
}
|
||||
Rectangle {
|
||||
border-radius: 20 * Tv.u;
|
||||
clip: true;
|
||||
Image {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
source: root.art;
|
||||
image-fit: cover;
|
||||
}
|
||||
if root.loading: Rectangle {
|
||||
background: #00000080;
|
||||
Spinner { size: 72 * Tv.u; }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// ---- texts ----
|
||||
property <length> tx: root.mix(870, 120);
|
||||
property <length> tw: root.mix(900, 620);
|
||||
property <length> ty: root.mix(220, 520);
|
||||
HorizontalLayout {
|
||||
x: root.tx;
|
||||
y: root.ty;
|
||||
width: root.tw;
|
||||
height: 36 * Tv.u;
|
||||
spacing: 12 * Tv.u;
|
||||
alignment: start;
|
||||
opacity: root.alpha;
|
||||
Equalizer {
|
||||
y: (parent.height - self.height) / 2;
|
||||
size: 22 * Tv.u;
|
||||
moving: root.playing;
|
||||
}
|
||||
Text {
|
||||
vertical-alignment: center;
|
||||
text: root.device;
|
||||
font-size: 22 * Tv.u;
|
||||
font-weight: 600;
|
||||
color: Accent.green;
|
||||
overflow: elide;
|
||||
}
|
||||
}
|
||||
title-text := Text {
|
||||
x: root.tx;
|
||||
y: root.ty + root.mix(52, 44);
|
||||
width: root.tw;
|
||||
height: min(self.preferred-height, root.mix(170, 64));
|
||||
vertical-alignment: top;
|
||||
text: root.title;
|
||||
font-size: root.panel != 0 ? 40 * Tv.u : (root.title.character-count > 30 ? 52 : 68) * Tv.u;
|
||||
font-weight: 700;
|
||||
letter-spacing: -1.5 * Tv.u;
|
||||
color: Tv.text;
|
||||
wrap: root.panel != 0 ? no-wrap : word-wrap;
|
||||
overflow: elide;
|
||||
opacity: root.alpha;
|
||||
}
|
||||
HorizontalLayout {
|
||||
x: root.tx;
|
||||
y: title-text.y + title-text.height + 10 * Tv.u;
|
||||
width: root.tw;
|
||||
height: 44 * Tv.u;
|
||||
spacing: 12 * Tv.u;
|
||||
alignment: start;
|
||||
opacity: root.alpha;
|
||||
if root.explicit: Rectangle {
|
||||
y: (parent.height - self.height) / 2;
|
||||
width: 28 * Tv.u;
|
||||
height: 28 * Tv.u;
|
||||
border-radius: 5 * Tv.u;
|
||||
background: #ffffffb0;
|
||||
Text {
|
||||
text: "E";
|
||||
font-size: 18 * Tv.u;
|
||||
font-weight: 700;
|
||||
color: #121317;
|
||||
}
|
||||
}
|
||||
Text {
|
||||
vertical-alignment: center;
|
||||
text: root.artist;
|
||||
font-size: root.mix(34, 28);
|
||||
font-weight: 600;
|
||||
color: Tv.text-secondary;
|
||||
overflow: elide;
|
||||
}
|
||||
}
|
||||
Text {
|
||||
x: root.tx;
|
||||
y: title-text.y + title-text.height + 58 * Tv.u;
|
||||
width: root.tw;
|
||||
text: root.album;
|
||||
font-size: 24 * Tv.u;
|
||||
color: Tv.text-tertiary;
|
||||
overflow: elide;
|
||||
opacity: root.alpha;
|
||||
}
|
||||
|
||||
// ---- progress ----
|
||||
property <length> py: root.ty + root.mix(400, 236);
|
||||
property <float> pf: root.area == 1 ? 1 : 0;
|
||||
animate pf { duration: 200ms; easing: ease-out; }
|
||||
property <length> rail-h: (8 + 6 * self.pf) * Tv.u;
|
||||
rail := Rectangle {
|
||||
x: root.tx;
|
||||
y: root.py - root.rail-h / 2;
|
||||
width: root.tw;
|
||||
height: root.rail-h;
|
||||
opacity: root.alpha;
|
||||
Rectangle {
|
||||
x: 0;
|
||||
width: parent.width * clamp(root.progress, 0, 1);
|
||||
border-radius: parent.height / 2;
|
||||
background: root.pf > 0.5 ? Accent.green : #ffffff;
|
||||
}
|
||||
if root.area == 1: Rectangle {
|
||||
x: parent.width * clamp(root.progress, 0, 1) - self.width / 2;
|
||||
y: (parent.height - self.height) / 2;
|
||||
width: 28 * Tv.u;
|
||||
height: 28 * Tv.u;
|
||||
border-radius: self.width / 2;
|
||||
background: #ffffff;
|
||||
drop-shadow-blur: 10 * Tv.u;
|
||||
drop-shadow-color: #00000080;
|
||||
}
|
||||
}
|
||||
Text {
|
||||
x: root.tx;
|
||||
y: root.py + 22 * Tv.u;
|
||||
text: root.time;
|
||||
font-size: 22 * Tv.u;
|
||||
font-weight: 600;
|
||||
color: Tv.text-secondary;
|
||||
opacity: root.alpha;
|
||||
}
|
||||
Text {
|
||||
x: root.tx;
|
||||
y: root.py + 22 * Tv.u;
|
||||
width: root.tw;
|
||||
horizontal-alignment: right;
|
||||
text: root.area == 1 ? "◀ ▶ tekerés" : root.duration;
|
||||
font-size: 22 * Tv.u;
|
||||
font-weight: 600;
|
||||
color: root.area == 1 ? Accent.green : Tv.text-secondary;
|
||||
opacity: root.alpha;
|
||||
}
|
||||
|
||||
// ---- buttons ----
|
||||
property <length> bs: root.mix(80, 64);
|
||||
property <length> gap: root.mix(22, 12);
|
||||
controls := HorizontalLayout {
|
||||
x: root.tx;
|
||||
y: root.py + root.mix(90, 76);
|
||||
height: root.bs * 1.25;
|
||||
spacing: root.gap;
|
||||
alignment: start;
|
||||
b0 := NpButton { y: (parent.height - self.height) / 2; icon: "shuffle"; size: root.bs; on: root.shuffle; focused: root.area == 0 && root.button == 0; alpha: root.alpha * (root.episode ? 0.4 : 1); }
|
||||
b1 := NpButton { y: (parent.height - self.height) / 2; icon: "previous"; size: root.bs; focused: root.area == 0 && root.button == 1; alpha: root.alpha; }
|
||||
b2 := NpButton { y: (parent.height - self.height) / 2; icon: root.playing ? "pause" : "play"; size: root.bs * 1.25; primary: true; focused: root.area == 0 && root.button == 2; alpha: root.alpha; }
|
||||
b3 := NpButton { y: (parent.height - self.height) / 2; icon: "next"; size: root.bs; focused: root.area == 0 && root.button == 3; alpha: root.alpha; }
|
||||
b4 := NpButton { y: (parent.height - self.height) / 2; icon: root.repeat == 2 ? "repeat-one" : "repeat"; size: root.bs; on: root.repeat > 0; focused: root.area == 0 && root.button == 4; alpha: root.alpha; }
|
||||
Rectangle { width: root.mix(24, 6); }
|
||||
b5 := NpButton { y: (parent.height - self.height) / 2; icon: root.liked == 1 ? "heart-filled" : "heart"; size: root.bs; on: root.liked == 1; focused: root.area == 0 && root.button == 5; alpha: root.alpha * (root.liked < 0 ? 0.4 : 1); }
|
||||
b6 := NpButton { y: (parent.height - self.height) / 2; icon: "lyrics"; size: root.bs; on: root.panel == 1; focused: root.area == 0 && root.button == 6; alpha: root.alpha; }
|
||||
b7 := NpButton { y: (parent.height - self.height) / 2; icon: "queue"; size: root.bs; on: root.panel == 2; focused: root.area == 0 && root.button == 7; alpha: root.alpha; }
|
||||
}
|
||||
property <[string]> hints: ["Keverés", "Előző", root.playing ? "Szünet" : "Lejátszás", "Következő", "Ismétlés", "Kedvelés", "Dalszöveg", "Lejátszási sor"];
|
||||
Caption {
|
||||
x: root.tx;
|
||||
y: controls.y + controls.height + 18 * Tv.u;
|
||||
width: root.tw;
|
||||
text: root.area == 0 ? root.hints[root.button] : "";
|
||||
opacity: root.alpha;
|
||||
}
|
||||
|
||||
// ---- the panel: lyrics or the queue ----
|
||||
property <float> pa: root.alpha * clamp(root.t * 1.6 - 0.6, 0, 1);
|
||||
panel-pane := GlassPane {
|
||||
x: 820 * Tv.u;
|
||||
y: 90 * Tv.u;
|
||||
width: 1000 * Tv.u;
|
||||
height: 900 * Tv.u;
|
||||
radius: 48 * Tv.u;
|
||||
frost: 3.2;
|
||||
tint: Tv.smoke.with-alpha(0.38);
|
||||
alpha: root.panel != 0 ? root.pa : 0;
|
||||
visible: root.t > 0.01;
|
||||
// lyrics
|
||||
if root.panel == 1: Rectangle {
|
||||
clip: true;
|
||||
opacity: root.pa;
|
||||
property <length> line-h: 76 * Tv.u;
|
||||
property <length> offset: root.lyrics-synced && root.lyric-line >= 0 ? self.height * 0.38 - root.lyric-line * self.line-h : 56 * Tv.u;
|
||||
animate offset { duration: 420ms; easing: cubic-bezier(0.22, 1, 0.36, 1); }
|
||||
for l[i] in root.lyrics: Text {
|
||||
x: 64 * Tv.u;
|
||||
y: parent.offset + i * parent.line-h;
|
||||
width: parent.width - 128 * Tv.u;
|
||||
height: parent.line-h;
|
||||
vertical-alignment: center;
|
||||
text: l == "" ? "♪" : l;
|
||||
font-size: 38 * Tv.u;
|
||||
font-weight: 700;
|
||||
color: !root.lyrics-synced ? Tv.text : i == root.lyric-line ? Tv.text : i < root.lyric-line ? #ffffff66 : #ffffff8c;
|
||||
overflow: elide;
|
||||
animate color { duration: 300ms; }
|
||||
}
|
||||
if root.lyrics-note != "": Text {
|
||||
x: 64 * Tv.u;
|
||||
width: parent.width - 128 * Tv.u;
|
||||
horizontal-alignment: center;
|
||||
text: root.lyrics-note;
|
||||
font-size: 30 * Tv.u;
|
||||
font-weight: 600;
|
||||
color: Tv.text-secondary;
|
||||
wrap: word-wrap;
|
||||
}
|
||||
}
|
||||
// queue
|
||||
if root.panel == 2: Rectangle {
|
||||
clip: true;
|
||||
opacity: root.pa;
|
||||
Text {
|
||||
x: 56 * Tv.u;
|
||||
y: 44 * Tv.u;
|
||||
text: "Következik";
|
||||
font-size: 38 * Tv.u;
|
||||
font-weight: 700;
|
||||
color: Tv.text;
|
||||
}
|
||||
for q[i] in root.queue: Rectangle {
|
||||
x: 56 * Tv.u;
|
||||
y: (120 + i * 84) * Tv.u;
|
||||
width: parent.width - 112 * Tv.u;
|
||||
height: 72 * Tv.u;
|
||||
Rectangle {
|
||||
x: 0;
|
||||
width: 64 * Tv.u;
|
||||
height: 64 * Tv.u;
|
||||
y: 4 * Tv.u;
|
||||
border-radius: 8 * Tv.u;
|
||||
clip: true;
|
||||
background: #1b1d24;
|
||||
Image {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
source: q.image;
|
||||
image-fit: cover;
|
||||
}
|
||||
}
|
||||
Text {
|
||||
x: 88 * Tv.u;
|
||||
y: 6 * Tv.u;
|
||||
width: parent.width - 88 * Tv.u;
|
||||
text: q.title;
|
||||
font-size: 26 * Tv.u;
|
||||
font-weight: 600;
|
||||
color: Tv.text;
|
||||
overflow: elide;
|
||||
}
|
||||
Text {
|
||||
x: 88 * Tv.u;
|
||||
y: 40 * Tv.u;
|
||||
width: parent.width - 88 * Tv.u;
|
||||
text: q.artist;
|
||||
font-size: 21 * Tv.u;
|
||||
color: Tv.text-tertiary;
|
||||
overflow: elide;
|
||||
}
|
||||
}
|
||||
if root.queue-note != "": Text {
|
||||
x: 56 * Tv.u;
|
||||
y: 130 * Tv.u;
|
||||
text: root.queue-note;
|
||||
font-size: 26 * Tv.u;
|
||||
color: Tv.text-secondary;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
out property <[GlassRect]> glass: [
|
||||
{
|
||||
x: rail.absolute-position.x,
|
||||
y: rail.absolute-position.y,
|
||||
w: rail.width,
|
||||
h: rail.height,
|
||||
r: rail.height / 2,
|
||||
focus: root.pf,
|
||||
alpha: root.alpha,
|
||||
blur: 1.2,
|
||||
glow: Accent.green,
|
||||
tint: #ffffff.with-alpha(0.14 + 0.1 * root.pf),
|
||||
group: 0,
|
||||
},
|
||||
b0.glass, b1.glass, b2.glass, b3.glass, b4.glass, b5.glass, b6.glass, b7.glass,
|
||||
panel-pane.glass,
|
||||
];
|
||||
}
|
||||
66
ui/overlays.slint
Normal file
66
ui/overlays.slint
Normal file
@@ -0,0 +1,66 @@
|
||||
// Overlays over any page: a picker (Select) and a toast. The page under them
|
||||
// fades out first (Nothing-under-glass): app.slint dims it while one is open.
|
||||
|
||||
import { Tv, GlassRect, GlassPane, GlassMenu, MenuItem, Icon } from "@sf-ui/sf-ui.slint";
|
||||
|
||||
// A list to choose from, centred.
|
||||
export component SelectOverlay inherits Rectangle {
|
||||
in property <float> alpha;
|
||||
in property <string> title;
|
||||
in property <[MenuItem]> items;
|
||||
in property <int> focus-index;
|
||||
menu := GlassMenu {
|
||||
x: (root.width - self.width) / 2;
|
||||
y: (root.height - self.height) / 2;
|
||||
width: 640 * Tv.u;
|
||||
title: root.title;
|
||||
items: root.items;
|
||||
focused-index: root.focus-index;
|
||||
alpha: root.alpha;
|
||||
accent: #1ed760;
|
||||
visible-rows: 9;
|
||||
}
|
||||
out property <[GlassRect]> glass: menu.glass;
|
||||
}
|
||||
|
||||
// A short message at the bottom ("Elmentve", errors).
|
||||
export component Toast inherits Rectangle {
|
||||
in property <string> text;
|
||||
in property <bool> bad;
|
||||
out property <float> t: self.text != "" ? 1 : 0;
|
||||
animate t { duration: 300ms; easing: cubic-bezier(0.3, 1.18, 0.4, 1); }
|
||||
pane := GlassPane {
|
||||
x: (root.width - self.width) / 2;
|
||||
y: root.height - (64 + 96 * root.t) * Tv.u;
|
||||
width: min(1400 * Tv.u, label.preferred-width + 140 * Tv.u);
|
||||
height: 80 * Tv.u;
|
||||
radius: self.height / 2;
|
||||
frost: 2.4;
|
||||
tint: Tv.smoke.with-alpha(0.5);
|
||||
glow: root.bad ? Tv.danger : #ffffff;
|
||||
lit: 0.3;
|
||||
alpha: root.t;
|
||||
HorizontalLayout {
|
||||
padding-left: 36 * Tv.u;
|
||||
padding-right: 36 * Tv.u;
|
||||
spacing: 14 * Tv.u;
|
||||
alignment: center;
|
||||
opacity: root.t;
|
||||
Icon {
|
||||
y: (parent.height - self.height) / 2;
|
||||
name: root.bad ? "warning" : "check";
|
||||
size: 30 * Tv.u;
|
||||
ink: root.bad ? Tv.danger-ink : Tv.ok-ink;
|
||||
}
|
||||
label := Text {
|
||||
vertical-alignment: center;
|
||||
text: root.text;
|
||||
font-size: 25 * Tv.u;
|
||||
font-weight: 600;
|
||||
color: Tv.text;
|
||||
overflow: elide;
|
||||
}
|
||||
}
|
||||
}
|
||||
out property <[GlassRect]> glass: [pane.glass];
|
||||
}
|
||||
804
ui/page.slint
Normal file
804
ui/page.slint
Normal file
@@ -0,0 +1,804 @@
|
||||
// The page renderer (from Netflex TV): every browsing screen is a list of
|
||||
// Lines built by Rust (src/page.rs), which also owns the focus and the
|
||||
// scroll position. This file draws them and their glass:
|
||||
// - the top navigation capsule and, right of it, "now playing",
|
||||
// - hero buttons (glass at rest),
|
||||
// - one focus pill that glides to the focused chip on any other line
|
||||
// (on a track row it covers the whole row),
|
||||
// - the search keyboard's pane.
|
||||
// Everything else (cards, texts, unfocused chips) is plain Slint over the
|
||||
// backdrop, so nothing Slint draws sits under glass.
|
||||
|
||||
import { Tv, GlassRect, GlassPane, Keyboard, Spinner, Display, Headline, Title, SectionTitle, Body, Item, Label, Caption } from "@sf-ui/sf-ui.slint";
|
||||
import { Line, Chip, Card, Check } from "types.slint";
|
||||
import { SpIcon } from "icons.slint";
|
||||
|
||||
export global Accent {
|
||||
out property <color> green: #1ed760;
|
||||
out property <color> deep: #1db954;
|
||||
}
|
||||
|
||||
// The liked songs' picture: a heart on Spotify's violet gradient.
|
||||
component LikedArt inherits Rectangle {
|
||||
in property <length> icon-size: 72 * Tv.u;
|
||||
background: @linear-gradient(135deg, #450af5 0%, #8e8ee5 100%);
|
||||
SpIcon {
|
||||
name: "heart-filled";
|
||||
size: root.icon-size;
|
||||
ink: #ffffff;
|
||||
}
|
||||
}
|
||||
|
||||
// An album, playlist, show (square) or artist (round) card.
|
||||
component SpCard inherits Rectangle {
|
||||
in property <Card> card;
|
||||
in property <bool> focused;
|
||||
in property <bool> round;
|
||||
in property <length> art-h;
|
||||
in property <bool> captions;
|
||||
out property <float> f: self.focused ? 1 : 0;
|
||||
animate f { duration: 260ms; easing: cubic-bezier(0.22, 1, 0.36, 1); }
|
||||
property <length> r: self.round ? root.art-h / 2 : 14 * Tv.u;
|
||||
|
||||
art := Rectangle {
|
||||
y: 0;
|
||||
height: root.art-h;
|
||||
transform-scale: 1 + 0.08 * root.f;
|
||||
Rectangle {
|
||||
border-radius: root.r;
|
||||
background: #1b1d24;
|
||||
drop-shadow-blur: (14 + 22 * root.f) * Tv.u;
|
||||
drop-shadow-offset-y: (8 + 12 * root.f) * Tv.u;
|
||||
drop-shadow-color: #00000090;
|
||||
}
|
||||
Rectangle {
|
||||
border-radius: root.r;
|
||||
clip: true;
|
||||
if root.card.mark == "liked": LikedArt { }
|
||||
if root.card.image.width == 0 && root.card.mark != "liked": Text {
|
||||
x: 20 * Tv.u;
|
||||
width: parent.width - 40 * Tv.u;
|
||||
horizontal-alignment: center;
|
||||
vertical-alignment: center;
|
||||
text: root.card.title;
|
||||
font-size: 24 * Tv.u;
|
||||
font-weight: 600;
|
||||
color: Tv.text-tertiary;
|
||||
wrap: word-wrap;
|
||||
}
|
||||
Image {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
source: root.card.image;
|
||||
image-fit: cover;
|
||||
}
|
||||
Rectangle {
|
||||
background: #000000;
|
||||
opacity: 0.2 * (1 - root.f);
|
||||
}
|
||||
}
|
||||
if root.card.current: Rectangle {
|
||||
border-radius: root.r;
|
||||
border-width: 4 * Tv.u;
|
||||
border-color: Accent.green;
|
||||
}
|
||||
}
|
||||
if root.captions: Text {
|
||||
x: 0;
|
||||
y: root.art-h + 18 * Tv.u;
|
||||
width: root.width;
|
||||
horizontal-alignment: root.round ? center : left;
|
||||
text: root.card.caption;
|
||||
font-size: 24 * Tv.u;
|
||||
font-weight: 600;
|
||||
color: root.focused ? Tv.text : #ffffffd0;
|
||||
overflow: elide;
|
||||
}
|
||||
if root.captions: Text {
|
||||
x: 0;
|
||||
y: root.art-h + 52 * Tv.u;
|
||||
width: root.width;
|
||||
horizontal-alignment: root.round ? center : left;
|
||||
text: root.card.detail;
|
||||
font-size: 20 * Tv.u;
|
||||
color: Tv.text-tertiary;
|
||||
overflow: elide;
|
||||
}
|
||||
}
|
||||
|
||||
// A chip drawn by Slint. Focused chips get the page's glass pill underneath,
|
||||
// hero chips are glass all the time: neither draws a background then.
|
||||
component SpChip inherits Rectangle {
|
||||
in property <Chip> chip;
|
||||
in property <bool> focused;
|
||||
in property <bool> on-glass;
|
||||
property <bool> plain: root.focused || root.on-glass;
|
||||
property <color> ink: root.focused && root.chip.tone != "primary" ? Tv.ink
|
||||
: root.chip.tone == "danger" ? Tv.danger-ink
|
||||
: root.chip.active || root.on-glass || root.chip.tone == "primary" ? Tv.text
|
||||
: #ffffffd0;
|
||||
x: root.chip.x * Tv.u;
|
||||
y: root.chip.y * Tv.u;
|
||||
width: root.chip.w * Tv.u;
|
||||
height: root.chip.h * Tv.u;
|
||||
opacity: root.chip.enabled ? 1 : 0.42;
|
||||
Rectangle {
|
||||
visible: !root.plain;
|
||||
border-radius: root.chip.tone == "field" ? 22 * Tv.u : self.height / 2;
|
||||
background: root.chip.tone == "field" ? #ffffff10
|
||||
: root.chip.tone == "primary" ? #1ed76080
|
||||
: root.chip.active ? #ffffff2c
|
||||
: #ffffff12;
|
||||
border-width: root.chip.tone == "field" ? 1.5 * Tv.u : 0;
|
||||
border-color: #ffffff38;
|
||||
}
|
||||
HorizontalLayout {
|
||||
padding-left: root.chip.tone == "field" ? 28 * Tv.u : root.chip.text == "" ? (root.height - 30 * Tv.u) / 2 : (root.chip.icon == "" ? 26 : 20) * Tv.u;
|
||||
padding-right: root.chip.tone == "field" ? 28 * Tv.u : root.chip.text == "" ? (root.height - 30 * Tv.u) / 2 : 26 * Tv.u;
|
||||
spacing: 10 * Tv.u;
|
||||
alignment: root.chip.tone == "field" ? start : center;
|
||||
if root.chip.icon != "": SpIcon {
|
||||
y: (parent.height - self.height) / 2;
|
||||
name: root.chip.icon;
|
||||
size: (root.chip.text == "" ? 30 : 28) * Tv.u;
|
||||
ink: root.ink;
|
||||
}
|
||||
if root.chip.text != "": Text {
|
||||
vertical-alignment: center;
|
||||
horizontal-stretch: root.chip.tone == "field" ? 1 : 0;
|
||||
text: root.chip.text;
|
||||
font-size: (root.chip.tone == "field" ? 26 : 23) * Tv.u;
|
||||
font-weight: root.chip.active || root.focused || root.chip.tone == "primary" ? 700 : 600;
|
||||
color: root.ink;
|
||||
overflow: elide;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Three bars that move while a track plays (track rows, the nav capsule).
|
||||
export component Equalizer inherits Rectangle {
|
||||
in property <color> ink: Accent.green;
|
||||
in property <bool> moving: true;
|
||||
in property <length> size: 24 * Tv.u;
|
||||
width: self.size;
|
||||
height: self.size;
|
||||
// Only ticks while moving: a paused screen draws no frames.
|
||||
property <duration> t: root.moving ? animation-tick() : 0ms;
|
||||
for i in 3: Rectangle {
|
||||
property <float> phase: root.moving ? (1 + sin((root.t / 1ms) * (0.45 + i * 0.17) * 1deg)) / 2 : 0.35;
|
||||
x: i * root.size / 3 + root.size / 18;
|
||||
width: root.size / 4.5;
|
||||
height: root.size * (0.25 + 0.75 * self.phase);
|
||||
y: root.size - self.height;
|
||||
border-radius: self.width / 3;
|
||||
background: root.ink;
|
||||
}
|
||||
}
|
||||
|
||||
export component LinePage inherits Rectangle {
|
||||
in property <float> alpha: 1;
|
||||
in property <[Line]> lines;
|
||||
in property <int> focus-line: -1;
|
||||
// Vertical scroll position (design px), animated here.
|
||||
in property <float> scroll;
|
||||
// Top navigation (main sections).
|
||||
in property <bool> show-nav;
|
||||
in property <[string]> nav-items;
|
||||
in property <int> nav-index;
|
||||
in property <bool> nav-focused;
|
||||
// "Now playing" right of the nav ("" = nothing loaded).
|
||||
in property <string> np-title;
|
||||
in property <string> np-artist;
|
||||
in property <bool> np-playing;
|
||||
in property <bool> np-focused;
|
||||
// The signed-in user (top right): their picture, or their initial.
|
||||
in property <image> user-image;
|
||||
in property <string> user-initial;
|
||||
// Embedded search keyboard: its top (design px, page coordinates; < 0 = none).
|
||||
in property <float> kb-y: -1;
|
||||
in property <bool> kb-focused;
|
||||
in property <string> kb-placeholder;
|
||||
in property <string> kb-submit-label: "Keresés";
|
||||
in-out property <string> query;
|
||||
callback search-submitted(string);
|
||||
callback search-exit-down();
|
||||
callback search-exit-up();
|
||||
callback search-cancelled();
|
||||
public function kb-key(event: KeyEvent) -> EventResult {
|
||||
kb.key(event)
|
||||
}
|
||||
public function kb-reset() {
|
||||
kb.reset();
|
||||
}
|
||||
|
||||
// Content left edge (design px).
|
||||
property <float> cx: 96;
|
||||
out property <float> scroll-anim: self.scroll;
|
||||
animate scroll-anim { duration: 380ms; easing: cubic-bezier(0.22, 1, 0.36, 1); }
|
||||
property <bool> content-focus: !self.nav-focused && !self.np-focused && !self.kb-focused;
|
||||
|
||||
// ---- lines ----
|
||||
for line[li] in root.lines: Rectangle {
|
||||
property <float> ty: line.y - root.scroll-anim;
|
||||
property <bool> lf: li == root.focus-line && root.content-focus;
|
||||
x: (root.cx + line.x) * Tv.u;
|
||||
y: self.ty * Tv.u;
|
||||
width: line.w * Tv.u;
|
||||
height: line.h * Tv.u;
|
||||
visible: self.ty + line.h > -40 && self.ty < 1120;
|
||||
opacity: root.alpha;
|
||||
|
||||
// hero without a cover (big title)
|
||||
if line.kind == "hero" && !line.framed: Rectangle {
|
||||
if line.style != "": Text {
|
||||
x: 0;
|
||||
y: 12 * Tv.u;
|
||||
text: line.style;
|
||||
font-size: 20 * Tv.u;
|
||||
font-weight: 700;
|
||||
letter-spacing: 3 * Tv.u;
|
||||
color: Tv.text-secondary;
|
||||
}
|
||||
Display {
|
||||
x: 0;
|
||||
y: 90 * Tv.u;
|
||||
width: 1300 * Tv.u;
|
||||
text: line.title;
|
||||
font-size: (line.title.character-count > 24 ? 64 : 88) * Tv.u;
|
||||
}
|
||||
Caption {
|
||||
x: 0;
|
||||
y: 242 * Tv.u;
|
||||
width: 1300 * Tv.u;
|
||||
text: line.subtitle;
|
||||
}
|
||||
Label {
|
||||
x: 0;
|
||||
y: 274 * Tv.u;
|
||||
width: 1500 * Tv.u;
|
||||
text: line.meta;
|
||||
color: Tv.text;
|
||||
}
|
||||
Body {
|
||||
x: 0;
|
||||
y: 316 * Tv.u;
|
||||
width: 1100 * Tv.u;
|
||||
height: 152 * Tv.u;
|
||||
text: line.text;
|
||||
font-size: 26 * Tv.u;
|
||||
}
|
||||
for chip[ci] in line.chips: SpChip {
|
||||
chip: chip;
|
||||
focused: lf && line.col == ci;
|
||||
on-glass: true;
|
||||
}
|
||||
}
|
||||
|
||||
// hero with a cover: picture left, texts and buttons right
|
||||
if line.kind == "hero" && line.framed: Rectangle {
|
||||
Rectangle {
|
||||
x: 0;
|
||||
y: 20 * Tv.u;
|
||||
width: 360 * Tv.u;
|
||||
height: 360 * Tv.u;
|
||||
border-radius: line.round ? self.width / 2 : 18 * Tv.u;
|
||||
background: #1b1d24;
|
||||
drop-shadow-blur: 40 * Tv.u;
|
||||
drop-shadow-offset-y: 16 * Tv.u;
|
||||
drop-shadow-color: #000000a0;
|
||||
}
|
||||
Rectangle {
|
||||
x: 0;
|
||||
y: 20 * Tv.u;
|
||||
width: 360 * Tv.u;
|
||||
height: 360 * Tv.u;
|
||||
border-radius: line.round ? self.width / 2 : 18 * Tv.u;
|
||||
clip: true;
|
||||
if line.icon == "liked": LikedArt { icon-size: 120 * Tv.u; }
|
||||
Image {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
source: line.cover;
|
||||
image-fit: cover;
|
||||
}
|
||||
}
|
||||
property <length> tx: 420 * Tv.u;
|
||||
Text {
|
||||
x: parent.tx;
|
||||
y: 28 * Tv.u;
|
||||
text: line.style;
|
||||
font-size: 20 * Tv.u;
|
||||
font-weight: 700;
|
||||
letter-spacing: 3 * Tv.u;
|
||||
color: Tv.text-secondary;
|
||||
}
|
||||
Text {
|
||||
x: parent.tx;
|
||||
y: 58 * Tv.u;
|
||||
width: parent.width - parent.tx;
|
||||
height: 120 * Tv.u;
|
||||
vertical-alignment: center;
|
||||
text: line.title;
|
||||
font-size: (line.title.character-count > 40 ? 44 : line.title.character-count > 22 ? 58 : 80) * Tv.u;
|
||||
font-weight: 700;
|
||||
letter-spacing: -2 * Tv.u;
|
||||
color: Tv.text;
|
||||
wrap: word-wrap;
|
||||
overflow: elide;
|
||||
}
|
||||
Text {
|
||||
x: parent.tx;
|
||||
y: 186 * Tv.u;
|
||||
width: parent.width - parent.tx;
|
||||
text: line.subtitle;
|
||||
font-size: 28 * Tv.u;
|
||||
font-weight: 700;
|
||||
color: Tv.text;
|
||||
overflow: elide;
|
||||
}
|
||||
Label {
|
||||
x: parent.tx;
|
||||
y: 226 * Tv.u;
|
||||
width: parent.width - parent.tx;
|
||||
text: line.meta;
|
||||
color: Tv.text-secondary;
|
||||
overflow: elide;
|
||||
}
|
||||
Text {
|
||||
x: parent.tx;
|
||||
y: 262 * Tv.u;
|
||||
width: min(parent.width - parent.tx, 1100 * Tv.u);
|
||||
height: 62 * Tv.u;
|
||||
text: line.text;
|
||||
font-size: 22 * Tv.u;
|
||||
color: Tv.text-tertiary;
|
||||
wrap: word-wrap;
|
||||
overflow: elide;
|
||||
}
|
||||
for chip[ci] in line.chips: SpChip {
|
||||
chip: chip;
|
||||
focused: lf && line.col == ci;
|
||||
on-glass: true;
|
||||
}
|
||||
}
|
||||
|
||||
// heading
|
||||
if line.kind == "heading": Rectangle {
|
||||
Text {
|
||||
x: 0;
|
||||
y: 4 * Tv.u;
|
||||
text: line.title;
|
||||
font-size: (line.style == "big" ? 56 : 38) * Tv.u;
|
||||
font-weight: 700;
|
||||
letter-spacing: (line.style == "big" ? -1 : -0.4) * Tv.u;
|
||||
color: Tv.text;
|
||||
}
|
||||
Caption {
|
||||
x: 0;
|
||||
y: (line.style == "big" ? 76 : 54) * Tv.u;
|
||||
width: parent.width;
|
||||
text: line.subtitle;
|
||||
}
|
||||
}
|
||||
|
||||
// text
|
||||
if line.kind == "text": Text {
|
||||
x: 0;
|
||||
y: 0;
|
||||
width: parent.width;
|
||||
height: parent.height;
|
||||
text: line.text;
|
||||
wrap: word-wrap;
|
||||
vertical-alignment: top;
|
||||
font-size: (line.style == "caption" ? 22 : line.style == "label" ? 24 : 26) * Tv.u;
|
||||
font-weight: line.style == "label" ? 600 : 400;
|
||||
color: line.style == "warn" ? Tv.warn-ink : line.style == "bad" ? Tv.danger-ink : line.style == "good" ? Tv.ok-ink : line.style == "caption" ? Tv.text-tertiary : Tv.text-secondary;
|
||||
}
|
||||
|
||||
// notice
|
||||
if line.kind == "notice": Rectangle {
|
||||
SpIcon {
|
||||
x: 0;
|
||||
y: 4 * Tv.u;
|
||||
size: 36 * Tv.u;
|
||||
name: line.icon != "" ? line.icon : line.tone == "good" ? "check" : line.tone == "info" ? "info" : "warning";
|
||||
ink: line.tone == "good" ? Tv.ok-ink : line.tone == "bad" ? Tv.danger-ink : line.tone == "warn" ? Tv.warn-ink : Tv.text-secondary;
|
||||
}
|
||||
Item {
|
||||
x: 56 * Tv.u;
|
||||
y: 4 * Tv.u;
|
||||
width: parent.width - 56 * Tv.u;
|
||||
text: line.title;
|
||||
font-size: 27 * Tv.u;
|
||||
}
|
||||
Text {
|
||||
x: 56 * Tv.u;
|
||||
y: 44 * Tv.u;
|
||||
width: parent.width - 56 * Tv.u;
|
||||
height: parent.height - 44 * Tv.u;
|
||||
text: line.text;
|
||||
wrap: word-wrap;
|
||||
font-size: 23 * Tv.u;
|
||||
color: Tv.text-secondary;
|
||||
}
|
||||
}
|
||||
|
||||
// chips
|
||||
if line.kind == "chips": Rectangle {
|
||||
if line.title != "": Text {
|
||||
x: 0;
|
||||
y: 0;
|
||||
text: line.title;
|
||||
font-size: 22 * Tv.u;
|
||||
font-weight: 600;
|
||||
letter-spacing: 1 * Tv.u;
|
||||
color: Tv.text-tertiary;
|
||||
}
|
||||
for chip[ci] in line.chips: SpChip {
|
||||
chip: chip;
|
||||
focused: lf && line.col == ci;
|
||||
}
|
||||
}
|
||||
|
||||
// item
|
||||
if line.kind == "item": Rectangle {
|
||||
Text {
|
||||
x: 0;
|
||||
y: 6 * Tv.u;
|
||||
width: parent.width;
|
||||
text: line.title;
|
||||
font-size: 26 * Tv.u;
|
||||
font-weight: 600;
|
||||
color: Tv.text;
|
||||
overflow: elide;
|
||||
}
|
||||
Text {
|
||||
x: 0;
|
||||
y: 42 * Tv.u;
|
||||
width: parent.width;
|
||||
text: line.meta;
|
||||
font-size: 21 * Tv.u;
|
||||
font-weight: 500;
|
||||
color: Tv.text-tertiary;
|
||||
overflow: elide;
|
||||
}
|
||||
Text {
|
||||
x: 0;
|
||||
y: 74 * Tv.u;
|
||||
width: min(parent.width, 1100 * Tv.u);
|
||||
height: 58 * Tv.u;
|
||||
text: line.text;
|
||||
font-size: 21 * Tv.u;
|
||||
color: Tv.text-secondary;
|
||||
wrap: word-wrap;
|
||||
overflow: elide;
|
||||
}
|
||||
for chip[ci] in line.chips: SpChip {
|
||||
chip: chip;
|
||||
focused: lf && line.col == ci;
|
||||
}
|
||||
}
|
||||
|
||||
// track row
|
||||
if line.kind == "track": Rectangle {
|
||||
property <bool> f0: lf && line.col == 0;
|
||||
property <bool> playing: line.tone == "playing";
|
||||
property <length> body-w: parent.width - 96 * Tv.u;
|
||||
property <color> ink: self.f0 ? Tv.ink : self.playing ? Accent.green : line.tone == "dim" ? Tv.text-tertiary : Tv.text;
|
||||
if line.note != "" && line.tone != "playing": Text {
|
||||
x: 8 * Tv.u;
|
||||
width: 64 * Tv.u;
|
||||
height: parent.height;
|
||||
horizontal-alignment: center;
|
||||
vertical-alignment: center;
|
||||
text: line.note;
|
||||
font-size: 24 * Tv.u;
|
||||
font-weight: 600;
|
||||
color: parent.f0 ? Tv.ink : Tv.text-tertiary;
|
||||
}
|
||||
if line.note != "" && line.tone == "playing": Equalizer {
|
||||
x: 28 * Tv.u;
|
||||
y: (parent.height - self.height) / 2;
|
||||
ink: parent.f0 ? Tv.ink : Accent.green;
|
||||
}
|
||||
if line.note == "": Rectangle {
|
||||
x: 10 * Tv.u;
|
||||
y: 8 * Tv.u;
|
||||
width: 64 * Tv.u;
|
||||
height: 64 * Tv.u;
|
||||
border-radius: 8 * Tv.u;
|
||||
clip: true;
|
||||
background: #1b1d24;
|
||||
Image {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
source: line.image;
|
||||
image-fit: cover;
|
||||
}
|
||||
}
|
||||
Text {
|
||||
x: 96 * Tv.u;
|
||||
y: 10 * Tv.u;
|
||||
width: parent.body-w - 96 * Tv.u - 130 * Tv.u;
|
||||
text: line.title;
|
||||
font-size: 26 * Tv.u;
|
||||
font-weight: 600;
|
||||
color: parent.ink;
|
||||
overflow: elide;
|
||||
}
|
||||
Text {
|
||||
x: 96 * Tv.u;
|
||||
y: 44 * Tv.u;
|
||||
width: parent.body-w - 96 * Tv.u - 130 * Tv.u;
|
||||
text: line.meta;
|
||||
font-size: 21 * Tv.u;
|
||||
font-weight: 500;
|
||||
color: parent.f0 ? #121317b0 : Tv.text-tertiary;
|
||||
overflow: elide;
|
||||
}
|
||||
Text {
|
||||
x: parent.body-w - 130 * Tv.u;
|
||||
width: 100 * Tv.u;
|
||||
height: parent.height;
|
||||
horizontal-alignment: right;
|
||||
vertical-alignment: center;
|
||||
text: line.extra;
|
||||
font-size: 22 * Tv.u;
|
||||
font-weight: 500;
|
||||
color: parent.f0 ? Tv.ink : Tv.text-tertiary;
|
||||
}
|
||||
if line.chips.length > 1: SpChip {
|
||||
chip: line.chips[1];
|
||||
focused: lf && line.col == 1;
|
||||
}
|
||||
}
|
||||
|
||||
// cards
|
||||
if line.kind == "cards": Rectangle {
|
||||
property <float> cw: line.style == "landscape" ? 400 : 216;
|
||||
property <float> ch: line.style == "landscape" ? 225 : 216;
|
||||
property <float> step: self.cw + 32;
|
||||
property <float> head: line.title != "" ? 56 : 0;
|
||||
property <int> fit: floor((line.w + 32) / self.step);
|
||||
property <float> scroll-to: clamp(line.col - 1, 0, max(0, line.cards.length - self.fit));
|
||||
property <float> sc: self.scroll-to;
|
||||
animate sc { duration: 320ms; easing: cubic-bezier(0.22, 1, 0.36, 1); }
|
||||
if line.title != "": Text {
|
||||
x: 0;
|
||||
y: 0;
|
||||
text: line.title;
|
||||
font-size: 32 * Tv.u;
|
||||
font-weight: 700;
|
||||
color: lf ? Tv.text : #ffffffc8;
|
||||
}
|
||||
for card[ci] in line.cards: SpCard {
|
||||
x: (ci - parent.sc) * parent.step * Tv.u;
|
||||
y: parent.head * Tv.u;
|
||||
width: parent.cw * Tv.u;
|
||||
height: (parent.ch + (line.captions ? 80 : 0)) * Tv.u;
|
||||
art-h: parent.ch * Tv.u;
|
||||
round: line.style == "round";
|
||||
visible: ci >= parent.sc - 2 && ci < parent.sc + parent.fit + 2;
|
||||
card: card;
|
||||
captions: line.captions;
|
||||
focused: lf && line.col == ci;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// ---- embedded keyboard (search) ----
|
||||
kb-pane := GlassPane {
|
||||
x: (root.width - self.width) / 2;
|
||||
y: (root.kb-y - root.scroll-anim) * Tv.u;
|
||||
width: 1720 * Tv.u;
|
||||
height: 508 * Tv.u;
|
||||
radius: 48 * Tv.u;
|
||||
frost: 3.4;
|
||||
tint: Tv.smoke.with-alpha(0.44);
|
||||
alpha: root.kb-y >= 0 ? root.alpha : 0;
|
||||
visible: root.kb-y >= 0;
|
||||
kb := Keyboard {
|
||||
x: 0;
|
||||
y: 40 * Tv.u;
|
||||
width: parent.width;
|
||||
compact: true;
|
||||
placeholder: root.kb-placeholder;
|
||||
submit-label: root.kb-submit-label;
|
||||
min-length: 2;
|
||||
max-length: 60;
|
||||
active: root.kb-focused;
|
||||
alpha: root.kb-y >= 0 ? root.alpha : 0;
|
||||
text <=> root.query;
|
||||
submitted(t) => { root.search-submitted(t); }
|
||||
cancelled => { root.search-cancelled(); }
|
||||
exit-down => { root.search-exit-down(); }
|
||||
exit-up => { root.search-exit-up(); }
|
||||
}
|
||||
}
|
||||
|
||||
// ---- top navigation ----
|
||||
property <length> tab-w: 190 * Tv.u;
|
||||
property <float> nav-a: root.show-nav ? root.alpha * (root.nav-focused || root.np-focused ? 1 : clamp(1 - root.scroll-anim / 120, 0, 1)) : 0;
|
||||
nav := GlassPane {
|
||||
x: (root.width - self.width) / 2;
|
||||
y: 40 * Tv.u;
|
||||
width: root.nav-items.length * root.tab-w + 16 * Tv.u;
|
||||
height: 80 * Tv.u;
|
||||
radius: self.height / 2;
|
||||
frost: 1.6;
|
||||
tint: #ffffff0a;
|
||||
alpha: root.nav-a;
|
||||
visible: root.show-nav;
|
||||
for t[i] in root.nav-items: Text {
|
||||
x: 8 * Tv.u + i * root.tab-w;
|
||||
width: root.tab-w;
|
||||
height: parent.height;
|
||||
horizontal-alignment: center;
|
||||
vertical-alignment: center;
|
||||
text: t;
|
||||
font-size: 25 * Tv.u;
|
||||
font-weight: 600;
|
||||
color: i == root.nav-index ? (root.nav-focused ? Tv.ink : Tv.text) : Tv.text-secondary;
|
||||
opacity: root.nav-a;
|
||||
}
|
||||
}
|
||||
|
||||
// ---- now playing capsule ----
|
||||
property <bool> np-on: root.show-nav && root.np-title != "";
|
||||
out property <float> np-t: self.np-focused ? 1 : 0;
|
||||
animate np-t { duration: 220ms; easing: ease-out; }
|
||||
np := Rectangle {
|
||||
x: nav.x + nav.width + 24 * Tv.u;
|
||||
y: nav.y + 4 * Tv.u;
|
||||
width: max(0, min(460 * Tv.u, np-text.preferred-width + 100 * Tv.u, avatar.x - 24 * Tv.u - self.x));
|
||||
height: 72 * Tv.u;
|
||||
visible: root.np-on;
|
||||
opacity: root.nav-a;
|
||||
Equalizer {
|
||||
x: 24 * Tv.u;
|
||||
y: (parent.height - self.height) / 2;
|
||||
moving: root.np-playing;
|
||||
ink: root.np-focused ? Tv.ink : Accent.green;
|
||||
}
|
||||
np-text := VerticalLayout {
|
||||
x: 64 * Tv.u;
|
||||
width: parent.width - 88 * Tv.u;
|
||||
alignment: center;
|
||||
Text {
|
||||
text: root.np-title;
|
||||
font-size: 22 * Tv.u;
|
||||
font-weight: 700;
|
||||
color: root.np-focused ? Tv.ink : Tv.text;
|
||||
overflow: elide;
|
||||
}
|
||||
Text {
|
||||
text: root.np-artist;
|
||||
font-size: 19 * Tv.u;
|
||||
font-weight: 500;
|
||||
color: root.np-focused ? #121317b0 : Tv.text-secondary;
|
||||
overflow: elide;
|
||||
}
|
||||
}
|
||||
}
|
||||
// ---- the signed-in user ----
|
||||
avatar := Rectangle {
|
||||
x: root.width - Tv.safe-x - self.width;
|
||||
y: 44 * Tv.u;
|
||||
width: 72 * Tv.u;
|
||||
height: 72 * Tv.u;
|
||||
visible: root.show-nav && (root.user-initial != "" || root.user-image.width > 0);
|
||||
opacity: root.nav-a;
|
||||
Rectangle {
|
||||
border-radius: self.width / 2;
|
||||
background: #ffffff26;
|
||||
drop-shadow-blur: 16 * Tv.u;
|
||||
drop-shadow-offset-y: 6 * Tv.u;
|
||||
drop-shadow-color: #00000070;
|
||||
}
|
||||
Rectangle {
|
||||
border-radius: self.width / 2;
|
||||
clip: true;
|
||||
if root.user-image.width == 0: Text {
|
||||
text: root.user-initial;
|
||||
font-size: 32 * Tv.u;
|
||||
font-weight: 700;
|
||||
color: Tv.text;
|
||||
}
|
||||
Image {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
source: root.user-image;
|
||||
image-fit: cover;
|
||||
}
|
||||
}
|
||||
}
|
||||
out property <float> tab-pos: self.nav-index;
|
||||
animate tab-pos { duration: 260ms; easing: cubic-bezier(0.22, 1, 0.36, 1); }
|
||||
out property <float> nav-t: self.nav-focused ? 1 : 0;
|
||||
animate nav-t { duration: 220ms; easing: ease-out; }
|
||||
|
||||
// ---- glass ----
|
||||
property <Line> fl: root.focus-line >= 0 && root.focus-line < root.lines.length ? root.lines[root.focus-line] : root.lines[0];
|
||||
property <Chip> fc: root.fl.chips[max(0, root.fl.col)];
|
||||
property <bool> pill-on: root.content-focus && root.focus-line >= 0 && root.fl.kind != "hero" && root.fl.kind != "cards" && root.fc.w > 0;
|
||||
out property <float> pill-x: root.cx + root.fl.x + root.fc.x;
|
||||
animate pill-x { duration: 220ms; easing: cubic-bezier(0.22, 1, 0.36, 1); }
|
||||
out property <float> pill-w: root.fc.w;
|
||||
animate pill-w { duration: 220ms; easing: cubic-bezier(0.22, 1, 0.36, 1); }
|
||||
out property <float> pill-y: root.fl.y + root.fc.y;
|
||||
animate pill-y { duration: 260ms; easing: cubic-bezier(0.22, 1, 0.36, 1); }
|
||||
out property <float> pill-h: root.fc.h;
|
||||
animate pill-h { duration: 220ms; easing: cubic-bezier(0.22, 1, 0.36, 1); }
|
||||
out property <float> pill-a: root.pill-on ? 1 : 0;
|
||||
animate pill-a { duration: 160ms; easing: ease-out; }
|
||||
property <Line> hero: root.lines.length > 0 && root.lines[0].kind == "hero" ? root.lines[0] : root.fl;
|
||||
property <bool> has-hero: root.lines.length > 0 && root.lines[0].kind == "hero";
|
||||
|
||||
pure function hero-rect(i: int) -> GlassRect {
|
||||
let c = root.hero.chips[i];
|
||||
let f = root.has-hero && root.focus-line == 0 && root.content-focus && root.hero.col == i ? 1 : 0;
|
||||
let s = 1 + 0.05 * f;
|
||||
{
|
||||
x: (root.cx + root.hero.x + c.x) * Tv.u - c.w * Tv.u * (s - 1) / 2,
|
||||
y: (root.hero.y + c.y - root.scroll-anim) * Tv.u - c.h * Tv.u * (s - 1) / 2,
|
||||
w: c.w * Tv.u * s,
|
||||
h: c.h * Tv.u * s,
|
||||
r: c.h * Tv.u * s / 2,
|
||||
focus: f,
|
||||
alpha: root.has-hero && c.w > 0 && i < root.hero.chips.length ? root.alpha * (c.enabled ? 1 : 0.5) : 0,
|
||||
blur: 1.4,
|
||||
glow: c.tone == "primary" ? Accent.green : #ffffff,
|
||||
tint: c.tone == "primary" ? Accent.deep.with-alpha(0.5 + 0.4 * f) : #ffffff.with-alpha((c.active ? 0.16 : 0.07) + 0.8 * f),
|
||||
group: 0,
|
||||
}
|
||||
}
|
||||
|
||||
out property <[GlassRect]> glass: [
|
||||
nav.glass,
|
||||
{
|
||||
x: nav.absolute-position.x + 8 * Tv.u + root.tab-pos * root.tab-w,
|
||||
y: nav.absolute-position.y + 8 * Tv.u,
|
||||
w: root.tab-w,
|
||||
h: nav.height - 16 * Tv.u,
|
||||
r: (nav.height - 16 * Tv.u) / 2,
|
||||
focus: root.nav-t,
|
||||
alpha: root.nav-a,
|
||||
blur: -1,
|
||||
glow: #ffffff,
|
||||
tint: #ffffff.with-alpha(0.12 + 0.76 * root.nav-t),
|
||||
group: 0,
|
||||
},
|
||||
{
|
||||
x: np.absolute-position.x,
|
||||
y: np.absolute-position.y,
|
||||
w: np.width,
|
||||
h: np.height,
|
||||
r: np.height / 2,
|
||||
focus: root.np-t,
|
||||
alpha: root.np-on ? root.nav-a : 0,
|
||||
blur: 1.6,
|
||||
glow: Accent.green,
|
||||
tint: #ffffff.with-alpha(0.06 + 0.82 * root.np-t),
|
||||
group: 0,
|
||||
},
|
||||
root.hero-rect(0),
|
||||
root.hero-rect(1),
|
||||
root.hero-rect(2),
|
||||
root.hero-rect(3),
|
||||
{
|
||||
x: root.pill-x * Tv.u,
|
||||
y: (root.pill-y - root.scroll-anim) * Tv.u,
|
||||
w: root.pill-w * Tv.u,
|
||||
h: root.pill-h * Tv.u,
|
||||
r: root.fc.tone == "field" ? 22 * Tv.u : root.pill-h * Tv.u / 2,
|
||||
focus: 1,
|
||||
alpha: root.alpha * root.pill-a,
|
||||
blur: 1.2,
|
||||
glow: root.fc.tone == "primary" ? Accent.green : #ffffff,
|
||||
tint: root.fc.tone == "primary" ? Accent.deep.with-alpha(0.85) : #ffffff.with-alpha(root.fc.tone == "field" ? 0.82 : 0.88),
|
||||
group: 0,
|
||||
},
|
||||
kb-pane.glass,
|
||||
];
|
||||
out property <[GlassRect]> glass-keyboard: kb.glass;
|
||||
}
|
||||
244
ui/signin.slint
Normal file
244
ui/signin.slint
Normal file
@@ -0,0 +1,244 @@
|
||||
// Sign-in from the phone (Spotify Connect), the text input overlay (on a
|
||||
// modal glass pane with the on-screen keyboard) and a plain message screen.
|
||||
|
||||
import { Tv, GlassRect, GlassPane, Keyboard, Spinner, Display, Title, Body, Label, Caption, Icon } from "@sf-ui/sf-ui.slint";
|
||||
import { SpIcon } from "icons.slint";
|
||||
|
||||
// Sign-in, two ways: a pairing code (QR code or spotify.com/pair) or this
|
||||
// TV picked in the Spotify app on the phone (Spotify Connect).
|
||||
export component ConnectScreen inherits Rectangle {
|
||||
in property <float> alpha: 1;
|
||||
in property <string> device;
|
||||
in property <string> code;
|
||||
in property <image> qr;
|
||||
in property <bool> busy;
|
||||
in property <string> error;
|
||||
|
||||
pane := GlassPane {
|
||||
x: (root.width - self.width) / 2;
|
||||
y: (root.height - self.height) / 2 - 20 * Tv.u;
|
||||
width: 1640 * Tv.u;
|
||||
height: 760 * Tv.u;
|
||||
radius: 56 * Tv.u;
|
||||
frost: 3.6;
|
||||
tint: Tv.smoke.with-alpha(0.46);
|
||||
glow: #1ed760;
|
||||
alpha: root.alpha;
|
||||
|
||||
// ---- left: title and the two ways ----
|
||||
VerticalLayout {
|
||||
x: 80 * Tv.u;
|
||||
y: 72 * Tv.u;
|
||||
width: 860 * Tv.u;
|
||||
height: parent.height - 144 * Tv.u;
|
||||
spacing: 18 * Tv.u;
|
||||
opacity: root.alpha;
|
||||
HorizontalLayout {
|
||||
spacing: 24 * Tv.u;
|
||||
alignment: start;
|
||||
Rectangle {
|
||||
width: 80 * Tv.u;
|
||||
height: 80 * Tv.u;
|
||||
border-radius: self.width / 2;
|
||||
background: #1ed760;
|
||||
SpIcon {
|
||||
name: "audio";
|
||||
size: 44 * Tv.u;
|
||||
ink: #121317;
|
||||
}
|
||||
}
|
||||
VerticalLayout {
|
||||
alignment: center;
|
||||
Title { text: "Jelentkezz be a telefonoddal"; }
|
||||
Caption { text: "Spotify Premium fiók kell hozzá"; }
|
||||
}
|
||||
}
|
||||
Rectangle { height: 14 * Tv.u; }
|
||||
Text {
|
||||
text: "QR-KÓDDAL";
|
||||
font-size: 20 * Tv.u;
|
||||
font-weight: 700;
|
||||
letter-spacing: 3 * Tv.u;
|
||||
color: #1ed760;
|
||||
}
|
||||
Body {
|
||||
text: "Olvasd be a kódot a telefon kamerájával, és jelentkezz be. Vagy nyisd meg a spotify.com/pair oldalt, és írd be a kódot.";
|
||||
font-size: 26 * Tv.u;
|
||||
color: Tv.text;
|
||||
}
|
||||
Rectangle { height: 10 * Tv.u; }
|
||||
Text {
|
||||
text: "A SPOTIFY APPBÓL";
|
||||
font-size: 20 * Tv.u;
|
||||
font-weight: 700;
|
||||
letter-spacing: 3 * Tv.u;
|
||||
color: #1ed760;
|
||||
}
|
||||
Body {
|
||||
text: "Ha a telefon ugyanazon a Wi-Fin van: indíts el egy számot, koppints az eszközök ikonjára, és válaszd: „" + root.device + "”.";
|
||||
font-size: 26 * Tv.u;
|
||||
color: Tv.text;
|
||||
}
|
||||
Rectangle { }
|
||||
HorizontalLayout {
|
||||
spacing: 16 * Tv.u;
|
||||
alignment: start;
|
||||
height: 48 * Tv.u;
|
||||
Spinner { size: 40 * Tv.u; }
|
||||
Label {
|
||||
vertical-alignment: center;
|
||||
text: root.busy ? "Bejelentkezés…" : root.error != "" ? root.error : "Várakozás a telefonra…";
|
||||
color: root.error != "" && !root.busy ? Tv.warn-ink : Tv.text-secondary;
|
||||
wrap: word-wrap;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// ---- right: the QR code and the code ----
|
||||
qr-box := Rectangle {
|
||||
x: parent.width - self.width - 96 * Tv.u;
|
||||
y: 80 * Tv.u;
|
||||
width: 440 * Tv.u;
|
||||
height: 440 * Tv.u;
|
||||
border-radius: 28 * Tv.u;
|
||||
background: #ffffff;
|
||||
opacity: root.alpha;
|
||||
clip: true;
|
||||
if root.qr.width > 0: Image {
|
||||
x: 20 * Tv.u;
|
||||
y: 20 * Tv.u;
|
||||
width: parent.width - 40 * Tv.u;
|
||||
height: parent.height - 40 * Tv.u;
|
||||
source: root.qr;
|
||||
image-rendering: pixelated;
|
||||
}
|
||||
if root.qr.width == 0: Spinner {
|
||||
size: 64 * Tv.u;
|
||||
ink: #121317;
|
||||
}
|
||||
}
|
||||
Text {
|
||||
x: qr-box.x;
|
||||
y: qr-box.y + qr-box.height + 28 * Tv.u;
|
||||
width: qr-box.width;
|
||||
horizontal-alignment: center;
|
||||
text: "spotify.com/pair";
|
||||
font-size: 24 * Tv.u;
|
||||
font-weight: 600;
|
||||
color: Tv.text-secondary;
|
||||
opacity: root.alpha;
|
||||
}
|
||||
Text {
|
||||
x: qr-box.x;
|
||||
y: qr-box.y + qr-box.height + 66 * Tv.u;
|
||||
width: qr-box.width;
|
||||
horizontal-alignment: center;
|
||||
text: root.code;
|
||||
font-size: 64 * Tv.u;
|
||||
font-weight: 700;
|
||||
letter-spacing: 10 * Tv.u;
|
||||
color: Tv.text;
|
||||
opacity: root.alpha;
|
||||
}
|
||||
}
|
||||
Caption {
|
||||
x: pane.x;
|
||||
y: pane.y + pane.height + 28 * Tv.u;
|
||||
width: pane.width;
|
||||
horizontal-alignment: center;
|
||||
text: "Vissza: kilépés";
|
||||
opacity: root.alpha;
|
||||
}
|
||||
|
||||
out property <[GlassRect]> glass: [pane.glass];
|
||||
}
|
||||
|
||||
// A text field over everything (the TV's name...).
|
||||
export component InputScreen inherits Rectangle {
|
||||
in property <float> alpha: 1;
|
||||
in property <string> title;
|
||||
in property <string> subtitle;
|
||||
in property <string> placeholder;
|
||||
in property <string> submit-label: "Kész";
|
||||
in property <int> min-length: 1;
|
||||
in-out property <string> text;
|
||||
in-out property <string> error;
|
||||
callback submitted(string);
|
||||
callback cancelled();
|
||||
|
||||
public function key(event: KeyEvent) -> EventResult {
|
||||
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: #1ed760;
|
||||
alpha: root.alpha;
|
||||
kb := Keyboard {
|
||||
x: 0;
|
||||
y: 72 * Tv.u;
|
||||
width: parent.width;
|
||||
title: root.title;
|
||||
subtitle: root.subtitle;
|
||||
placeholder: root.placeholder;
|
||||
submit-label: root.submit-label;
|
||||
min-length: root.min-length;
|
||||
max-length: 60;
|
||||
alpha: root.alpha;
|
||||
active: true;
|
||||
text <=> root.text;
|
||||
error <=> root.error;
|
||||
submitted(t) => { root.submitted(t); }
|
||||
cancelled => { root.cancelled(); }
|
||||
}
|
||||
}
|
||||
|
||||
out property <[GlassRect]> glass: [pane.glass];
|
||||
out property <[GlassRect]> glass-keyboard: kb.glass;
|
||||
}
|
||||
|
||||
// Loading and errors.
|
||||
export component MessageScreen inherits Rectangle {
|
||||
in property <float> alpha: 1;
|
||||
in property <bool> busy;
|
||||
in property <string> title;
|
||||
in property <string> text;
|
||||
|
||||
VerticalLayout {
|
||||
x: Tv.safe-x;
|
||||
width: root.width - 2 * Tv.safe-x;
|
||||
y: 340 * Tv.u;
|
||||
height: 400 * 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;
|
||||
}
|
||||
Caption {
|
||||
horizontal-alignment: center;
|
||||
text: root.busy ? "" : "Újrapróbálkozik magától. Vissza: kilépés";
|
||||
}
|
||||
}
|
||||
}
|
||||
91
ui/types.slint
Normal file
91
ui/types.slint
Normal file
@@ -0,0 +1,91 @@
|
||||
// Data the Rust side fills in. Every page is a list of Lines (src/page.rs);
|
||||
// all lengths here are design px (1920x1080 grid), multiplied by Tv.u.
|
||||
|
||||
// A button / choice / text field on a line. x, y relative to the line.
|
||||
export struct Chip {
|
||||
id: string,
|
||||
text: string,
|
||||
icon: string,
|
||||
x: float,
|
||||
y: float,
|
||||
w: float,
|
||||
h: float,
|
||||
// Selected (a choice, the current tab).
|
||||
active: bool,
|
||||
// "" | "primary" (accent glass) | "danger" | "field" (text field)
|
||||
tone: string,
|
||||
enabled: bool,
|
||||
}
|
||||
|
||||
// A card in a cards line.
|
||||
export struct Card {
|
||||
id: string,
|
||||
title: string,
|
||||
// Under the card (cards lines with captions).
|
||||
caption: string,
|
||||
detail: string,
|
||||
image: image,
|
||||
// 0..1; negative = no bar.
|
||||
progress: float,
|
||||
badge: string,
|
||||
badge-tone: string,
|
||||
// "liked": the liked songs' card (a heart on a gradient).
|
||||
mark: string,
|
||||
big: string,
|
||||
// Highlighted (plays now).
|
||||
current: bool,
|
||||
}
|
||||
|
||||
export struct Check {
|
||||
state: int,
|
||||
label: string,
|
||||
detail: string,
|
||||
}
|
||||
|
||||
// One line of a page.
|
||||
// hero big title block with buttons; with a cover (`framed`) the
|
||||
// texts sit right of a square (or round) picture
|
||||
// heading section title (+ subtitle)
|
||||
// text paragraph (style "body" | "caption" | "label" | "warn" | "bad" | "good")
|
||||
// notice icon + title + text, toned ("good" | "bad" | "warn" | "info")
|
||||
// chips a row of chips (title = label above them)
|
||||
// cards a row of cards (style "square" | "round" | "landscape"; captions under them)
|
||||
// item list row: optional picture, title, meta, text, chips
|
||||
// track a song row: number or art, title, meta, duration, "more" chip
|
||||
// checks two columns of check rows
|
||||
// keyboard room for the page's on-screen keyboard
|
||||
export struct Line {
|
||||
id: string,
|
||||
kind: string,
|
||||
y: float,
|
||||
h: float,
|
||||
x: float,
|
||||
w: float,
|
||||
title: string,
|
||||
subtitle: string,
|
||||
meta: string,
|
||||
extra: string,
|
||||
text: string,
|
||||
note: string,
|
||||
style: string,
|
||||
tone: string,
|
||||
icon: string,
|
||||
image: image,
|
||||
logo: image,
|
||||
cover: image,
|
||||
round: bool,
|
||||
framed: bool,
|
||||
progress: float,
|
||||
col: int,
|
||||
captions: bool,
|
||||
cards: [Card],
|
||||
chips: [Chip],
|
||||
checks: [Check],
|
||||
}
|
||||
|
||||
// A row of the queue (now playing).
|
||||
export struct QueueItem {
|
||||
title: string,
|
||||
artist: string,
|
||||
image: image,
|
||||
}
|
||||
Reference in New Issue
Block a user