fix: back button should take you to the previous screen instead of quitting the app.

This commit is contained in:
2026-07-30 23:15:53 -04:00
parent 3e186b7c8b
commit 3abd2c4c96
@@ -1,5 +1,6 @@
package ca.ksamad.encore.ui
import androidx.activity.compose.BackHandler
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Spacer
@@ -75,6 +76,18 @@ fun EncoreApp(vm: PlayerViewModel = viewModel()) {
}
is AppScreen.Player -> {
// The overlays form a back stack the OS knows nothing about (we don't use a
// nav library). Intercept the system/gesture back button and pop one level so
// it mirrors the on-screen back arrow, instead of falling through and closing
// the app. Only enabled when there's somewhere to pop back to.
BackHandler(enabled = overlay != PlayerOverlay.None) {
if (detailAlbum != null) {
detailAlbum = null
} else {
overlay = PlayerOverlay.None
}
}
when (overlay) {
PlayerOverlay.Settings -> {
SettingsScreen(vm, onBack = { overlay = PlayerOverlay.None })