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

View File

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