@@ -62,6 +62,10 @@ fun PatcherScreen(
62
62
onBackClick : () -> Unit ,
63
63
viewModel : PatcherViewModel
64
64
) {
65
+ fun onLeave () {
66
+ viewModel.onBack()
67
+ onBackClick()
68
+ }
65
69
66
70
val context = LocalContext .current
67
71
val exportApkLauncher =
@@ -72,7 +76,14 @@ fun PatcherScreen(
72
76
var showInstallPicker by rememberSaveable { mutableStateOf(false ) }
73
77
var showDismissConfirmationDialog by rememberSaveable { mutableStateOf(false ) }
74
78
75
- BackHandler (onBack = { showDismissConfirmationDialog = true })
79
+ fun onPageBack () {
80
+ if (patcherSucceeded == null )
81
+ showDismissConfirmationDialog = true
82
+ else
83
+ onLeave()
84
+ }
85
+
86
+ BackHandler (onBack = ::onPageBack)
76
87
77
88
val steps by remember {
78
89
derivedStateOf {
@@ -99,10 +110,7 @@ fun PatcherScreen(
99
110
if (showDismissConfirmationDialog) {
100
111
ConfirmDialog (
101
112
onDismiss = { showDismissConfirmationDialog = false },
102
- onConfirm = {
103
- viewModel.onBack()
104
- onBackClick()
105
- },
113
+ onConfirm = ::onLeave,
106
114
title = stringResource(R .string.patcher_stop_confirm_title),
107
115
description = stringResource(R .string.patcher_stop_confirm_description),
108
116
icon = Icons .Outlined .Cancel
@@ -150,7 +158,7 @@ fun PatcherScreen(
150
158
AppTopBar (
151
159
title = stringResource(R .string.patcher),
152
160
scrollBehavior = scrollBehavior,
153
- onBackClick = { showDismissConfirmationDialog = true }
161
+ onBackClick = ::onPageBack
154
162
)
155
163
},
156
164
bottomBar = {
@@ -229,4 +237,4 @@ fun PatcherScreen(
229
237
}
230
238
}
231
239
}
232
- }
240
+ }
0 commit comments