feat(android): playbar everywhere, song-search context menu, offline tab loads offline
- MiniPlayer now shows on every screen (album/artist/playlist detail), not just top-level tabs; the tab bar stays top-level-only. - Local library song search results get the 3-dot context menu (add to playlist, favorite, queue, download, …) via onShowContextMenu. - Offline tab is fed by the local Room DB and no longer waits on the online library: it stays usable while the library is loading or the server is unreachable. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
1 parent
03046cd631
commit
419f80568c
3 files changed
+44
-34
No files matched your search
@@ -155,41 +155,43 @@ fun AppNavigation() {
|
||||
containerColor = NsBackground,
|
||||
modifier = Modifier.background(NsBackground).background(bgGlow),
|
||||
bottomBar = {
|
||||
if (isTopLevel) {
|
||||
Column {
|
||||
// ABS audio routes through MusicService — one notification, one mini player.
|
||||
// When an ABS book is loaded, tapping the mini player opens the ABS overlay
|
||||
// instead of the music NowPlaying screen.
|
||||
val hasAbsItem = absState.item != null
|
||||
val showMiniPlayer = playerState.isPlaying ||
|
||||
playerState.currentSong != null ||
|
||||
(lastPlayedSong != null && !showNowPlaying)
|
||||
AnimatedVisibility(
|
||||
visible = showMiniPlayer,
|
||||
enter = slideInVertically { it } + fadeIn(tween(220)),
|
||||
exit = slideOutVertically { it } + fadeOut(tween(180)),
|
||||
) {
|
||||
MiniPlayer(
|
||||
state = playerState,
|
||||
coverUrl = coverUrl(playerState.currentSong?.coverArt) ?: playerState.artworkUri,
|
||||
onTap = { if (hasAbsItem) showAbsPlayer = true else showNowPlaying = true },
|
||||
onTogglePlay = { if (hasAbsItem) absPlayerController.togglePlay() else player.togglePlay() },
|
||||
onSkipPrev = { if (hasAbsItem) absPlayerController.prevChapter() else player.skipPrev() },
|
||||
onSkipNext = { if (hasAbsItem) absPlayerController.nextChapter() else player.skipNext() },
|
||||
lastSong = if (playerState.currentSong == null) lastPlayedSong else null,
|
||||
lastSongCoverUrl = lastPlayedSong?.coverArtId?.let { coverUrl(it) },
|
||||
onPlayLast = {
|
||||
lastPlayedSong?.let { ls ->
|
||||
scope.launch {
|
||||
runCatching {
|
||||
val song = repo.getSong(ls.id)
|
||||
player.playSongs(listOf(song), 0)
|
||||
}
|
||||
// MiniPlayer shows on EVERY screen (incl. album/artist/playlist detail) so playback
|
||||
// is always reachable; the tab bar stays top-level-only.
|
||||
Column {
|
||||
// ABS audio routes through MusicService — one notification, one mini player.
|
||||
// When an ABS book is loaded, tapping the mini player opens the ABS overlay
|
||||
// instead of the music NowPlaying screen.
|
||||
val hasAbsItem = absState.item != null
|
||||
val showMiniPlayer = playerState.isPlaying ||
|
||||
playerState.currentSong != null ||
|
||||
(lastPlayedSong != null && !showNowPlaying)
|
||||
AnimatedVisibility(
|
||||
visible = showMiniPlayer,
|
||||
enter = slideInVertically { it } + fadeIn(tween(220)),
|
||||
exit = slideOutVertically { it } + fadeOut(tween(180)),
|
||||
) {
|
||||
MiniPlayer(
|
||||
state = playerState,
|
||||
coverUrl = coverUrl(playerState.currentSong?.coverArt) ?: playerState.artworkUri,
|
||||
onTap = { if (hasAbsItem) showAbsPlayer = true else showNowPlaying = true },
|
||||
onTogglePlay = { if (hasAbsItem) absPlayerController.togglePlay() else player.togglePlay() },
|
||||
onSkipPrev = { if (hasAbsItem) absPlayerController.prevChapter() else player.skipPrev() },
|
||||
onSkipNext = { if (hasAbsItem) absPlayerController.nextChapter() else player.skipNext() },
|
||||
lastSong = if (playerState.currentSong == null) lastPlayedSong else null,
|
||||
lastSongCoverUrl = lastPlayedSong?.coverArtId?.let { coverUrl(it) },
|
||||
onPlayLast = {
|
||||
lastPlayedSong?.let { ls ->
|
||||
scope.launch {
|
||||
runCatching {
|
||||
val song = repo.getSong(ls.id)
|
||||
player.playSongs(listOf(song), 0)
|
||||
}
|
||||
}
|
||||
},
|
||||
)
|
||||
}
|
||||
}
|
||||
},
|
||||
)
|
||||
}
|
||||
if (isTopLevel) {
|
||||
NavigationBar(containerColor = NavBg, tonalElevation = 0.dp) {
|
||||
navItems.forEach { dest ->
|
||||
NavigationBarItem(
|
||||
@@ -272,6 +274,7 @@ fun AppNavigation() {
|
||||
onSongPlay = { songs, idx -> player.playSongs(songs, idx) },
|
||||
onAlbumClick = { album -> navController.navigate("album/${album.id}") },
|
||||
onArtistClick = { artist -> navController.navigate("artist/${artist.id}") },
|
||||
onShowContextMenu = ::showContextMenu,
|
||||
onOpenImporter = { navController.navigate("importer") },
|
||||
)
|
||||
}
|
||||
|
||||
@@ -49,6 +49,7 @@ fun ExploreScreen(
|
||||
onSongPlay: (List<com.novasonic.app.api.model.Song>, Int) -> Unit,
|
||||
onAlbumClick: (com.novasonic.app.api.model.Album) -> Unit,
|
||||
onArtistClick: (com.novasonic.app.api.model.Artist) -> Unit,
|
||||
onShowContextMenu: ((com.novasonic.app.api.model.Song) -> Unit)? = null,
|
||||
onOpenImporter: () -> Unit = {},
|
||||
) {
|
||||
val vm: ExploreViewModel = viewModel()
|
||||
@@ -214,6 +215,7 @@ fun ExploreScreen(
|
||||
onSongPlay = onSongPlay,
|
||||
onAlbumClick = onAlbumClick,
|
||||
onArtistClick = onArtistClick,
|
||||
onShowContextMenu = onShowContextMenu,
|
||||
)
|
||||
ExploreTab.GLOBAL -> GlobalExploreContent(
|
||||
state = state,
|
||||
@@ -238,6 +240,7 @@ private fun LibrarySearchContent(
|
||||
onSongPlay: (List<com.novasonic.app.api.model.Song>, Int) -> Unit,
|
||||
onAlbumClick: (com.novasonic.app.api.model.Album) -> Unit,
|
||||
onArtistClick: (com.novasonic.app.api.model.Artist) -> Unit,
|
||||
onShowContextMenu: ((com.novasonic.app.api.model.Song) -> Unit)? = null,
|
||||
) {
|
||||
// Reuse SearchScreen's ViewModel
|
||||
val vm: com.novasonic.app.viewmodel.SearchViewModel = viewModel()
|
||||
@@ -315,7 +318,9 @@ private fun LibrarySearchContent(
|
||||
song = song,
|
||||
coverUrl = coverUrl(song.coverArt),
|
||||
isPlaying = playerState.currentSong?.id == song.id,
|
||||
starred = song.starred != null,
|
||||
onPlay = { onSongPlay(songs, idx) },
|
||||
onMore = onShowContextMenu?.let { cb -> { cb(song) } },
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -108,7 +108,9 @@ fun LibraryScreen(
|
||||
}
|
||||
}
|
||||
|
||||
if (state.isLoading) {
|
||||
// The Offline tab is fed by the local Room DB (offlineGroups) and must stay usable even while
|
||||
// the online library is still loading or unreachable — only gate the network-backed tabs.
|
||||
if (state.isLoading && state.tab != LibraryTab.OFFLINE) {
|
||||
Box(Modifier.fillMaxSize(), contentAlignment = Alignment.Center) {
|
||||
CircularProgressIndicator(color = NsAccent)
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user