diff --git a/app/src/main/java/net/jeena/jtubetv/ui/screens/HomeScreen.kt b/app/src/main/java/net/jeena/jtubetv/ui/screens/HomeScreen.kt index e14554d..019e2ff 100644 --- a/app/src/main/java/net/jeena/jtubetv/ui/screens/HomeScreen.kt +++ b/app/src/main/java/net/jeena/jtubetv/ui/screens/HomeScreen.kt @@ -114,19 +114,15 @@ fun HomeScreen(viewModel: AppViewModel = androidx.lifecycle.viewmodel.compose.vi } } - // BACK order (TV standard): player (own handler) → drawer close → channel - // drilldown → non-Home destination → Home; from Home: double-press exits. + // BACK order (issue #26): the sidebar is the root of a list view, reached + // with one BACK press instead of scrolling all the way left. + // player → its own handler + // drawer open, Home → double-press exits (the sidebar is the root) + // drawer open, else → close the drawer + // channel drilldown → back up to the list that opened it + // any list view → open the sidebar BackHandler(enabled = drawerOpen && playingVideo == null) { - dismissDrawer() - } - BackHandler(enabled = !drawerOpen && playingVideo == null && channelDetails != null) { - channelDetails = null - } - BackHandler(enabled = !drawerOpen && playingVideo == null && channelDetails == null) { - if (destination != Destination.Home) { - channelDetails = null - destination = Destination.Home - } else { + if (destination == Destination.Home && channelDetails == null) { val now = System.currentTimeMillis() if (now - lastBackAt < 2500) { (context as? android.app.Activity)?.finish() @@ -134,8 +130,16 @@ fun HomeScreen(viewModel: AppViewModel = androidx.lifecycle.viewmodel.compose.vi } lastBackAt = now android.widget.Toast.makeText(context, "Press BACK again to exit", android.widget.Toast.LENGTH_SHORT).show() + } else { + dismissDrawer() } } + BackHandler(enabled = !drawerOpen && playingVideo == null && channelDetails != null) { + channelDetails = null + } + BackHandler(enabled = !drawerOpen && playingVideo == null && channelDetails == null) { + drawerOpen = true + } Box( modifier = Modifier @@ -151,7 +155,9 @@ fun HomeScreen(viewModel: AppViewModel = androidx.lifecycle.viewmodel.compose.vi when { drawerOpen -> { dismissDrawer(); true } channelDetails != null -> { channelDetails = null; true } - else -> false + // Mirror the D-pad BACK model (issue #26): Esc opens the + // sidebar from a top-level list view too. + else -> { drawerOpen = true; true } } } else false },