ui: show plural artists in song subtitles and info dialog

This commit is contained in:
austinried
2026-10-19 14:16:31 +00:00
parent d81efe168e
commit fb1c2a02ff
6 changed files with 138 additions and 3 deletions
@@ -80,7 +80,7 @@ sealed interface MenuTarget {
) : MenuTarget {
override val title: String get() = song.title
override val subtitle: String? get() = song.artist
override val subtitle: String? get() = song.artistSubtitle()
}
data class Album(
@@ -0,0 +1,15 @@
package com.subtracks.ui.components
import com.subtracks.data.model.Song
private const val ARTIST_SEPARATOR = " \u00B7 "
internal fun Song.artistSubtitle(): String? {
val names = artists.map { it.name }.filter { it.isNotBlank() }.distinct()
if (names.isEmpty()) return artist?.takeIf { it.isNotBlank() }
val primary = artist?.takeIf { it in names }
return buildList {
primary?.let(::add)
addAll(names.filterNot { it == primary })
}.joinToString(ARTIST_SEPARATOR)
}
@@ -54,7 +54,7 @@ fun SongInfoDialog(
text = {
Column(verticalArrangement = Arrangement.spacedBy(6.dp)) {
InfoRow(stringResource(R.string.resources_sort_by_title), song.title)
InfoRow(stringResource(R.string.resources_filter_artist), song.artist)
InfoRow(stringResource(R.string.resources_filter_artist), song.artistSubtitle())
InfoRow(stringResource(R.string.resources_filter_album), song.album)
InfoRow(stringResource(R.string.info_duration), song.duration?.let(DateUtils::formatElapsedTime))
InfoRow(
@@ -61,6 +61,7 @@ import com.subtracks.data.model.DownloadStatus
import com.subtracks.data.model.Song
import com.subtracks.data.model.SongDownload
import com.subtracks.ui.components.CoverArt
import com.subtracks.ui.components.artistSubtitle
private val TRACK_COLUMN_WIDTH = 24.dp
private val TIME_COLUMN_WIDTH = 36.dp
@@ -146,7 +147,7 @@ fun SongRow(
},
supportingContent = {
Text(
text = song.artist.orEmpty().ifEmpty { "\u00A0" },
text = song.artistSubtitle().orEmpty().ifEmpty { "\u00A0" },
color = if (isPlaying) MaterialTheme.colorScheme.primary else MaterialTheme.colorScheme.onSurfaceVariant,
maxLines = 1,
overflow = TextOverflow.Ellipsis,