Files
spotify/ui/app.slint
Tamas Csikel 740397ea59
Some checks failed
release / release (push) Failing after 13s
0.1.1: browse through Spotify's internal endpoints
The public Web API answers librespot's client id with 429 on every call
(and the old keymaster token endpoint with 403), so every page failed.
Browsing now goes through the same librespot session as playback:
metadata, /playlist/v2 (rootlist and lists), /collection/v2 (liked songs,
saved albums, followed artists and podcasts; save and like too),
recently played, the search context, and a Connect command for the queue.

- Home: recently played albums/playlists/artists, your playlists, your
  artists, saved albums, podcasts (no top lists or new releases there).
- Search finds songs; artists and albums come from them.
- Playlists without a picture get Spotify's mosaic cover.
- The queue panel is gone (the internal API does not show the queue).
- The Web API client stays for the mock server only.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-03 18:15:02 +01:00

194 lines
8.1 KiB
Plaintext

// 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 <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;
}