Skip to content

Commit

Permalink
refine ui
Browse files Browse the repository at this point in the history
  • Loading branch information
5ec1cff committed Dec 31, 2024
1 parent 76bfccd commit c34260c
Showing 1 changed file with 5 additions and 8 deletions.
13 changes: 5 additions & 8 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 @@ -456,7 +456,6 @@ private fun ModuleList(

else -> {
items(viewModel.moduleList) { module ->
val isChecked = module.enabled
val scope = rememberCoroutineScope()
val updatedModule by produceState(initialValue = Triple("", "", "")) {
scope.launch(Dispatchers.IO) {
Expand All @@ -467,7 +466,6 @@ private fun ModuleList(
ModuleItem(
navigator = navigator,
module = module,
isChecked = isChecked,
updateUrl = updatedModule.first,
onUninstallClicked = {
scope.launch { onModuleUninstallClicked(module) }
Expand All @@ -476,7 +474,7 @@ private fun ModuleList(
scope.launch {
val success = loadingDialog.withLoading {
withContext(Dispatchers.IO) {
toggleModule(module.dirId, !isChecked)
toggleModule(module.dirId, !module.enabled)
}
}
if (success) {
Expand All @@ -491,7 +489,7 @@ private fun ModuleList(
reboot()
}
} else {
val message = if (isChecked) failedDisable else failedEnable
val message = if (module.enabled) failedDisable else failedEnable
snackBarHost.showSnackbar(message.format(module.name))
}
}
Expand Down Expand Up @@ -527,7 +525,6 @@ private fun ModuleList(
fun ModuleItem(
navigator: DestinationsNavigator,
module: ModuleViewModel.ModuleInfo,
isChecked: Boolean,
updateUrl: String,
onUninstallClicked: (ModuleViewModel.ModuleInfo) -> Unit,
onCheckChanged: (Boolean) -> Unit,
Expand All @@ -547,7 +544,7 @@ fun ModuleItem(
.run {
if (module.hasWebUi) {
toggleable(
value = isChecked,
value = module.enabled,
interactionSource = interactionSource,
role = Role.Button,
indication = indication,
Expand Down Expand Up @@ -603,7 +600,7 @@ fun ModuleItem(
) {
Switch(
enabled = !module.update,
checked = isChecked,
checked = module.enabled,
onCheckedChange = onCheckChanged,
interactionSource = if (!module.hasWebUi) interactionSource else null
)
Expand Down Expand Up @@ -761,5 +758,5 @@ fun ModuleItemPreview() {
hasActionScript = false,
dirId = "dirId"
)
ModuleItem(EmptyDestinationsNavigator, module, true, "", {}, {}, {}, {})
ModuleItem(EmptyDestinationsNavigator, module, "", {}, {}, {}, {})
}

0 comments on commit c34260c

Please sign in to comment.