@@ -11,6 +11,12 @@ import androidx.compose.foundation.layout.Spacer
1111import androidx.compose.foundation.layout.fillMaxWidth
1212import androidx.compose.foundation.layout.height
1313import androidx.compose.foundation.layout.offset
14+ import androidx.compose.runtime.getValue
15+ import androidx.compose.runtime.setValue
16+ import androidx.compose.runtime.mutableStateOf
17+ import androidx.compose.runtime.remember
18+ import androidx.compose.material3.OutlinedTextField
19+ import androidx.compose.material3.TextButton
1420import androidx.compose.foundation.shape.RoundedCornerShape
1521import androidx.compose.foundation.layout.Arrangement
1622import androidx.compose.foundation.layout.padding
@@ -66,6 +72,8 @@ fun ColumnScope.SlotFlashContent(
6672 val isFlashImage = currentRoute.endsWith(" /flash/image" )
6773 val isBackup = currentRoute.endsWith(" /backup" )
6874 val isBackupResult = currentRoute.endsWith(" /backup/backup" )
75+ var showBackupDialog by remember { mutableStateOf(false ) }
76+ var customBackupName by remember { mutableStateOf(" " ) }
6977 val isFlashAk3 = currentRoute.endsWith(" /flash/ak3" )
7078 val isImageFlashResult = currentRoute.endsWith(" /flash/image/flash" )
7179
@@ -154,10 +162,7 @@ fun ColumnScope.SlotFlashContent(
154162 .fillMaxWidth(),
155163 shape = RoundedCornerShape (4 .dp),
156164 onClick = {
157- viewModel.backup(context)
158- navController.navigate(" slot$slotSuffix /backup/backup" ) {
159- popUpTo(" slot$slotSuffix " )
160- }
165+ showBackupDialog = true
161166 },
162167 enabled = viewModel.backupPartitions.filter { it.value }.isNotEmpty()
163168 ) {
@@ -277,9 +282,15 @@ fun ColumnScope.SlotFlashContent(
277282 title = { Text (" CAUTION!" , style = MaterialTheme .typography.titleLarge, fontWeight = FontWeight .Bold ) },
278283 text = {
279284 Column (verticalArrangement = Arrangement .spacedBy(8 .dp)) {
280- Text (" Are you Sure you want to flash this file?" , fontWeight = FontWeight .Bold )
281- Text (" " , fontWeight = FontWeight .Bold )
282- Text (" $filename " , fontWeight = FontWeight .Bold )
285+ Text (" Are you sure you want to flash this file?" , fontWeight = FontWeight .Bold )
286+
287+ Text (" Source: $filename " )
288+
289+ if (viewModel.flashActionType == " flashImage" && viewModel.flashActionPartName != null ) {
290+ Text (" Destination Partition: ${viewModel.flashActionPartName} " , fontWeight = FontWeight .Bold )
291+ } else if (viewModel.flashActionType == " flashAk3" || viewModel.flashActionType == " flashAk3_mkbootfs" ) {
292+ Text (" Destination: AnyKernel3 (Auto-detect)" , fontWeight = FontWeight .Bold )
293+ }
283294 }
284295 },
285296 confirmButton = {
@@ -345,4 +356,35 @@ fun ColumnScope.SlotFlashContent(
345356 modifier = Modifier .padding(16 .dp)
346357 )
347358 }
359+ if (showBackupDialog) {
360+ AlertDialog (
361+ onDismissRequest = { showBackupDialog = false },
362+ title = { Text (" Custom Backup Name" ) },
363+ text = {
364+ OutlinedTextField (
365+ value = customBackupName,
366+ onValueChange = { customBackupName = it },
367+ label = { Text (" Optional Prefix (e.g. Sultan)" ) },
368+ singleLine = true
369+ )
370+ },
371+ confirmButton = {
372+ TextButton (onClick = {
373+ showBackupDialog = false
374+ viewModel.backup(context, customBackupName, slotSuffix) // <-- Add the suffix here!
375+ navController.navigate(" slot$slotSuffix /backup/backup" ) {
376+ popUpTo(" slot$slotSuffix " )
377+ }
378+ }) {
379+ Text (" Start Backup" )
380+ }
381+ },
382+ dismissButton = {
383+ TextButton (onClick = { showBackupDialog = false }) {
384+ Text (" Cancel" )
385+ }
386+ }
387+ )
388+ }
348389}
390+
0 commit comments