Redesign the TV interface for the remote and the room

Navigation and focus:
- The search field no longer traps the D-pad or opens the keyboard on
  focus; Select starts editing, and up and down always leave.
- Focus is ink instead of an outline: rows, buttons, chips, tabs and the
  drawer fill with the text colour; covers and tiles lift with a soft
  shadow (a light one in the dark theme). Selected chips carry a check.
- Track lists are one stop per row; right reaches the heart and menu, and
  left from a row always opens the drawer.
- Chip rows and tab bars land on the selected item; card rows and the
  genre grid return to the card last visited.
- Pages scroll only as far as focus needs, so headers stay in view.
- The drawer lights the section a page was reached from.

Screens:
- Now Playing is a stage: a large cover over a blurred copy of itself,
  display-size title, album and year, amber progress, and the queue and
  lyrics in a panel that slides in on request (Back or Left closes it).
- Home shows Recently played and the Chart as shelves, the chart ending
  in a Show all tile; search results end their tracks with Show all.
- Browse is a genre grid under one title. Artist pages put the album,
  not the artist, under each track; album, artist and playlist pages put
  the heart beside Play.
- Books and podcast episodes get their own menu (no similar tracks,
  dislike or "go to" the page you're on), no "Unknown artist", and
  books are labelled as books.
- Playing tracks, albums and stations carry an equaliser badge; hearts
  are hidden where every item is liked.

Theme:
- Light is warm paper with aubergine ink and a deeper amber; every text
  colour passes 4.5:1. DESIGN.md records the palette and the focus rules.

ThemeTest now checks the current font scales.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
yuriy.pandClaude Opus 5.5 committed 2026-10-18 00:14:39 +06:00
1 parent a7079adb3b
commit 350b387723
29 files changed
+1105 -291

No files matched your search

@@ -0,0 +1,55 @@
---
target: whole TV app UI
total_score: 26
max_score: 40
na_heuristics:
p0_count: 1
p1_count: 3
target_identity: "file:/Users/yp/Projects/musyx-mobile/app/src/main/java/it/panov/musyx/tv/ui"
timestamp: 2026-10-17T12-56-43Z
slug: app-src-main-java-it-panov-musyx-tv-ui
---
Method: design review only (detector not applicable, native platform). Evidence: Android TV emulator (sdk_google_atv64_arm64, 1080p), app build 0.1.1, Light and Dark themes, Small font size.
## Design Health Score
| # | Heuristic | Score | Key Issue |
|---|-----------|-------|-----------|
| 1 | Visibility of System Status | 2 | Focus is invisible on selected chips (amber ring on amber fill); playing station card not marked; rail shows no location on Now Playing |
| 2 | Match System / Real World | 3 | Podcast episodes say "Unknown artist"; podcast menu offers "Play similar tracks" |
| 3 | User Control and Freedom | 2 | Search field traps the D-pad: only Back leaves the page |
| 4 | Consistency and Standards | 2 | Seek fill is fg on Now Playing, accent elsewhere; three focus styles; podcast pages light Home in the rail |
| 5 | Error Prevention | 3 | Dislike sits directly beside Like on Now Playing |
| 6 | Recognition Rather Than Recall | 3 | Hold-select for menus documented only in README |
| 7 | Flexibility and Efficiency | 3 | Media keys, Play/Shuffle, long-press menus; three focus stops per track row slow vertical travel |
| 8 | Aesthetic and Minimalist Design | 3 | Dark theme is authored; Now Playing leaves a large void; Home is a long vertical stack |
| 9 | Error Recovery | 3 | Load failures offer retry |
| 10 | Help and Documentation | 2 | No in-app hint for hold-select or keyboard use |
| **Total** | | **26/40** | **Acceptable** |
## Design Specificity Verdict
LLM: Dark theme is authored (aubergine graphite, amber VU accent, Unbounded display, animated wave hero). Light theme loses that and reads as a generic lavender-white settings app, and it is the active setting. Layout grammar is ported from desktop (track table with album column, per-row heart and ellipsis, small Now Playing cover) rather than built for the 10-foot screen.
Deterministic scan: not applicable (native platform).
## Priority Issues
1. [P0] Search field traps D-pad focus and opens the IME on focus. Genres unreachable, rail unreachable, Back is the only exit. Fix: TextInput becomes a focusable surface; Select enters edit mode and shows keyboard; Up/Down/Left leave via focusManager when not editing. Same component on sign-in token field. Command: harden.
2. [P1] Focus ring invisible on selected/accent controls (Chip focusedContainer=accent + amber ring). Fix: one focus treatment: scale + 3dp fg ring with 2dp bg gap, never amber on amber; entering a chip row lands on the selected chip. Command: polish.
3. [P1] Track rows split into three focus stops; Down from hero lands on the heart column; focused row ring overlaps heart. Fix: row is the single vertical stop (focusGroup + onEnter to row), Right reaches heart/more. Command: layout.
4. [P1] Now Playing underuses the TV: 180dp cover, 20-scale title, empty middle-left, seek fill fg not accent, shuffle-off looks disabled. Fix: 360-420dp cover, displayM title, blurred cover backdrop, transport under meta, accent fill, distinct off state. Command: layout / bolder.
5. [P2] Home is a long vertical stack (10 recently played rows, 5 chart rows) before shelves. Fix: Recently played and Chart as card shelves; My Wave hero compact. Command: layout.
## Persona Red Flags
Alex: three stops per row; tabs need Select; Up into chip rows lands on first chip.
Jordan: Search keyboard pops over Browse and D-pad won't leave; collapsed rail is icon-only with a lone dot for brand; hold-select undiscoverable.
Sam: invisible focus on selected chips and the selected Light/Small/English chips; Mix genre card white on light gray.
## Minor Observations
Podcast episodes "Unknown artist"; menu "Go to album" on album page; "Play similar" for podcasts; 7 menu items. Heart badge overlaps cover typography on podcast cards. Detail heart floats alone under title. Drawer focus landed on My Wave while Home was current. "Show all 100" doesn't read as a control. Active station card not marked. Settings version line showed 0.1.1.
## Questions to Consider
What if Now Playing were the screen saver's calmer sibling: full-bleed art, controls on demand? Should Light exist on a TV at all? Does a 10-foot track list need an album column?
@@ -0,0 +1,39 @@
---
target: whole TV app UI (after fixes)
total_score: 29
max_score: 40
na_heuristics:
p0_count: 0
p1_count: 0
target_identity: "file:/Users/yp/Projects/musyx-mobile/app/src/main/java/it/panov/musyx/tv/ui"
timestamp: 2026-10-17T13-22-38Z
slug: app-src-main-java-it-panov-musyx-tv-ui
---
Method: design review only (detector not applicable, native platform). Evidence: Android TV emulator 1080p, uncommitted build after the first critique's fixes, Light theme, Small font; Now Playing from earlier in the session on the same layout code.
## Design Health Score
| # | Heuristic | Score | Key Issue |
|---|-----------|-------|-----------|
| 1 | Visibility of System Status | 3 | Focus visible everywhere; no location on Now Playing; playing station/card unmarked |
| 2 | Match System / Real World | 3 | Books and podcasts get music actions |
| 3 | User Control and Freedom | 3 | Search trap fixed; Back closes the panel |
| 4 | Consistency and Standards | 3 | One focus style; podcast pages light Home; desktop palette not updated |
| 5 | Error Prevention | 3 | Dislike moved into the menu |
| 6 | Recognition Rather Than Recall | 3 | Every row has a menu button |
| 7 | Flexibility and Efficiency | 3 | One stop per row; tabs still need Select |
| 8 | Aesthetic and Minimalist Design | 3 | Detail pages open with the title cut off; heart badges clutter covers |
| 9 | Error Recovery | 3 | Failed loads offer a retry |
| 10 | Help and Documentation | 2 | Nothing in the app explains how to use it |
| **Total** | | **29/40** | **Good** |
## Priority Issues
1. [P2] Detail pages open with the header clipped (entry focus on Play scrolls the list). Fix: pin to top on first focus or keep the header in view. layout.
2. [P2] Books and podcasts treated as music: 8-item menu with "Play similar tracks", "Go to album" on its own page, "Don't recommend"; "Unknown artist" on episodes; rail lights Home; audiobook labelled Podcast. clarify.
3. [P2] Now Playing: no section lit in the side menu; Left from the open panel opens the side menu over it. polish.
4. [P3] Redundant hearts in Liked tracks and on the Podcasts "Yours" covers; no playing marker on shelf or station tiles. polish.
## Minor Observations
Down from an empty search field lands on the third genre; collapsed menu shows a lone dot; desktop theme.rs still has the old light palette; ThemeTest.fontSizeScalesType is stale.
@@ -0,0 +1,39 @@
---
target: whole TV app UI (round 3)
total_score: 30
max_score: 40
na_heuristics:
p0_count: 0
p1_count: 0
target_identity: "file:/Users/yp/Projects/musyx-mobile/app/src/main/java/it/panov/musyx/tv/ui"
timestamp: 2026-10-17T13-42-52Z
slug: app-src-main-java-it-panov-musyx-tv-ui
---
Method: design review only (detector not applicable, native platform). Evidence: Android TV emulator 1080p, uncommitted build after both rounds of fixes, Light theme, Small font. New this run: search results, artist page, Browse.
## Design Health Score
| # | Heuristic | Score | Key Issue |
|---|-----------|-------|-----------|
| 1 | Visibility of System Status | 3 | Playing markers and section lighting in place; loading is still plain text |
| 2 | Match System / Real World | 4 | Books, podcasts and music each speak their own language now |
| 3 | User Control and Freedom | 3 | Back and Left exits work everywhere; no undo for likes |
| 4 | Consistency and Standards | 3 | "Show all" is a tile on Home but bare text in Search; rows entered at the wrong card |
| 5 | Error Prevention | 3 | Dislike out of reach of the heart |
| 6 | Recognition Rather Than Recall | 3 | Search "Show all" hard to find with the D-pad |
| 7 | Flexibility and Efficiency | 3 | One stop per row, shelves, tabs counts |
| 8 | Aesthetic and Minimalist Design | 3 | Browse page sparse with stacked headings; artist rows repeat the artist |
| 9 | Error Recovery | 3 | Retry on failures |
| 10 | Help and Documentation | 2 | No in-app guidance |
| **Total** | | **30/40** | **Good** |
## Priority Issues
1. [P2] Entering a horizontal row from above lands on the card under the previous focus, not the first (Genres from the search field: Rock; artist Albums from the last track: second album). polish.
2. [P2] Search results' "Show all" is bare text that Down skips; Home uses an end tile. polish.
3. [P3] Browse: "Browse" title and "Genres" heading stacked over one row on an empty screen. layout.
4. [P3] Artist page rows repeat the artist's name on every row. distill.
## Minor Observations
Collapsed menu shows only the brand dot; ThemeTest.fontSizeScalesType stale; desktop light palette not updated; nothing committed.
+24 -10
View File
@@ -8,23 +8,26 @@ https://claude.ai/artifact/2gmswtceJM61fcE2F5uYYM). This file records its tokens
## Direction
The ground is aubergine graphite, with one amber accent taken from a tape deck's VU needle.
The app is dark-first, and the light theme follows the system setting. Everything stays quiet
The app is dark-first, and the light theme follows the system setting. Light is warm paper
with aubergine ink: the same character in daylight rather than an inverted dark theme, with
the amber taken deeper so it reads as text on paper (every text colour passes 4.5:1 on `bg`,
`panel` and `raised`). Everything stays quiet
except the My Wave hero, which is the one animated, accent-heavy surface.
## Colour
| Token | Dark | Light | Used for |
|--------------|-----------|-----------|----------|
| `bg` | `#1C1A22` | `#F3F1F6` | Window and content background |
| `panel` | `#23202B` | `#FFFFFF` | Sidebar, player bar, drawer, cards that need separation |
| `raised` | `#2D2937` | `#EAE6F0` | Hover and selected rows, chip fills, progress track |
| `line` | `#3A3546` | `#DCD6E4` | 1px dividers and outlines |
| `fg` | `#EEEAF3` | `#1F1B27` | Primary text, the play/pause disc |
| `muted` | `#A39CB0` | `#686178` | Secondary text, idle icons |
| `accent` | `#F0B23E` | `#A86C05` | Current track, progress fill, primary buttons, active nav icon |
| `bg` | `#1C1A22` | `#F4EEE4` | Window and content background |
| `panel` | `#23202B` | `#FBF7F0` | Sidebar, player bar, drawer, cards that need separation |
| `raised` | `#2D2937` | `#EAE2D4` | Hover and selected rows, chip fills, progress track |
| `line` | `#3A3546` | `#DCD2C1` | 1px dividers and outlines |
| `fg` | `#EEEAF3` | `#231C2B` | Primary text, the play/pause disc |
| `muted` | `#A39CB0` | `#62586A` | Secondary text, idle icons |
| `accent` | `#F0B23E` | `#8E5A04` | Current track, progress fill, primary buttons, active nav icon |
| `accent_ink` | `#2A1D04` | `#FFF7E6` | Text and icons on `accent` |
| `like` | `#F27286` | `#D2405A` | Filled heart, falling chart position |
| `ok` | `#7FCB9B` | `#2E8A55` | Subscription status, rising chart position |
| `like` | `#F27286` | `#B5304B` | Filled heart, falling chart position |
| `ok` | `#7FCB9B` | `#24704A` | Subscription status, rising chart position |
Covers that have no artwork yet get a placeholder made of two hues (`h1`, `h2`) derived from
the item id, painted as a diagonal gradient between them.
@@ -50,6 +53,17 @@ counts use tabular figures.
- Icons: Lucide 0.460 (ISC), 18px and tinted via `currentColor`. The `-fill` variants are for
liked, play and pause.
## Focus (TV)
There's no hover on a TV, and no outline around focus either. Two treatments, nothing else:
- **Ink**: rows, buttons, chips, tabs and drawer items fill with `fg` while focused, and
everything on them (title, meta, icons, the playing amber) turns to `bg`. Amber buttons
and the selected chip keep their fill. A selected chip also carries a check, so the
choice still shows while focus is on it.
- **Lift**: covers, cards and coloured tiles keep their own colours, grow 6–10% and cast
a soft shadow below them: black in light, a light shadow in dark, where black disappears.
## Components
- **Sidebar**: wordmark, five nav items (Home, My Wave, Search, Collection, Podcasts), a
@@ -40,6 +40,8 @@ data class Track(
val available: Boolean,
val explicit: Boolean,
val lyricsAvailable: Boolean,
/** A podcast episode or a chapter of an audiobook, not a song. */
val spoken: Boolean = false,
) {
/** `trackId:albumId`, the form station feedback and queues use. */
val fullId: String
@@ -57,6 +59,8 @@ data class Track(
companion object {
fun from(t: JsonElement?): Track? {
val id = t.str("id") ?: return null
val firstAlbum = t.list("albums").firstOrNull()
val albumKind = AlbumKind.from(firstAlbum.str("metaType"), firstAlbum.str("type"))
val album = t.list("albums").firstNotNullOfOrNull { a ->
a.long("id")?.let { AlbumRef(it, a.str("title").orEmpty(), a.long("year")?.toInt()) }
}
@@ -78,9 +82,13 @@ data class Track(
} else {
t.bool("lyricsAvailable") == true
},
spoken = t.str("type") in SPOKEN_TYPES || albumKind == AlbumKind.Podcast || albumKind == AlbumKind.Audiobook,
)
}
/** Track `type`s that are speech rather than music. */
private val SPOKEN_TYPES = setOf("podcast-episode", "audiobook")
/** A bare track for tests and previews. */
fun bare(id: String, title: String = "T$id", durationMs: Long = 100_000) =
Track(id, title, null, emptyList(), null, durationMs, null, true, false, false)
@@ -99,8 +107,9 @@ enum class AlbumKind {
companion object {
fun from(metaType: String?, type: String?): AlbumKind = when {
metaType == "podcast" || type == "podcast" -> Podcast
// Books come as metaType "podcast" with type "audiobook": the type decides.
type == "audiobook" || metaType == "audiobook" -> Audiobook
metaType == "podcast" || type == "podcast" -> Podcast
type == "single" -> Single
type == "compilation" -> Compilation
else -> Album
@@ -25,6 +25,9 @@ sealed interface Route {
companion object {
/** Navigation drawer order. */
val NAV: List<Route> = listOf(Home, Wave, Search, Collection, Podcasts)
/** The drawer destinations, Settings included. */
val SECTIONS: Set<Route> = (NAV + Settings).toSet()
}
}
@@ -36,6 +39,12 @@ class Navigator(start: Route = Route.Home) {
val canGoBack: Boolean get() = history.isNotEmpty()
/**
* The drawer destination the current page belongs to: the last one visited on the way
* here, so a podcast opened from Podcasts lights Podcasts and Now Playing keeps its place.
*/
val section: Route get() = (history + current).lastOrNull { it in Route.SECTIONS } ?: Route.Home
fun go(route: Route) {
if (route == current) return
history = (history + current).takeLast(MAX_HISTORY)
@@ -27,7 +27,7 @@ fun text(ui: UiText): String {
@Composable
@ReadOnlyComposable
fun Track.artistsOrUnknown(): String = artistLine ?: stringResource(R.string.unknown_artist)
fun Track.artistsOrUnknown(): String = artistLine ?: if (spoken) "" else stringResource(R.string.unknown_artist)
@Composable
@ReadOnlyComposable
@@ -29,6 +29,7 @@ import androidx.compose.foundation.layout.width
import androidx.compose.foundation.selection.selectableGroup
import androidx.compose.foundation.shape.CircleShape
import androidx.compose.runtime.Composable
import androidx.compose.runtime.CompositionLocalProvider
import androidx.compose.runtime.LaunchedEffect
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
@@ -57,8 +58,10 @@ import it.panov.musyx.tv.R
import it.panov.musyx.tv.state.AppState
import it.panov.musyx.tv.state.Route
import it.panov.musyx.tv.state.Session
import it.panov.musyx.tv.ui.components.onInk
import it.panov.musyx.tv.ui.components.FocusEntry
import it.panov.musyx.tv.ui.components.Focusable
import it.panov.musyx.tv.ui.components.LocalDrawer
import it.panov.musyx.tv.ui.components.MusyxIcon
import it.panov.musyx.tv.ui.screens.AlbumScreen
import it.panov.musyx.tv.ui.screens.ArtistScreen
@@ -115,13 +118,6 @@ private val NAV = listOf(
)
private val SETTINGS = NavItem(Route.Settings, R.string.nav_settings, R.drawable.ic_settings)
/** The drawer item a route belongs to: detail pages light up where they're usually reached from. */
private fun Route.section(): Route = when (this) {
Route.Chart, is Route.Album, is Route.Artist, is Route.Playlist -> Route.Home
is Route.Genre -> Route.Search
else -> this
}
@Composable
private fun Shell(state: AppState, onExit: () -> Unit) {
val c = MusyxTheme.colors
@@ -134,18 +130,19 @@ private fun Shell(state: AppState, onExit: () -> Unit) {
BackHandler { if (!state.back()) onExit() }
val drawerItem = remember { FocusRequester() }
Box(Modifier.fillMaxSize().background(c.bg)) {
// The page sits beside the rail and keeps its size: the open drawer covers it rather
// than pushing it, so opening never re-lays out the page.
Column(Modifier.fillMaxSize().padding(start = drawerWidth(open = false))) {
Box(Modifier.weight(1f).fillMaxWidth()) {
pages.SaveableStateProvider(route.toString()) {
Page(state, route, entry)
CompositionLocalProvider(LocalDrawer provides drawerItem) { Page(state, route, entry) }
}
}
if (route != Route.NowPlaying && state.playback.state.hasTrack) MiniPlayer(state)
}
Drawer(current = route.section(), onNavigate = state::navigate)
Drawer(current = state.nav.section, onNavigate = state::navigate, selectedItem = drawerItem)
}
SheetHost(state)
}
@@ -176,10 +173,9 @@ private fun drawerWidth(open: Boolean): Dp =
/** The rail opens while it holds focus: one short tween, and only the drawer itself moves. */
@Composable
private fun Drawer(current: Route, onNavigate: (Route) -> Unit) {
private fun Drawer(current: Route, onNavigate: (Route) -> Unit, selectedItem: FocusRequester) {
val c = MusyxTheme.colors
val space = MusyxTheme.space
val selectedItem = remember { FocusRequester() }
var open by remember { mutableStateOf(false) }
val motion = tween<Float>(DRAWER_MS, easing = FastOutSlowInEasing)
val width by animateDpAsState(drawerWidth(open), tween(DRAWER_MS, easing = FastOutSlowInEasing), label = "drawer")
@@ -221,14 +217,13 @@ private fun DrawerItem(item: NavItem, current: Route, open: Boolean, selectedIte
.then(if (selected) Modifier.focusRequester(selectedItem) else Modifier),
container = if (selected) c.raised else Color.Transparent,
contentColor = if (selected) c.fg else c.muted,
focusedContentColor = c.fg,
scale = DRAWER_ITEM_SCALE,
) {
Row(
Modifier.fillMaxSize().padding(start = (NavigationDrawerItemDefaults.CollapsedDrawerItemWidth - iconSize) / 2),
verticalAlignment = Alignment.CenterVertically,
) {
MusyxIcon(item.icon, tint = if (selected) c.accent else LocalContentColor.current, size = iconSize)
MusyxIcon(item.icon, tint = if (selected) onInk(c.accent) else LocalContentColor.current, size = iconSize)
if (open) {
// One unwrapped line, clipped while the drawer is still widening.
Text(
@@ -1,9 +1,10 @@
// Buttons, chips, tabs and the focus plumbing every screen uses. Desktop hover becomes TV
// focus: the raised fill, plus the mockup's amber focus ring.
// focus, and focus is ink: a focused control fills with the text colour and its content turns
// to the background colour, the way TV launchers mark focus. Tiles and covers keep their own
// colours and lift instead: they grow and cast a soft shadow.
package it.panov.musyx.tv.ui.components
import androidx.annotation.DrawableRes
import androidx.compose.foundation.BorderStroke
import androidx.compose.foundation.background
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Box
@@ -18,7 +19,18 @@ import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.size
import androidx.compose.foundation.layout.width
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.foundation.focusGroup
import androidx.compose.animation.core.FastOutSlowInEasing
import androidx.compose.animation.core.animateFloatAsState
import androidx.compose.animation.core.tween
import androidx.compose.foundation.interaction.InteractionSource
import androidx.compose.foundation.interaction.MutableInteractionSource
import androidx.compose.foundation.interaction.collectIsFocusedAsState
import androidx.compose.runtime.Composable
import androidx.compose.runtime.ReadOnlyComposable
import androidx.compose.runtime.CompositionLocalProvider
import androidx.compose.runtime.compositionLocalOf
import androidx.compose.runtime.remember
import androidx.compose.runtime.Stable
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
@@ -26,19 +38,22 @@ import androidx.compose.runtime.setValue
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.focus.FocusRequester
import androidx.compose.ui.focus.focusProperties
import androidx.compose.ui.focus.focusRequester
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.graphics.Shape
import androidx.compose.ui.graphics.graphicsLayer
import androidx.compose.ui.layout.onGloballyPositioned
import androidx.compose.ui.platform.LocalDensity
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.unit.Dp
import androidx.compose.ui.unit.dp
import androidx.tv.material3.Border
import androidx.tv.material3.ClickableSurfaceDefaults
import androidx.tv.material3.Icon
import androidx.tv.material3.LocalContentColor
import androidx.tv.material3.Surface
import androidx.tv.material3.Text
import it.panov.musyx.tv.R
import it.panov.musyx.tv.ui.theme.MusyxTheme
import it.panov.musyx.tv.ui.theme.TV_TYPE_SCALE
@@ -56,6 +71,12 @@ class FocusEntry {
var pending by mutableStateOf(false)
}
/**
* The drawer's current item, for controls at a page's left edge whose Left must open the
* drawer rather than whatever the geometric search finds above them.
*/
val LocalDrawer = compositionLocalOf<FocusRequester?> { null }
fun Modifier.entry(entry: FocusEntry?): Modifier {
if (entry == null) return this
return focusRequester(entry.requester).onGloballyPositioned {
@@ -63,7 +84,52 @@ fun Modifier.entry(entry: FocusEntry?): Modifier {
}
}
/** A focusable area: transparent at rest, raised with an amber ring when focused. */
/** Whether the enclosing [Focusable] has focus, for content that picks its own colours. */
val LocalFocused = compositionLocalOf { false }
/** `color` at rest; on a focused control's ink fill, the content colour instead. */
@Composable
@ReadOnlyComposable
fun onInk(color: Color): Color = if (LocalFocused.current) LocalContentColor.current else color
/** Secondary text: muted at rest, the content colour softened on a focused control's ink fill. */
@Composable
@ReadOnlyComposable
fun subtle(): Color = if (LocalFocused.current) LocalContentColor.current.copy(alpha = 0.72f) else MusyxTheme.colors.muted
/** How far a lifted tile rises: the elevation its shadow is drawn at. */
private val LiftElevation = 14.dp
private const val LIFT_MS = 150
/**
* Lifts a tile while `interaction` has focus: it grows to `scale` and casts a real shadow,
* offset below it the way light falls, rather than a halo around it. A black shadow vanishes
* on the dark theme's ground, so there the tile casts light instead.
*/
@Composable
fun Modifier.lift(interaction: InteractionSource, shape: Shape, scale: Float): Modifier {
val focused by interaction.collectIsFocusedAsState()
val t by animateFloatAsState(if (focused) 1f else 0f, tween(LIFT_MS, easing = FastOutSlowInEasing), label = "lift")
val elevation = with(LocalDensity.current) { LiftElevation.toPx() }
val c = MusyxTheme.colors
val shadow = if (c.isDark) c.fg.copy(alpha = 0.5f) else Color.Black
return graphicsLayer {
val grown = 1f + (scale - 1f) * t
scaleX = grown
scaleY = grown
shadowElevation = elevation * t
ambientShadowColor = shadow
spotShadowColor = shadow
this.shape = shape
clip = false
}
}
/**
* A focusable area. Focused, it fills with ink (the text colour) and its content turns to the
* background colour; `lift` keeps the resting colours and grows the area with a shadow
* instead, for coloured tiles.
*/
@Composable
fun Focusable(
onClick: () -> Unit,
@@ -72,45 +138,44 @@ fun Focusable(
enabled: Boolean = true,
shape: Shape = RoundedCornerShape(MusyxTheme.radius.control),
container: Color = Color.Transparent,
focusedContainer: Color = MusyxTheme.colors.raised,
contentColor: Color = MusyxTheme.colors.fg,
focusedContentColor: Color = contentColor,
scale: Float = 1f,
ring: Boolean = true,
ringColor: Color = MusyxTheme.colors.accent,
lift: Boolean = false,
content: @Composable BoxScope.() -> Unit,
) {
val c = MusyxTheme.colors
val interaction = remember { MutableInteractionSource() }
val focused by interaction.collectIsFocusedAsState()
val focusedContainer = if (lift) container else c.fg
val focusedContent = if (lift) contentColor else c.bg
Surface(
onClick = onClick,
onLongClick = onLongClick,
enabled = enabled,
modifier = modifier,
modifier = if (lift) modifier.lift(interaction, shape, maxOf(scale, LIFT_SCALE)) else modifier,
shape = ClickableSurfaceDefaults.shape(shape),
colors = ClickableSurfaceDefaults.colors(
containerColor = container,
contentColor = contentColor,
focusedContainerColor = focusedContainer,
focusedContentColor = focusedContentColor,
focusedContentColor = focusedContent,
pressedContainerColor = focusedContainer,
pressedContentColor = focusedContentColor,
pressedContentColor = focusedContent,
disabledContainerColor = container,
disabledContentColor = c.muted.copy(alpha = 0.5f),
),
scale = ClickableSurfaceDefaults.scale(focusedScale = scale),
border = if (ring) {
ClickableSurfaceDefaults.border(
focusedBorder = Border(BorderStroke(2.dp, ringColor), shape = shape),
pressedBorder = Border(BorderStroke(2.dp, ringColor), shape = shape),
)
} else {
ClickableSurfaceDefaults.border()
},
scale = ClickableSurfaceDefaults.scale(focusedScale = if (lift) 1f else scale),
border = ClickableSurfaceDefaults.border(),
glow = ClickableSurfaceDefaults.glow(),
content = content,
)
interactionSource = interaction,
) {
CompositionLocalProvider(LocalFocused provides (focused && !lift)) { content() }
}
}
/** How much a lifted tile grows on focus. */
private const val LIFT_SCALE = 1.06f
@Composable
fun MusyxIcon(@DrawableRes icon: Int, modifier: Modifier = Modifier, tint: Color = LocalContentColor.current, size: Dp = IconSize) {
Icon(painterResource(icon), contentDescription = null, tint = tint, modifier = modifier.size(size))
@@ -133,11 +198,8 @@ fun PrimaryButton(
modifier = modifier,
shape = shape,
container = c.accent,
focusedContainer = c.accent,
contentColor = c.accentInk,
scale = 1.06f,
// Amber on amber wouldn't show; the ring is the text colour instead.
ringColor = c.fg,
) {
ButtonContent(label, icon, PaddingValues(horizontal = 26.dp, vertical = 14.dp))
}
@@ -161,7 +223,6 @@ fun GhostButton(
modifier = modifier,
shape = shape,
container = if (danger) c.like else c.raised,
focusedContainer = if (danger) c.like else c.line,
contentColor = if (danger) Color.White else c.fg,
scale = 1.05f,
) {
@@ -181,14 +242,13 @@ private fun ButtonContent(label: String, @DrawableRes icon: Int?, padding: Paddi
}
}
/** A round icon-only button: like, more, transport. `on` tints it amber. */
/** A round icon-only button: like, more, transport. Focused, it's an ink disc. */
@Composable
fun IconButton(
@DrawableRes icon: Int,
onClick: () -> Unit,
modifier: Modifier = Modifier,
tint: Color = MusyxTheme.colors.muted,
focusedTint: Color = MusyxTheme.colors.fg,
size: Dp = IconSize,
padding: Dp = 10.dp,
enabled: Boolean = true,
@@ -199,13 +259,42 @@ fun IconButton(
modifier = modifier,
shape = RoundedCornerShape(MusyxTheme.radius.pill),
contentColor = tint,
focusedContentColor = focusedTint,
scale = 1.1f,
) {
MusyxIcon(icon, size = size, modifier = Modifier.padding(padding))
}
}
/** The chosen item of the [ChoiceRow] or [TabBar] around it: where focus lands on entering. */
private val LocalChosen = compositionLocalOf<FocusRequester?> { null }
/** Tags the chosen item of a row so entering the row lands on it. */
@Composable
private fun Modifier.chosen(on: Boolean): Modifier {
val chosen = LocalChosen.current
return if (on && chosen != null) focusRequester(chosen) else this
}
/** A row of choices; moving into it lands on the chosen one, not the nearest. */
@Composable
private fun ChoiceGroup(modifier: Modifier, spacing: Dp, content: @Composable () -> Unit) {
val chosen = remember { FocusRequester() }
Row(
modifier
.focusProperties { onEnter = { runCatching { chosen.requestFocus() } } }
.focusGroup(),
horizontalArrangement = Arrangement.spacedBy(spacing),
verticalAlignment = Alignment.CenterVertically,
) {
CompositionLocalProvider(LocalChosen provides chosen, content = content)
}
}
/** Chips for one setting: quality, appearance, wave mood. */
@Composable
fun ChoiceRow(modifier: Modifier = Modifier, content: @Composable () -> Unit) =
ChoiceGroup(modifier, MusyxTheme.space.s, content)
/** A choice among a few: quality, appearance, wave mood. */
@Composable
fun Chip(label: String, on: Boolean, onClick: () -> Unit, modifier: Modifier = Modifier, enabled: Boolean = true) {
@@ -213,14 +302,21 @@ fun Chip(label: String, on: Boolean, onClick: () -> Unit, modifier: Modifier = M
Focusable(
onClick = onClick,
enabled = enabled,
modifier = modifier,
modifier = modifier.chosen(on),
shape = RoundedCornerShape(MusyxTheme.radius.pill),
container = if (on) c.accent else c.raised,
focusedContainer = if (on) c.accent else c.line,
contentColor = if (on) c.accentInk else c.fg,
scale = 1.05f,
) {
Text(label, style = MusyxTheme.type.meta, maxLines = 1, modifier = Modifier.padding(horizontal = 18.dp, vertical = 10.dp))
// The check keeps the choice readable while focus fills the chip with ink.
Row(
Modifier.padding(start = if (on) 12.dp else 18.dp, end = 18.dp, top = 10.dp, bottom = 10.dp),
verticalAlignment = Alignment.CenterVertically,
horizontalArrangement = Arrangement.spacedBy(6.dp),
) {
if (on) MusyxIcon(R.drawable.ic_check, size = 18.dp)
Text(label, style = MusyxTheme.type.meta, maxLines = 1)
}
}
}
@@ -228,12 +324,12 @@ fun Chip(label: String, on: Boolean, onClick: () -> Unit, modifier: Modifier = M
@Composable
fun Tab(label: String, on: Boolean, onClick: () -> Unit, modifier: Modifier = Modifier, count: String? = null) {
val c = MusyxTheme.colors
Focusable(onClick = onClick, modifier = modifier, contentColor = if (on) c.fg else c.muted, focusedContentColor = c.fg) {
Focusable(onClick = onClick, modifier = modifier.chosen(on), contentColor = if (on) c.fg else c.muted) {
// As wide as the label, so the underline doesn't stretch the tab across the row.
Column(Modifier.width(IntrinsicSize.Max).padding(horizontal = 14.dp, vertical = 8.dp)) {
Row(verticalAlignment = Alignment.CenterVertically, horizontalArrangement = Arrangement.spacedBy(8.dp)) {
Text(label, style = MusyxTheme.type.bodyMedium, maxLines = 1)
if (count != null) Text(count, style = MusyxTheme.type.small, color = c.muted, maxLines = 1)
if (count != null) Text(count, style = MusyxTheme.type.small, color = subtle(), maxLines = 1)
}
Box(
Modifier
@@ -246,12 +342,9 @@ fun Tab(label: String, on: Boolean, onClick: () -> Unit, modifier: Modifier = Mo
}
}
/** Tabs; moving into the bar lands on the selected tab. */
@Composable
fun TabBar(modifier: Modifier = Modifier, content: @Composable () -> Unit) {
Row(modifier, horizontalArrangement = Arrangement.spacedBy(6.dp), verticalAlignment = Alignment.CenterVertically) {
content()
}
}
fun TabBar(modifier: Modifier = Modifier, content: @Composable () -> Unit) = ChoiceGroup(modifier, 6.dp, content)
/** A thin rule between sections. */
@Composable
@@ -1,7 +1,8 @@
// Covers, cards, rows of cards and grids.
package it.panov.musyx.tv.ui.components
import androidx.compose.foundation.BorderStroke
import androidx.compose.foundation.background
import androidx.compose.foundation.interaction.MutableInteractionSource
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.BoxWithConstraints
@@ -15,26 +16,32 @@ import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.size
import androidx.compose.foundation.layout.width
import androidx.compose.foundation.lazy.LazyListScope
import androidx.compose.foundation.lazy.LazyRow
import androidx.compose.foundation.lazy.itemsIndexed
import androidx.compose.foundation.shape.CircleShape
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.runtime.Composable
import androidx.compose.runtime.remember
import androidx.compose.ui.focus.FocusRequester
import androidx.compose.ui.focus.focusRequester
import androidx.compose.ui.focus.focusRestorer
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.clip
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.graphics.Shape
import androidx.compose.ui.layout.ContentScale
import androidx.compose.ui.text.style.TextOverflow
import androidx.compose.ui.unit.Dp
import androidx.compose.ui.unit.dp
import androidx.tv.material3.Border
import androidx.tv.material3.Card
import androidx.tv.material3.CardDefaults
import androidx.tv.material3.Text
import coil3.compose.AsyncImage
import it.panov.musyx.tv.R
import it.panov.musyx.tv.ui.theme.CoverPlaceholder
import it.panov.musyx.tv.ui.theme.DarkColors
import it.panov.musyx.tv.ui.theme.MusyxTheme
/** Cover sizes asked of the image server. */
@@ -43,7 +50,7 @@ const val COVER_LARGE = 400
/** Desktop cards are 168 px wide; on TV they keep that in dp and grow on focus. */
val CardWidth = 168.dp
private const val FOCUSED_SCALE = 1.08f
private const val FOCUSED_SCALE = 1.1f
/** A cover image, with the two-hue placeholder while it loads or when there's none. */
@Composable
@@ -70,6 +77,10 @@ class CardData(
val hues: Pair<Float, Float>,
val round: Boolean = false,
val liked: Boolean? = null,
/** A short label on the cover's corner, such as a chart position. */
val badge: String? = null,
/** What's playing comes from this card: an equaliser on its cover. */
val playing: Boolean = false,
val onClick: () -> Unit,
val onLongClick: (() -> Unit)? = null,
)
@@ -79,18 +90,31 @@ fun MediaCard(card: CardData, modifier: Modifier = Modifier, width: Dp = CardWid
val c = MusyxTheme.colors
val shape = if (card.round) CircleShape else RoundedCornerShape(MusyxTheme.radius.cover)
Column(Modifier.width(width), verticalArrangement = Arrangement.spacedBy(9.dp)) {
val interaction = remember { MutableInteractionSource() }
Card(
onClick = card.onClick,
onLongClick = card.onLongClick,
modifier = modifier.fillMaxWidth().aspectRatio(1f),
modifier = modifier.lift(interaction, shape, FOCUSED_SCALE).fillMaxWidth().aspectRatio(1f),
shape = CardDefaults.shape(shape),
colors = CardDefaults.colors(containerColor = c.raised),
scale = CardDefaults.scale(focusedScale = FOCUSED_SCALE),
border = CardDefaults.border(focusedBorder = Border(BorderStroke(3.dp, c.accent), inset = 0.dp, shape = shape)),
glow = CardDefaults.glow(),
scale = CardDefaults.scale(focusedScale = 1f),
interactionSource = interaction,
) {
Box(Modifier.fillMaxSize()) {
Cover(card.cover, card.hues, Modifier.fillMaxSize(), shape)
card.badge?.let { badge ->
Text(
badge,
style = MusyxTheme.type.wordmark,
color = Color.White,
modifier = Modifier
.align(Alignment.BottomStart)
.padding(10.dp)
.background(Color.Black.copy(alpha = 0.55f), RoundedCornerShape(MusyxTheme.radius.control))
.padding(horizontal = 10.dp, vertical = 4.dp),
)
}
if (card.playing) PlayingBadge(Modifier.align(Alignment.TopStart).padding(10.dp))
if (card.liked == true) {
MusyxIcon(
R.drawable.ic_heart_fill,
@@ -107,20 +131,81 @@ fun MediaCard(card: CardData, modifier: Modifier = Modifier, width: Dp = CardWid
}
}
/** The equaliser on a cover whose music is playing: amber on a dark disc, legible on any art. */
@Composable
fun PlayingBadge(modifier: Modifier = Modifier) {
Box(
modifier.size(40.dp).background(Color.Black.copy(alpha = 0.6f), CircleShape),
contentAlignment = Alignment.Center,
) {
MusyxIcon(R.drawable.ic_audio_lines, tint = DarkColors.accent, size = 22.dp)
}
}
/** A heading over a horizontal row of cards, the TV way to show a shelf. */
@Composable
fun CardShelf(title: String?, cards: List<CardData>, modifier: Modifier = Modifier, entry: FocusEntry? = null) {
fun CardShelf(
title: String?,
cards: List<CardData>,
modifier: Modifier = Modifier,
entry: FocusEntry? = null,
/** A last tile that opens the whole list, such as the full chart. */
more: ShelfMore? = null,
) {
val space = MusyxTheme.space
Column(modifier, verticalArrangement = Arrangement.spacedBy(space.s)) {
if (title != null) SectionTitle(title, Modifier.padding(horizontal = space.safeX))
LazyRow(
horizontalArrangement = Arrangement.spacedBy(space.xl),
// Room for the focused card to grow without being clipped by the row.
contentPadding = PaddingValues(vertical = space.m, horizontal = space.safeX),
) {
ShelfRow { first ->
itemsIndexed(cards, key = { _, it -> it.key }) { i, card ->
MediaCard(card, if (i == 0) Modifier.entry(entry) else Modifier)
MediaCard(card, if (i == 0) first.entry(entry) else Modifier)
}
if (more != null) item(key = "more") { MoreCard(more) }
}
}
}
/**
* A horizontal row of tiles that remembers where you left it: moving into it returns to the
* tile last visited, or the first on a first visit, never whichever tile happens to sit
* under the control above. Content tags its first tile with the modifier it's given.
*/
@Composable
fun ShelfRow(spacing: Dp = MusyxTheme.space.xl, content: LazyListScope.(first: Modifier) -> Unit) {
val space = MusyxTheme.space
val first = remember { FocusRequester() }
LazyRow(
modifier = Modifier.focusRestorer(first),
horizontalArrangement = Arrangement.spacedBy(spacing),
// Room for the focused tile to grow, and for the shadow it casts below, inside the row.
contentPadding = PaddingValues(start = space.safeX, end = space.safeX, top = space.m, bottom = space.xl + space.s),
) {
content(Modifier.focusRequester(first))
}
}
/** The tile at the end of a shelf that opens the whole list. */
class ShelfMore(val label: String, val onClick: () -> Unit)
@Composable
private fun MoreCard(more: ShelfMore) {
val c = MusyxTheme.colors
val shape = RoundedCornerShape(MusyxTheme.radius.cover)
val interaction = remember { MutableInteractionSource() }
Card(
onClick = more.onClick,
modifier = Modifier.lift(interaction, shape, FOCUSED_SCALE).width(CardWidth).aspectRatio(1f),
shape = CardDefaults.shape(shape),
colors = CardDefaults.colors(containerColor = c.raised, focusedContainerColor = c.raised),
scale = CardDefaults.scale(focusedScale = 1f),
interactionSource = interaction,
) {
Column(
Modifier.fillMaxSize().padding(16.dp),
verticalArrangement = Arrangement.spacedBy(10.dp, Alignment.CenterVertically),
horizontalAlignment = Alignment.CenterHorizontally,
) {
MusyxIcon(R.drawable.ic_chevron_right, tint = c.accent, size = 36.dp)
Text(more.label, style = MusyxTheme.type.bodyMedium, color = c.fg, maxLines = 2, overflow = TextOverflow.Ellipsis)
}
}
}
@@ -1,5 +1,6 @@
// Track rows and the play bar above lists. A row plays on select and opens its menu on a
// long press; the heart and "more" sit to its right for D-pad users.
// long press; the heart and "more" sit to its right for D-pad users. Up and down always land
// on the row itself, so a list reads as one column of stops; right reaches the buttons.
package it.panov.musyx.tv.ui.components
import androidx.compose.foundation.layout.Arrangement
@@ -12,9 +13,14 @@ import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.width
import androidx.compose.foundation.lazy.LazyListScope
import androidx.compose.foundation.lazy.itemsIndexed
import androidx.compose.foundation.focusGroup
import androidx.compose.runtime.Composable
import androidx.compose.runtime.remember
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.focus.FocusRequester
import androidx.compose.ui.focus.focusProperties
import androidx.compose.ui.focus.focusRequester
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.text.style.TextAlign
import androidx.compose.ui.text.style.TextOverflow
@@ -31,11 +37,15 @@ import it.panov.musyx.tv.ui.clock
import it.panov.musyx.tv.ui.theme.MusyxTheme
import it.panov.musyx.tv.ui.theme.tabular
/** Which columns a list shows. Album pages drop the cover and album. */
data class Columns(val cover: Boolean = true, val album: Boolean = true) {
/**
* Which columns a list shows. Album pages drop the cover and album; an artist's page puts the
* album under the title instead of the artist, who would be the same on every row.
*/
data class Columns(val cover: Boolean = true, val album: Boolean = true, val artist: Boolean = true) {
companion object {
val FULL = Columns()
val ALBUM_PAGE = Columns(cover = false, album = false)
val ARTIST_PAGE = Columns(album = false, artist = false)
}
}
@@ -53,6 +63,8 @@ fun LazyListScope.trackItems(
positions: List<Int>? = null,
entry: FocusEntry? = null,
keyPrefix: String = "t",
/** Off in Liked tracks, where every heart would be full; unliking is in the menu. */
hearts: Boolean = true,
) {
itemsIndexed(tracks, key = { i, t -> "$keyPrefix:$i:${t.id}" }) { i, track ->
TrackRow(
@@ -63,7 +75,7 @@ fun LazyListScope.trackItems(
columns = columns,
shift = shifts?.getOrNull(i),
onPlay = { state.playTracks(tracks, i) },
onLike = { state.likeTrack(track, !state.liked.contains(track.id)) },
onLike = if (hearts) ({ state.likeTrack(track, !state.liked.contains(track.id)) }) else null,
onMore = {
val at = positions ?: tracks.indices.toList()
state.openSheet(Sheet.TrackMenu(track, playlist?.let { PlaylistSlot(it, at[i], at.getOrNull(i - 1), at.getOrNull(i + 1)) }))
@@ -82,7 +94,8 @@ fun TrackRow(
columns: Columns,
shift: Int?,
onPlay: () -> Unit,
onLike: () -> Unit,
/** Null hides the heart. */
onLike: (() -> Unit)?,
onMore: () -> Unit,
modifier: Modifier = Modifier,
) {
@@ -93,15 +106,26 @@ fun TrackRow(
playing -> c.accent
else -> c.fg
}
// On the focused row's ink fill, every colour gives way to the fill's content colour.
val row = remember { FocusRequester() }
val drawer = LocalDrawer.current
Row(
Modifier.fillMaxWidth().padding(horizontal = space.safeX - 12.dp),
Modifier
.fillMaxWidth()
.padding(horizontal = space.safeX - 12.dp)
.focusProperties { onEnter = { runCatching { row.requestFocus() } } }
.focusGroup(),
verticalAlignment = Alignment.CenterVertically,
horizontalArrangement = Arrangement.spacedBy(6.dp),
) {
Focusable(
onClick = { if (track.available) onPlay() },
onLongClick = onMore,
modifier = modifier.weight(1f),
modifier = modifier
.focusRequester(row)
// The row is the left edge of the list: Left opens the drawer, never the row above.
.focusProperties { if (drawer != null) left = drawer }
.weight(1f),
) {
Row(
Modifier.padding(horizontal = 12.dp).height(MusyxTheme.shell.trackRow * 1.3f),
@@ -110,22 +134,25 @@ fun TrackRow(
) {
Box(Modifier.width(40.dp), contentAlignment = Alignment.Center) {
if (playing) {
MusyxIcon(R.drawable.ic_audio_lines, tint = c.accent)
MusyxIcon(R.drawable.ic_audio_lines, tint = onInk(c.accent))
} else {
Text("${index + 1}", style = MusyxTheme.type.meta.tabular(), color = c.muted)
Text("${index + 1}", style = MusyxTheme.type.meta.tabular(), color = subtle())
}
}
if (shift != null) ShiftMarker(shift)
if (columns.cover) Thumb(track.coverUrl(COVER_SMALL), track.hues, 48.dp)
Column(Modifier.weight(22f)) {
Text(track.fullTitle, style = MusyxTheme.type.bodyMedium, color = titleColor, maxLines = 1, overflow = TextOverflow.Ellipsis)
Text(track.artistsOrUnknown(), style = MusyxTheme.type.meta, color = c.muted, maxLines = 1, overflow = TextOverflow.Ellipsis)
Text(track.fullTitle, style = MusyxTheme.type.bodyMedium, color = onInk(titleColor), maxLines = 1, overflow = TextOverflow.Ellipsis)
val subtitle = if (columns.artist) track.artistsOrUnknown() else track.album?.title.orEmpty()
if (subtitle.isNotEmpty()) {
Text(subtitle, style = MusyxTheme.type.meta, color = subtle(), maxLines = 1, overflow = TextOverflow.Ellipsis)
}
}
if (columns.album) {
Text(
track.album?.title.orEmpty(),
style = MusyxTheme.type.meta,
color = c.muted,
color = subtle(),
maxLines = 1,
overflow = TextOverflow.Ellipsis,
modifier = Modifier.weight(14f),
@@ -134,18 +161,19 @@ fun TrackRow(
Text(
clock(track.durationMs),
style = MusyxTheme.type.meta.tabular(),
color = c.muted,
color = subtle(),
textAlign = TextAlign.End,
modifier = Modifier.width(64.dp),
)
}
}
if (onLike != null) {
IconButton(
if (liked) R.drawable.ic_heart_fill else R.drawable.ic_heart,
onClick = onLike,
tint = if (liked) c.like else c.muted.copy(alpha = 0.5f),
focusedTint = if (liked) c.like else c.fg,
)
}
IconButton(R.drawable.ic_ellipsis, onClick = onMore)
}
}
@@ -162,9 +190,19 @@ fun ShiftMarker(shift: Int) {
Text(glyph, style = MusyxTheme.type.small, color = colour, modifier = Modifier.width(18.dp), textAlign = TextAlign.Center)
}
/** Play and Shuffle with a summary on the left. Shared by every page with tracks. */
/**
* Play and Shuffle, then any page actions (the heart), then a summary. Shared by every page
* with tracks.
*/
@Composable
fun PlayBar(state: AppState, tracks: List<Track>, modifier: Modifier = Modifier, summary: String = "", entry: FocusEntry? = null) {
fun PlayBar(
state: AppState,
tracks: List<Track>,
modifier: Modifier = Modifier,
summary: String = "",
entry: FocusEntry? = null,
actions: @Composable () -> Unit = {},
) {
val space = MusyxTheme.space
Row(
modifier.fillMaxWidth().padding(horizontal = space.safeX),
@@ -184,6 +222,7 @@ fun PlayBar(state: AppState, tracks: List<Track>, modifier: Modifier = Modifier,
icon = R.drawable.ic_shuffle,
enabled = tracks.isNotEmpty(),
)
actions()
if (summary.isNotEmpty()) {
Text(summary, style = MusyxTheme.type.meta, color = MusyxTheme.colors.muted, modifier = Modifier.padding(start = space.s))
}
@@ -5,11 +5,19 @@ import android.content.ActivityNotFoundException
import android.content.Context
import android.content.Intent
import androidx.annotation.StringRes
import androidx.compose.foundation.ExperimentalFoundationApi
import androidx.compose.foundation.background
import androidx.compose.foundation.focusGroup
import androidx.compose.foundation.gestures.BringIntoViewSpec
import androidx.compose.foundation.gestures.LocalBringIntoViewSpec
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.BoxWithConstraints
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.PaddingValues
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.width
@@ -20,14 +28,20 @@ import androidx.compose.foundation.lazy.itemsIndexed
import androidx.compose.foundation.lazy.rememberLazyListState
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.runtime.Composable
import androidx.core.net.toUri
import androidx.compose.runtime.CompositionLocalProvider
import androidx.compose.runtime.remember
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.focus.FocusRequester
import androidx.compose.ui.focus.focusRequester
import androidx.compose.ui.focus.focusRestorer
import androidx.compose.ui.graphics.Brush
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.platform.LocalDensity
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.unit.dp
import androidx.core.net.toUri
import androidx.tv.material3.Text
import it.panov.musyx.tv.R
import it.panov.musyx.tv.api.AlbumSummary
@@ -35,9 +49,11 @@ import it.panov.musyx.tv.api.ArtistSummary
import it.panov.musyx.tv.api.Clip
import it.panov.musyx.tv.api.Genre
import it.panov.musyx.tv.api.PlaylistSummary
import it.panov.musyx.tv.api.Track
import it.panov.musyx.tv.state.AppState
import it.panov.musyx.tv.state.Loadable
import it.panov.musyx.tv.state.Route
import it.panov.musyx.tv.state.Sheet
import it.panov.musyx.tv.state.UiText
import it.panov.musyx.tv.ui.artistsOrUnknown
import it.panov.musyx.tv.ui.clock
@@ -50,15 +66,20 @@ import it.panov.musyx.tv.ui.components.FocusEntry
import it.panov.musyx.tv.ui.components.Focusable
import it.panov.musyx.tv.ui.components.Note
import it.panov.musyx.tv.ui.components.SectionTitle
import it.panov.musyx.tv.ui.components.ShelfMore
import it.panov.musyx.tv.ui.components.ShelfRow
import it.panov.musyx.tv.ui.components.entry
import it.panov.musyx.tv.ui.subtitle
import it.panov.musyx.tv.ui.theme.DarkColors
import it.panov.musyx.tv.ui.theme.MusyxTheme
import it.panov.musyx.tv.ui.theme.mix
/** A scrolling page: sections stacked with the section gap, inside the TV's safe area. */
@OptIn(ExperimentalFoundationApi::class)
@Composable
fun PageColumn(content: LazyListScope.() -> Unit) {
val space = MusyxTheme.space
CompositionLocalProvider(LocalBringIntoViewSpec provides rememberEnoughScroll()) {
LazyColumn(
state = rememberLazyListState(),
modifier = Modifier.fillMaxSize(),
@@ -66,6 +87,38 @@ fun PageColumn(content: LazyListScope.() -> Unit) {
verticalArrangement = Arrangement.spacedBy(space.s),
content = content,
)
}
}
/** Room kept above a focused item, and below it for a card's title and subtitle. */
private val ScrollMarginTop = 40.dp
private val ScrollMarginBottom = 88.dp
/**
* Scrolls only as far as it takes to show the focused item with some room around it. TV's
* default parks focus a third of the way down, which pushed page headers off the top as soon
* as the first button took focus.
*/
@OptIn(ExperimentalFoundationApi::class)
@Composable
private fun rememberEnoughScroll(): BringIntoViewSpec {
val density = LocalDensity.current
return remember(density) {
val top = with(density) { ScrollMarginTop.toPx() }
val bottom = with(density) { ScrollMarginBottom.toPx() }
object : BringIntoViewSpec {
override fun calculateScrollDistance(offset: Float, size: Float, containerSize: Float): Float {
val end = offset + size
return when {
// Taller than the room there is: line its top up with the margin.
size > containerSize - top - bottom -> offset - top
offset < top -> offset - top
end > containerSize - bottom -> end - (containerSize - bottom)
else -> 0f
}
}
}
}
}
/** Space between two sections of a page. */
@@ -73,14 +126,16 @@ fun LazyListScope.gap(key: Any) {
item(key = key) { androidx.compose.foundation.layout.Spacer(Modifier.height(MusyxTheme.space.section - MusyxTheme.space.s)) }
}
/** An album, podcast or book. `heart` is off where every card is liked anyway. */
@Composable
fun albumCard(state: AppState, a: AlbumSummary) = CardData(
fun albumCard(state: AppState, a: AlbumSummary, heart: Boolean = true) = CardData(
key = "al${a.id}",
title = a.fullTitle,
subtitle = a.subtitle(),
cover = a.coverUrl(COVER_LARGE),
hues = a.hues,
liked = a.id in state.likes.albums,
liked = heart && a.id in state.likes.albums,
playing = state.playback.state.track?.album?.id == a.id,
onClick = { state.navigate(Route.Album(a.id)) },
)
@@ -105,6 +160,27 @@ fun playlistCard(state: AppState, p: PlaylistSummary, subtitle: String? = null)
onClick = { state.navigate(Route.Playlist(p.id)) },
)
/**
* A track as a card: select plays `tracks` from it, a long press opens its menu. `badge`
* labels the cover, such as a chart position.
*/
@Composable
fun trackCard(state: AppState, tracks: List<Track>, index: Int, badge: String? = null): CardData {
val track = tracks[index]
return CardData(
key = "tr$index:${track.id}",
title = track.fullTitle,
subtitle = track.artistsOrUnknown(),
cover = track.coverUrl(COVER_LARGE),
hues = track.hues,
liked = state.liked.contains(track.id),
badge = badge,
playing = state.playback.state.track?.id == track.id,
onClick = { if (track.available) state.playTracks(tracks, index) },
onLongClick = { state.openSheet(Sheet.TrackMenu(track)) },
)
}
/** A music video. It opens in the browser; a long press likes or unlikes it. */
@Composable
fun clipCard(state: AppState, clip: Clip): CardData {
@@ -152,8 +228,14 @@ fun <T> LazyListScope.loadable(
}
/** Genre tiles in a shelf; sub-genres are reached from their parent's page. */
fun LazyListScope.genreShelf(state: AppState, entry: FocusEntry?) {
/**
* The top-level genres: a titled row on Home, or on Browse, where they're the whole page, a
* grid under the page's own title.
*/
fun LazyListScope.genreShelf(state: AppState, entry: FocusEntry?, grid: Boolean = false) {
if (!grid) {
item(key = "genres-title") { SectionTitle(stringResource(R.string.section_genres), Modifier.padding(horizontal = MusyxTheme.space.safeX)) }
}
loadable(
"genres",
state.genres,
@@ -164,12 +246,13 @@ fun LazyListScope.genreShelf(state: AppState, entry: FocusEntry?) {
) { list ->
val top = list.withIndex().filter { (_, g) -> list.none { p -> p.subGenres.any { it.id == g.id } } }
item(key = "genres-row") {
LazyRow(
horizontalArrangement = Arrangement.spacedBy(MusyxTheme.space.m),
contentPadding = PaddingValues(horizontal = MusyxTheme.space.safeX, vertical = MusyxTheme.space.m),
) {
if (grid) {
GenreGrid(top.map { (index, genre) -> genre to { state.navigate(Route.Genre(index)) } }, entry)
} else {
ShelfRow(MusyxTheme.space.m) { first ->
itemsIndexed(top, key = { _, g -> g.value.id }) { i, (index, genre) ->
GenreTile(genre, { state.navigate(Route.Genre(index)) }, if (i == 0) Modifier.entry(entry) else Modifier)
GenreTile(genre, { state.navigate(Route.Genre(index)) }, if (i == 0) first.entry(entry) else Modifier)
}
}
}
}
@@ -177,13 +260,14 @@ fun LazyListScope.genreShelf(state: AppState, entry: FocusEntry?) {
}
@Composable
fun GenreTile(genre: Genre, onClick: () -> Unit, modifier: Modifier = Modifier) {
val tint = genre.color?.let(::parseHex) ?: MusyxTheme.colors.raised
fun GenreTile(genre: Genre, onClick: () -> Unit, modifier: Modifier = Modifier, fill: Boolean = false) {
// Genres without a colour get the dark raised tone, so the white title reads in either theme.
val tint = genre.color?.let(::parseHex) ?: DarkColors.raised
val shape = RoundedCornerShape(MusyxTheme.radius.cover)
Focusable(onClick = onClick, modifier = modifier, shape = shape, scale = 1.06f) {
Focusable(onClick = onClick, modifier = modifier, shape = shape, scale = 1.06f, lift = true) {
Box(
Modifier
.width(CardWidth)
.then(if (fill) Modifier.fillMaxWidth() else Modifier.width(CardWidth))
.height(88.dp)
.background(Brush.linearGradient(listOf(tint, mix(tint, Color.Black, 0.45f))), shape)
.padding(horizontal = 16.dp),
@@ -194,6 +278,31 @@ fun GenreTile(genre: Genre, onClick: () -> Unit, modifier: Modifier = Modifier)
}
}
/** Genre tiles wrapped into as many columns as fit; moving in returns to the last tile visited. */
@Composable
private fun GenreGrid(genres: List<Pair<Genre, () -> Unit>>, entry: FocusEntry?) {
val space = MusyxTheme.space
val first = remember { FocusRequester() }
BoxWithConstraints(Modifier.fillMaxWidth().padding(horizontal = space.safeX).padding(vertical = space.m)) {
val columns = ((maxWidth + space.m) / (CardWidth + space.m)).toInt().coerceAtLeast(1)
Column(
Modifier.focusRestorer(first).focusGroup(),
verticalArrangement = Arrangement.spacedBy(space.m),
) {
genres.chunked(columns).forEachIndexed { r, row ->
// Columns share the width; a short last row keeps the same tile size.
Row(Modifier.fillMaxWidth(), horizontalArrangement = Arrangement.spacedBy(space.m)) {
row.forEachIndexed { i, (genre, open) ->
val tagged = if (r == 0 && i == 0) Modifier.focusRequester(first).entry(entry) else Modifier
GenreTile(genre, open, Modifier.weight(1f).then(tagged), fill = true)
}
repeat(columns - row.size) { androidx.compose.foundation.layout.Spacer(Modifier.weight(1f)) }
}
}
}
}
}
/** `#rrggbb` → colour. */
fun parseHex(s: String): Color? {
val h = s.removePrefix("#").takeIf { s.startsWith('#') && it.length == 6 } ?: return null
@@ -202,9 +311,15 @@ fun parseHex(s: String): Color? {
}
/** A shelf of cards as one item of a page. */
fun LazyListScope.shelf(key: String, @StringRes title: Int?, cards: @Composable () -> List<CardData>, entry: FocusEntry? = null) {
fun LazyListScope.shelf(
key: String,
@StringRes title: Int?,
cards: @Composable () -> List<CardData>,
entry: FocusEntry? = null,
more: (@Composable () -> ShelfMore)? = null,
) {
item(key = key) {
val list = cards()
if (list.isNotEmpty()) CardShelf(title?.let { stringResource(it) }, list, entry = entry)
if (list.isNotEmpty()) CardShelf(title?.let { stringResource(it) }, list, entry = entry, more = more?.invoke())
}
}
@@ -22,6 +22,7 @@ import it.panov.musyx.tv.R
import it.panov.musyx.tv.api.AlbumPage
import it.panov.musyx.tv.api.ArtistPage
import it.panov.musyx.tv.api.PlaylistPage
import it.panov.musyx.tv.api.PlaylistSummary
import it.panov.musyx.tv.api.YmError
import it.panov.musyx.tv.state.AppState
import it.panov.musyx.tv.state.Loadable
@@ -72,7 +73,7 @@ private fun Head(
title: String,
by: String?,
meta: String,
actions: @Composable () -> Unit,
actions: (@Composable () -> Unit)? = null,
) {
val c = MusyxTheme.colors
val space = MusyxTheme.space
@@ -87,9 +88,11 @@ private fun Head(
Text(title, style = MusyxTheme.type.displayL, color = c.fg, maxLines = 2, overflow = TextOverflow.Ellipsis)
if (by != null) Text(by, style = MusyxTheme.type.bodyMedium, color = c.fg, maxLines = 1)
if (meta.isNotEmpty()) Text(meta, style = MusyxTheme.type.meta, color = c.muted, maxLines = 1)
if (actions != null) {
Row(horizontalArrangement = Arrangement.spacedBy(space.s), verticalAlignment = Alignment.CenterVertically) { actions() }
}
}
}
}
/** A round heart that adds or removes something from the collection. */
@@ -100,7 +103,6 @@ private fun LikeButton(liked: Boolean, onClick: () -> Unit) {
if (liked) R.drawable.ic_heart_fill else R.drawable.ic_heart,
onClick = onClick,
tint = if (liked) c.like else c.fg,
focusedTint = if (liked) c.like else c.fg,
padding = 12.dp,
)
}
@@ -118,19 +120,18 @@ private fun LazyListScope.albumPage(state: AppState, info: AlbumPage, entry: Foc
item(key = "head") {
val kind = kindLabel(a.kind).let { if (a.year != null) "$it · ${a.year}" else it }
val length = "${tracksWord(info.tracks.size)} · ${durationWords(info.tracks.sumOf { it.durationMs })}"
val liked = a.id in state.likes.albums
val artist = a.artists.firstOrNull { it.id != null }
Head(
a.coverUrl(COVER_LARGE), a.hues, false, kind, a.fullTitle, a.artistLine,
listOfNotNull(length, info.label).joinToString(" · "),
) {
LikeButton(liked) { state.likeAlbum(a.id, !liked) }
a.artists.firstOrNull { it.id != null }?.let { artist ->
GhostButton(artist.name, onClick = { state.navigate(Route.Artist(artist.id!!)) }, icon = R.drawable.ic_chevron_right)
}
}
artist?.let { { GhostButton(it.name, onClick = { state.navigate(Route.Artist(it.id!!)) }, icon = R.drawable.ic_chevron_right) } },
)
}
gap("play-gap")
item(key = "play") { PlayBar(state, info.tracks, entry = entry) }
item(key = "play") {
val liked = a.id in state.likes.albums
PlayBar(state, info.tracks, entry = entry) { LikeButton(liked) { state.likeAlbum(a.id, !liked) } }
}
trackItems(state, info.tracks, Columns.ALBUM_PAGE, keyPrefix = "album")
}
@@ -150,9 +151,11 @@ private fun LazyListScope.artistPage(state: AppState, info: ArtistPage, entry: F
?: a.likes?.let { counted(it, R.plurals.likes) }
?: ""
val liked = a.id in state.likes.artists
Head(a.coverUrl(COVER_LARGE), a.hues, true, kind, a.name, null, meta) {
LikeButton(liked) { state.likeArtist(a.id, !liked) }
}
// With popular tracks the heart sits beside Play; without, it stays here.
Head(
a.coverUrl(COVER_LARGE), a.hues, true, kind, a.name, null, meta,
if (info.popular.isEmpty()) ({ LikeButton(liked) { state.likeArtist(a.id, !liked) } }) else null,
)
}
if (info.popular.isNotEmpty()) {
gap("popular-gap")
@@ -164,8 +167,11 @@ private fun LazyListScope.artistPage(state: AppState, info: ArtistPage, entry: F
modifier = Modifier.padding(horizontal = MusyxTheme.space.safeX),
)
}
item(key = "play") { PlayBar(state, info.popular, entry = entry) }
trackItems(state, info.popular, keyPrefix = "popular")
item(key = "play") {
val liked = a.id in state.likes.artists
PlayBar(state, info.popular, entry = entry) { LikeButton(liked) { state.likeArtist(a.id, !liked) } }
}
trackItems(state, info.popular, Columns.ARTIST_PAGE, keyPrefix = "popular")
}
if (info.albums.isNotEmpty()) {
gap("albums-gap")
@@ -198,20 +204,11 @@ private fun LazyListScope.playlistPage(state: AppState, info: PlaylistPage, entr
item(key = "head") {
val kind = stringResource(R.string.kind_playlist_by, stringResource(if (p.public) R.string.visibility_public else R.string.visibility_private))
val meta = "${tracksWord(info.tracks.size)} · ${durationWords(info.tracks.sumOf { it.durationMs })}"
Head(p.coverUrl(COVER_LARGE), p.hues, false, kind, p.title, p.ownerName.takeIf { it.isNotEmpty() }, meta) {
if (own) {
GhostButton(stringResource(R.string.action_rename), onClick = { state.openSheet(Sheet.Rename(p.id, p.title)) }, icon = R.drawable.ic_pencil)
GhostButton(
stringResource(if (p.public) R.string.action_make_private else R.string.action_make_public),
onClick = { state.setPlaylistPublic(p.id, !p.public) },
icon = if (p.public) R.drawable.ic_lock else R.drawable.ic_globe,
val likeHere = !own && info.tracks.isEmpty()
Head(
p.coverUrl(COVER_LARGE), p.hues, false, kind, p.title, p.ownerName.takeIf { it.isNotEmpty() }, meta,
if (own || likeHere) ({ PlaylistActions(state, p, own) }) else null,
)
GhostButton(stringResource(R.string.action_delete), onClick = { state.openSheet(Sheet.ConfirmDelete(p.id, p.title)) }, icon = R.drawable.ic_trash_2)
} else {
val liked = p.id in state.likes.playlists
LikeButton(liked) { state.likePlaylist(p.id, !liked) }
}
}
}
info.description?.let { d ->
item(key = "description") {
@@ -230,6 +227,30 @@ private fun LazyListScope.playlistPage(state: AppState, info: PlaylistPage, entr
item(key = "empty") { Note(stringResource(R.string.playlist_empty)) }
return
}
item(key = "play") { PlayBar(state, info.tracks, entry = entry) }
item(key = "play") {
PlayBar(state, info.tracks, entry = entry) {
if (!own) {
val liked = p.id in state.likes.playlists
LikeButton(liked) { state.likePlaylist(p.id, !liked) }
}
}
}
trackItems(state, info.tracks, playlist = if (own) p.id else null, positions = info.positions, keyPrefix = "pl")
}
/** Rename, visibility and delete for your own playlist; the heart for someone else's. */
@Composable
private fun PlaylistActions(state: AppState, p: PlaylistSummary, own: Boolean) {
if (own) {
GhostButton(stringResource(R.string.action_rename), onClick = { state.openSheet(Sheet.Rename(p.id, p.title)) }, icon = R.drawable.ic_pencil)
GhostButton(
stringResource(if (p.public) R.string.action_make_private else R.string.action_make_public),
onClick = { state.setPlaylistPublic(p.id, !p.public) },
icon = if (p.public) R.drawable.ic_lock else R.drawable.ic_globe,
)
GhostButton(stringResource(R.string.action_delete), onClick = { state.openSheet(Sheet.ConfirmDelete(p.id, p.title)) }, icon = R.drawable.ic_trash_2)
} else {
val liked = p.id in state.likes.playlists
LikeButton(liked) { state.likePlaylist(p.id, !liked) }
}
}
@@ -47,6 +47,10 @@ import it.panov.musyx.tv.state.AppState
import it.panov.musyx.tv.state.Route
import it.panov.musyx.tv.ui.components.CardWidth
import it.panov.musyx.tv.ui.components.Chip
import it.panov.musyx.tv.ui.components.PlayingBadge
import it.panov.musyx.tv.ui.components.ShelfMore
import it.panov.musyx.tv.ui.components.ShelfRow
import it.panov.musyx.tv.ui.components.ChoiceRow
import coil3.compose.AsyncImage
import it.panov.musyx.tv.ui.components.FocusEntry
import it.panov.musyx.tv.ui.components.Focusable
@@ -54,15 +58,14 @@ import it.panov.musyx.tv.ui.components.Note
import it.panov.musyx.tv.ui.components.PrimaryButton
import it.panov.musyx.tv.ui.components.SectionTitle
import it.panov.musyx.tv.ui.components.entry
import it.panov.musyx.tv.ui.components.trackItems
import it.panov.musyx.tv.ui.theme.MusyxTheme
import it.panov.musyx.tv.ui.theme.mix
import kotlin.math.PI
import kotlin.math.ceil
import kotlin.math.sin
/** Chart rows shown on Home before "Show all". */
private const val HOME_CHART = 10
/** Chart positions shown on Home before "Show all". */
private const val HOME_CHART = 12
/** Cards per Home shelf. */
private const val HOME_CARDS = 12
@@ -74,8 +77,7 @@ fun HomeScreen(state: AppState, entry: FocusEntry) {
// Only worth a section when it has something; a failure stays in the log.
state.recent.get()?.takeIf { it.isNotEmpty() }?.let { recent ->
gap("recent-gap")
item(key = "recent-title") { SectionTitle(stringResource(R.string.section_recent), Modifier.padding(horizontal = MusyxTheme.space.safeX)) }
trackItems(state, recent, keyPrefix = "recent")
shelf("recent", R.string.section_recent, { recent.indices.map { trackCard(state, recent, it) } })
}
gap("home-gap")
@@ -94,23 +96,14 @@ fun HomeScreen(state: AppState, entry: FocusEntry) {
}
if (home.chart.isNotEmpty()) {
gap("chart-gap")
item(key = "chart-title") {
SectionTitle(
stringResource(R.string.section_chart),
Modifier.padding(horizontal = MusyxTheme.space.safeX),
) {
Focusable(onClick = { state.navigate(Route.Chart) }, contentColor = MusyxTheme.colors.muted, focusedContentColor = MusyxTheme.colors.fg) {
Text(
stringResource(R.string.action_show_all_n, home.chart.size),
style = MusyxTheme.type.meta,
modifier = Modifier.padding(horizontal = 12.dp, vertical = 6.dp),
val top = home.chart.take(HOME_CHART).map { it.track }
shelf(
"chart",
R.string.section_chart,
{ top.indices.map { trackCard(state, top, it, badge = "${it + 1}") } },
more = { ShelfMore(stringResource(R.string.action_show_all_n, home.chart.size)) { state.navigate(Route.Chart) } },
)
}
}
}
val top = home.chart.take(HOME_CHART)
trackItems(state, top.map { it.track }, shifts = top.map { it.shift }, keyPrefix = "chart")
}
if (home.newReleases.isNotEmpty()) {
gap("releases-gap")
shelf("releases", R.string.section_new_releases, { home.newReleases.take(HOME_CARDS).map { albumCard(state, it) } })
@@ -162,7 +155,7 @@ fun WaveHero(state: AppState, big: Boolean, entry: FocusEntry?) {
Modifier
.padding(horizontal = space.safeX)
.fillMaxWidth()
.height(if (big) 240.dp else 200.dp)
.height(if (big) 240.dp else 168.dp)
.clip(shape)
.background(Brush.horizontalGradient(listOf(c.panel, mix(c.panel, c.accent, 0.10f))), shape),
) {
@@ -287,11 +280,10 @@ fun WaveScreen(state: AppState, entry: FocusEntry) {
item(key = "no-stations") { Note(stringResource(R.string.stations_none)) }
} else {
item(key = "stations-row") {
LazyRow(
horizontalArrangement = Arrangement.spacedBy(space.xl),
contentPadding = PaddingValues(horizontal = space.safeX, vertical = space.m),
) {
itemsIndexed(others, key = { _, s -> s.id }) { _, s -> StationTile(s) { state.playWave(s.id) } }
ShelfRow { first ->
itemsIndexed(others, key = { _, s -> s.id }) { i, s ->
StationTile(s, playing = state.playback.state.waveStation == s.id, if (i == 0) first else Modifier) { state.playWave(s.id) }
}
}
}
}
@@ -304,22 +296,23 @@ private fun SettingRow(title: String, options: List<Triple<String, Boolean, Wave
val space = MusyxTheme.space
Column(Modifier.padding(horizontal = space.safeX, vertical = space.s), verticalArrangement = Arrangement.spacedBy(space.s)) {
Text(title, style = MusyxTheme.type.bodyMedium, color = MusyxTheme.colors.muted)
Row(horizontalArrangement = Arrangement.spacedBy(space.s)) {
ChoiceRow {
options.forEach { (label, on, next) -> Chip(label, on, onClick = { if (!on && !saving) pick(next) }) }
}
}
}
@Composable
private fun StationTile(station: Station, onClick: () -> Unit) {
private fun StationTile(station: Station, playing: Boolean, modifier: Modifier = Modifier, onClick: () -> Unit) {
val c = MusyxTheme.colors
val tint = station.color?.let(::parseHex) ?: c.raised
val shape = RoundedCornerShape(MusyxTheme.radius.cover)
Column(Modifier.width(CardWidth), verticalArrangement = Arrangement.spacedBy(9.dp)) {
Focusable(onClick = onClick, shape = shape, container = tint, focusedContainer = tint, scale = 1.08f) {
Focusable(onClick = onClick, modifier = modifier, shape = shape, container = tint, scale = 1.08f, lift = true) {
Box(Modifier.size(CardWidth), contentAlignment = Alignment.Center) {
val icon = station.iconUrl(200)
if (icon != null) AsyncImage(model = icon, contentDescription = null, modifier = Modifier.size(96.dp))
if (playing) PlayingBadge(Modifier.align(Alignment.TopStart).padding(10.dp))
}
}
Text(station.name, style = MusyxTheme.type.bodyMedium, color = c.fg, maxLines = 1)
@@ -48,7 +48,7 @@ fun CollectionScreen(state: AppState, entry: FocusEntry) {
item(key = "title") { ScreenTitle(stringResource(R.string.nav_collection)) }
item(key = "tabs") {
TabBar(Modifier.padding(horizontal = space.safeX - 14.dp)) {
CollectionTab.entries.forEachIndexed { i, tab ->
CollectionTab.entries.forEach { tab ->
val count = when (tab) {
CollectionTab.Tracks -> state.liked.tracks()?.size
CollectionTab.Albums -> state.albums.get()?.size
@@ -60,7 +60,7 @@ fun CollectionScreen(state: AppState, entry: FocusEntry) {
stringResource(tabLabel(tab)),
tab == state.collectionTab,
{ state.selectTab(tab) },
modifier = if (i == 0) Modifier.entry(entry) else Modifier,
modifier = if (tab == state.collectionTab) Modifier.entry(entry) else Modifier,
count = count?.toString(),
)
}
@@ -83,7 +83,7 @@ fun CollectionScreen(state: AppState, entry: FocusEntry) {
summary = "${tracksWord(liked.tracks.size)} · ${durationWords(liked.tracks.sumOf { it.durationMs })}",
)
}
trackItems(state, liked.tracks, keyPrefix = "liked")
trackItems(state, liked.tracks, keyPrefix = "liked", hearts = false)
}
}
CollectionTab.Albums -> loadable(
@@ -95,7 +95,7 @@ fun CollectionScreen(state: AppState, entry: FocusEntry) {
) { albums ->
item(key = "grid") {
if (albums.isEmpty()) Note(stringResource(R.string.empty_albums))
else CardGrid(albums.map { albumCard(state, it) })
else CardGrid(albums.map { albumCard(state, it, heart = false) })
}
}
CollectionTab.Artists -> loadable(
@@ -226,7 +226,7 @@ fun PodcastsScreen(state: AppState, entry: FocusEntry) {
item(key = "title") { ScreenTitle(stringResource(R.string.podcasts_title)) }
val mine = state.albums.get()?.filter { it.isPodcast }.orEmpty()
if (mine.isNotEmpty()) {
shelf("yours", R.string.section_yours, { mine.map { albumCard(state, it) } }, entry)
shelf("yours", R.string.section_yours, { mine.map { albumCard(state, it, heart = false) } }, entry)
gap("featured-gap")
}
loadable(
@@ -1,7 +1,31 @@
// Now Playing: the full-screen player with the queue and lyrics, and the mini player that
// sits under every other screen.
// Now Playing: a stage with the cover over a blurred copy of itself, what's playing beside it
// and the transport along the bottom; the queue and lyrics slide in from the right on request.
// Also the mini player that sits under every other screen.
package it.panov.musyx.tv.ui.screens
import android.os.Build
import androidx.activity.compose.BackHandler
import androidx.annotation.DrawableRes
import androidx.annotation.StringRes
import androidx.compose.animation.AnimatedVisibility
import androidx.compose.animation.core.tween
import androidx.compose.animation.fadeIn
import androidx.compose.animation.fadeOut
import androidx.compose.animation.slideInHorizontally
import androidx.compose.animation.slideOutHorizontally
import androidx.compose.foundation.focusGroup
import androidx.compose.foundation.layout.BoxWithConstraints
import androidx.compose.foundation.layout.offset
import androidx.compose.ui.draw.blur
import androidx.compose.ui.draw.shadow
import androidx.compose.ui.focus.FocusDirection
import androidx.compose.ui.focus.FocusRequester
import androidx.compose.ui.focus.focusProperties
import androidx.compose.ui.focus.focusRequester
import androidx.compose.ui.graphics.Brush
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.layout.ContentScale
import coil3.compose.AsyncImage
import androidx.compose.foundation.background
import androidx.compose.foundation.border
import androidx.compose.foundation.focusable
@@ -58,6 +82,8 @@ import it.panov.musyx.tv.state.Route
import it.panov.musyx.tv.state.Sheet
import it.panov.musyx.tv.ui.artistsOrUnknown
import it.panov.musyx.tv.ui.clock
import it.panov.musyx.tv.ui.components.subtle
import it.panov.musyx.tv.ui.components.onInk
import it.panov.musyx.tv.ui.components.COVER_LARGE
import it.panov.musyx.tv.ui.components.COVER_SMALL
import it.panov.musyx.tv.ui.components.Cover
@@ -83,25 +109,154 @@ internal fun noticeText(notice: Notice): String = when (notice) {
is Notice.Skipped -> stringResource(R.string.notice_skipped, notice.title)
}
/** The cover on the stage: as large as the stage's height allows under the transport. */
private val StageCover = 320.dp
/** The queue and lyrics panel that slides in over the stage's right edge. */
private val PanelWidth = 380.dp
@Composable
fun NowPlayingScreen(state: AppState, entry: FocusEntry) {
val p = state.playback.state
val c = MusyxTheme.colors
val space = MusyxTheme.space
val track = p.track
Row(
Modifier.fillMaxSize().padding(start = space.safeX, end = space.safeX, top = space.safeY, bottom = space.safeY),
horizontalArrangement = Arrangement.spacedBy(space.section),
) {
Column(Modifier.weight(1f).fillMaxHeight(), verticalArrangement = Arrangement.spacedBy(space.m)) {
if (track == null) {
Column(
Modifier.fillMaxSize().padding(horizontal = space.safeX, vertical = space.safeY),
verticalArrangement = Arrangement.spacedBy(space.m),
) {
Text(stringResource(R.string.nothing_playing), style = MusyxTheme.type.displayS, color = c.fg)
Text(p.notice?.let { noticeText(it) } ?: stringResource(R.string.pick_a_track), style = MusyxTheme.type.body, color = c.muted)
return@Column
}
Row(horizontalArrangement = Arrangement.spacedBy(space.xl), verticalAlignment = Alignment.Bottom) {
Cover(track.coverUrl(COVER_LARGE), track.hues, Modifier.size(180.dp), RoundedCornerShape(MusyxTheme.radius.cover))
Column(Modifier.weight(1f), verticalArrangement = Arrangement.spacedBy(6.dp)) {
return
}
var panel by rememberSaveable { mutableStateOf<Panel?>(null) }
val panelEntry = remember { FocusEntry() }
val toggles = remember { mapOf(Panel.Queue to FocusRequester(), Panel.Lyrics to FocusRequester()) }
var closedFrom by remember { mutableStateOf<Panel?>(null) }
val open = { which: Panel ->
panel = which
panelEntry.pending = true
}
val close = {
closedFrom = panel
panel = null
}
BackHandler(enabled = panel != null) { close() }
// Back from the panel returns focus to the button that opened it.
LaunchedEffect(closedFrom) {
closedFrom?.let { runCatching { toggles.getValue(it).requestFocus() } }
closedFrom = null
}
Box(Modifier.fillMaxSize()) {
Backdrop(track)
Column(
Modifier
.fillMaxSize()
.padding(horizontal = space.safeX, vertical = space.safeY)
// While the panel is open the stage sits behind it, out of the D-pad's reach.
.focusProperties { onEnter = { if (panel != null) cancelFocusChange() } }
.focusGroup(),
) {
Row(
Modifier.weight(1f).fillMaxWidth(),
horizontalArrangement = Arrangement.spacedBy(space.section + 6.dp),
verticalAlignment = Alignment.CenterVertically,
) {
Cover(
track.coverUrl(COVER_LARGE),
track.hues,
Modifier
.size(StageCover)
.shadow(28.dp, RoundedCornerShape(MusyxTheme.radius.cover), clip = false),
RoundedCornerShape(MusyxTheme.radius.cover),
)
TrackInfo(state, p, track, Modifier.weight(1f))
}
SeekBar(state, p, Modifier.padding(top = space.xl))
Row(Modifier.fillMaxWidth().padding(top = space.s), verticalAlignment = Alignment.CenterVertically) {
Transport(state, p, entry)
androidx.compose.foundation.layout.Spacer(Modifier.weight(1f))
PanelToggle(R.drawable.ic_list_music, R.string.panel_queue, panel == Panel.Queue, toggles.getValue(Panel.Queue)) {
if (panel == Panel.Queue) close() else open(Panel.Queue)
}
PanelToggle(R.drawable.ic_mic_vocal, R.string.panel_lyrics, panel == Panel.Lyrics, toggles.getValue(Panel.Lyrics)) {
if (panel == Panel.Lyrics) close() else open(Panel.Lyrics)
}
}
}
AnimatedVisibility(
panel != null,
modifier = Modifier.align(Alignment.CenterEnd),
enter = slideInHorizontally(tween(PANEL_MS)) { it } + fadeIn(tween(PANEL_MS)),
exit = slideOutHorizontally(tween(PANEL_MS)) { it } + fadeOut(tween(PANEL_MS)),
) {
// The last panel stays composed while it slides away.
val shown = remember { mutableStateOf(Panel.Queue) }
panel?.let { shown.value = it }
SidePanel(
state,
p,
shown.value,
onPanel = { panel = it },
entry = panelEntry,
modifier = Modifier
.width(PanelWidth)
.fillMaxHeight()
// Leaving the panel leftward closes it, rather than jumping over the stage
// into the drawer; up, down and right stay inside.
.focusProperties {
onExit = {
when (requestedFocusDirection) {
FocusDirection.Left -> {
cancelFocusChange()
close()
}
FocusDirection.Up, FocusDirection.Down, FocusDirection.Right -> cancelFocusChange()
// Focus handed back to the button that opened the panel goes through.
else -> Unit
}
}
},
)
}
}
}
private const val PANEL_MS = 220
/** The cover again, blurred across the whole stage and washed with the background. */
@Composable
private fun Backdrop(track: Track) {
val c = MusyxTheme.colors
// Blur needs Android 12; before it the cover would show sharp, so it's washed out further.
val blurs = Build.VERSION.SDK_INT >= Build.VERSION_CODES.S
AsyncImage(
model = track.coverUrl(COVER_LARGE),
contentDescription = null,
contentScale = ContentScale.Crop,
modifier = Modifier.fillMaxSize().then(if (blurs) Modifier.blur(90.dp) else Modifier),
)
Box(
Modifier
.fillMaxSize()
.background(
Brush.verticalGradient(
0f to c.bg.copy(alpha = if (blurs) 0.62f else 0.9f),
1f to c.bg.copy(alpha = if (blurs) 0.9f else 0.96f),
),
),
)
}
/** Quality, title, artist, album and year, the notice when there is one, and the actions. */
@Composable
private fun TrackInfo(state: AppState, p: PlaybackState, track: Track, modifier: Modifier) {
val c = MusyxTheme.colors
Column(modifier, verticalArrangement = Arrangement.spacedBy(10.dp)) {
p.stream?.let { s ->
val label = if (s.preview) stringResource(R.string.badge_preview) else s.label
Text(
@@ -109,39 +264,35 @@ fun NowPlayingScreen(state: AppState, entry: FocusEntry) {
style = MusyxTheme.type.small,
color = if (s.lossless) c.accent else c.muted,
modifier = Modifier
.border(1.dp, c.line, RoundedCornerShape(4.dp))
.border(1.dp, if (s.lossless) c.accent else c.line, RoundedCornerShape(4.dp))
.padding(horizontal = 8.dp, vertical = 2.dp),
)
}
Text(track.fullTitle, style = MusyxTheme.type.wordmark, color = c.fg, maxLines = 2, overflow = TextOverflow.Ellipsis)
Text(track.artistsOrUnknown(), style = MusyxTheme.type.bodyMedium, color = c.muted, maxLines = 1, overflow = TextOverflow.Ellipsis)
track.album?.let { Text(it.title, style = MusyxTheme.type.meta, color = c.muted, maxLines = 1, overflow = TextOverflow.Ellipsis) }
TrackActions(state, track)
Text(track.fullTitle, style = MusyxTheme.type.displayM, color = c.fg, maxLines = 3, overflow = TextOverflow.Ellipsis)
Text(track.artistsOrUnknown(), style = MusyxTheme.type.section, color = c.fg, maxLines = 1, overflow = TextOverflow.Ellipsis)
track.album?.let { album ->
val line = listOfNotNull(album.title.takeIf { it.isNotBlank() }, album.year?.toString()).joinToString(" · ")
if (line.isNotEmpty()) Text(line, style = MusyxTheme.type.body, color = c.muted, maxLines = 1, overflow = TextOverflow.Ellipsis)
}
val notice = p.notice
if (notice != null && (p.status == Status.Loading || p.status == Status.Paused)) {
Text(noticeText(notice), style = MusyxTheme.type.meta, color = c.like, maxLines = 2)
}
}
}
androidx.compose.foundation.layout.Spacer(Modifier.weight(1f))
SeekBar(state, p)
Transport(state, p, track, entry)
}
SidePanel(state, p, Modifier.width(340.dp).fillMaxHeight())
TrackActions(state, track, Modifier.padding(top = 6.dp))
}
}
/** Position and length around a bar; focused, left and right step through the track. */
@Composable
private fun SeekBar(state: AppState, p: PlaybackState) {
private fun SeekBar(state: AppState, p: PlaybackState, modifier: Modifier = Modifier) {
val c = MusyxTheme.colors
val position = state.playback.positionMs.coerceAtMost(p.durationMs)
val interaction = remember { MutableInteractionSource() }
val focused by interaction.collectIsFocusedAsState()
val fraction = if (p.durationMs > 0) position.toFloat() / p.durationMs else 0f
Row(verticalAlignment = Alignment.CenterVertically, horizontalArrangement = Arrangement.spacedBy(14.dp)) {
Row(modifier, verticalAlignment = Alignment.CenterVertically, horizontalArrangement = Arrangement.spacedBy(14.dp)) {
Text(clock(position), style = MusyxTheme.type.meta.tabular(), color = c.muted)
Box(
BoxWithConstraints(
Modifier
.weight(1f)
.height(28.dp)
@@ -156,26 +307,32 @@ private fun SeekBar(state: AppState, p: PlaybackState) {
.focusable(interactionSource = interaction),
contentAlignment = Alignment.CenterStart,
) {
val track = if (focused) 8.dp else 5.dp
Box(Modifier.fillMaxWidth().height(track).background(c.raised, RoundedCornerShape(4.dp)))
Box(Modifier.fillMaxWidth(fraction.coerceIn(0f, 1f)).height(track).background(if (focused) c.accent else c.fg, RoundedCornerShape(4.dp)))
val bar = if (focused) 8.dp else 5.dp
val done = fraction.coerceIn(0f, 1f)
Box(Modifier.fillMaxWidth().height(bar).background(c.fg.copy(alpha = 0.18f), RoundedCornerShape(4.dp)))
Box(Modifier.fillMaxWidth(done).height(bar).background(c.accent, RoundedCornerShape(4.dp)))
// Focused, a knob marks the playhead: left and right move it.
if (focused) {
Box(
Modifier
.offset(x = maxWidth * done - 9.dp)
.size(18.dp)
.background(c.fg, CircleShape),
)
}
}
Text(clock(p.durationMs), style = MusyxTheme.type.meta.tabular(), color = c.muted)
}
}
@Composable
private fun Transport(state: AppState, p: PlaybackState, track: Track, entry: FocusEntry) {
private fun Transport(state: AppState, p: PlaybackState, entry: FocusEntry) {
val c = MusyxTheme.colors
val playback = state.playback
val playing = p.status == Status.Playing || p.status == Status.Loading
Row(verticalAlignment = Alignment.CenterVertically, horizontalArrangement = Arrangement.spacedBy(12.dp)) {
// A station decides its own order.
IconButton(
R.drawable.ic_shuffle, onClick = playback::toggleShuffle,
tint = if (p.shuffle) c.accent else c.muted, focusedTint = if (p.shuffle) c.accent else c.fg,
enabled = p.waveStation == null,
)
Toggle(R.drawable.ic_shuffle, on = p.shuffle, onClick = playback::toggleShuffle, enabled = p.waveStation == null)
IconButton(R.drawable.ic_skip_back, onClick = playback::previous, tint = c.fg)
// The play disc: amber, round, with the text colour as its focus ring.
Focusable(
@@ -183,57 +340,86 @@ private fun Transport(state: AppState, p: PlaybackState, track: Track, entry: Fo
modifier = Modifier.entry(entry),
shape = CircleShape,
container = c.accent,
focusedContainer = c.accent,
contentColor = c.accentInk,
ringColor = c.fg,
scale = 1.08f,
) {
MusyxIcon(if (playing) R.drawable.ic_pause_fill else R.drawable.ic_play_fill, Modifier.padding(18.dp), size = 30.dp)
}
IconButton(R.drawable.ic_skip_forward, onClick = playback::next, tint = c.fg)
IconButton(
Toggle(
if (p.repeat == Repeat.One) R.drawable.ic_repeat_1 else R.drawable.ic_repeat,
on = p.repeat != Repeat.Off,
onClick = playback::cycleRepeat,
tint = if (p.repeat != Repeat.Off) c.accent else c.muted,
focusedTint = if (p.repeat != Repeat.Off) c.accent else c.fg,
)
}
}
/** Like, "don't recommend" and the track menu, under the title. */
/**
* Shuffle and repeat: the text colour when off, amber with a dot under it when on, and faded
* only when it can't be used, so off never reads as disabled.
*/
@Composable
private fun TrackActions(state: AppState, track: Track) {
private fun Toggle(@DrawableRes icon: Int, on: Boolean, onClick: () -> Unit, enabled: Boolean = true) {
val c = MusyxTheme.colors
Box(contentAlignment = Alignment.BottomCenter) {
IconButton(icon, onClick = onClick, tint = if (on) c.accent else c.fg, enabled = enabled)
if (on && enabled) Box(Modifier.padding(bottom = 1.dp).size(5.dp).background(c.accent, CircleShape))
}
}
/** Opens the queue or the lyrics panel; lit while its panel is open. */
@Composable
private fun PanelToggle(@DrawableRes icon: Int, @StringRes label: Int, on: Boolean, requester: FocusRequester, onClick: () -> Unit) {
val c = MusyxTheme.colors
Focusable(
onClick = onClick,
modifier = Modifier.focusRequester(requester),
shape = RoundedCornerShape(MusyxTheme.radius.pill),
container = if (on) c.raised else Color.Transparent,
contentColor = if (on) c.accent else c.fg,
scale = 1.05f,
) {
Row(
Modifier.padding(horizontal = 16.dp, vertical = 10.dp),
verticalAlignment = Alignment.CenterVertically,
horizontalArrangement = Arrangement.spacedBy(8.dp),
) {
MusyxIcon(icon)
Text(stringResource(label), style = MusyxTheme.type.bodyMedium, maxLines = 1)
}
}
}
/** Like and the track menu, under the title. "Don't recommend" lives in the menu, away from the heart. */
@Composable
private fun TrackActions(state: AppState, track: Track, modifier: Modifier = Modifier) {
val c = MusyxTheme.colors
val liked = state.liked.contains(track.id)
val disliked = track.id in state.likes.dislikedTracks
Row(verticalAlignment = Alignment.CenterVertically, horizontalArrangement = Arrangement.spacedBy(4.dp)) {
Row(modifier, verticalAlignment = Alignment.CenterVertically, horizontalArrangement = Arrangement.spacedBy(4.dp)) {
IconButton(
if (liked) R.drawable.ic_heart_fill else R.drawable.ic_heart,
onClick = { state.likeTrack(track, !liked) },
tint = if (liked) c.like else c.muted,
focusedTint = if (liked) c.like else c.fg,
tint = if (liked) c.like else c.fg,
)
IconButton(
R.drawable.ic_ban,
onClick = { state.dislikeTrack(track, !disliked) },
tint = if (disliked) c.like else c.muted,
)
IconButton(R.drawable.ic_ellipsis, onClick = { state.openSheet(Sheet.TrackMenu(track)) })
IconButton(R.drawable.ic_ellipsis, onClick = { state.openSheet(Sheet.TrackMenu(track)) }, tint = c.fg)
}
}
private enum class Panel { Queue, Lyrics }
@Composable
private fun SidePanel(state: AppState, p: PlaybackState, modifier: Modifier) {
private fun SidePanel(state: AppState, p: PlaybackState, panel: Panel, onPanel: (Panel) -> Unit, entry: FocusEntry, modifier: Modifier) {
val c = MusyxTheme.colors
var panel by rememberSaveable { mutableStateOf(Panel.Queue) }
Column(
modifier.background(c.panel, RoundedCornerShape(MusyxTheme.radius.card)).padding(vertical = 12.dp),
modifier
.shadow(24.dp, RoundedCornerShape(topStart = MusyxTheme.radius.card, bottomStart = MusyxTheme.radius.card))
.background(c.panel, RoundedCornerShape(topStart = MusyxTheme.radius.card, bottomStart = MusyxTheme.radius.card))
.padding(vertical = 20.dp, horizontal = 8.dp)
.focusGroup(),
) {
TabBar(Modifier.padding(horizontal = 8.dp)) {
Tab(stringResource(R.string.panel_queue), panel == Panel.Queue, { panel = Panel.Queue })
Tab(stringResource(R.string.panel_lyrics), panel == Panel.Lyrics, { panel = Panel.Lyrics })
Tab(stringResource(R.string.panel_queue), panel == Panel.Queue, { onPanel(Panel.Queue) }, if (panel == Panel.Queue) Modifier.entry(entry) else Modifier)
Tab(stringResource(R.string.panel_lyrics), panel == Panel.Lyrics, { onPanel(Panel.Lyrics) }, if (panel == Panel.Lyrics) Modifier.entry(entry) else Modifier)
}
val track = p.track
when {
@@ -302,10 +488,10 @@ private fun QueueItem(track: Track, now: Boolean, onClick: (() -> Unit)?) {
) {
Thumb(track.coverUrl(COVER_SMALL), track.hues, 40.dp)
Column(Modifier.weight(1f)) {
Text(track.fullTitle, style = MusyxTheme.type.meta, color = if (now) c.accent else c.fg, maxLines = 1, overflow = TextOverflow.Ellipsis)
Text(track.artistsOrUnknown(), style = MusyxTheme.type.small, color = c.muted, maxLines = 1, overflow = TextOverflow.Ellipsis)
Text(track.fullTitle, style = MusyxTheme.type.meta, color = onInk(if (now) c.accent else c.fg), maxLines = 1, overflow = TextOverflow.Ellipsis)
Text(track.artistsOrUnknown(), style = MusyxTheme.type.small, color = subtle(), maxLines = 1, overflow = TextOverflow.Ellipsis)
}
Text(clock(track.durationMs), style = MusyxTheme.type.small.tabular(), color = c.muted)
Text(clock(track.durationMs), style = MusyxTheme.type.small.tabular(), color = subtle())
}
}
}
@@ -327,7 +513,7 @@ private fun LyricsList(state: AppState, lyrics: Lyrics) {
}
val at = line.atMs
Focusable(onClick = { if (at != null) state.playback.seek(at) }, modifier = Modifier.fillMaxWidth()) {
Text(line.text.ifEmpty { "♪" }, style = style, color = color, modifier = Modifier.padding(horizontal = 10.dp, vertical = 4.dp))
Text(line.text.ifEmpty { "♪" }, style = style, color = onInk(color), modifier = Modifier.padding(horizontal = 10.dp, vertical = 4.dp))
}
}
if (lyrics.writers.isNotEmpty()) {
@@ -369,17 +555,17 @@ fun MiniPlayer(state: AppState) {
) {
Thumb(track.coverUrl(COVER_SMALL), track.hues, 44.dp)
Column(Modifier.weight(1f)) {
Text(track.fullTitle, style = MusyxTheme.type.bodyMedium, color = c.fg, maxLines = 1, overflow = TextOverflow.Ellipsis)
Text(track.fullTitle, style = MusyxTheme.type.bodyMedium, color = onInk(c.fg), maxLines = 1, overflow = TextOverflow.Ellipsis)
val notice = p.notice?.takeIf { p.status == Status.Loading || p.status == Status.Paused }
Text(
notice?.let { noticeText(it) } ?: track.artistsOrUnknown(),
style = MusyxTheme.type.meta,
color = if (notice != null) c.like else c.muted,
color = if (notice != null) onInk(c.like) else subtle(),
maxLines = 1,
overflow = TextOverflow.Ellipsis,
)
}
MusyxIcon(R.drawable.ic_list_music, tint = c.muted)
MusyxIcon(R.drawable.ic_list_music, tint = subtle())
}
}
IconButton(if (playing) R.drawable.ic_pause_fill else R.drawable.ic_play_fill, onClick = state.playback::toggle, tint = c.fg)
@@ -27,6 +27,8 @@ import it.panov.musyx.tv.state.AppState
import it.panov.musyx.tv.state.Route
import it.panov.musyx.tv.ui.artistsOrUnknown
import it.panov.musyx.tv.ui.compact
import it.panov.musyx.tv.ui.components.subtle
import it.panov.musyx.tv.ui.components.onInk
import it.panov.musyx.tv.ui.components.COVER_LARGE
import it.panov.musyx.tv.ui.components.CardGrid
import it.panov.musyx.tv.ui.components.Cover
@@ -86,7 +88,7 @@ fun SearchScreen(state: AppState, entry: FocusEntry) {
verticalAlignment = Alignment.CenterVertically,
horizontalArrangement = Arrangement.spacedBy(12.dp),
) {
MusyxIcon(R.drawable.ic_search, tint = MusyxTheme.colors.muted)
MusyxIcon(R.drawable.ic_search, tint = subtle())
Text(s, style = MusyxTheme.type.body)
}
}
@@ -95,7 +97,7 @@ fun SearchScreen(state: AppState, entry: FocusEntry) {
gap("title-gap")
if (search.query.isEmpty()) {
item(key = "browse") { ScreenTitle(stringResource(R.string.search_browse)) }
genreShelf(state, null)
genreShelf(state, null, grid = true)
return@PageColumn
}
item(key = "title") { ScreenTitle(stringResource(R.string.search_results_for, search.query)) }
@@ -129,14 +131,18 @@ fun SearchScreen(state: AppState, entry: FocusEntry) {
d.best?.let { best -> item(key = "best") { BestCard(state, best) } }
if (d.tracks.isNotEmpty()) {
gap("tracks-gap")
item(key = "tracks-title") {
SectionTitle(stringResource(R.string.search_tracks), Modifier.padding(horizontal = space.safeX)) {
Focusable(onClick = { search.tab(SearchKind.Tracks) }, contentColor = MusyxTheme.colors.muted, focusedContentColor = MusyxTheme.colors.fg) {
Text(stringResource(R.string.action_show_all), style = MusyxTheme.type.meta, modifier = Modifier.padding(horizontal = 12.dp, vertical = 6.dp))
}
}
}
item(key = "tracks-title") { SectionTitle(stringResource(R.string.search_tracks), Modifier.padding(horizontal = space.safeX)) }
trackItems(state, d.tracks.take(ALL_TAB_TRACKS), keyPrefix = "top")
// Where Down from the last track lands, like the tile at the end of a shelf.
item(key = "tracks-all") {
Box(Modifier.padding(horizontal = space.safeX, vertical = space.xs)) {
GhostButton(
stringResource(R.string.search_show_all_tracks),
onClick = { search.tab(SearchKind.Tracks) },
icon = R.drawable.ic_chevron_right,
)
}
}
}
if (d.artists.isNotEmpty()) {
gap("artists-gap")
@@ -211,13 +217,13 @@ private fun BestCard(state: AppState, best: BestMatch) {
Row(Modifier.padding(18.dp), verticalAlignment = Alignment.CenterVertically, horizontalArrangement = Arrangement.spacedBy(20.dp)) {
Cover(shown.cover, shown.hues, Modifier.size(108.dp), if (shown.round) CircleShape else RoundedCornerShape(MusyxTheme.radius.cover))
Column(Modifier.weight(1f), verticalArrangement = Arrangement.spacedBy(6.dp)) {
Text(stringResource(R.string.search_top_result), style = MusyxTheme.type.small, color = c.muted)
Text(shown.title, style = MusyxTheme.type.displayS, color = c.fg, maxLines = 1)
Text(shown.kind, style = MusyxTheme.type.meta, color = c.muted, maxLines = 1)
Text(stringResource(R.string.search_top_result), style = MusyxTheme.type.small, color = subtle())
Text(shown.title, style = MusyxTheme.type.displayS, color = onInk(c.fg), maxLines = 1)
Text(shown.kind, style = MusyxTheme.type.meta, color = subtle(), maxLines = 1)
}
MusyxIcon(
if (best is BestMatch.OfTrack) R.drawable.ic_play_fill else R.drawable.ic_chevron_right,
tint = c.accent,
tint = onInk(c.accent),
modifier = Modifier.width(32.dp),
)
}
@@ -5,6 +5,17 @@ import android.os.SystemClock
import androidx.compose.foundation.BorderStroke
import androidx.compose.foundation.Canvas
import androidx.compose.foundation.background
import androidx.compose.foundation.clickable
import androidx.compose.foundation.interaction.MutableInteractionSource
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.ui.focus.FocusDirection
import androidx.compose.ui.focus.focusProperties
import androidx.compose.ui.input.key.Key
import androidx.compose.ui.input.key.KeyEventType
import androidx.compose.ui.input.key.key
import androidx.compose.ui.input.key.onPreviewKeyEvent
import androidx.compose.ui.input.key.type
import androidx.compose.ui.platform.LocalFocusManager
import androidx.compose.foundation.border
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Box
@@ -242,7 +253,7 @@ private fun Badge(n: Int) {
private fun TokenFallback(signIn: SignInState) {
val c = MusyxTheme.colors
Column(verticalArrangement = Arrangement.spacedBy(MusyxTheme.space.s)) {
Focusable(onClick = signIn::toggleToken, contentColor = c.muted, focusedContentColor = c.fg) {
Focusable(onClick = signIn::toggleToken, contentColor = c.muted) {
Text(
stringResource(if (signIn.tokenOpen) R.string.signin_token_hide else R.string.signin_token_show),
style = MusyxTheme.type.meta,
@@ -265,7 +276,11 @@ private fun TokenFallback(signIn: SignInState) {
}
}
/** A text field that the TV keyboard edits; the amber ring shows it's focused. */
/**
* A text field the remote can pass through. Focused, it's a control like any other: the
* D-pad moves on and the keyboard stays down. Select (or a tap) starts editing and brings the
* keyboard up; up and down still leave, and submitting ends editing. The amber ring shows focus.
*/
@Composable
fun TextInput(
value: String,
@@ -279,36 +294,69 @@ fun TextInput(
val c = MusyxTheme.colors
val shape = RoundedCornerShape(MusyxTheme.radius.pill)
var focused by remember { mutableStateOf(false) }
var editing by remember { mutableStateOf(false) }
// Focused, the field takes the ink fill every focused control has.
val ink = if (focused) c.bg else c.fg
val field = remember { FocusRequester() }
val shell = remember { FocusRequester() }
val keyboard = LocalSoftwareKeyboardController.current
val submit = {
val focusManager = LocalFocusManager.current
LaunchedEffect(editing) {
if (editing) {
field.requestFocus()
keyboard?.show()
}
}
val stop = {
keyboard?.hide()
editing = false
shell.requestFocus()
}
val submit = {
stop()
onSubmit()
}
Box(
modifier
.focusRequester(shell)
.onFocusChanged { focused = it.hasFocus }
.clickable(interactionSource = remember { MutableInteractionSource() }, indication = null) { editing = true }
.background(if (focused) c.fg else c.raised, shape)
.border(BorderStroke(1.dp, if (focused) c.fg else c.line), shape)
.padding(horizontal = 20.dp, vertical = 12.dp),
) {
if (value.isEmpty()) Text(placeholder, style = MusyxTheme.type.body, color = if (focused) ink.copy(alpha = 0.72f) else c.muted, maxLines = 1)
BasicTextField(
value = value,
onValueChange = onChange,
singleLine = true,
textStyle = MusyxTheme.type.body.copy(color = c.fg),
cursorBrush = SolidColor(c.accent),
textStyle = MusyxTheme.type.body.copy(color = ink),
cursorBrush = SolidColor(if (focused) ink else c.accent),
visualTransformation = if (secret) PasswordVisualTransformation() else androidx.compose.ui.text.input.VisualTransformation.None,
keyboardOptions = KeyboardOptions(
keyboardType = if (secret) KeyboardType.Password else KeyboardType.Text,
imeAction = imeAction,
),
keyboardActions = KeyboardActions(onDone = { submit() }, onSearch = { submit() }, onGo = { submit() }),
modifier = modifier.onFocusChanged { focused = it.isFocused },
decorationBox = { field ->
Box(
Modifier
.background(c.raised, shape)
.border(BorderStroke(2.dp, if (focused) c.accent else c.line), shape)
.padding(horizontal = 20.dp, vertical = 12.dp),
) {
if (value.isEmpty()) Text(placeholder, style = MusyxTheme.type.body, color = c.muted, maxLines = 1)
field()
modifier = Modifier
.fillMaxWidth()
.focusRequester(field)
// Only reachable while editing, so moving through the page never lands in it.
.focusProperties { canFocus = editing }
.onFocusChanged { if (!it.isFocused && editing) editing = false }
.onPreviewKeyEvent { e ->
if (e.type != KeyEventType.KeyDown) return@onPreviewKeyEvent false
val direction = when (e.key) {
Key.DirectionUp -> FocusDirection.Up
Key.DirectionDown -> FocusDirection.Down
else -> return@onPreviewKeyEvent false
}
stop()
focusManager.moveFocus(direction)
true
},
)
}
}
/** The QR for the sign-in page, on a white card; a lock until a code exists. */
@@ -28,6 +28,7 @@ import it.panov.musyx.tv.data.Quality
import it.panov.musyx.tv.state.AppState
import it.panov.musyx.tv.state.qualityLabel
import it.panov.musyx.tv.ui.components.Chip
import it.panov.musyx.tv.ui.components.ChoiceRow
import it.panov.musyx.tv.ui.components.FocusEntry
import it.panov.musyx.tv.ui.components.GhostButton
import it.panov.musyx.tv.ui.components.ScreenTitle
@@ -62,13 +63,13 @@ fun SettingsScreen(state: AppState, entry: FocusEntry) {
item(key = "account") { AccountCard(state) }
item(key = "quality") {
Section(stringResource(R.string.settings_quality)) {
Row(horizontalArrangement = Arrangement.spacedBy(MusyxTheme.space.s)) {
Quality.entries.forEachIndexed { i, q ->
ChoiceRow {
Quality.entries.forEach { q ->
Chip(
stringResource(qualityLabel(q)),
q == settings.quality,
{ if (q != settings.quality) state.setQuality(q) },
if (i == 0) Modifier.entry(entry) else Modifier,
if (q == settings.quality) Modifier.entry(entry) else Modifier,
)
}
}
@@ -77,7 +78,7 @@ fun SettingsScreen(state: AppState, entry: FocusEntry) {
}
item(key = "appearance") {
Section(stringResource(R.string.settings_appearance)) {
Row(horizontalArrangement = Arrangement.spacedBy(MusyxTheme.space.s)) {
ChoiceRow {
Appearance.entries.forEach { a ->
Chip(stringResource(appearanceLabel(a)), a == settings.appearance, { state.setAppearance(a) })
}
@@ -86,7 +87,7 @@ fun SettingsScreen(state: AppState, entry: FocusEntry) {
}
item(key = "font-size") {
Section(stringResource(R.string.settings_font_size)) {
Row(horizontalArrangement = Arrangement.spacedBy(MusyxTheme.space.s)) {
ChoiceRow {
FontSize.entries.forEach { f ->
Chip(stringResource(fontSizeLabel(f)), f == settings.fontSize, { state.setFontSize(f) })
}
@@ -95,7 +96,7 @@ fun SettingsScreen(state: AppState, entry: FocusEntry) {
}
item(key = "language") {
Section(stringResource(R.string.settings_language)) {
Row(horizontalArrangement = Arrangement.spacedBy(MusyxTheme.space.s)) {
ChoiceRow {
Locale.entries.forEach { l ->
// Language names stay in their own language so they can be found in either.
val label = when (l) {
@@ -38,6 +38,7 @@ import it.panov.musyx.tv.state.AppState
import it.panov.musyx.tv.state.Route
import it.panov.musyx.tv.state.Sheet
import it.panov.musyx.tv.ui.artistsOrUnknown
import it.panov.musyx.tv.ui.components.subtle
import it.panov.musyx.tv.ui.components.Divider
import it.panov.musyx.tv.ui.components.Focusable
import it.panov.musyx.tv.ui.components.GhostButton
@@ -123,7 +124,7 @@ private fun Item(@DrawableRes icon: Int, label: String, modifier: Modifier = Mod
verticalAlignment = Alignment.CenterVertically,
horizontalArrangement = Arrangement.spacedBy(14.dp),
) {
MusyxIcon(icon, tint = MusyxTheme.colors.muted)
MusyxIcon(icon, tint = subtle())
Text(label, style = MusyxTheme.type.bodyMedium, maxLines = 1, overflow = TextOverflow.Ellipsis)
}
}
@@ -135,7 +136,9 @@ private fun TrackMenu(state: AppState, sheet: Sheet.TrackMenu) {
val playing = state.playback.state.track?.id == track.id
val liked = state.liked.contains(track.id)
val disliked = track.id in state.likes.dislikedTracks
Title(track.fullTitle, track.artistsOrUnknown())
// Where the menu was opened: no "go to" for the page already showing.
val here = state.nav.current
Title(track.fullTitle, track.artistsOrUnknown().ifEmpty { null })
Actions { first ->
item {
if (playing) Item(R.drawable.ic_skip_forward, stringResource(R.string.menu_next_track), Modifier.focusRequester(first), state::skipFromMenu)
@@ -152,22 +155,27 @@ private fun TrackMenu(state: AppState, sheet: Sheet.TrackMenu) {
}
}
item { Item(R.drawable.ic_plus, stringResource(R.string.menu_add_to_playlist)) { state.openSheet(sheet.copy(choosing = true)) } }
// Similar tracks and recommendations are about music; an episode or a chapter has neither.
if (!track.spoken) {
item { Item(R.drawable.ic_audio_lines, stringResource(R.string.menu_play_similar)) { state.playSimilar(track) } }
track.album?.let { album ->
}
track.album?.takeIf { here != Route.Album(it.id) }?.let { album ->
item { Item(R.drawable.ic_disc_3, stringResource(R.string.menu_go_to_album)) { state.navigate(Route.Album(album.id)) } }
}
track.artists.filter { it.id != null }.take(3).forEach { artist ->
track.artists.filter { it.id != null && here != Route.Artist(it.id) }.take(3).forEach { artist ->
item {
Item(R.drawable.ic_mic_vocal, stringResource(R.string.menu_go_to_artist_named, artist.name)) {
state.navigate(Route.Artist(artist.id!!))
}
}
}
if (!track.spoken) {
item {
Item(R.drawable.ic_ban, stringResource(if (disliked) R.string.menu_undislike else R.string.menu_dislike)) {
state.dislikeTrack(track, !disliked)
}
}
}
sheet.playlist?.let { slot ->
item { Divider(Modifier.padding(vertical = 6.dp)) }
slot.up?.let { up ->
@@ -66,17 +66,21 @@ val DarkColors = MusyxColors(
isDark = true,
)
/**
* Light is warm paper with aubergine ink: the dark theme's character in daylight, not its
* inverse. Amber goes deeper so it still reads as text on paper.
*/
val LightColors = MusyxColors(
bg = Color(0xFFF3F1F6),
panel = Color(0xFFFFFFFF),
raised = Color(0xFFEAE6F0),
line = Color(0xFFDCD6E4),
fg = Color(0xFF1F1B27),
muted = Color(0xFF686178),
accent = Color(0xFFA86C05),
bg = Color(0xFFF4EEE4),
panel = Color(0xFFFBF7F0),
raised = Color(0xFFEAE2D4),
line = Color(0xFFDCD2C1),
fg = Color(0xFF231C2B),
muted = Color(0xFF62586A),
accent = Color(0xFF8E5A04),
accentInk = Color(0xFFFFF7E6),
like = Color(0xFFD2405A),
ok = Color(0xFF2E8A55),
like = Color(0xFFB5304B),
ok = Color(0xFF24704A),
isDark = false,
)
+14
View File
@@ -0,0 +1,14 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Lucide check (ISC, assets/icons/LICENSE.txt). Generated by tool/svg_to_vector.py; tint it in code. -->
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24"
android:viewportHeight="24">
<path
android:pathData="M 20 6 9 17 l -5 -5"
android:strokeColor="@android:color/white"
android:strokeWidth="2"
android:strokeLineCap="round"
android:strokeLineJoin="round" />
</vector>
+1 -1
View File
@@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="bg">#F3F1F6</color>
<color name="bg">#F4EEE4</color>
</resources>
+1 -1
View File
@@ -48,7 +48,6 @@
<string name="action_cancel">Отмена</string>
<string name="action_sign_in">Войти</string>
<string name="action_sign_out">Выйти</string>
<string name="action_show_all">Показать все</string>
<string name="action_show_all_n">Показать все %1$d</string>
<string name="action_show_more">Показать ещё</string>
<string name="action_play_radio">Включить радио</string>
@@ -145,6 +144,7 @@
<string name="search_browse">Обзор</string>
<string name="search_all">Всё</string>
<string name="search_tracks">Треки</string>
<string name="search_show_all_tracks">Все треки</string>
<string name="search_albums">Альбомы</string>
<string name="search_artists">Исполнители</string>
<string name="search_playlists">Плейлисты</string>
+1 -1
View File
@@ -53,7 +53,6 @@
<string name="action_cancel">Cancel</string>
<string name="action_sign_in">Sign in</string>
<string name="action_sign_out">Sign out</string>
<string name="action_show_all">Show all</string>
<string name="action_show_all_n">Show all %1$d</string>
<string name="action_show_more">Show more</string>
<string name="action_play_radio">Play radio</string>
@@ -156,6 +155,7 @@
<string name="search_browse">Browse</string>
<string name="search_all">All</string>
<string name="search_tracks">Tracks</string>
<string name="search_show_all_tracks">Show all tracks</string>
<string name="search_albums">Albums</string>
<string name="search_artists">Artists</string>
<string name="search_playlists">Playlists</string>
@@ -99,6 +99,15 @@ class ApiTest {
assertEquals(AlbumKind.Podcast, AlbumKind.from("podcast", null))
assertEquals(AlbumKind.Audiobook, AlbumKind.from(null, "audiobook"))
assertEquals(AlbumKind.Album, AlbumKind.from("music", null))
// Books arrive as podcasts by metaType; the type says what they are.
assertEquals(AlbumKind.Audiobook, AlbumKind.from("podcast", "audiobook"))
}
@Test
fun episodesAndChaptersAreSpoken() {
assertTrue(Track.from(json("""{"id":1,"type":"podcast-episode"}"""))!!.spoken)
assertTrue(Track.from(json("""{"id":1,"albums":[{"id":2,"metaType":"podcast","type":"audiobook"}]}"""))!!.spoken)
assertFalse(Track.from(json("""{"id":1,"type":"music","albums":[{"id":2,"type":"single"}]}"""))!!.spoken)
}
@Test
@@ -24,6 +24,20 @@ class StateTest {
assertEquals(Route.Home, nav.current)
}
@Test
fun sectionIsWherePagesWereReachedFrom() {
val nav = Navigator(Route.Home)
assertEquals(Route.Home, nav.section)
nav.go(Route.Podcasts)
nav.go(Route.Album(7))
assertEquals(Route.Podcasts, nav.section)
nav.go(Route.NowPlaying)
assertEquals(Route.Podcasts, nav.section)
nav.go(Route.Search)
nav.go(Route.Genre(0))
assertEquals(Route.Search, nav.section)
}
@Test
fun revisitingTheCurrentRouteDoesNotGrowHistory() {
val nav = Navigator(Route.Home)
@@ -4,6 +4,7 @@ import androidx.compose.ui.graphics.Color
import androidx.compose.ui.unit.sp
import it.panov.musyx.tv.data.FontSize
import org.junit.Assert.assertEquals
import org.junit.Assert.assertTrue
import org.junit.Test
/** Ports the desktop theme.rs tests, plus parity checks for the placeholder hues. */
@@ -11,7 +12,7 @@ class ThemeTest {
@Test
fun accentMatchesDesign() {
assertEquals(Color(0xF0, 0xB2, 0x3E), DarkColors.accent)
assertEquals(Color(0xA8, 0x6C, 0x05), LightColors.accent)
assertEquals(Color(0x8E, 0x5A, 0x04), LightColors.accent)
}
@Test
@@ -36,11 +37,13 @@ class ThemeTest {
assertEquals(CoverHues.album(7), CoverHues.track("12345:678", albumId = 7))
}
// Large is the size the app shipped with; the others only shrink it.
// Every size scales the desktop sizes, and all of them stay under the original TV scale.
@Test
fun fontSizeScalesType() {
assertEquals(MusyxTypeScale, musyxType(FontSize.Large.scale))
assertEquals(21.sp, musyxType(FontSize.Large.scale).body.fontSize)
assertEquals(16.8f, musyxType(FontSize.Small.scale).body.fontSize.value, 1e-4f)
assertEquals(12.6f, musyxType(FontSize.Small.scale).body.fontSize.value, 1e-4f)
assertEquals(14.7f, musyxType(FontSize.Medium.scale).body.fontSize.value, 1e-4f)
assertEquals(16.8f, musyxType(FontSize.Large.scale).body.fontSize.value, 1e-4f)
FontSize.entries.forEach { assertTrue(it.scale < TV_TYPE_SCALE) }
assertEquals(21.sp, MusyxTypeScale.body.fontSize)
}
}
+15
View File
@@ -0,0 +1,15 @@
<!-- @license lucide-static v0.460.0 - ISC -->
<svg
class="lucide lucide-check"
xmlns="http://www.w3.org/2000/svg"
width="24"
height="24"
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
stroke-width="2"
stroke-linecap="round"
stroke-linejoin="round"
>
<path d="M20 6 9 17l-5-5" />
</svg>

After

Width:  |  Height:  |  Size: 316 B