// Most szól: the cover, the title, the progress and the controls. With the // lyrics open, the cover and the texts move to the left and a glass panel // holds the lyrics on the right. // // Rust owns the focus: `button` is the focused button (0..6), `area` 1 means // the progress bar (left/right seek there). import { Tv, GlassRect, GlassPane, Spinner, Caption } from "@sf-ui/sf-ui.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 icon; in property focused; in property on; in property primary; in property alpha: 1; in property size: 80 * Tv.u; out property f: self.focused ? 1 : 0; animate f { duration: 220ms; easing: cubic-bezier(0.22, 1, 0.36, 1); } property 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 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 alpha: 1; in property title; in property artist; in property album; in property art; in property explicit; in property episode; in property playing; in property loading; in property progress; in property time; in property duration; in property shuffle; // 0 off, 1 the list, 2 this track in property repeat; // -1 unknown, 0 no, 1 yes in property liked: -1; in property button: 2; in property area; // 0 none, 1 lyrics in property panel; in property <[string]> lyrics; in property lyric-line: -1; in property lyrics-synced; in property lyrics-note; in property device; // 0: the big layout, 1: side by side with the panel. out property 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 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 tx: root.mix(870, 120); property tw: root.mix(900, 620); property 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 py: root.ty + root.mix(400, 236); property pf: root.area == 1 ? 1 : 0; animate pf { duration: 200ms; easing: ease-out; } property 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 bs: root.mix(80, 64); property 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; } } property <[string]> hints: ["Keverés", "Előző", root.playing ? "Szünet" : "Lejátszás", "Következő", "Ismétlés", "Kedvelés", "Dalszöveg"]; 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 ---- property 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 line-h: 76 * Tv.u; property 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; } } } 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, panel-pane.glass, ]; }