774 lines
28 KiB
Plaintext
774 lines
28 KiB
Plaintext
// 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;
|
|
}
|
|
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 : #e50914;
|
|
}
|
|
}
|
|
}
|
|
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" ? #e50914d8 : #000000b8;
|
|
badge-text := Text {
|
|
text: root.card.badge;
|
|
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: #e50914;
|
|
}
|
|
}
|
|
if root.captions: Text {
|
|
x: 0;
|
|
y: root.art-h + 18 * Tv.u;
|
|
width: root.width;
|
|
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;
|
|
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" ? #e5091480
|
|
: 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> vpn-label;
|
|
in property <bool> vpn-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: #e50914;
|
|
}
|
|
}
|
|
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 : #e50914;
|
|
}
|
|
}
|
|
}
|
|
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 ----
|
|
if root.side: 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: 176 * 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.vpn-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.vpn-ok ? Tv.ok : Tv.danger;
|
|
}
|
|
}
|
|
Text {
|
|
vertical-alignment: center;
|
|
text: root.vpn-label;
|
|
font-size: 22 * Tv.u;
|
|
font-weight: 600;
|
|
color: root.vpn-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" ? #e50914 : #ffffff,
|
|
tint: c.tone == "primary" ? #e50914.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" ? #e50914 : #ffffff,
|
|
tint: root.fc.tone == "primary" ? #e50914.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;
|
|
}
|