home: Back opens the sidebar from a list view (#26)
Reaching the sidebar used to mean scrolling all the way left to the first card. Back from any list view now opens it directly; from the open sidebar on Home a double Back still exits, and Esc (keyboard/scrcpy) mirrors the same model.
This commit is contained in:
parent
6307addfb8
commit
349c1aa447
1 changed files with 19 additions and 13 deletions
|
|
@ -114,19 +114,15 @@ fun HomeScreen(viewModel: AppViewModel = androidx.lifecycle.viewmodel.compose.vi
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// BACK order (TV standard): player (own handler) → drawer close → channel
|
// BACK order (issue #26): the sidebar is the root of a list view, reached
|
||||||
// drilldown → non-Home destination → Home; from Home: double-press exits.
|
// 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) {
|
BackHandler(enabled = drawerOpen && playingVideo == null) {
|
||||||
dismissDrawer()
|
if (destination == Destination.Home && channelDetails == null) {
|
||||||
}
|
|
||||||
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 {
|
|
||||||
val now = System.currentTimeMillis()
|
val now = System.currentTimeMillis()
|
||||||
if (now - lastBackAt < 2500) {
|
if (now - lastBackAt < 2500) {
|
||||||
(context as? android.app.Activity)?.finish()
|
(context as? android.app.Activity)?.finish()
|
||||||
|
|
@ -134,8 +130,16 @@ fun HomeScreen(viewModel: AppViewModel = androidx.lifecycle.viewmodel.compose.vi
|
||||||
}
|
}
|
||||||
lastBackAt = now
|
lastBackAt = now
|
||||||
android.widget.Toast.makeText(context, "Press BACK again to exit", android.widget.Toast.LENGTH_SHORT).show()
|
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(
|
Box(
|
||||||
modifier = Modifier
|
modifier = Modifier
|
||||||
|
|
@ -151,7 +155,9 @@ fun HomeScreen(viewModel: AppViewModel = androidx.lifecycle.viewmodel.compose.vi
|
||||||
when {
|
when {
|
||||||
drawerOpen -> { dismissDrawer(); true }
|
drawerOpen -> { dismissDrawer(); true }
|
||||||
channelDetails != null -> { channelDetails = null; 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
|
} else false
|
||||||
},
|
},
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue