You've already forked KernelSU-Next
mirror of
https://github.com/KernelSU-Next/KernelSU-Next.git
synced 2025-08-27 23:46:34 +00:00
manager: make the module card neat and clean with less clutter and add useful indicators
This commit is contained in:
@@ -660,7 +660,7 @@ fun ModuleItem(
|
|||||||
) {
|
) {
|
||||||
Row(
|
Row(
|
||||||
modifier = Modifier.fillMaxWidth(),
|
modifier = Modifier.fillMaxWidth(),
|
||||||
horizontalArrangement = Arrangement.SpaceBetween,
|
horizontalArrangement = Arrangement.SpaceBetween
|
||||||
) {
|
) {
|
||||||
val moduleVersion = stringResource(id = R.string.module_version)
|
val moduleVersion = stringResource(id = R.string.module_version)
|
||||||
val moduleAuthor = stringResource(id = R.string.module_author)
|
val moduleAuthor = stringResource(id = R.string.module_author)
|
||||||
@@ -670,88 +670,57 @@ fun ModuleItem(
|
|||||||
val moduleUpdateJsonEmpty = stringResource(id = R.string.module_update_json_empty)
|
val moduleUpdateJsonEmpty = stringResource(id = R.string.module_update_json_empty)
|
||||||
|
|
||||||
Column(
|
Column(
|
||||||
modifier = Modifier.fillMaxWidth()
|
modifier = Modifier.fillMaxWidth(0.8f)
|
||||||
) {
|
) {
|
||||||
// Combined row: left and right labels
|
|
||||||
Row(
|
Row(
|
||||||
modifier = Modifier.fillMaxWidth(),
|
verticalAlignment = Alignment.CenterVertically,
|
||||||
horizontalArrangement = Arrangement.SpaceBetween,
|
horizontalArrangement = Arrangement.spacedBy(6.dp)
|
||||||
verticalAlignment = Alignment.CenterVertically
|
|
||||||
) {
|
) {
|
||||||
// Left side: status, uninstall/restore, update
|
LabelItem(
|
||||||
Row(
|
text = if (module.enabled) stringResource(R.string.enabled) else stringResource(R.string.disabled),
|
||||||
horizontalArrangement = Arrangement.spacedBy(6.dp),
|
style = if (module.enabled)
|
||||||
verticalAlignment = Alignment.CenterVertically
|
com.dergoogler.mmrl.ui.component.LabelItemDefaults.style.copy()
|
||||||
) {
|
else
|
||||||
|
com.dergoogler.mmrl.ui.component.LabelItemDefaults.style.copy(
|
||||||
|
containerColor = MaterialTheme.colorScheme.errorContainer,
|
||||||
|
contentColor = MaterialTheme.colorScheme.onErrorContainer
|
||||||
|
)
|
||||||
|
)
|
||||||
|
if (module.remove) {
|
||||||
LabelItem(
|
LabelItem(
|
||||||
text = if (module.enabled) stringResource(R.string.enabled) else stringResource(R.string.disabled),
|
text = stringResource(R.string.uninstall),
|
||||||
style = if (module.enabled)
|
style = com.dergoogler.mmrl.ui.component.LabelItemDefaults.style.copy(
|
||||||
com.dergoogler.mmrl.ui.component.LabelItemDefaults.style.copy()
|
containerColor = MaterialTheme.colorScheme.errorContainer,
|
||||||
else
|
contentColor = MaterialTheme.colorScheme.onErrorContainer
|
||||||
com.dergoogler.mmrl.ui.component.LabelItemDefaults.style.copy(
|
)
|
||||||
containerColor = MaterialTheme.colorScheme.errorContainer,
|
|
||||||
contentColor = MaterialTheme.colorScheme.onErrorContainer
|
|
||||||
),
|
|
||||||
modifier = Modifier.clickable { onCheckChanged(!module.enabled) }
|
|
||||||
)
|
)
|
||||||
if (module.remove) {
|
|
||||||
LabelItem(
|
|
||||||
text = stringResource(R.string.restore),
|
|
||||||
style = com.dergoogler.mmrl.ui.component.LabelItemDefaults.style.copy(
|
|
||||||
containerColor = MaterialTheme.colorScheme.tertiaryContainer,
|
|
||||||
contentColor = MaterialTheme.colorScheme.onTertiaryContainer
|
|
||||||
),
|
|
||||||
modifier = Modifier.clickable { onRestore(module) }
|
|
||||||
)
|
|
||||||
} else {
|
|
||||||
LabelItem(
|
|
||||||
text = stringResource(R.string.uninstall),
|
|
||||||
style = com.dergoogler.mmrl.ui.component.LabelItemDefaults.style.copy(
|
|
||||||
containerColor = MaterialTheme.colorScheme.errorContainer,
|
|
||||||
contentColor = MaterialTheme.colorScheme.onErrorContainer
|
|
||||||
),
|
|
||||||
modifier = Modifier.clickable { onUninstall(module) }
|
|
||||||
)
|
|
||||||
}
|
|
||||||
if (updateUrl.isNotEmpty() && !module.remove) {
|
|
||||||
LabelItem(
|
|
||||||
text = stringResource(R.string.module_update),
|
|
||||||
style = com.dergoogler.mmrl.ui.component.LabelItemDefaults.style.copy(
|
|
||||||
containerColor = MaterialTheme.colorScheme.onTertiary,
|
|
||||||
contentColor = MaterialTheme.colorScheme.onTertiaryContainer
|
|
||||||
),
|
|
||||||
modifier = Modifier.clickable { onUpdate(module) }
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
// Right side: WebUI and Action
|
if (updateUrl.isNotEmpty() && !module.remove) {
|
||||||
Row(
|
LabelItem(
|
||||||
horizontalArrangement = Arrangement.spacedBy(6.dp),
|
text = stringResource(R.string.module_update),
|
||||||
verticalAlignment = Alignment.CenterVertically
|
style = com.dergoogler.mmrl.ui.component.LabelItemDefaults.style.copy(
|
||||||
) {
|
containerColor = MaterialTheme.colorScheme.onTertiary,
|
||||||
if (module.hasWebUi) {
|
contentColor = MaterialTheme.colorScheme.onTertiaryContainer
|
||||||
LabelItem(
|
|
||||||
text = stringResource(R.string.webui),
|
|
||||||
style = com.dergoogler.mmrl.ui.component.LabelItemDefaults.style.copy(
|
|
||||||
containerColor = MaterialTheme.colorScheme.primaryContainer,
|
|
||||||
contentColor = MaterialTheme.colorScheme.onPrimaryContainer
|
|
||||||
),
|
|
||||||
modifier = Modifier.clickable { onClick(module) }
|
|
||||||
)
|
)
|
||||||
}
|
)
|
||||||
if (module.hasActionScript) {
|
}
|
||||||
LabelItem(
|
if (module.hasWebUi) {
|
||||||
text = stringResource(R.string.action),
|
LabelItem(
|
||||||
style = com.dergoogler.mmrl.ui.component.LabelItemDefaults.style.copy(
|
text = stringResource(R.string.webui),
|
||||||
containerColor = MaterialTheme.colorScheme.secondaryContainer,
|
style = com.dergoogler.mmrl.ui.component.LabelItemDefaults.style.copy(
|
||||||
contentColor = MaterialTheme.colorScheme.onSecondaryContainer
|
containerColor = MaterialTheme.colorScheme.primaryContainer,
|
||||||
),
|
contentColor = MaterialTheme.colorScheme.onPrimaryContainer
|
||||||
modifier = Modifier.clickable {
|
|
||||||
navigator.navigate(ExecuteModuleActionScreenDestination(module.dirId))
|
|
||||||
viewModel.markNeedRefresh()
|
|
||||||
}
|
|
||||||
)
|
)
|
||||||
}
|
)
|
||||||
|
}
|
||||||
|
if (module.hasActionScript) {
|
||||||
|
LabelItem(
|
||||||
|
text = stringResource(R.string.action),
|
||||||
|
style = com.dergoogler.mmrl.ui.component.LabelItemDefaults.style.copy(
|
||||||
|
containerColor = MaterialTheme.colorScheme.secondaryContainer,
|
||||||
|
contentColor = MaterialTheme.colorScheme.onSecondaryContainer
|
||||||
|
)
|
||||||
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -809,6 +778,90 @@ fun ModuleItem(
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Row(
|
||||||
|
modifier = Modifier.fillMaxWidth(),
|
||||||
|
horizontalArrangement = Arrangement.End,
|
||||||
|
) {
|
||||||
|
var expanded by remember { mutableStateOf(false) }
|
||||||
|
IconButton(onClick = { expanded = true }) {
|
||||||
|
Icon(
|
||||||
|
Icons.Filled.MoreVert,
|
||||||
|
contentDescription = "Module actions"
|
||||||
|
)
|
||||||
|
}
|
||||||
|
DropdownMenu(
|
||||||
|
expanded = expanded,
|
||||||
|
onDismissRequest = { expanded = false }
|
||||||
|
) {
|
||||||
|
if (updateUrl.isNotEmpty() && !module.remove) {
|
||||||
|
DropdownMenuItem(
|
||||||
|
text = { Text(stringResource(R.string.module_update)) },
|
||||||
|
onClick = {
|
||||||
|
expanded = false
|
||||||
|
onUpdate(module)
|
||||||
|
}
|
||||||
|
)
|
||||||
|
}
|
||||||
|
if (module.hasWebUi) {
|
||||||
|
DropdownMenuItem(
|
||||||
|
text = { Text(stringResource(R.string.webui)) },
|
||||||
|
onClick = {
|
||||||
|
expanded = false
|
||||||
|
onClick(module)
|
||||||
|
}
|
||||||
|
)
|
||||||
|
}
|
||||||
|
if (module.hasActionScript) {
|
||||||
|
DropdownMenuItem(
|
||||||
|
text = { Text(stringResource(R.string.action)) },
|
||||||
|
onClick = {
|
||||||
|
expanded = false
|
||||||
|
navigator.navigate(ExecuteModuleActionScreenDestination(module.dirId))
|
||||||
|
viewModel.markNeedRefresh()
|
||||||
|
}
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
if (
|
||||||
|
(updateUrl.isNotEmpty() && !module.remove) ||
|
||||||
|
module.hasWebUi ||
|
||||||
|
module.hasActionScript
|
||||||
|
) {
|
||||||
|
HorizontalDivider()
|
||||||
|
}
|
||||||
|
|
||||||
|
DropdownMenuItem(
|
||||||
|
text = {
|
||||||
|
Text(
|
||||||
|
if (module.enabled) stringResource(R.string.disable)
|
||||||
|
else stringResource(R.string.enable)
|
||||||
|
)
|
||||||
|
},
|
||||||
|
onClick = {
|
||||||
|
expanded = false
|
||||||
|
onCheckChanged(!module.enabled)
|
||||||
|
}
|
||||||
|
)
|
||||||
|
if (module.remove) {
|
||||||
|
DropdownMenuItem(
|
||||||
|
text = { Text(stringResource(R.string.restore)) },
|
||||||
|
onClick = {
|
||||||
|
expanded = false
|
||||||
|
onRestore(module)
|
||||||
|
}
|
||||||
|
)
|
||||||
|
} else {
|
||||||
|
DropdownMenuItem(
|
||||||
|
text = { Text(stringResource(R.string.uninstall)) },
|
||||||
|
onClick = {
|
||||||
|
expanded = false
|
||||||
|
onUninstall(module)
|
||||||
|
}
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Spacer(modifier = Modifier.height(12.dp))
|
Spacer(modifier = Modifier.height(12.dp))
|
||||||
|
|||||||
Reference in New Issue
Block a user