fix: back button should take you to the previous screen instead of quitting the app.
This commit is contained in:
@@ -1,5 +1,6 @@
|
|||||||
package ca.ksamad.encore.ui
|
package ca.ksamad.encore.ui
|
||||||
|
|
||||||
|
import androidx.activity.compose.BackHandler
|
||||||
import androidx.compose.foundation.layout.Arrangement
|
import androidx.compose.foundation.layout.Arrangement
|
||||||
import androidx.compose.foundation.layout.Column
|
import androidx.compose.foundation.layout.Column
|
||||||
import androidx.compose.foundation.layout.Spacer
|
import androidx.compose.foundation.layout.Spacer
|
||||||
@@ -75,6 +76,18 @@ fun EncoreApp(vm: PlayerViewModel = viewModel()) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
is AppScreen.Player -> {
|
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) {
|
when (overlay) {
|
||||||
PlayerOverlay.Settings -> {
|
PlayerOverlay.Settings -> {
|
||||||
SettingsScreen(vm, onBack = { overlay = PlayerOverlay.None })
|
SettingsScreen(vm, onBack = { overlay = PlayerOverlay.None })
|
||||||
|
|||||||
Reference in New Issue
Block a user