manager: make the module card neat and clean with less clutter and add useful indicators

This commit is contained in:
rifsxd
2025-05-29 16:09:29 +06:00
parent 22a48e52eb
commit bf20965c46
@@ -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,18 +670,11 @@ 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
Row(
horizontalArrangement = Arrangement.spacedBy(6.dp),
verticalAlignment = Alignment.CenterVertically
) { ) {
LabelItem( LabelItem(
text = if (module.enabled) stringResource(R.string.enabled) else stringResource(R.string.disabled), text = if (module.enabled) stringResource(R.string.enabled) else stringResource(R.string.disabled),
@@ -691,26 +684,15 @@ fun ModuleItem(
com.dergoogler.mmrl.ui.component.LabelItemDefaults.style.copy( com.dergoogler.mmrl.ui.component.LabelItemDefaults.style.copy(
containerColor = MaterialTheme.colorScheme.errorContainer, containerColor = MaterialTheme.colorScheme.errorContainer,
contentColor = MaterialTheme.colorScheme.onErrorContainer contentColor = MaterialTheme.colorScheme.onErrorContainer
), )
modifier = Modifier.clickable { onCheckChanged(!module.enabled) }
) )
if (module.remove) { 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( LabelItem(
text = stringResource(R.string.uninstall), text = stringResource(R.string.uninstall),
style = com.dergoogler.mmrl.ui.component.LabelItemDefaults.style.copy( style = com.dergoogler.mmrl.ui.component.LabelItemDefaults.style.copy(
containerColor = MaterialTheme.colorScheme.errorContainer, containerColor = MaterialTheme.colorScheme.errorContainer,
contentColor = MaterialTheme.colorScheme.onErrorContainer contentColor = MaterialTheme.colorScheme.onErrorContainer
), )
modifier = Modifier.clickable { onUninstall(module) }
) )
} }
if (updateUrl.isNotEmpty() && !module.remove) { if (updateUrl.isNotEmpty() && !module.remove) {
@@ -719,24 +701,16 @@ fun ModuleItem(
style = com.dergoogler.mmrl.ui.component.LabelItemDefaults.style.copy( style = com.dergoogler.mmrl.ui.component.LabelItemDefaults.style.copy(
containerColor = MaterialTheme.colorScheme.onTertiary, containerColor = MaterialTheme.colorScheme.onTertiary,
contentColor = MaterialTheme.colorScheme.onTertiaryContainer contentColor = MaterialTheme.colorScheme.onTertiaryContainer
), )
modifier = Modifier.clickable { onUpdate(module) }
) )
} }
}
// Right side: WebUI and Action
Row(
horizontalArrangement = Arrangement.spacedBy(6.dp),
verticalAlignment = Alignment.CenterVertically
) {
if (module.hasWebUi) { if (module.hasWebUi) {
LabelItem( LabelItem(
text = stringResource(R.string.webui), text = stringResource(R.string.webui),
style = com.dergoogler.mmrl.ui.component.LabelItemDefaults.style.copy( style = com.dergoogler.mmrl.ui.component.LabelItemDefaults.style.copy(
containerColor = MaterialTheme.colorScheme.primaryContainer, containerColor = MaterialTheme.colorScheme.primaryContainer,
contentColor = MaterialTheme.colorScheme.onPrimaryContainer contentColor = MaterialTheme.colorScheme.onPrimaryContainer
), )
modifier = Modifier.clickable { onClick(module) }
) )
} }
if (module.hasActionScript) { if (module.hasActionScript) {
@@ -745,13 +719,8 @@ fun ModuleItem(
style = com.dergoogler.mmrl.ui.component.LabelItemDefaults.style.copy( style = com.dergoogler.mmrl.ui.component.LabelItemDefaults.style.copy(
containerColor = MaterialTheme.colorScheme.secondaryContainer, containerColor = MaterialTheme.colorScheme.secondaryContainer,
contentColor = MaterialTheme.colorScheme.onSecondaryContainer contentColor = MaterialTheme.colorScheme.onSecondaryContainer
),
modifier = Modifier.clickable {
navigator.navigate(ExecuteModuleActionScreenDestination(module.dirId))
viewModel.markNeedRefresh()
}
) )
} )
} }
} }
@@ -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))