mirror of
https://github.com/austinried/subtracks.git
synced 2026-11-11 15:29:15 +01:00
use titleLarge for disc headings and number album tracks
This commit is contained in:
@@ -103,6 +103,7 @@ fun AlbumDetailScreen(
|
|||||||
SongRow(
|
SongRow(
|
||||||
song = song,
|
song = song,
|
||||||
isPlaying = song.id == playingSongId,
|
isPlaying = song.id == playingSongId,
|
||||||
|
trackNumber = song.track,
|
||||||
modifier = rowModifier.clickable { onSongClick(index) },
|
modifier = rowModifier.clickable { onSongClick(index) },
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
@@ -116,7 +117,7 @@ fun AlbumDetailScreen(
|
|||||||
private fun DiscHeader(disc: Long) {
|
private fun DiscHeader(disc: Long) {
|
||||||
Text(
|
Text(
|
||||||
text = "Disc $disc",
|
text = "Disc $disc",
|
||||||
style = MaterialTheme.typography.titleSmall,
|
style = MaterialTheme.typography.titleLarge,
|
||||||
color = MaterialTheme.colorScheme.onSurfaceVariant,
|
color = MaterialTheme.colorScheme.onSurfaceVariant,
|
||||||
modifier = Modifier.padding(start = 16.dp, end = 16.dp, top = 20.dp, bottom = 4.dp),
|
modifier = Modifier.padding(start = 16.dp, end = 16.dp, top = 20.dp, bottom = 4.dp),
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -2,12 +2,14 @@ package com.subtracks.ui.library
|
|||||||
|
|
||||||
import androidx.compose.foundation.clickable
|
import androidx.compose.foundation.clickable
|
||||||
import androidx.compose.foundation.layout.Arrangement
|
import androidx.compose.foundation.layout.Arrangement
|
||||||
|
import androidx.compose.foundation.layout.Box
|
||||||
import androidx.compose.foundation.layout.PaddingValues
|
import androidx.compose.foundation.layout.PaddingValues
|
||||||
import androidx.compose.foundation.layout.Row
|
import androidx.compose.foundation.layout.Row
|
||||||
import androidx.compose.foundation.layout.Spacer
|
import androidx.compose.foundation.layout.Spacer
|
||||||
import androidx.compose.foundation.layout.fillMaxSize
|
import androidx.compose.foundation.layout.fillMaxSize
|
||||||
import androidx.compose.foundation.layout.height
|
import androidx.compose.foundation.layout.height
|
||||||
import androidx.compose.foundation.layout.size
|
import androidx.compose.foundation.layout.size
|
||||||
|
import androidx.compose.foundation.layout.width
|
||||||
import androidx.compose.foundation.lazy.LazyColumn
|
import androidx.compose.foundation.lazy.LazyColumn
|
||||||
import androidx.compose.foundation.lazy.rememberLazyListState
|
import androidx.compose.foundation.lazy.rememberLazyListState
|
||||||
import androidx.compose.foundation.shape.RoundedCornerShape
|
import androidx.compose.foundation.shape.RoundedCornerShape
|
||||||
@@ -88,13 +90,16 @@ fun SongRow(
|
|||||||
coverArtId: String? = null,
|
coverArtId: String? = null,
|
||||||
coverArt: ((String?, Boolean) -> CoverArtRef?)? = null,
|
coverArt: ((String?, Boolean) -> CoverArtRef?)? = null,
|
||||||
isPlaying: Boolean = false,
|
isPlaying: Boolean = false,
|
||||||
|
trackNumber: Long? = null,
|
||||||
trailingContent: (@Composable () -> Unit)? = null,
|
trailingContent: (@Composable () -> Unit)? = null,
|
||||||
modifier: Modifier = Modifier,
|
modifier: Modifier = Modifier,
|
||||||
) {
|
) {
|
||||||
|
val leadingTrack = trackNumber?.takeIf { coverArt == null }
|
||||||
ListItem(
|
ListItem(
|
||||||
modifier = modifier,
|
modifier = modifier,
|
||||||
leadingContent =
|
leadingContent =
|
||||||
if (coverArt != null) {
|
when {
|
||||||
|
coverArt != null -> {
|
||||||
{
|
{
|
||||||
CoverArt(
|
CoverArt(
|
||||||
ref = coverArt(coverArtId, true),
|
ref = coverArt(coverArtId, true),
|
||||||
@@ -102,8 +107,15 @@ fun SongRow(
|
|||||||
modifier = Modifier.size(48.dp).clip(RoundedCornerShape(6.dp)),
|
modifier = Modifier.size(48.dp).clip(RoundedCornerShape(6.dp)),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
} else {
|
}
|
||||||
|
|
||||||
|
leadingTrack != null -> {
|
||||||
|
{ TrackNumber(leadingTrack, isPlaying) }
|
||||||
|
}
|
||||||
|
|
||||||
|
else -> {
|
||||||
null
|
null
|
||||||
|
}
|
||||||
},
|
},
|
||||||
trailingContent = trailingContent,
|
trailingContent = trailingContent,
|
||||||
headlineContent = {
|
headlineContent = {
|
||||||
@@ -111,7 +123,7 @@ fun SongRow(
|
|||||||
verticalAlignment = Alignment.CenterVertically,
|
verticalAlignment = Alignment.CenterVertically,
|
||||||
horizontalArrangement = Arrangement.spacedBy(8.dp),
|
horizontalArrangement = Arrangement.spacedBy(8.dp),
|
||||||
) {
|
) {
|
||||||
if (isPlaying) {
|
if (isPlaying && leadingTrack == null) {
|
||||||
Icon(
|
Icon(
|
||||||
imageVector = Icons.Rounded.PlayArrow,
|
imageVector = Icons.Rounded.PlayArrow,
|
||||||
contentDescription = "Playing",
|
contentDescription = "Playing",
|
||||||
@@ -140,3 +152,29 @@ fun SongRow(
|
|||||||
colors = ListItemDefaults.colors(containerColor = Color.Transparent),
|
colors = ListItemDefaults.colors(containerColor = Color.Transparent),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Composable
|
||||||
|
private fun TrackNumber(
|
||||||
|
track: Long,
|
||||||
|
isPlaying: Boolean,
|
||||||
|
) {
|
||||||
|
Box(
|
||||||
|
modifier = Modifier.width(28.dp),
|
||||||
|
contentAlignment = Alignment.CenterEnd,
|
||||||
|
) {
|
||||||
|
if (isPlaying) {
|
||||||
|
Icon(
|
||||||
|
imageVector = Icons.Rounded.PlayArrow,
|
||||||
|
contentDescription = "Playing",
|
||||||
|
tint = MaterialTheme.colorScheme.primary,
|
||||||
|
modifier = Modifier.size(18.dp),
|
||||||
|
)
|
||||||
|
} else {
|
||||||
|
Text(
|
||||||
|
text = track.toString(),
|
||||||
|
style = MaterialTheme.typography.bodyMedium,
|
||||||
|
color = MaterialTheme.colorScheme.onSurfaceVariant,
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -32,6 +32,13 @@ class AlbumDiscsTest {
|
|||||||
assertEquals(1, nodesWithText("Disc 2"))
|
assertEquals(1, nodesWithText("Disc 2"))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun albumTracksShowTheirTrackNumbers() {
|
||||||
|
setContent(listOf(song("s-a", disc = 1, track = 1), song("s-b", disc = 1, track = 2)))
|
||||||
|
assertEquals(1, nodesWithText("1"))
|
||||||
|
assertEquals(1, nodesWithText("2"))
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun singleDiscAlbumShowsNoDiscHeaders() {
|
fun singleDiscAlbumShowsNoDiscHeaders() {
|
||||||
setContent(listOf(song("s-a", disc = 1, track = 1), song("s-b", disc = 1, track = 2)))
|
setContent(listOf(song("s-a", disc = 1, track = 1), song("s-b", disc = 1, track = 2)))
|
||||||
|
|||||||
Reference in New Issue
Block a user