Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -420,6 +420,7 @@ private fun ConfirmDialog(
show = showDialog,
title = visuals.title,
onDismissRequest = {
dismiss()
showDialog.value = false
},
content = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.padding
import androidx.compose.runtime.Composable
import androidx.compose.runtime.MutableState
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.ui.Modifier
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.res.stringResource
Expand Down Expand Up @@ -43,6 +45,9 @@ fun UninstallDialog(
val showTodo = {
Toast.makeText(context, "TODO", Toast.LENGTH_SHORT).show()
}
val showConfirmDialog = remember(showDialog.value) { mutableStateOf(false) }
val runType = remember(showDialog.value) { mutableStateOf<UninstallType?>(null) }

val run = { type: UninstallType ->
when (type) {
PERMANENT -> navigator.navigate(FlashScreenDestination(FlashIt.FlashUninstall)) {
Expand Down Expand Up @@ -84,11 +89,10 @@ fun UninstallDialog(
options.forEachIndexed { index, type ->
SuperArrow(
onClick = {
showDialog.value = false
run(type)
showConfirmDialog.value = true
runType.value = type
},
title = stringResource(type.title),
summary = if (type.message != 0) stringResource(type.message) else null,
leftAction = {
Icon(
imageVector = type.icon,
Expand All @@ -112,4 +116,25 @@ fun UninstallDialog(
)
}
)
val confirmDialog = rememberConfirmDialog(
onConfirm = {
showConfirmDialog.value = false
showDialog.value = false
runType.value?.let { type ->
run(type)
}
},
onDismiss = {
showConfirmDialog.value = false
}
)
val dialogTitle = runType.value?.let { type ->
options.find { it == type }?.let { stringResource(it.title) }
} ?: ""
val dialogContent = runType.value?.let { type ->
options.find { it == type }?.let { stringResource(it.message) }
}
if (showConfirmDialog.value) {
confirmDialog.showConfirm(title = dialogTitle, content = dialogContent)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -259,8 +259,7 @@ private fun SelectInstallMethod(onSelected: (InstallMethod) -> Unit = {}) {
onConfirm = {
selectedOption = InstallMethod.DirectInstallToInactiveSlot
onSelected(InstallMethod.DirectInstallToInactiveSlot)
},
onDismiss = null
}
)
val dialogTitle = stringResource(id = android.R.string.dialog_alert_title)
val dialogContent = stringResource(id = R.string.install_inactive_slot_warning)
Expand Down
12 changes: 7 additions & 5 deletions manager/app/src/main/java/me/weishu/kernelsu/ui/screen/Module.kt
Original file line number Diff line number Diff line change
Expand Up @@ -257,12 +257,14 @@ fun ModulePager(
val moduleInstall = stringResource(id = R.string.module_install)
val confirmTitle = stringResource(R.string.module)
var zipUris by remember { mutableStateOf<List<Uri>>(emptyList()) }
val confirmDialog = rememberConfirmDialog(onConfirm = {
navigator.navigate(FlashScreenDestination(FlashIt.FlashModules(zipUris))) {
launchSingleTop = true
val confirmDialog = rememberConfirmDialog(
onConfirm = {
navigator.navigate(FlashScreenDestination(FlashIt.FlashModules(zipUris))) {
launchSingleTop = true
}
viewModel.markNeedRefresh()
}
viewModel.markNeedRefresh()
})
)
val selectZipLauncher = rememberLauncherForActivityResult(
contract = ActivityResultContracts.StartActivityForResult()
) {
Expand Down
Loading