Close navigation drawer on back press
Some checks failed
Build & Test / Validate (pull_request) Successful in 18s
Build & Test / Run Unit Tests (pull_request) Failing after 9m52s
Build & Test / Run UI Tests (pull_request) Successful in 13m2s

This commit is contained in:
William Brawner 2024-08-21 22:20:25 -06:00
parent 2901ef8523
commit b691aa8a0f
Signed by: wbrawner
GPG key ID: 8FF12381C6C90D35

View file

@ -1,5 +1,6 @@
package com.wbrawner.simplemarkdown.ui package com.wbrawner.simplemarkdown.ui
import androidx.activity.compose.BackHandler
import androidx.compose.foundation.layout.Row import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.size import androidx.compose.foundation.layout.size
@ -29,6 +30,11 @@ fun MarkdownNavigationDrawer(
) { ) {
val drawerState = rememberDrawerState(initialValue = DrawerValue.Closed) val drawerState = rememberDrawerState(initialValue = DrawerValue.Closed)
val coroutineScope = rememberCoroutineScope() val coroutineScope = rememberCoroutineScope()
BackHandler(enabled = drawerState.isOpen) {
coroutineScope.launch {
drawerState.close()
}
}
DismissibleNavigationDrawer( DismissibleNavigationDrawer(
gesturesEnabled = drawerState.isOpen, gesturesEnabled = drawerState.isOpen,
drawerState = drawerState, drawerState = drawerState,