File tree Expand file tree Collapse file tree
app/src/main/java/io/simplelogin/android/root Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -95,8 +95,7 @@ fun AppRoot(
9595 onOpenDrawer : () -> Unit
9696) = with (viewModel) {
9797 val backStack by navBackStack.collectAsState()
98- val dialogStack by dialogStack.collectAsState()
99- val activeDialog = dialogStack.lastOrNull()
98+ val showLogOutDialog by showLogOutDialog.collectAsState()
10099 val configuration = LocalConfiguration .current
101100 val screenWidth = configuration.screenWidthDp.dp
102101
@@ -235,8 +234,8 @@ fun AppRoot(
235234 }
236235 )
237236
238- when (activeDialog ) {
239- AppRootDialog . LogOut -> AlertDialog (
237+ if (showLogOutDialog ) {
238+ AlertDialog (
240239 onDismissRequest = ::dismissActiveDialog,
241240 title = { Text (stringResource(R .string.sign_out)) },
242241 text = { Text (stringResource(R .string.sign_out_message)) },
@@ -251,8 +250,6 @@ fun AppRoot(
251250 }
252251 }
253252 )
254-
255- null -> Unit
256253 }
257254}
258255
Load diff This file was deleted.
Original file line number Diff line number Diff line change @@ -44,8 +44,8 @@ class AppRootViewModel @Inject constructor(
4444 private val _createdAlias = Channel <Alias >(Channel .BUFFERED )
4545 val createdAlias = _createdAlias .receiveAsFlow()
4646
47- private val _dialogStack = MutableStateFlow < List < AppRootDialog >>(emptyList() )
48- val dialogStack = _dialogStack .asStateFlow()
47+ private val _showLogOutDialog = MutableStateFlow ( false )
48+ val showLogOutDialog = _showLogOutDialog
4949
5050 val stateFlow: StateFlow <AppRootState > = observeSessionSettings().map {
5151 AppRootState (isReady = true , apiKey = it.apiKey)
@@ -81,15 +81,15 @@ class AppRootViewModel @Inject constructor(
8181
8282 // region Drawer
8383 fun showLogOutDialog () {
84- _dialogStack .value = listOf ( AppRootDialog . LogOut )
84+ _showLogOutDialog .value = true
8585 }
8686
8787 fun dismissActiveDialog () {
88- _dialogStack .value = _dialogStack .value.dropLast( 1 )
88+ _showLogOutDialog .value = false
8989 }
9090
9191 fun logOut () {
92- _dialogStack .value = emptyList()
92+ _showLogOutDialog .value = false
9393 viewModelScope.launch {
9494 logOutUseCase()
9595 }
You can’t perform that action at this time.
0 commit comments