mirror of
https://github.com/austinried/subtracks.git
synced 2026-11-11 15:29:15 +01:00
Address review: scale artist title cap and cover it with the scrim
This commit is contained in:
@@ -280,7 +280,7 @@ fun HeroHeader(
|
|||||||
style = MaterialTheme.typography.headlineMedium,
|
style = MaterialTheme.typography.headlineMedium,
|
||||||
textAlign = TextAlign.Center,
|
textAlign = TextAlign.Center,
|
||||||
maxLines = nameMaxLines,
|
maxLines = nameMaxLines,
|
||||||
overflow = if (nameMaxLines == Int.MAX_VALUE) TextOverflow.Clip else TextOverflow.Ellipsis,
|
overflow = TextOverflow.Ellipsis,
|
||||||
)
|
)
|
||||||
val subtitleIsTarget = onSubtitleClick != null && subtitle.isNotEmpty() && comment.isNullOrBlank()
|
val subtitleIsTarget = onSubtitleClick != null && subtitle.isNotEmpty() && comment.isNullOrBlank()
|
||||||
if (subtitleIsTarget) {
|
if (subtitleIsTarget) {
|
||||||
|
|||||||
@@ -52,7 +52,6 @@ import androidx.compose.runtime.LaunchedEffect
|
|||||||
import androidx.compose.runtime.derivedStateOf
|
import androidx.compose.runtime.derivedStateOf
|
||||||
import androidx.compose.runtime.getValue
|
import androidx.compose.runtime.getValue
|
||||||
import androidx.compose.runtime.mutableFloatStateOf
|
import androidx.compose.runtime.mutableFloatStateOf
|
||||||
import androidx.compose.runtime.mutableIntStateOf
|
|
||||||
import androidx.compose.runtime.mutableStateOf
|
import androidx.compose.runtime.mutableStateOf
|
||||||
import androidx.compose.runtime.remember
|
import androidx.compose.runtime.remember
|
||||||
import androidx.compose.runtime.rememberCoroutineScope
|
import androidx.compose.runtime.rememberCoroutineScope
|
||||||
@@ -257,8 +256,13 @@ fun ArtistDetailScreen(
|
|||||||
val albumCount = albums.size.toLong()
|
val albumCount = albums.size.toLong()
|
||||||
val displayName = artistName.ifBlank { artist?.name.orEmpty() }
|
val displayName = artistName.ifBlank { artist?.name.orEmpty() }
|
||||||
val artistType = stringResource(if (isAlbumArtist == true) R.string.artist_type_album_artist else R.string.artist_type_artist)
|
val artistType = stringResource(if (isAlbumArtist == true) R.string.artist_type_album_artist else R.string.artist_type_artist)
|
||||||
var titleLineCount by remember { mutableIntStateOf(1) }
|
var titleHeightPx by remember { mutableFloatStateOf(0f) }
|
||||||
val imageTitleTop = ART_HEIGHT - TITLE_INSET - lineHeight * titleLineCount
|
val titleHeight = if (titleHeightPx > 0f) with(density) { titleHeightPx.toDp() } else lineHeight
|
||||||
|
val titleMaxLines =
|
||||||
|
((ART_HEIGHT - TITLE_INSET - barHeight - FADE_LEAD) / lineHeight)
|
||||||
|
.toInt()
|
||||||
|
.coerceIn(1, ARTIST_NAME_MAX_LINES)
|
||||||
|
val imageTitleTop = ART_HEIGHT - TITLE_INSET - titleHeight
|
||||||
val fadeStartPx = with(density) { (imageTitleTop - barHeight - FADE_LEAD).toPx() }
|
val fadeStartPx = with(density) { (imageTitleTop - barHeight - FADE_LEAD).toPx() }
|
||||||
val fadeEndPx = with(density) { (imageTitleTop + lineHeight / 2 - barHeight).toPx() }
|
val fadeEndPx = with(density) { (imageTitleTop + lineHeight / 2 - barHeight).toPx() }
|
||||||
val barFraction by remember(fadeStartPx, fadeEndPx) {
|
val barFraction by remember(fadeStartPx, fadeEndPx) {
|
||||||
@@ -338,7 +342,7 @@ fun ArtistDetailScreen(
|
|||||||
Modifier
|
Modifier
|
||||||
.align(Alignment.BottomStart)
|
.align(Alignment.BottomStart)
|
||||||
.fillMaxWidth()
|
.fillMaxWidth()
|
||||||
.height(ART_HEIGHT * 0.4f)
|
.height(maxOf(ART_HEIGHT * 0.4f, titleHeight + TITLE_INSET * 2))
|
||||||
.graphicsLayer { alpha = nameScrimAlpha }
|
.graphicsLayer { alpha = nameScrimAlpha }
|
||||||
.background(
|
.background(
|
||||||
Brush.verticalGradient(
|
Brush.verticalGradient(
|
||||||
@@ -353,8 +357,13 @@ fun ArtistDetailScreen(
|
|||||||
style = imageNameStyle,
|
style = imageNameStyle,
|
||||||
color = Color.White,
|
color = Color.White,
|
||||||
endReserve = SHUFFLE_RESERVE,
|
endReserve = SHUFFLE_RESERVE,
|
||||||
modifier = Modifier.align(Alignment.BottomStart).fillMaxWidth().padding(TITLE_INSET),
|
maxLines = titleMaxLines,
|
||||||
onLineCountChanged = { titleLineCount = it },
|
modifier =
|
||||||
|
Modifier
|
||||||
|
.align(Alignment.BottomStart)
|
||||||
|
.fillMaxWidth()
|
||||||
|
.padding(TITLE_INSET)
|
||||||
|
.onSizeChanged { titleHeightPx = it.height.toFloat() },
|
||||||
)
|
)
|
||||||
FilledIconButton(
|
FilledIconButton(
|
||||||
onClick = onShuffle,
|
onClick = onShuffle,
|
||||||
@@ -521,9 +530,8 @@ private fun ArtistTitle(
|
|||||||
style: TextStyle,
|
style: TextStyle,
|
||||||
color: Color,
|
color: Color,
|
||||||
endReserve: Dp,
|
endReserve: Dp,
|
||||||
|
maxLines: Int,
|
||||||
modifier: Modifier = Modifier,
|
modifier: Modifier = Modifier,
|
||||||
maxLines: Int = ARTIST_NAME_MAX_LINES,
|
|
||||||
onLineCountChanged: (Int) -> Unit = {},
|
|
||||||
) {
|
) {
|
||||||
val measurer = rememberTextMeasurer()
|
val measurer = rememberTextMeasurer()
|
||||||
val density = LocalDensity.current
|
val density = LocalDensity.current
|
||||||
@@ -534,7 +542,6 @@ private fun ArtistTitle(
|
|||||||
remember(text, style, fullWidth, reserve, maxLines) {
|
remember(text, style, fullWidth, reserve, maxLines) {
|
||||||
splitTitle(measurer, text, style, fullWidth, reserve, maxLines)
|
splitTitle(measurer, text, style, fullWidth, reserve, maxLines)
|
||||||
}
|
}
|
||||||
LaunchedEffect(lines.size) { onLineCountChanged(lines.size) }
|
|
||||||
Column {
|
Column {
|
||||||
lines.forEachIndexed { index, line ->
|
lines.forEachIndexed { index, line ->
|
||||||
Text(
|
Text(
|
||||||
|
|||||||
@@ -37,6 +37,29 @@ class DownloadTreeTest {
|
|||||||
assertEquals(36L, tree.bytes)
|
assertEquals(36L, tree.bytes)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun songsKeepTheOrderTheRepositoryReturns() {
|
||||||
|
val tree =
|
||||||
|
buildTree(
|
||||||
|
listOf(
|
||||||
|
song("s2", "Two", "ar1", "Artist", "al1", "First", size = 20),
|
||||||
|
song("s1", "One", "ar1", "Artist", "al1", "First", size = 10),
|
||||||
|
),
|
||||||
|
"Unknown artist",
|
||||||
|
"Unknown album",
|
||||||
|
)
|
||||||
|
|
||||||
|
assertEquals(
|
||||||
|
listOf("Two", "One"),
|
||||||
|
tree.artists
|
||||||
|
.single()
|
||||||
|
.albums
|
||||||
|
.single()
|
||||||
|
.songs
|
||||||
|
.map { it.title },
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun aSongWithNoArtistOrAlbumIsStillShown() {
|
fun aSongWithNoArtistOrAlbumIsStillShown() {
|
||||||
val tree = buildTree(listOf(song("s1", "One", null, null, null, null, size = 3)), "Unknown artist", "Unknown album")
|
val tree = buildTree(listOf(song("s1", "One", null, null, null, null, size = 3)), "Unknown artist", "Unknown album")
|
||||||
|
|||||||
Reference in New Issue
Block a user