Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add track number and artist to AlbumInfoScreen #309

Merged
merged 3 commits into from
Jan 6, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,9 @@ internal class AlbumInfoRepositoryImpl(
private fun Song.toDomain(): AlbumSong {
return AlbumSong(
id = id,
track = track,
title = title,
artist = artist,
duration = formatSongDuration((duration ?: 0) * 1000)
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ package ru.stersh.youamp.feature.album.domain

internal data class AlbumSong(
val id: String,
val track: Int?,
val title: String,
val artist: String?,
val duration: String
)
Original file line number Diff line number Diff line change
Expand Up @@ -267,13 +267,25 @@ private fun AlbumSongItem(
onClick: () -> Unit
) {
ListItem(
leadingContent = {
song.track?.let { Text(text = it.toString()) }
},
headlineContent = {
Text(
text = song.title,
maxLines = 1,
overflow = TextOverflow.Ellipsis
)
},
supportingContent = {
song.artist?.let {
Text(
text = it,
maxLines = 1,
overflow = TextOverflow.Ellipsis
)
}
},
trailingContent = {
Text(text = song.duration)
},
Expand All @@ -287,7 +299,9 @@ private fun AlbumSongItemPreview() {
val song = AlbumSongUi(
id = "1",
title = "Coolest song in the world with very long title",
duration = "12:00"
duration = "12:00",
track = 1,
artist = "Someone"
)
AlbumSongItem(
song = song,
Expand All @@ -301,17 +315,24 @@ private fun AlbumInfoScreenPreview() {
val songs = listOf(
AlbumSongUi(
id = "1",
track = 1,
title = "Test song",
duration = "2:11"
duration = "2:11",
artist = "Test artist"

),
AlbumSongUi(
id = "2",
track = 2,
title = "Test song 2",
duration = "6:23"
artist = "Someone else",
duration = "6:23",
),
AlbumSongUi(
id = "3",
track = 3,
title = "Test song 3",
artist = "Test artist",
duration = "5:11"
)
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,7 @@ internal data class AlbumInfoUi(
internal data class AlbumSongUi(
val id: String,
val title: String,
val track: Int?,
val artist: String?,
val duration: String
)
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ internal fun AlbumSong.toUi(): AlbumSongUi {
return AlbumSongUi(
id = id,
title = title,
track = track,
artist = artist,
duration = duration
)
}
Loading