mirror of
https://github.com/JustinZeus/Wholphin.git
synced 2026-07-09 08:01:20 +02:00
Fix nav drawer focus when pressing back on home page (#274)
Fixes the nav drawer not being focused on when pressing back to open it on the home page Dev notes: I think the bug was introduced in #228 due to the new `Column` not being focusable, but we don't need it to be since we want to focus on the selected page.
This commit is contained in:
parent
45567bf4eb
commit
99e8b69c0e
1 changed files with 3 additions and 5 deletions
|
|
@ -218,14 +218,14 @@ fun NavDrawer(
|
||||||
val listState = rememberLazyListState()
|
val listState = rememberLazyListState()
|
||||||
val scope = rememberCoroutineScope()
|
val scope = rememberCoroutineScope()
|
||||||
val context = LocalContext.current
|
val context = LocalContext.current
|
||||||
val drawerFocusRequester = remember { FocusRequester() }
|
|
||||||
val focusRequester = remember { FocusRequester() }
|
val focusRequester = remember { FocusRequester() }
|
||||||
val searchFocusRequester = remember { FocusRequester() }
|
val searchFocusRequester = remember { FocusRequester() }
|
||||||
|
|
||||||
// If the user presses back while on the home page, open the nav drawer, another back press will quit the app
|
// If the user presses back while on the home page, open the nav drawer, another back press will quit the app
|
||||||
BackHandler(enabled = (drawerState.currentValue == DrawerValue.Closed && destination is Destination.Home)) {
|
BackHandler(enabled = (drawerState.currentValue == DrawerValue.Closed && destination is Destination.Home)) {
|
||||||
drawerState.setValue(DrawerValue.Open)
|
drawerState.setValue(DrawerValue.Open)
|
||||||
drawerFocusRequester.requestFocus()
|
focusRequester.requestFocus()
|
||||||
}
|
}
|
||||||
val moreLibraries by viewModel.moreLibraries.observeAsState(listOf())
|
val moreLibraries by viewModel.moreLibraries.observeAsState(listOf())
|
||||||
val libraries by viewModel.libraries.observeAsState(listOf())
|
val libraries by viewModel.libraries.observeAsState(listOf())
|
||||||
|
|
@ -305,9 +305,7 @@ fun NavDrawer(
|
||||||
)
|
)
|
||||||
val spacedBy = 4.dp
|
val spacedBy = 4.dp
|
||||||
NavigationDrawer(
|
NavigationDrawer(
|
||||||
modifier =
|
modifier = modifier,
|
||||||
modifier
|
|
||||||
.focusRequester(drawerFocusRequester),
|
|
||||||
drawerState = drawerState,
|
drawerState = drawerState,
|
||||||
drawerContent = {
|
drawerContent = {
|
||||||
ProvideTextStyle(MaterialTheme.typography.labelMedium) {
|
ProvideTextStyle(MaterialTheme.typography.labelMedium) {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue