Close navigation drawer on back press
This commit is contained in:
parent
2901ef8523
commit
b691aa8a0f
1 changed files with 6 additions and 0 deletions
|
@ -1,5 +1,6 @@
|
|||
package com.wbrawner.simplemarkdown.ui
|
||||
|
||||
import androidx.activity.compose.BackHandler
|
||||
import androidx.compose.foundation.layout.Row
|
||||
import androidx.compose.foundation.layout.fillMaxWidth
|
||||
import androidx.compose.foundation.layout.size
|
||||
|
@ -29,6 +30,11 @@ fun MarkdownNavigationDrawer(
|
|||
) {
|
||||
val drawerState = rememberDrawerState(initialValue = DrawerValue.Closed)
|
||||
val coroutineScope = rememberCoroutineScope()
|
||||
BackHandler(enabled = drawerState.isOpen) {
|
||||
coroutineScope.launch {
|
||||
drawerState.close()
|
||||
}
|
||||
}
|
||||
DismissibleNavigationDrawer(
|
||||
gesturesEnabled = drawerState.isOpen,
|
||||
drawerState = drawerState,
|
||||
|
|
Loading…
Reference in a new issue