// Sign-in from the phone (Spotify Connect), the text input overlay (on a // modal glass pane with the on-screen keyboard) and a plain message screen. import { Tv, GlassRect, GlassPane, Keyboard, Spinner, Display, Title, Body, Label, Caption, Icon } from "@sf-ui/sf-ui.slint"; import { SpIcon } from "icons.slint"; // Sign-in, two ways: a pairing code (QR code or spotify.com/pair) or this // TV picked in the Spotify app on the phone (Spotify Connect). export component ConnectScreen inherits Rectangle { in property alpha: 1; in property device; in property code; in property qr; in property busy; in property error; pane := GlassPane { x: (root.width - self.width) / 2; y: (root.height - self.height) / 2 - 20 * Tv.u; width: 1640 * Tv.u; height: 760 * Tv.u; radius: 56 * Tv.u; frost: 3.6; tint: Tv.smoke.with-alpha(0.46); glow: #1ed760; alpha: root.alpha; // ---- left: title and the two ways ---- VerticalLayout { x: 80 * Tv.u; y: 72 * Tv.u; width: 860 * Tv.u; height: parent.height - 144 * Tv.u; spacing: 18 * Tv.u; opacity: root.alpha; HorizontalLayout { spacing: 24 * Tv.u; alignment: start; Rectangle { width: 80 * Tv.u; height: 80 * Tv.u; border-radius: self.width / 2; background: #1ed760; SpIcon { name: "audio"; size: 44 * Tv.u; ink: #121317; } } VerticalLayout { alignment: center; Title { text: "Jelentkezz be a telefonoddal"; } Caption { text: "Spotify Premium fiók kell hozzá"; } } } Rectangle { height: 14 * Tv.u; } Text { text: "QR-KÓDDAL"; font-size: 20 * Tv.u; font-weight: 700; letter-spacing: 3 * Tv.u; color: #1ed760; } Body { text: "Olvasd be a kódot a telefon kamerájával, és jelentkezz be. Vagy nyisd meg a spotify.com/pair oldalt, és írd be a kódot."; font-size: 26 * Tv.u; color: Tv.text; } Rectangle { height: 10 * Tv.u; } Text { text: "A SPOTIFY APPBÓL"; font-size: 20 * Tv.u; font-weight: 700; letter-spacing: 3 * Tv.u; color: #1ed760; } Body { text: "Ha a telefon ugyanazon a Wi-Fin van: indíts el egy számot, koppints az eszközök ikonjára, és válaszd: „" + root.device + "”."; font-size: 26 * Tv.u; color: Tv.text; } Rectangle { } HorizontalLayout { spacing: 16 * Tv.u; alignment: start; height: 48 * Tv.u; Spinner { size: 40 * Tv.u; } Label { vertical-alignment: center; text: root.busy ? "Bejelentkezés…" : root.error != "" ? root.error : "Várakozás a telefonra…"; color: root.error != "" && !root.busy ? Tv.warn-ink : Tv.text-secondary; wrap: word-wrap; } } } // ---- right: the QR code and the code ---- qr-box := Rectangle { x: parent.width - self.width - 96 * Tv.u; y: 80 * Tv.u; width: 440 * Tv.u; height: 440 * Tv.u; border-radius: 28 * Tv.u; background: #ffffff; opacity: root.alpha; clip: true; if root.qr.width > 0: Image { x: 20 * Tv.u; y: 20 * Tv.u; width: parent.width - 40 * Tv.u; height: parent.height - 40 * Tv.u; source: root.qr; image-rendering: pixelated; } if root.qr.width == 0: Spinner { size: 64 * Tv.u; ink: #121317; } } Text { x: qr-box.x; y: qr-box.y + qr-box.height + 28 * Tv.u; width: qr-box.width; horizontal-alignment: center; text: "spotify.com/pair"; font-size: 24 * Tv.u; font-weight: 600; color: Tv.text-secondary; opacity: root.alpha; } Text { x: qr-box.x; y: qr-box.y + qr-box.height + 66 * Tv.u; width: qr-box.width; horizontal-alignment: center; text: root.code; font-size: 64 * Tv.u; font-weight: 700; letter-spacing: 10 * Tv.u; color: Tv.text; opacity: root.alpha; } } Caption { x: pane.x; y: pane.y + pane.height + 28 * Tv.u; width: pane.width; horizontal-alignment: center; text: "Vissza: kilépés"; opacity: root.alpha; } out property <[GlassRect]> glass: [pane.glass]; } // A text field over everything (the TV's name...). export component InputScreen inherits Rectangle { in property alpha: 1; in property title; in property subtitle; in property placeholder; in property submit-label: "Kész"; in property min-length: 1; in-out property text; in-out property error; callback submitted(string); callback cancelled(); public function key(event: KeyEvent) -> EventResult { kb.key(event) } public function reset() { kb.reset(); } pane := GlassPane { x: (root.width - self.width) / 2; y: (root.height - self.height) / 2 - 24 * Tv.u; width: 1720 * Tv.u; height: 720 * Tv.u; radius: 56 * Tv.u; frost: 3.8; tint: Tv.smoke.with-alpha(0.48); glow: #1ed760; alpha: root.alpha; kb := Keyboard { x: 0; y: 72 * Tv.u; width: parent.width; title: root.title; subtitle: root.subtitle; placeholder: root.placeholder; submit-label: root.submit-label; min-length: root.min-length; max-length: 60; alpha: root.alpha; active: true; text <=> root.text; error <=> root.error; submitted(t) => { root.submitted(t); } cancelled => { root.cancelled(); } } } out property <[GlassRect]> glass: [pane.glass]; out property <[GlassRect]> glass-keyboard: kb.glass; } // Loading and errors. export component MessageScreen inherits Rectangle { in property alpha: 1; in property busy; in property title; in property text; VerticalLayout { x: Tv.safe-x; width: root.width - 2 * Tv.safe-x; y: 340 * Tv.u; height: 400 * Tv.u; spacing: 24 * Tv.u; alignment: start; opacity: root.alpha; HorizontalLayout { alignment: center; if root.busy: Spinner { size: 72 * Tv.u; } if !root.busy: Icon { name: "warning"; size: 64 * Tv.u; ink: Tv.warn-ink; } } Title { horizontal-alignment: center; text: root.title; } Label { horizontal-alignment: center; text: root.text; wrap: word-wrap; } Caption { horizontal-alignment: center; text: root.busy ? "" : "Újrapróbálkozik magától. Vissza: kilépés"; } } }