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: improve layout and look of module cards
This commit is contained in:
@@ -113,6 +113,7 @@ import com.rifsxd.ksunext.ui.webui.WebUIXActivity
|
|||||||
import androidx.core.net.toUri
|
import androidx.core.net.toUri
|
||||||
import com.dergoogler.mmrl.platform.model.ModuleConfig
|
import com.dergoogler.mmrl.platform.model.ModuleConfig
|
||||||
import com.dergoogler.mmrl.platform.model.ModuleConfig.Companion.asModuleConfig
|
import com.dergoogler.mmrl.platform.model.ModuleConfig.Companion.asModuleConfig
|
||||||
|
import com.dergoogler.mmrl.ui.component.LabelItem
|
||||||
|
|
||||||
@OptIn(ExperimentalMaterial3Api::class)
|
@OptIn(ExperimentalMaterial3Api::class)
|
||||||
@Destination<RootGraph>
|
@Destination<RootGraph>
|
||||||
@@ -670,6 +671,38 @@ fun ModuleItem(
|
|||||||
Column(
|
Column(
|
||||||
modifier = Modifier.fillMaxWidth(0.8f)
|
modifier = Modifier.fillMaxWidth(0.8f)
|
||||||
) {
|
) {
|
||||||
|
Row(
|
||||||
|
verticalAlignment = Alignment.CenterVertically,
|
||||||
|
horizontalArrangement = Arrangement.spacedBy(6.dp)
|
||||||
|
) {
|
||||||
|
// Enabled/Disabled indicator
|
||||||
|
LabelItem(
|
||||||
|
text = if (module.enabled) stringResource(R.string.enabled) else stringResource(R.string.disabled),
|
||||||
|
style = if (module.enabled)
|
||||||
|
com.dergoogler.mmrl.ui.component.LabelItemDefaults.style.copy(
|
||||||
|
containerColor = MaterialTheme.colorScheme.primaryContainer,
|
||||||
|
contentColor = MaterialTheme.colorScheme.onPrimaryContainer
|
||||||
|
)
|
||||||
|
else
|
||||||
|
com.dergoogler.mmrl.ui.component.LabelItemDefaults.style.copy(
|
||||||
|
containerColor = MaterialTheme.colorScheme.errorContainer,
|
||||||
|
contentColor = MaterialTheme.colorScheme.onErrorContainer
|
||||||
|
)
|
||||||
|
)
|
||||||
|
// Update notifier indicator
|
||||||
|
if (updateUrl.isNotEmpty() && !module.remove) {
|
||||||
|
LabelItem(
|
||||||
|
text = stringResource(R.string.module_update),
|
||||||
|
style = com.dergoogler.mmrl.ui.component.LabelItemDefaults.style.copy(
|
||||||
|
containerColor = MaterialTheme.colorScheme.secondaryContainer,
|
||||||
|
contentColor = MaterialTheme.colorScheme.onSecondaryContainer
|
||||||
|
)
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Spacer(modifier = Modifier.height(8.dp))
|
||||||
|
|
||||||
Text(
|
Text(
|
||||||
text = module.name,
|
text = module.name,
|
||||||
fontSize = MaterialTheme.typography.titleMedium.fontSize,
|
fontSize = MaterialTheme.typography.titleMedium.fontSize,
|
||||||
@@ -723,18 +756,84 @@ fun ModuleItem(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Spacer(modifier = Modifier.weight(1f))
|
|
||||||
|
|
||||||
Row(
|
Row(
|
||||||
modifier = Modifier.fillMaxWidth(),
|
modifier = Modifier.fillMaxWidth(),
|
||||||
horizontalArrangement = Arrangement.End,
|
horizontalArrangement = Arrangement.End,
|
||||||
) {
|
) {
|
||||||
Switch(
|
var menuExpanded by remember { mutableStateOf(false) }
|
||||||
enabled = !module.update,
|
IconButton(onClick = { menuExpanded = true }) {
|
||||||
checked = module.enabled,
|
Icon(
|
||||||
onCheckedChange = onCheckChanged,
|
imageVector = Icons.Filled.MoreVert,
|
||||||
interactionSource = if (!module.hasWebUi) interactionSource else null
|
contentDescription = "Module options"
|
||||||
)
|
)
|
||||||
|
}
|
||||||
|
DropdownMenu(
|
||||||
|
expanded = menuExpanded,
|
||||||
|
onDismissRequest = { menuExpanded = false }
|
||||||
|
) {
|
||||||
|
// WebUI
|
||||||
|
if (module.hasWebUi) {
|
||||||
|
DropdownMenuItem(
|
||||||
|
text = { Text(stringResource(R.string.open)) },
|
||||||
|
onClick = {
|
||||||
|
menuExpanded = false
|
||||||
|
onClick(module)
|
||||||
|
}
|
||||||
|
)
|
||||||
|
}
|
||||||
|
// ActionScript
|
||||||
|
if (module.hasActionScript) {
|
||||||
|
DropdownMenuItem(
|
||||||
|
text = { Text(stringResource(R.string.action)) },
|
||||||
|
onClick = {
|
||||||
|
menuExpanded = false
|
||||||
|
navigator.navigate(ExecuteModuleActionScreenDestination(module.dirId))
|
||||||
|
viewModel.markNeedRefresh()
|
||||||
|
}
|
||||||
|
)
|
||||||
|
}
|
||||||
|
// Update
|
||||||
|
if (updateUrl.isNotEmpty() && !module.remove) {
|
||||||
|
DropdownMenuItem(
|
||||||
|
text = { Text(stringResource(R.string.module_update)) },
|
||||||
|
onClick = {
|
||||||
|
menuExpanded = false
|
||||||
|
onUpdate(module)
|
||||||
|
}
|
||||||
|
)
|
||||||
|
}
|
||||||
|
// Enable/Disable
|
||||||
|
DropdownMenuItem(
|
||||||
|
text = {
|
||||||
|
Text(
|
||||||
|
if (module.enabled) stringResource(R.string.disable)
|
||||||
|
else stringResource(R.string.enable)
|
||||||
|
)
|
||||||
|
},
|
||||||
|
onClick = {
|
||||||
|
menuExpanded = false
|
||||||
|
onCheckChanged(!module.enabled)
|
||||||
|
}
|
||||||
|
)
|
||||||
|
// Restore/Uninstall
|
||||||
|
if (module.remove) {
|
||||||
|
DropdownMenuItem(
|
||||||
|
text = { Text(stringResource(R.string.restore)) },
|
||||||
|
onClick = {
|
||||||
|
menuExpanded = false
|
||||||
|
onRestore(module)
|
||||||
|
}
|
||||||
|
)
|
||||||
|
} else {
|
||||||
|
DropdownMenuItem(
|
||||||
|
text = { Text(stringResource(R.string.uninstall)) },
|
||||||
|
onClick = {
|
||||||
|
menuExpanded = false
|
||||||
|
onUninstall(module)
|
||||||
|
}
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -751,139 +850,7 @@ fun ModuleItem(
|
|||||||
textDecoration = textDecoration
|
textDecoration = textDecoration
|
||||||
)
|
)
|
||||||
|
|
||||||
Spacer(modifier = Modifier.height(16.dp))
|
Spacer(modifier = Modifier.height(6.dp))
|
||||||
|
|
||||||
HorizontalDivider(thickness = Dp.Hairline)
|
|
||||||
|
|
||||||
Spacer(modifier = Modifier.height(4.dp))
|
|
||||||
|
|
||||||
Row(
|
|
||||||
horizontalArrangement = Arrangement.SpaceBetween,
|
|
||||||
verticalAlignment = Alignment.CenterVertically
|
|
||||||
) {
|
|
||||||
if (module.hasActionScript) {
|
|
||||||
FilledTonalButton(
|
|
||||||
modifier = Modifier.defaultMinSize(52.dp, 32.dp),
|
|
||||||
enabled = !module.remove && module.enabled,
|
|
||||||
onClick = {
|
|
||||||
navigator.navigate(ExecuteModuleActionScreenDestination(module.dirId))
|
|
||||||
viewModel.markNeedRefresh()
|
|
||||||
},
|
|
||||||
contentPadding = ButtonDefaults.TextButtonContentPadding
|
|
||||||
) {
|
|
||||||
Icon(
|
|
||||||
modifier = Modifier.size(20.dp),
|
|
||||||
imageVector = Icons.Outlined.PlayArrow,
|
|
||||||
contentDescription = null
|
|
||||||
)
|
|
||||||
if (!module.hasWebUi && updateUrl.isEmpty()) {
|
|
||||||
Text(
|
|
||||||
modifier = Modifier.padding(start = 7.dp),
|
|
||||||
text = stringResource(R.string.action),
|
|
||||||
fontFamily = MaterialTheme.typography.labelMedium.fontFamily,
|
|
||||||
fontSize = MaterialTheme.typography.labelMedium.fontSize
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Spacer(modifier = Modifier.weight(0.1f, true))
|
|
||||||
}
|
|
||||||
|
|
||||||
if (module.hasWebUi) {
|
|
||||||
FilledTonalButton(
|
|
||||||
modifier = Modifier.defaultMinSize(52.dp, 32.dp),
|
|
||||||
enabled = !module.remove && module.enabled,
|
|
||||||
onClick = { onClick(module) },
|
|
||||||
interactionSource = interactionSource,
|
|
||||||
contentPadding = ButtonDefaults.TextButtonContentPadding
|
|
||||||
) {
|
|
||||||
Icon(
|
|
||||||
modifier = Modifier.size(20.dp),
|
|
||||||
imageVector = Icons.AutoMirrored.Outlined.Wysiwyg,
|
|
||||||
contentDescription = null
|
|
||||||
)
|
|
||||||
if (!module.hasActionScript && updateUrl.isEmpty()) {
|
|
||||||
Text(
|
|
||||||
modifier = Modifier.padding(start = 7.dp),
|
|
||||||
fontFamily = MaterialTheme.typography.labelMedium.fontFamily,
|
|
||||||
fontSize = MaterialTheme.typography.labelMedium.fontSize,
|
|
||||||
text = stringResource(R.string.open)
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Spacer(modifier = Modifier.weight(1f, true))
|
|
||||||
|
|
||||||
if (updateUrl.isNotEmpty()) {
|
|
||||||
Button(
|
|
||||||
modifier = Modifier.defaultMinSize(52.dp, 32.dp),
|
|
||||||
enabled = !module.remove,
|
|
||||||
onClick = { onUpdate(module) },
|
|
||||||
shape = ButtonDefaults.textShape,
|
|
||||||
contentPadding = ButtonDefaults.TextButtonContentPadding
|
|
||||||
) {
|
|
||||||
Icon(
|
|
||||||
modifier = Modifier.size(20.dp),
|
|
||||||
imageVector = Icons.Outlined.Download,
|
|
||||||
contentDescription = null
|
|
||||||
)
|
|
||||||
if (!module.hasActionScript || !module.hasWebUi) {
|
|
||||||
Text(
|
|
||||||
modifier = Modifier.padding(start = 7.dp),
|
|
||||||
fontFamily = MaterialTheme.typography.labelMedium.fontFamily,
|
|
||||||
fontSize = MaterialTheme.typography.labelMedium.fontSize,
|
|
||||||
text = stringResource(R.string.module_update)
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Spacer(modifier = Modifier.weight(0.1f, true))
|
|
||||||
}
|
|
||||||
|
|
||||||
if (module.remove) {
|
|
||||||
FilledTonalButton(
|
|
||||||
modifier = Modifier.defaultMinSize(52.dp, 32.dp),
|
|
||||||
onClick = { onRestore(module) },
|
|
||||||
contentPadding = ButtonDefaults.TextButtonContentPadding
|
|
||||||
) {
|
|
||||||
Icon(
|
|
||||||
modifier = Modifier.size(20.dp),
|
|
||||||
imageVector = Icons.Outlined.Restore,
|
|
||||||
contentDescription = null
|
|
||||||
)
|
|
||||||
if (!module.hasActionScript && !module.hasWebUi && updateUrl.isEmpty()) {
|
|
||||||
Text(
|
|
||||||
modifier = Modifier.padding(start = 7.dp),
|
|
||||||
fontFamily = MaterialTheme.typography.labelMedium.fontFamily,
|
|
||||||
fontSize = MaterialTheme.typography.labelMedium.fontSize,
|
|
||||||
text = stringResource(R.string.restore)
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
FilledTonalButton(
|
|
||||||
modifier = Modifier.defaultMinSize(52.dp, 32.dp),
|
|
||||||
enabled = true,
|
|
||||||
onClick = { onUninstall(module) },
|
|
||||||
contentPadding = ButtonDefaults.TextButtonContentPadding
|
|
||||||
) {
|
|
||||||
Icon(
|
|
||||||
modifier = Modifier.size(20.dp),
|
|
||||||
imageVector = Icons.Outlined.Delete,
|
|
||||||
contentDescription = null
|
|
||||||
)
|
|
||||||
if (!module.hasActionScript && !module.hasWebUi && updateUrl.isEmpty()) {
|
|
||||||
Text(
|
|
||||||
modifier = Modifier.padding(start = 7.dp),
|
|
||||||
fontFamily = MaterialTheme.typography.labelMedium.fontFamily,
|
|
||||||
fontSize = MaterialTheme.typography.labelMedium.fontSize,
|
|
||||||
text = stringResource(R.string.uninstall)
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -23,6 +23,8 @@
|
|||||||
<string name="home_failure_tip">Ask your kernel developer to integrate KernelSU Next!</string>
|
<string name="home_failure_tip">Ask your kernel developer to integrate KernelSU Next!</string>
|
||||||
<string name="home_kernel">Kernel version</string>
|
<string name="home_kernel">Kernel version</string>
|
||||||
<string name="hook_mode">Hook mode</string>
|
<string name="hook_mode">Hook mode</string>
|
||||||
|
<string name="enable">Enable</string>
|
||||||
|
<string name="disable">Disable</string>
|
||||||
<string name="enabled">Enabled</string>
|
<string name="enabled">Enabled</string>
|
||||||
<string name="disabled">Disabled</string>
|
<string name="disabled">Disabled</string>
|
||||||
<string name="susfs_supported">Supported</string>
|
<string name="susfs_supported">Supported</string>
|
||||||
|
|||||||
Reference in New Issue
Block a user