From 3abd2c4c962f139fa0a64f9df8eb6aa3deca3b34 Mon Sep 17 00:00:00 2001 From: Karim Abdul-Samad Date: Thu, 30 Jul 2026 13:24:37 -0400 Subject: [PATCH] fix: back button should take you to the previous screen instead of quitting the app. --- .../main/kotlin/ca/ksamad/encore/ui/EncoreApp.kt | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/app/src/main/kotlin/ca/ksamad/encore/ui/EncoreApp.kt b/app/src/main/kotlin/ca/ksamad/encore/ui/EncoreApp.kt index 4e6c101..43969ee 100644 --- a/app/src/main/kotlin/ca/ksamad/encore/ui/EncoreApp.kt +++ b/app/src/main/kotlin/ca/ksamad/encore/ui/EncoreApp.kt @@ -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 })