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

Feat: Album year display #681

Merged
merged 2 commits into from
Nov 27, 2024
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 @@ -23,4 +23,13 @@ data class Album(
symphony.settings.lastUsedAlbumSongsSortBy.value,
symphony.settings.lastUsedAlbumSongsSortReverse.value,
)
fun getDisplayYear(): String? {
if ((startYear == null) && (endYear == null)) {
return null
}
if (startYear == endYear) {
return startYear.toString()
}
return "%s-%s".format(startYear.toString(), endYear.toString())
}
}
37 changes: 32 additions & 5 deletions app/src/main/java/io/github/zyrouge/symphony/ui/view/Album.kt
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
package io.github.zyrouge.symphony.ui.view

import androidx.compose.foundation.Canvas
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.requiredSize
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.automirrored.filled.ArrowBack
import androidx.compose.material.icons.filled.Album
Expand All @@ -21,9 +25,11 @@ import androidx.compose.runtime.derivedStateOf
import androidx.compose.runtime.getValue
import androidx.compose.runtime.remember
import androidx.compose.ui.Modifier
import androidx.compose.ui.geometry.Offset
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.text.style.TextOverflow
import androidx.compose.ui.unit.dp
import io.github.zyrouge.symphony.services.groove.Album
import io.github.zyrouge.symphony.ui.components.AlbumDropdownMenu
import io.github.zyrouge.symphony.ui.components.AnimatedNowPlayingBottomBar
Expand Down Expand Up @@ -135,11 +141,20 @@ private fun AlbumHero(context: ViewContext, album: Album) {
.copy(fontWeight = FontWeight.Bold)
)
}
Text(
album.duration.toString(),
style = MaterialTheme.typography.bodyMedium
.copy(fontWeight = FontWeight.Bold)
)
Row(horizontalArrangement = Arrangement.spacedBy(8.dp)) {
album.getDisplayYear()?.let {
Text(
it, style = MaterialTheme.typography.bodyMedium
.copy(fontWeight = FontWeight.Bold)
)
CircleSeparator()
}
Text(
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add a separator that is small circle in shape which is the same color as the text but with a lower opacity. Should make the design much better.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

image
image

album.duration.toString(),
style = MaterialTheme.typography.bodyMedium
.copy(fontWeight = FontWeight.Bold)
)
}
}
}
)
Expand All @@ -160,3 +175,15 @@ private fun UnknownAlbum(context: ViewContext, albumId: String) {
}
)
}

@Composable
private fun CircleSeparator() {
val color = MaterialTheme.colorScheme.onSurface.copy(alpha = .4f)
Canvas(modifier = Modifier.requiredSize(4.dp, 20.dp)) {
drawCircle(
color,
center = Offset(x = size.width / 2, y = size.height / 2),
radius = size.minDimension * .8f
)
}
}