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
|
package com.readrops.app.compose.timelime
|
||||||
|
|
||||||
|
import androidx.activity.compose.BackHandler
|
||||||
import androidx.compose.foundation.layout.Arrangement
|
import androidx.compose.foundation.layout.Arrangement
|
||||||
import androidx.compose.foundation.layout.Column
|
import androidx.compose.foundation.layout.Column
|
||||||
import androidx.compose.foundation.layout.fillMaxSize
|
import androidx.compose.foundation.layout.fillMaxSize
|
||||||
|
@ -64,10 +65,19 @@ object TimelineTab : Tab {
|
||||||
val navigator = LocalNavigator.currentOrThrow
|
val navigator = LocalNavigator.currentOrThrow
|
||||||
|
|
||||||
val scrollState = rememberLazyListState()
|
val scrollState = rememberLazyListState()
|
||||||
val swipeToRefreshState = rememberSwipeRefreshState(isRefreshing)
|
val swipeState = rememberSwipeRefreshState(isRefreshing)
|
||||||
val drawerState = rememberDrawerState(initialValue = DrawerValue.Closed)
|
val drawerState = rememberDrawerState(initialValue = DrawerValue.Closed)
|
||||||
val scope = rememberCoroutineScope()
|
val scope = rememberCoroutineScope()
|
||||||
|
|
||||||
|
BackHandler(
|
||||||
|
enabled = drawerState.isOpen,
|
||||||
|
onBack = {
|
||||||
|
scope.launch {
|
||||||
|
drawerState.close()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
ModalNavigationDrawer(
|
ModalNavigationDrawer(
|
||||||
drawerState = drawerState,
|
drawerState = drawerState,
|
||||||
drawerContent = {
|
drawerContent = {
|
||||||
|
@ -119,7 +129,7 @@ object TimelineTab : Tab {
|
||||||
},
|
},
|
||||||
) { paddingValues ->
|
) { paddingValues ->
|
||||||
SwipeRefresh(
|
SwipeRefresh(
|
||||||
state = swipeToRefreshState,
|
state = swipeState,
|
||||||
onRefresh = {
|
onRefresh = {
|
||||||
viewModel.refreshTimeline()
|
viewModel.refreshTimeline()
|
||||||
},
|
},
|
||||||
|
|
Loading…
Reference in New Issue