YouTube 2.0.0: native client without ads
All checks were successful
release / release (push) Successful in 10m13s
All checks were successful
release / release (push) Successful in 10m13s
Replaces the web app (youtube.com/tv in Chromium) with a native Rust + Slint client on sf-ui, built on Netflex TV's page engine. - InnerTube: web client for public pages, the TV client with the account's OAuth token for personal ones, visionOS (direct URLs) for streams, the TV client with yt-dlp's ejs solver (QuickJS) as fallback. - One version, no ads: ad breaks are never requested, ad renderers are skipped in feeds. SponsorBlock skips sponsored parts. - Sign-in with a QR code / youtube.com/activate (OAuth device flow). - Signed out: subscriptions and history on the TV; a home filled with this week's popular Hungarian videos when YouTube's is empty. - Playback: one-quality DASH manifest for GStreamer, H.264 up to 1080p or AV1 up to 4K, captions, quality switching, up next, resume. - Release builds for x86-64 and the Raspberry Pi (aarch64). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
154
ui/app.slint
Normal file
154
ui/app.slint
Normal file
@@ -0,0 +1,154 @@
|
||||
// YouTube for Fennec OS: the root window.
|
||||
//
|
||||
// Screens: "page" (every browsing screen: a LinePage built by src/page.rs)
|
||||
// and "player". Over them: the QR sign-in and the toast.
|
||||
//
|
||||
// Rust owns state and focus: every key goes to the `key` callback, except
|
||||
// while the search keyboard has the focus.
|
||||
|
||||
import { TvWindow, Tv, SfText, GlassRect, MenuItem } from "@sf-ui/sf-ui.slint";
|
||||
import { Line, Chip, Card, Check } from "types.slint";
|
||||
import { LinePage } from "page.slint";
|
||||
import { PlayerScreen } from "player.slint";
|
||||
import { LinkScreen } from "link.slint";
|
||||
import { Toast } from "overlays.slint";
|
||||
|
||||
export { Tv, SfText, MenuItem, Line, Chip, Card, Check }
|
||||
|
||||
export component App inherits TvWindow {
|
||||
title: "YouTube";
|
||||
forward-focus: keys;
|
||||
|
||||
// "page", "player"
|
||||
in property <string> screen: "page";
|
||||
// The key text (Slint's Key codes) and whether it repeats; true = handled.
|
||||
callback key(string, bool) -> bool;
|
||||
|
||||
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> player-t: self.screen == "player" ? 1 : 0;
|
||||
animate player-t { duration: 420ms; easing: cubic-bezier(0.22, 1, 0.36, 1); }
|
||||
out property <float> link-t: self.link-open ? 1 : 0;
|
||||
animate link-t { duration: 420ms; easing: cubic-bezier(0.22, 1, 0.36, 1); }
|
||||
// Whatever an overlay would cover goes away first.
|
||||
property <float> under: max(0, 1 - 1.6 * self.link-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.screen == "page" && root.page-kb-focused && !root.link-open {
|
||||
return page.kb-key(event);
|
||||
}
|
||||
if root.key(event.text, event.repeat) {
|
||||
return accept;
|
||||
}
|
||||
reject
|
||||
}
|
||||
}
|
||||
|
||||
// ---- 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-account-label <=> page.account-label;
|
||||
in property <bool> page-account-ok <=> page.account-ok;
|
||||
in property <string> page-side-title <=> page.side-title;
|
||||
in property <[string]> page-side-items <=> page.side-items;
|
||||
in property <int> page-side-index <=> page.side-index;
|
||||
in property <int> page-side-focus <=> page.side-focus;
|
||||
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(); }
|
||||
}
|
||||
|
||||
// ---- player ----
|
||||
in property <string> player-stage <=> player.stage;
|
||||
in property <string> player-title <=> player.title;
|
||||
in property <string> player-heading <=> player.heading;
|
||||
in property <string> player-info <=> player.info;
|
||||
in property <string> player-caption <=> player.caption;
|
||||
in property <string> player-stage-text <=> player.stage-text;
|
||||
in property <string> player-detail-text <=> player.detail-text;
|
||||
in property <string> player-error-text <=> player.error-text;
|
||||
in property <bool> player-osd <=> player.osd;
|
||||
in property <bool> player-paused <=> player.paused;
|
||||
in property <bool> player-buffering <=> player.buffering;
|
||||
in property <string> player-buffer-text <=> player.buffer-text;
|
||||
in property <float> player-progress <=> player.progress;
|
||||
in property <float> player-buffered <=> player.buffered;
|
||||
in property <string> player-time-text <=> player.time-text;
|
||||
in property <string> player-remaining-text <=> player.remaining-text;
|
||||
in property <bool> player-seeking <=> player.seeking;
|
||||
in property <string> player-seek-text <=> player.seek-text;
|
||||
in property <string> player-seek-delta <=> player.seek-delta;
|
||||
in property <bool> player-seek-back <=> player.seek-back;
|
||||
in property <int> player-osd-area <=> player.osd-area;
|
||||
in property <int> player-osd-button <=> player.osd-button;
|
||||
in property <bool> player-has-next <=> player.has-next;
|
||||
in property <bool> player-has-channel <=> player.has-channel;
|
||||
in property <int> player-panel <=> player.panel;
|
||||
in property <[MenuItem]> player-subs <=> player.subs;
|
||||
in property <[MenuItem]> player-quality <=> player.quality;
|
||||
in property <int> player-subs-focus <=> player.subs-focus;
|
||||
in property <int> player-quality-focus <=> player.quality-focus;
|
||||
in property <string> player-skip-label <=> player.skip-label;
|
||||
in property <string> player-next-label <=> player.next-label;
|
||||
in property <string> player-next-text <=> player.next-text;
|
||||
player := PlayerScreen {
|
||||
alpha: root.vis(root.player-t) * root.under;
|
||||
visible: root.player-t > 0.001;
|
||||
stage-text: "Betöltés…";
|
||||
}
|
||||
|
||||
// ---- QR sign-in ----
|
||||
in property <bool> link-open;
|
||||
in property <image> link-qr <=> link.qr;
|
||||
in property <string> link-code <=> link.code;
|
||||
in property <string> link-url <=> link.url;
|
||||
in property <string> link-status <=> link.status;
|
||||
in-out property <bool> link-busy <=> link.busy;
|
||||
link := LinkScreen {
|
||||
alpha: root.vis(root.link-t);
|
||||
visible: root.link-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-page: page.glass;
|
||||
out property <[GlassRect]> glass-page-keyboard: page.glass-keyboard;
|
||||
out property <[GlassRect]> glass-player: player.glass;
|
||||
out property <[GlassRect]> glass-player-subs: player.glass-subs;
|
||||
out property <[GlassRect]> glass-player-quality: player.glass-quality;
|
||||
out property <[GlassRect]> glass-link: link.glass;
|
||||
out property <[GlassRect]> glass-toast: toast.glass;
|
||||
}
|
||||
99
ui/link.slint
Normal file
99
ui/link.slint
Normal file
@@ -0,0 +1,99 @@
|
||||
// Sign-in with a phone: a QR code and the code to type at
|
||||
// youtube.com/activate, on a modal glass pane. Rust polls YouTube until the
|
||||
// user confirms (src/app.rs, sign_in). Back cancels; OK asks for a new code
|
||||
// after an error.
|
||||
|
||||
import { Tv, GlassRect, GlassPane, Spinner, Title, Label, Caption, Icon } from "@sf-ui/sf-ui.slint";
|
||||
|
||||
export component LinkScreen inherits Rectangle {
|
||||
in property <float> alpha: 1;
|
||||
in property <image> qr;
|
||||
in property <string> code;
|
||||
in property <string> url;
|
||||
in property <string> status;
|
||||
in property <bool> busy;
|
||||
|
||||
pane := GlassPane {
|
||||
x: (root.width - self.width) / 2;
|
||||
y: (root.height - self.height) / 2;
|
||||
width: 1500 * Tv.u;
|
||||
height: 700 * Tv.u;
|
||||
radius: 56 * Tv.u;
|
||||
frost: 3.8;
|
||||
tint: Tv.smoke.with-alpha(0.5);
|
||||
glow: #ff0033;
|
||||
alpha: root.alpha;
|
||||
|
||||
// The QR code on a white card (Slint over glass is fine: it sits on
|
||||
// the pane, nothing glass is under it).
|
||||
Rectangle {
|
||||
x: 80 * Tv.u;
|
||||
y: (parent.height - self.height) / 2;
|
||||
width: 460 * Tv.u;
|
||||
height: 460 * Tv.u;
|
||||
border-radius: 28 * Tv.u;
|
||||
background: #ffffff;
|
||||
opacity: root.alpha;
|
||||
if root.qr.width > 0: Image {
|
||||
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; }
|
||||
}
|
||||
|
||||
VerticalLayout {
|
||||
x: 620 * Tv.u;
|
||||
y: 96 * Tv.u;
|
||||
width: parent.width - 700 * Tv.u;
|
||||
height: parent.height - 160 * Tv.u;
|
||||
spacing: 22 * Tv.u;
|
||||
alignment: start;
|
||||
opacity: root.alpha;
|
||||
Title { text: "Bejelentkezés a YouTube-ba"; }
|
||||
Label {
|
||||
text: "1. Olvasd be a QR-kódot a telefonoddal, vagy nyisd meg ezt az oldalt:";
|
||||
wrap: word-wrap;
|
||||
color: Tv.text-secondary;
|
||||
}
|
||||
Text {
|
||||
text: root.url == "" ? "youtube.com/activate" : root.url;
|
||||
font-size: 34 * Tv.u;
|
||||
font-weight: 700;
|
||||
color: Tv.text;
|
||||
}
|
||||
Label {
|
||||
text: "2. Írd be ezt a kódot, és válaszd ki a fiókodat:";
|
||||
wrap: word-wrap;
|
||||
color: Tv.text-secondary;
|
||||
}
|
||||
Text {
|
||||
text: root.code == "" ? "…" : root.code;
|
||||
font-size: 72 * Tv.u;
|
||||
font-weight: 800;
|
||||
letter-spacing: 6 * Tv.u;
|
||||
color: #ffffff;
|
||||
}
|
||||
HorizontalLayout {
|
||||
spacing: 16 * Tv.u;
|
||||
alignment: start;
|
||||
if root.busy: Spinner { size: 36 * Tv.u; }
|
||||
if !root.busy: Icon { name: "warning"; size: 34 * Tv.u; ink: Tv.warn-ink; }
|
||||
Caption {
|
||||
vertical-alignment: center;
|
||||
text: root.status;
|
||||
wrap: word-wrap;
|
||||
}
|
||||
}
|
||||
}
|
||||
Caption {
|
||||
x: 620 * Tv.u;
|
||||
y: parent.height - 72 * Tv.u;
|
||||
text: "Vissza: mégse";
|
||||
opacity: root.alpha;
|
||||
}
|
||||
}
|
||||
|
||||
out property <[GlassRect]> glass: [pane.glass];
|
||||
}
|
||||
45
ui/overlays.slint
Normal file
45
ui/overlays.slint
Normal file
@@ -0,0 +1,45 @@
|
||||
// The toast over any page.
|
||||
|
||||
import { Tv, GlassRect, GlassPane, Icon } from "@sf-ui/sf-ui.slint";
|
||||
|
||||
// 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];
|
||||
}
|
||||
810
ui/page.slint
Normal file
810
ui/page.slint
Normal file
@@ -0,0 +1,810 @@
|
||||
// The page renderer: every screen except the player and the sign-in 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 (main sections) or the settings side list,
|
||||
// - hero buttons (glass at rest),
|
||||
// - one focus pill that glides to the focused chip on any other line,
|
||||
// - 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, Icon, Spinner, Display, Headline, Title, SectionTitle, Body, Item, Label, Caption } from "@sf-ui/sf-ui.slint";
|
||||
import { Line, Chip, Card, Check } from "types.slint";
|
||||
|
||||
// A poster, landscape artwork or season card.
|
||||
component NfCard inherits Rectangle {
|
||||
in property <Card> card;
|
||||
in property <bool> focused;
|
||||
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); }
|
||||
|
||||
art := Rectangle {
|
||||
y: 0;
|
||||
height: root.art-h;
|
||||
transform-scale: 1 + 0.08 * root.f;
|
||||
Rectangle {
|
||||
border-radius: 20 * Tv.u;
|
||||
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: 20 * Tv.u;
|
||||
clip: true;
|
||||
if root.card.image.width == 0: Text {
|
||||
x: 20 * Tv.u;
|
||||
width: parent.width - 40 * Tv.u;
|
||||
horizontal-alignment: center;
|
||||
vertical-alignment: center;
|
||||
text: root.card.big != "" ? "" : root.card.title;
|
||||
font-size: 24 * Tv.u;
|
||||
font-weight: 600;
|
||||
color: Tv.text-tertiary;
|
||||
wrap: word-wrap;
|
||||
}
|
||||
if !root.card.round: Image {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
source: root.card.image;
|
||||
image-fit: cover;
|
||||
}
|
||||
// A channel: its round picture in the middle.
|
||||
if root.card.round: Rectangle {
|
||||
width: parent.height * 0.78;
|
||||
height: self.width;
|
||||
border-radius: self.width / 2;
|
||||
clip: true;
|
||||
Image {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
source: root.card.image;
|
||||
image-fit: cover;
|
||||
}
|
||||
}
|
||||
if root.card.big != "": Rectangle {
|
||||
background: #00000070;
|
||||
Text {
|
||||
text: root.card.big;
|
||||
font-size: 68 * Tv.u;
|
||||
font-weight: 700;
|
||||
letter-spacing: -2 * Tv.u;
|
||||
color: Tv.text;
|
||||
}
|
||||
}
|
||||
Rectangle {
|
||||
background: #000000;
|
||||
opacity: 0.22 * (1 - root.f);
|
||||
}
|
||||
if root.card.progress >= 0: Rectangle {
|
||||
x: 12 * Tv.u;
|
||||
y: parent.height - 18 * Tv.u;
|
||||
width: parent.width - 24 * Tv.u;
|
||||
height: 6 * Tv.u;
|
||||
border-radius: self.height / 2;
|
||||
background: #ffffff40;
|
||||
Rectangle {
|
||||
x: 0;
|
||||
width: parent.width * clamp(root.card.progress, 0, 1);
|
||||
border-radius: self.height / 2;
|
||||
background: root.card.progress >= 0.999 ? Tv.ok : #ff0033;
|
||||
}
|
||||
}
|
||||
}
|
||||
if root.card.badge != "": Rectangle {
|
||||
x: 12 * Tv.u;
|
||||
y: 12 * Tv.u;
|
||||
width: badge-text.preferred-width + 22 * Tv.u;
|
||||
height: 34 * Tv.u;
|
||||
border-radius: self.height / 2;
|
||||
background: root.card.badge-tone == "dub" ? #1f7a4dd8 : root.card.badge-tone == "sub" ? #2b5fa8d8 : root.card.badge-tone == "accent" ? #ff0033d8 : #000000b8;
|
||||
badge-text := Text {
|
||||
text: root.card.badge;
|
||||
font-size: 19 * Tv.u;
|
||||
font-weight: 700;
|
||||
color: Tv.text;
|
||||
}
|
||||
}
|
||||
// The length of a video, bottom right.
|
||||
if root.card.corner != "": Rectangle {
|
||||
x: parent.width - self.width - 12 * Tv.u;
|
||||
y: parent.height - self.height - (root.card.progress >= 0 ? 30 : 12) * Tv.u;
|
||||
width: corner-text.preferred-width + 18 * Tv.u;
|
||||
height: 32 * Tv.u;
|
||||
border-radius: 8 * Tv.u;
|
||||
background: #000000c8;
|
||||
corner-text := Text {
|
||||
text: root.card.corner;
|
||||
font-size: 19 * Tv.u;
|
||||
font-weight: 700;
|
||||
color: Tv.text;
|
||||
}
|
||||
}
|
||||
if root.card.mark == "check": Rectangle {
|
||||
x: parent.width - self.width - 12 * Tv.u;
|
||||
y: 12 * Tv.u;
|
||||
width: 36 * Tv.u;
|
||||
height: 36 * Tv.u;
|
||||
border-radius: self.height / 2;
|
||||
background: #000000b8;
|
||||
Icon {
|
||||
name: "check";
|
||||
size: 22 * Tv.u;
|
||||
ink: Tv.ok-ink;
|
||||
}
|
||||
}
|
||||
if root.card.current: Rectangle {
|
||||
border-radius: 20 * Tv.u;
|
||||
border-width: 4 * Tv.u;
|
||||
border-color: #ff0033;
|
||||
}
|
||||
}
|
||||
// Clipped: right-to-left titles may not elide inside the card.
|
||||
if root.captions: Rectangle {
|
||||
x: 0;
|
||||
y: root.art-h + 14 * Tv.u;
|
||||
width: root.width;
|
||||
height: 74 * Tv.u;
|
||||
clip: true;
|
||||
Text {
|
||||
x: 0;
|
||||
y: 4 * Tv.u;
|
||||
width: parent.width;
|
||||
text: root.card.caption;
|
||||
font-size: 24 * Tv.u;
|
||||
font-weight: 600;
|
||||
color: root.focused ? Tv.text : #ffffffd0;
|
||||
overflow: elide;
|
||||
}
|
||||
Text {
|
||||
x: 0;
|
||||
y: 38 * Tv.u;
|
||||
width: parent.width;
|
||||
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 NfChip 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 == "include" ? Tv.ok-ink
|
||||
: root.chip.tone == "exclude" || 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" ? #ff003380
|
||||
: root.chip.tone == "include" ? #34c75938
|
||||
: root.chip.tone == "exclude" ? #ff453a38
|
||||
: 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 != "": Icon {
|
||||
y: (parent.height - self.height) / 2;
|
||||
name: root.chip.icon;
|
||||
size: 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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
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;
|
||||
in property <string> account-label;
|
||||
in property <bool> account-ok;
|
||||
// Settings side list.
|
||||
in property <string> side-title;
|
||||
in property <[string]> side-items;
|
||||
in property <int> side-index;
|
||||
in property <int> side-focus: -1;
|
||||
// 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();
|
||||
}
|
||||
|
||||
property <bool> side: self.side-items.length > 0;
|
||||
// Content left edge (design px).
|
||||
property <float> cx: self.side ? 600 : 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.side-focus < 0 && !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
|
||||
if line.kind == "hero": Rectangle {
|
||||
if line.logo.width > 0: Image {
|
||||
x: 0;
|
||||
y: 40 * Tv.u;
|
||||
width: 620 * Tv.u;
|
||||
height: 190 * Tv.u;
|
||||
source: line.logo;
|
||||
image-fit: contain;
|
||||
horizontal-alignment: left;
|
||||
vertical-alignment: bottom;
|
||||
}
|
||||
if line.logo.width == 0: 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;
|
||||
}
|
||||
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;
|
||||
}
|
||||
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;
|
||||
}
|
||||
Label {
|
||||
x: 0;
|
||||
y: 312 * Tv.u;
|
||||
width: 1500 * Tv.u;
|
||||
text: line.extra;
|
||||
color: #ff8a8a;
|
||||
font-weight: 600;
|
||||
}
|
||||
Body {
|
||||
x: 0;
|
||||
y: (line.extra == "" ? 316 : 352) * Tv.u;
|
||||
width: 1100 * Tv.u;
|
||||
height: (line.extra == "" ? 152 : 116) * Tv.u;
|
||||
text: line.text;
|
||||
font-size: 26 * Tv.u;
|
||||
}
|
||||
for chip[ci] in line.chips: NfChip {
|
||||
chip: chip;
|
||||
focused: lf && line.col == ci;
|
||||
on-glass: true;
|
||||
}
|
||||
if line.progress >= 0: Rectangle {
|
||||
x: 0;
|
||||
y: (line.h - 22) * Tv.u;
|
||||
width: 360 * Tv.u;
|
||||
height: 6 * Tv.u;
|
||||
border-radius: self.height / 2;
|
||||
background: #ffffff33;
|
||||
Rectangle {
|
||||
x: 0;
|
||||
width: parent.width * clamp(line.progress, 0, 1);
|
||||
border-radius: self.height / 2;
|
||||
background: #ff0033;
|
||||
}
|
||||
}
|
||||
if line.note != "": Caption {
|
||||
x: 380 * Tv.u;
|
||||
y: (line.h - 34) * Tv.u;
|
||||
text: line.note;
|
||||
}
|
||||
}
|
||||
|
||||
// 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 {
|
||||
Icon {
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
// checks
|
||||
if line.kind == "checks": Rectangle {
|
||||
for c[i] in line.checks: Rectangle {
|
||||
x: mod(i, 2) * parent.width / 2;
|
||||
y: floor(i / 2) * 84 * Tv.u;
|
||||
width: parent.width / 2 - 24 * Tv.u;
|
||||
height: 80 * Tv.u;
|
||||
Icon {
|
||||
x: 0;
|
||||
y: 2 * Tv.u;
|
||||
size: 28 * Tv.u;
|
||||
name: c.state == 1 ? "check" : c.state == 0 ? "close" : "info";
|
||||
ink: c.state == 1 ? Tv.ok-ink : c.state == 0 ? Tv.danger-ink : Tv.warn-ink;
|
||||
}
|
||||
Text {
|
||||
x: 44 * Tv.u;
|
||||
y: 0;
|
||||
width: parent.width - 44 * Tv.u;
|
||||
text: c.label;
|
||||
font-size: 23 * Tv.u;
|
||||
font-weight: 600;
|
||||
color: Tv.text;
|
||||
overflow: elide;
|
||||
}
|
||||
Text {
|
||||
x: 44 * Tv.u;
|
||||
y: 32 * Tv.u;
|
||||
width: parent.width - 44 * Tv.u;
|
||||
height: 48 * Tv.u;
|
||||
text: c.detail;
|
||||
font-size: 20 * Tv.u;
|
||||
color: Tv.text-tertiary;
|
||||
wrap: word-wrap;
|
||||
overflow: elide;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 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: NfChip {
|
||||
chip: chip;
|
||||
focused: lf && line.col == ci;
|
||||
}
|
||||
}
|
||||
|
||||
// item
|
||||
if line.kind == "item": Rectangle {
|
||||
property <bool> pic: line.style == "image";
|
||||
property <length> tx: (self.pic ? 288 : 0) * Tv.u;
|
||||
if self.pic: Rectangle {
|
||||
x: 0;
|
||||
y: 8 * Tv.u;
|
||||
width: 256 * Tv.u;
|
||||
height: 144 * Tv.u;
|
||||
border-radius: 16 * Tv.u;
|
||||
clip: true;
|
||||
background: #1b1d24;
|
||||
Image {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
source: line.image;
|
||||
image-fit: cover;
|
||||
}
|
||||
if line.progress >= 0: Rectangle {
|
||||
x: 10 * Tv.u;
|
||||
y: parent.height - 16 * Tv.u;
|
||||
width: parent.width - 20 * Tv.u;
|
||||
height: 6 * Tv.u;
|
||||
border-radius: self.height / 2;
|
||||
background: #ffffff40;
|
||||
Rectangle {
|
||||
x: 0;
|
||||
width: parent.width * clamp(line.progress, 0, 1);
|
||||
border-radius: self.height / 2;
|
||||
background: line.progress >= 0.999 ? Tv.ok : #ff0033;
|
||||
}
|
||||
}
|
||||
}
|
||||
if !self.pic && line.progress >= 0: Rectangle {
|
||||
x: 0;
|
||||
y: parent.height - 12 * Tv.u;
|
||||
width: 900 * Tv.u;
|
||||
height: 6 * Tv.u;
|
||||
border-radius: self.height / 2;
|
||||
background: #ffffff26;
|
||||
Rectangle {
|
||||
x: 0;
|
||||
width: parent.width * clamp(line.progress, 0, 1);
|
||||
border-radius: self.height / 2;
|
||||
background: line.tone == "warn" ? Tv.warn : line.tone == "good" ? Tv.ok : #4f8cff;
|
||||
}
|
||||
}
|
||||
Text {
|
||||
x: parent.tx;
|
||||
y: 6 * Tv.u;
|
||||
width: parent.width - parent.tx;
|
||||
text: line.title;
|
||||
font-size: 26 * Tv.u;
|
||||
font-weight: 600;
|
||||
color: line.tone == "dim" ? Tv.text-tertiary : Tv.text;
|
||||
overflow: elide;
|
||||
}
|
||||
Text {
|
||||
x: parent.tx;
|
||||
y: 42 * Tv.u;
|
||||
width: parent.width - parent.tx;
|
||||
text: line.meta;
|
||||
font-size: 21 * Tv.u;
|
||||
font-weight: 500;
|
||||
color: line.tone == "bad" ? Tv.danger-ink : line.tone == "warn" ? Tv.warn-ink : Tv.text-tertiary;
|
||||
overflow: elide;
|
||||
}
|
||||
Text {
|
||||
x: parent.tx;
|
||||
y: 74 * Tv.u;
|
||||
width: min(parent.width - parent.tx, 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: NfChip {
|
||||
chip: chip;
|
||||
focused: lf && line.col == ci;
|
||||
}
|
||||
}
|
||||
|
||||
// cards
|
||||
if line.kind == "cards": Rectangle {
|
||||
property <float> cw: line.style == "landscape" ? 400 : line.style == "season" ? 168 : 196;
|
||||
property <float> ch: line.style == "landscape" ? 225 : line.style == "season" ? 252 : 294;
|
||||
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: 600;
|
||||
color: lf ? Tv.text : #ffffffc8;
|
||||
}
|
||||
if line.subtitle != "": Caption {
|
||||
x: title-w.preferred-width + 20 * Tv.u;
|
||||
y: 10 * Tv.u;
|
||||
text: line.subtitle;
|
||||
}
|
||||
title-w := Text {
|
||||
visible: false;
|
||||
text: line.title;
|
||||
font-size: 32 * Tv.u;
|
||||
font-weight: 600;
|
||||
}
|
||||
for card[ci] in line.cards: NfCard {
|
||||
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;
|
||||
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(); }
|
||||
}
|
||||
}
|
||||
|
||||
// ---- settings side list ----
|
||||
// Under the top nav its own tab already names the page.
|
||||
if root.side && !root.show-nav: Headline {
|
||||
x: Tv.safe-x;
|
||||
y: 56 * Tv.u;
|
||||
text: root.side-title;
|
||||
opacity: root.alpha;
|
||||
}
|
||||
for item[i] in root.side-items: Text {
|
||||
x: (96 + 28) * Tv.u;
|
||||
y: (184 + i * 80) * Tv.u;
|
||||
width: (440 - 56) * Tv.u;
|
||||
height: 72 * Tv.u;
|
||||
vertical-alignment: center;
|
||||
text: item;
|
||||
font-size: 26 * Tv.u;
|
||||
font-weight: 600;
|
||||
color: i == root.side-focus ? Tv.ink : i == root.side-index ? Tv.text : Tv.text-secondary;
|
||||
opacity: root.alpha;
|
||||
}
|
||||
|
||||
// ---- top navigation ----
|
||||
property <length> tab-w: 232 * Tv.u;
|
||||
property <float> nav-a: root.show-nav ? root.alpha * (root.nav-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;
|
||||
}
|
||||
}
|
||||
if root.show-nav && root.account-label != "": HorizontalLayout {
|
||||
x: nav.x + nav.width + 28 * Tv.u;
|
||||
y: nav.y;
|
||||
height: nav.height;
|
||||
spacing: 10 * Tv.u;
|
||||
opacity: root.nav-a;
|
||||
Rectangle {
|
||||
width: 12 * Tv.u;
|
||||
Rectangle {
|
||||
y: (parent.height - self.height) / 2;
|
||||
height: 12 * Tv.u;
|
||||
border-radius: self.height / 2;
|
||||
background: root.account-ok ? Tv.ok : Tv.danger;
|
||||
}
|
||||
}
|
||||
Text {
|
||||
vertical-alignment: center;
|
||||
text: root.account-label;
|
||||
font-size: 22 * Tv.u;
|
||||
font-weight: 600;
|
||||
color: root.account-ok ? Tv.ok-ink : Tv.danger-ink;
|
||||
}
|
||||
}
|
||||
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; }
|
||||
out property <float> side-pos: self.side-index;
|
||||
animate side-pos { duration: 260ms; easing: cubic-bezier(0.22, 1, 0.36, 1); }
|
||||
out property <float> side-fpos: max(0, self.side-focus);
|
||||
animate side-fpos { duration: 220ms; easing: cubic-bezier(0.22, 1, 0.36, 1); }
|
||||
|
||||
// ---- 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: 300ms; 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" ? #ff0033 : #ffffff,
|
||||
tint: c.tone == "primary" ? #ff0033.with-alpha(0.42 + 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: 96 * Tv.u,
|
||||
y: (184 + root.side-pos * 80) * Tv.u,
|
||||
w: 440 * Tv.u,
|
||||
h: 72 * Tv.u,
|
||||
r: 36 * Tv.u,
|
||||
focus: 0,
|
||||
alpha: root.side ? root.alpha * (root.side-focus == root.side-index ? 0 : 1) : 0,
|
||||
blur: 1.2,
|
||||
glow: #ffffff,
|
||||
tint: #ffffff14,
|
||||
group: 0,
|
||||
},
|
||||
{
|
||||
x: 96 * Tv.u,
|
||||
y: (184 + root.side-fpos * 80) * Tv.u,
|
||||
w: 440 * Tv.u,
|
||||
h: 72 * Tv.u,
|
||||
r: 36 * Tv.u,
|
||||
focus: 1,
|
||||
alpha: root.side && root.side-focus >= 0 ? root.alpha : 0,
|
||||
blur: 1.2,
|
||||
glow: #ffffff,
|
||||
tint: #ffffffe0,
|
||||
group: 0,
|
||||
},
|
||||
root.hero-rect(0),
|
||||
root.hero-rect(1),
|
||||
root.hero-rect(2),
|
||||
root.hero-rect(3),
|
||||
root.hero-rect(4),
|
||||
root.hero-rect(5),
|
||||
{
|
||||
x: root.pill-x * Tv.u,
|
||||
y: (root.pill-y - root.scroll-anim) * Tv.u,
|
||||
w: root.pill-w * Tv.u,
|
||||
h: root.fc.h * Tv.u,
|
||||
r: root.fc.tone == "field" ? 22 * Tv.u : root.fc.h * Tv.u / 2,
|
||||
focus: 1,
|
||||
alpha: root.alpha * root.pill-a,
|
||||
blur: 1.2,
|
||||
glow: root.fc.tone == "primary" ? #ff0033 : #ffffff,
|
||||
tint: root.fc.tone == "primary" ? #ff0033.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;
|
||||
}
|
||||
341
ui/player.slint
Normal file
341
ui/player.slint
Normal file
@@ -0,0 +1,341 @@
|
||||
// Playback. The video itself is the glass backdrop (Rust: glass.set_video),
|
||||
// so the controls are glass that refracts the picture. (From Netflex TV.)
|
||||
//
|
||||
// Stages: "prep" (asking YouTube for the formats), "play", "error". With
|
||||
// the controls hidden the remote drives playback directly (OK =
|
||||
// play/pause, left/right = seek); shown, up/down moves between the seek
|
||||
// bar and the buttons. All focus state is Rust's.
|
||||
|
||||
import { Tv, GlassRect, GlassPane, GlassButton, GlassMenu, MenuItem, ProgressBar, Spinner, Title, Label, Caption, Item, Icon } from "@sf-ui/sf-ui.slint";
|
||||
|
||||
export component PlayerScreen inherits Rectangle {
|
||||
in property <float> alpha: 1;
|
||||
in property <string> stage: "prep";
|
||||
in property <string> title;
|
||||
// The channel, above the title.
|
||||
in property <string> heading;
|
||||
// "1080p · 1,2 M megtekintés · Felirat: Magyar"
|
||||
in property <string> info;
|
||||
// The caption line at the current position.
|
||||
in property <string> caption;
|
||||
in property <string> stage-text;
|
||||
in property <string> detail-text;
|
||||
in property <string> error-text;
|
||||
// Playing.
|
||||
in property <bool> osd;
|
||||
in property <bool> paused;
|
||||
in property <bool> buffering;
|
||||
in property <string> buffer-text;
|
||||
in property <float> progress;
|
||||
in property <float> buffered;
|
||||
in property <string> time-text;
|
||||
in property <string> remaining-text;
|
||||
in property <string> downloaded-text;
|
||||
// Seeking with left/right: the target and how far it is.
|
||||
in property <bool> seeking;
|
||||
in property <string> seek-text;
|
||||
in property <string> seek-delta;
|
||||
in property <bool> seek-back;
|
||||
// Controls: 0 = seek bar, 1 = buttons; which button.
|
||||
in property <int> osd-area;
|
||||
in property <int> osd-button;
|
||||
in property <bool> has-next;
|
||||
in property <bool> has-channel;
|
||||
// Panel: 0 = closed, 1 = captions focused, 2 = quality focused.
|
||||
in property <int> panel;
|
||||
in property <[MenuItem]> subs;
|
||||
in property <[MenuItem]> quality;
|
||||
in property <int> subs-focus;
|
||||
in property <int> quality-focus;
|
||||
// Unused (kept for the shared layout).
|
||||
in property <string> skip-label;
|
||||
// The end: "Következik" card.
|
||||
in property <string> next-label;
|
||||
in property <string> next-text;
|
||||
|
||||
out property <float> osd-t: self.stage == "play" && (self.osd || self.paused || self.panel > 0) ? 1 : 0;
|
||||
animate osd-t { duration: 320ms; easing: cubic-bezier(0.22, 1, 0.36, 1); }
|
||||
out property <float> panel-t: self.panel > 0 ? 1 : 0;
|
||||
animate panel-t { duration: 360ms; easing: cubic-bezier(0.22, 1, 0.36, 1); }
|
||||
property <float> prep-a: self.alpha * (self.stage == "play" ? 0 : 1);
|
||||
property <float> osd-a: self.alpha * self.osd-t;
|
||||
property <bool> buttons: self.osd-t > 0.5 && self.osd-area == 1 && self.panel == 0;
|
||||
|
||||
// Darkens the film behind the controls (Slint over video is fine).
|
||||
Rectangle {
|
||||
y: root.height * 0.5;
|
||||
height: root.height * 0.5;
|
||||
background: @linear-gradient(180deg, #00000000 0%, #000000b8 100%);
|
||||
opacity: root.osd-a;
|
||||
}
|
||||
|
||||
// ---- preparing / error ----
|
||||
VerticalLayout {
|
||||
x: Tv.safe-x;
|
||||
width: root.width - 2 * Tv.safe-x;
|
||||
y: 330 * Tv.u;
|
||||
height: 460 * Tv.u;
|
||||
spacing: 24 * Tv.u;
|
||||
alignment: start;
|
||||
opacity: root.prep-a;
|
||||
if root.stage == "prep": HorizontalLayout {
|
||||
alignment: center;
|
||||
Spinner { size: 72 * Tv.u; }
|
||||
}
|
||||
if root.stage == "error": HorizontalLayout {
|
||||
alignment: center;
|
||||
Icon { name: "warning"; size: 64 * Tv.u; ink: Tv.danger-ink; }
|
||||
}
|
||||
Title {
|
||||
horizontal-alignment: center;
|
||||
text: root.stage == "error" ? "Nem sikerült elindítani" : root.heading == "" ? root.title : root.title + " · " + root.heading;
|
||||
}
|
||||
Label {
|
||||
horizontal-alignment: center;
|
||||
text: root.stage == "error" ? root.error-text : root.stage-text;
|
||||
wrap: word-wrap;
|
||||
color: Tv.text-secondary;
|
||||
}
|
||||
Caption {
|
||||
horizontal-alignment: center;
|
||||
text: root.stage == "error" ? "Vissza: vissza a listához" : root.detail-text;
|
||||
wrap: word-wrap;
|
||||
}
|
||||
}
|
||||
|
||||
// ---- buffering ----
|
||||
buf := GlassPane {
|
||||
x: (root.width - self.width) / 2;
|
||||
y: (root.height - self.height) / 2;
|
||||
width: 620 * Tv.u;
|
||||
height: 190 * Tv.u;
|
||||
radius: 40 * Tv.u;
|
||||
frost: 3.2;
|
||||
tint: Tv.smoke.with-alpha(0.4);
|
||||
alpha: root.stage == "play" && root.buffering && !root.seeking ? root.alpha : 0;
|
||||
VerticalLayout {
|
||||
padding: 32 * Tv.u;
|
||||
spacing: 20 * Tv.u;
|
||||
alignment: center;
|
||||
opacity: parent.alpha;
|
||||
HorizontalLayout {
|
||||
alignment: center;
|
||||
Spinner { size: 56 * Tv.u; }
|
||||
}
|
||||
Label {
|
||||
horizontal-alignment: center;
|
||||
text: root.buffer-text == "" ? "Betöltés…" : root.buffer-text;
|
||||
overflow: elide;
|
||||
}
|
||||
}
|
||||
}
|
||||
if root.stage == "play" && root.paused && !root.buffering && root.panel == 0 && !root.seeking && root.next-label == "": Icon {
|
||||
x: (root.width - self.width) / 2;
|
||||
y: (root.height - self.height) / 2 - 60 * Tv.u;
|
||||
name: "pause";
|
||||
size: 96 * Tv.u;
|
||||
opacity: 0.85 * root.alpha;
|
||||
}
|
||||
|
||||
// ---- seek preview ----
|
||||
seek := GlassPane {
|
||||
x: (root.width - self.width) / 2;
|
||||
y: (root.height - self.height) / 2 - 60 * Tv.u;
|
||||
width: 520 * Tv.u;
|
||||
height: 108 * Tv.u;
|
||||
radius: self.height / 2;
|
||||
frost: 3.0;
|
||||
tint: Tv.smoke.with-alpha(0.4);
|
||||
alpha: root.stage == "play" && root.seeking ? root.alpha : 0;
|
||||
HorizontalLayout {
|
||||
alignment: center;
|
||||
spacing: 18 * Tv.u;
|
||||
opacity: parent.alpha;
|
||||
Icon {
|
||||
y: (parent.height - self.height) / 2;
|
||||
name: root.seek-back ? "rewind" : "fast-forward";
|
||||
size: 40 * Tv.u;
|
||||
}
|
||||
Text {
|
||||
vertical-alignment: center;
|
||||
text: root.seek-text;
|
||||
font-size: 44 * Tv.u;
|
||||
font-weight: 700;
|
||||
color: Tv.text;
|
||||
}
|
||||
Text {
|
||||
vertical-alignment: center;
|
||||
text: root.seek-delta;
|
||||
font-size: 26 * Tv.u;
|
||||
color: Tv.text-secondary;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// ---- captions (Slint over the video, above the controls when shown) ----
|
||||
if root.stage == "play" && root.caption != "": Rectangle {
|
||||
property <length> bottom: (root.osd-t > 0.5 ? 400 : 90) * Tv.u;
|
||||
x: (root.width - self.width) / 2;
|
||||
y: root.height - self.bottom - self.height;
|
||||
width: min(1500 * Tv.u, cap.preferred-width + 48 * Tv.u);
|
||||
height: cap.preferred-height + 20 * Tv.u;
|
||||
border-radius: 12 * Tv.u;
|
||||
background: #000000b0;
|
||||
animate y { duration: 220ms; easing: ease-out; }
|
||||
cap := Text {
|
||||
width: min(1452 * Tv.u, self.preferred-width);
|
||||
text: root.caption;
|
||||
font-size: 38 * Tv.u;
|
||||
font-weight: 600;
|
||||
color: #ffffff;
|
||||
horizontal-alignment: center;
|
||||
wrap: word-wrap;
|
||||
}
|
||||
}
|
||||
|
||||
// ---- up next ----
|
||||
upnext := GlassPane {
|
||||
x: root.width - Tv.safe-x - self.width;
|
||||
y: root.height - 380 * Tv.u;
|
||||
width: 620 * Tv.u;
|
||||
height: 168 * Tv.u;
|
||||
radius: 40 * Tv.u;
|
||||
frost: 3.2;
|
||||
tint: Tv.smoke.with-alpha(0.42);
|
||||
alpha: root.next-label != "" ? root.alpha : 0;
|
||||
VerticalLayout {
|
||||
padding: 32 * Tv.u;
|
||||
spacing: 6 * Tv.u;
|
||||
opacity: parent.alpha;
|
||||
Caption { text: "KÖVETKEZIK"; letter-spacing: 2 * Tv.u; }
|
||||
Title { text: root.next-label; font-size: 30 * Tv.u; overflow: elide; }
|
||||
Label { text: root.next-text; }
|
||||
}
|
||||
}
|
||||
|
||||
// ---- controls ----
|
||||
Rectangle {
|
||||
x: Tv.safe-x;
|
||||
y: root.height - 360 * Tv.u + (1 - root.osd-t) * 30 * Tv.u;
|
||||
width: root.width - 2 * Tv.safe-x;
|
||||
height: 300 * Tv.u;
|
||||
opacity: root.osd-a;
|
||||
Text {
|
||||
x: 0;
|
||||
y: 0;
|
||||
text: root.heading;
|
||||
font-size: 24 * Tv.u;
|
||||
font-weight: 700;
|
||||
color: #ff8a8a;
|
||||
width: parent.width - 420 * Tv.u;
|
||||
overflow: elide;
|
||||
}
|
||||
Text {
|
||||
x: 0;
|
||||
y: 34 * Tv.u;
|
||||
width: parent.width - 420 * Tv.u;
|
||||
text: root.title;
|
||||
font-size: 44 * Tv.u;
|
||||
font-weight: 700;
|
||||
letter-spacing: -0.8 * Tv.u;
|
||||
color: Tv.text;
|
||||
overflow: elide;
|
||||
}
|
||||
Caption {
|
||||
x: 0;
|
||||
y: 96 * Tv.u;
|
||||
width: parent.width - 420 * Tv.u;
|
||||
text: root.info;
|
||||
color: Tv.text-secondary;
|
||||
}
|
||||
Caption {
|
||||
x: parent.width - 400 * Tv.u;
|
||||
y: 96 * Tv.u;
|
||||
width: 400 * Tv.u;
|
||||
horizontal-alignment: right;
|
||||
text: root.downloaded-text;
|
||||
}
|
||||
Text {
|
||||
x: 0;
|
||||
y: 172 * Tv.u;
|
||||
text: root.time-text;
|
||||
font-size: 24 * Tv.u;
|
||||
font-weight: 600;
|
||||
color: Tv.text;
|
||||
}
|
||||
Text {
|
||||
x: parent.width - 300 * Tv.u;
|
||||
y: 172 * Tv.u;
|
||||
width: 300 * Tv.u;
|
||||
horizontal-alignment: right;
|
||||
text: root.remaining-text;
|
||||
font-size: 24 * Tv.u;
|
||||
font-weight: 600;
|
||||
color: Tv.text-secondary;
|
||||
}
|
||||
}
|
||||
bar := ProgressBar {
|
||||
x: Tv.safe-x;
|
||||
y: root.height - 222 * Tv.u + (1 - root.osd-t) * 30 * Tv.u;
|
||||
width: root.width - 2 * Tv.safe-x;
|
||||
height: (root.osd-area == 0 && root.panel == 0 ? 14 : 10) * Tv.u;
|
||||
value: root.progress;
|
||||
buffered: root.buffered;
|
||||
fill: root.seeking ? #ff0033 : Tv.text;
|
||||
nested: false;
|
||||
alpha: root.osd-a;
|
||||
}
|
||||
HorizontalLayout {
|
||||
x: Tv.safe-x;
|
||||
y: root.height - 146 * Tv.u + (1 - root.osd-t) * 30 * Tv.u;
|
||||
height: 72 * Tv.u;
|
||||
spacing: 20 * Tv.u;
|
||||
alignment: start;
|
||||
b0 := GlassButton { icon: root.paused ? "play" : "pause"; focused: root.buttons && root.osd-button == 0; alpha: root.osd-a; }
|
||||
b1 := GlassButton { icon: "rewind"; text: "10 mp"; focused: root.buttons && root.osd-button == 1; alpha: root.osd-a; }
|
||||
b2 := GlassButton { icon: "fast-forward"; text: "10 mp"; focused: root.buttons && root.osd-button == 2; alpha: root.osd-a; }
|
||||
b3 := GlassButton { icon: "next"; text: "Következő"; enabled: root.has-next; focused: root.buttons && root.osd-button == 3; alpha: root.has-next ? root.osd-a : 0; visible: root.has-next; }
|
||||
b4 := GlassButton { icon: "user"; text: "Csatorna"; enabled: root.has-channel; focused: root.buttons && root.osd-button == 4; alpha: root.has-channel ? root.osd-a : 0; visible: root.has-channel; }
|
||||
}
|
||||
b5 := GlassButton {
|
||||
width: self.preferred-width;
|
||||
x: root.width - Tv.safe-x - self.width;
|
||||
y: root.height - 146 * Tv.u + (1 - root.osd-t) * 30 * Tv.u;
|
||||
icon: "subtitles";
|
||||
text: "Felirat és minőség";
|
||||
focused: root.buttons && root.osd-button == 5;
|
||||
alpha: root.osd-a;
|
||||
}
|
||||
|
||||
// ---- captions and quality panel ----
|
||||
property <length> col-w: 600 * Tv.u;
|
||||
property <length> panel-y: root.height - 400 * Tv.u;
|
||||
m-subs := GlassMenu {
|
||||
x: Tv.safe-x;
|
||||
y: root.panel-y - self.height + (1 - root.panel-t) * 30 * Tv.u;
|
||||
width: root.col-w;
|
||||
title: "Felirat";
|
||||
items: root.subs;
|
||||
focused-index: root.subs-focus;
|
||||
active: root.panel == 1;
|
||||
alpha: root.alpha * root.panel-t;
|
||||
accent: #ff0033;
|
||||
visible-rows: 6;
|
||||
}
|
||||
m-quality := GlassMenu {
|
||||
x: Tv.safe-x + root.col-w + 28 * Tv.u;
|
||||
y: root.panel-y - self.height + (1 - root.panel-t) * 30 * Tv.u;
|
||||
width: 400 * Tv.u;
|
||||
title: "Minőség";
|
||||
items: root.quality;
|
||||
focused-index: root.quality-focus;
|
||||
active: root.panel == 2;
|
||||
alpha: root.alpha * root.panel-t;
|
||||
accent: #ff0033;
|
||||
visible-rows: 7;
|
||||
}
|
||||
|
||||
out property <[GlassRect]> glass: [buf.glass, seek.glass, bar.glass, b0.glass, b1.glass, b2.glass, b3.glass, b4.glass, b5.glass, upnext.glass];
|
||||
out property <[GlassRect]> glass-subs: m-subs.glass;
|
||||
out property <[GlassRect]> glass-quality: m-quality.glass;
|
||||
}
|
||||
86
ui/types.slint
Normal file
86
ui/types.slint
Normal file
@@ -0,0 +1,86 @@
|
||||
// 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) | "include" | "exclude" | "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 watched; negative = no bar.
|
||||
progress: float,
|
||||
// Small pill over the top-left corner, and its tone ("dub", "sub", "accent", "").
|
||||
badge: string,
|
||||
badge-tone: string,
|
||||
// "check" = watched mark (top-right).
|
||||
mark: string,
|
||||
// Big number over a dimmed picture (a season without its own poster).
|
||||
big: string,
|
||||
// Highlighted (the video playing now).
|
||||
current: bool,
|
||||
// Bottom-right label (a video's length).
|
||||
corner: string,
|
||||
// A round picture in the middle (a channel's avatar).
|
||||
round: bool,
|
||||
}
|
||||
|
||||
// One line of a checks list: state 1 = ok, 0 = failed, -1 = unknown.
|
||||
export struct Check {
|
||||
state: int,
|
||||
label: string,
|
||||
detail: string,
|
||||
}
|
||||
|
||||
// One line of a page.
|
||||
// hero big title block with buttons (detail pages, spotlight)
|
||||
// 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 "poster" | "landscape" | "season"; captions under them)
|
||||
// item list row: optional picture, title, meta, text, progress, chips
|
||||
// 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,
|
||||
progress: float,
|
||||
col: int,
|
||||
captions: bool,
|
||||
cards: [Card],
|
||||
chips: [Chip],
|
||||
checks: [Check],
|
||||
}
|
||||
Reference in New Issue
Block a user