Skip to content

Commit

Permalink
fix abort warning
Browse files Browse the repository at this point in the history
  • Loading branch information
rushiiMachine committed Feb 7, 2024
1 parent f5947f2 commit f16184c
Showing 1 changed file with 15 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,20 @@ class InstallScreen : Screen {
navigator.back(currentActivity = null)
}

// Exit warning dialog (cancel itself if install process state changes)
// Exit warning dialog (dismiss itself if install process state changes, esp. for Success)
var showAbortWarning by remember(model.state.collectAsState()) { mutableStateOf(false) }

// Only show exit warning if currently working
val onTryExit: () -> Unit = remember {
{
if (state.value == InstallScreenState.Working) {
showAbortWarning = true
} else {
navigator.back(currentActivity = null)
}
}
}

if (showAbortWarning) {
InstallerAbortDialog(
onDismiss = { showAbortWarning = false },
Expand All @@ -54,20 +66,15 @@ class InstallScreen : Screen {
},
)
} else {
BackHandler {
showAbortWarning = true
}
BackHandler(onBack = onTryExit)
}

Scaffold(
topBar = {
TopAppBar(
title = { Text(stringResource(R.string.installer)) },
navigationIcon = {
IconButton(
// TODO: only show warning when in progress
onClick = { showAbortWarning = true },
) {
IconButton(onClick = onTryExit) {
Icon(
painter = painterResource(R.drawable.ic_back),
contentDescription = stringResource(R.string.navigation_back),
Expand Down

0 comments on commit f16184c

Please sign in to comment.