feat(web+android): Gesamtdauer mit Stunden, in Android neu
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
1 parent
c7fed82736
commit
37f8f8acac
7 files changed
+50
-7
No files matched your search
@@ -0,0 +1,16 @@
|
||||
package com.novasonic.app.ui
|
||||
|
||||
/**
|
||||
* Gesamtdauer einer Playlist oder eines Albums, in Sekunden hereingereicht.
|
||||
*
|
||||
* Ab einer Stunde werden Stunden ausgewiesen: "134 Min." muss man sonst selbst umrechnen, und bei
|
||||
* einer Playlist mit 2000 Titeln staende dort eine vierstellige Minutenzahl. Gleiche Regel und
|
||||
* gleiche Schreibweise wie `formatGesamtdauer` im Web (src/utils.js).
|
||||
*/
|
||||
fun formatGesamtdauer(sekunden: Int): String {
|
||||
val min = Math.round((sekunden.coerceAtLeast(0)) / 60.0).toInt()
|
||||
if (min < 60) return "$min Min."
|
||||
val std = min / 60
|
||||
val rest = min % 60
|
||||
return if (rest > 0) "$std Std. $rest Min." else "$std Std."
|
||||
}
|
||||
@@ -39,6 +39,7 @@ import com.novasonic.app.ui.component.SongRow
|
||||
import com.novasonic.app.ui.theme.*
|
||||
import com.novasonic.app.viewmodel.AlbumViewModel
|
||||
import com.novasonic.app.ui.component.Rollbalken
|
||||
import com.novasonic.app.ui.formatGesamtdauer
|
||||
|
||||
@Composable
|
||||
fun AlbumScreen(
|
||||
@@ -148,6 +149,7 @@ fun AlbumScreen(
|
||||
album.year?.toString(),
|
||||
album.genre?.takeIf { it.isNotBlank() },
|
||||
if (album.songCount > 0) "${album.songCount} Songs" else null,
|
||||
if (album.duration > 0) formatGesamtdauer(album.duration) else null,
|
||||
).joinToString(" · ")
|
||||
if (meta.isNotBlank()) {
|
||||
Spacer(Modifier.height(3.dp))
|
||||
|
||||
@@ -41,6 +41,7 @@ import com.novasonic.app.ui.component.SongRow
|
||||
import com.novasonic.app.ui.theme.*
|
||||
import com.novasonic.app.viewmodel.PlaylistViewModel
|
||||
import com.novasonic.app.ui.component.Rollbalken
|
||||
import com.novasonic.app.ui.formatGesamtdauer
|
||||
|
||||
@Composable
|
||||
fun PlaylistDetailScreen(
|
||||
@@ -182,6 +183,9 @@ fun PlaylistDetailScreen(
|
||||
// Beschriftung — bei einer geteilten Liste ist genau das die interessante Angabe.
|
||||
val meta = listOfNotNull(
|
||||
if (pl.songCount > 0) "${pl.songCount} Songs" else null,
|
||||
// Gesamtdauer: Subsonic liefert sie beim Playlist-Objekt mit, es kostet
|
||||
// also keinen zusaetzlichen Aufruf.
|
||||
if (pl.duration > 0) formatGesamtdauer(pl.duration) else null,
|
||||
pl.owner?.takeIf { it.isNotBlank() && it != state.currentUser }?.let { "von $it" },
|
||||
).joinToString(" · ")
|
||||
if (meta.isNotBlank()) {
|
||||
|
||||
Reference in new issue
Block a user