fix: Patch process cancelation dialog conditions (#2554)

This commit is contained in:
Brosssh
2025-05-21 18:24:16 +02:00
committed by oSumAtrIX
parent 7c5552f93f
commit 2c1ff4d2cd
2 changed files with 16 additions and 8 deletions

View File

@ -62,6 +62,10 @@ fun PatcherScreen(
onBackClick: () -> Unit,
viewModel: PatcherViewModel
) {
fun onLeave() {
viewModel.onBack()
onBackClick()
}
val context = LocalContext.current
val exportApkLauncher =
@ -72,7 +76,14 @@ fun PatcherScreen(
var showInstallPicker by rememberSaveable { mutableStateOf(false) }
var showDismissConfirmationDialog by rememberSaveable { mutableStateOf(false) }
BackHandler(onBack = { showDismissConfirmationDialog = true })
fun onPageBack() {
if(patcherSucceeded == null)
showDismissConfirmationDialog = true
else
onLeave()
}
BackHandler(onBack = ::onPageBack)
val steps by remember {
derivedStateOf {
@ -99,10 +110,7 @@ fun PatcherScreen(
if (showDismissConfirmationDialog) {
ConfirmDialog(
onDismiss = { showDismissConfirmationDialog = false },
onConfirm = {
viewModel.onBack()
onBackClick()
},
onConfirm = ::onLeave,
title = stringResource(R.string.patcher_stop_confirm_title),
description = stringResource(R.string.patcher_stop_confirm_description),
icon = Icons.Outlined.Cancel
@ -150,7 +158,7 @@ fun PatcherScreen(
AppTopBar(
title = stringResource(R.string.patcher),
scrollBehavior = scrollBehavior,
onBackClick = { showDismissConfirmationDialog = true }
onBackClick = ::onPageBack
)
},
bottomBar = {
@ -229,4 +237,4 @@ fun PatcherScreen(
}
}
}
}
}

View File

@ -9,7 +9,7 @@ appcompat = "1.7.0"
preferences-datastore = "1.1.2"
work-runtime = "2.10.1"
compose-bom = "2025.05.00"
navigation = "2.9.0"
navigation = "2.8.6"
accompanist = "0.37.0"
placeholder = "1.1.2"
reorderable = "2.4.3"