mirror of https://github.com/readrops/Readrops.git
Close Drawer on back pressed
This commit is contained in:
parent
3f665e6ab5
commit
deb6426edf
|
@ -1,5 +1,6 @@
|
|||
package com.readrops.app.compose.timelime
|
||||
|
||||
import androidx.activity.compose.BackHandler
|
||||
import androidx.compose.foundation.layout.Arrangement
|
||||
import androidx.compose.foundation.layout.Column
|
||||
import androidx.compose.foundation.layout.fillMaxSize
|
||||
|
@ -64,10 +65,19 @@ object TimelineTab : Tab {
|
|||
val navigator = LocalNavigator.currentOrThrow
|
||||
|
||||
val scrollState = rememberLazyListState()
|
||||
val swipeToRefreshState = rememberSwipeRefreshState(isRefreshing)
|
||||
val swipeState = rememberSwipeRefreshState(isRefreshing)
|
||||
val drawerState = rememberDrawerState(initialValue = DrawerValue.Closed)
|
||||
val scope = rememberCoroutineScope()
|
||||
|
||||
BackHandler(
|
||||
enabled = drawerState.isOpen,
|
||||
onBack = {
|
||||
scope.launch {
|
||||
drawerState.close()
|
||||
}
|
||||
}
|
||||
)
|
||||
|
||||
ModalNavigationDrawer(
|
||||
drawerState = drawerState,
|
||||
drawerContent = {
|
||||
|
@ -119,7 +129,7 @@ object TimelineTab : Tab {
|
|||
},
|
||||
) { paddingValues ->
|
||||
SwipeRefresh(
|
||||
state = swipeToRefreshState,
|
||||
state = swipeState,
|
||||
onRefresh = {
|
||||
viewModel.refreshTimeline()
|
||||
},
|
||||
|
|
Loading…
Reference in New Issue