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 module card ui
This commit is contained in:
@@ -90,28 +90,12 @@ fun CustomizationScreen(navigator: DestinationsNavigator) {
|
|||||||
|
|
||||||
val prefs = context.getSharedPreferences("settings", Context.MODE_PRIVATE)
|
val prefs = context.getSharedPreferences("settings", Context.MODE_PRIVATE)
|
||||||
|
|
||||||
var useLagacyUI by rememberSaveable {
|
|
||||||
mutableStateOf(
|
|
||||||
prefs.getBoolean("use_legacyui", false)
|
|
||||||
)
|
|
||||||
}
|
|
||||||
SwitchItem(
|
|
||||||
icon = Icons.Filled.Dashboard,
|
|
||||||
title = stringResource(id = R.string.settings_legacyui),
|
|
||||||
summary = stringResource(id = R.string.settings_legacyui_summary),
|
|
||||||
checked = useLagacyUI
|
|
||||||
) {
|
|
||||||
prefs.edit().putBoolean("use_legacyui", it).apply()
|
|
||||||
useLagacyUI = it
|
|
||||||
}
|
|
||||||
|
|
||||||
var useBanner by rememberSaveable {
|
var useBanner by rememberSaveable {
|
||||||
mutableStateOf(
|
mutableStateOf(
|
||||||
prefs.getBoolean("use_banner", true)
|
prefs.getBoolean("use_banner", true)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
SwitchItem(
|
SwitchItem(
|
||||||
enabled = !useLagacyUI,
|
|
||||||
icon = Icons.Filled.ViewCarousel,
|
icon = Icons.Filled.ViewCarousel,
|
||||||
title = stringResource(id = R.string.settings_banner),
|
title = stringResource(id = R.string.settings_banner),
|
||||||
summary = stringResource(id = R.string.settings_banner_summary),
|
summary = stringResource(id = R.string.settings_banner_summary),
|
||||||
|
|||||||
@@ -84,7 +84,6 @@ import androidx.compose.ui.res.stringResource
|
|||||||
import androidx.compose.ui.semantics.Role
|
import androidx.compose.ui.semantics.Role
|
||||||
import androidx.compose.ui.text.font.FontWeight
|
import androidx.compose.ui.text.font.FontWeight
|
||||||
import androidx.compose.ui.text.style.TextAlign
|
import androidx.compose.ui.text.style.TextAlign
|
||||||
import androidx.compose.ui.text.style.TextDecoration
|
|
||||||
import androidx.compose.ui.text.style.TextOverflow
|
import androidx.compose.ui.text.style.TextOverflow
|
||||||
import androidx.compose.ui.tooling.preview.Preview
|
import androidx.compose.ui.tooling.preview.Preview
|
||||||
import androidx.compose.ui.unit.Dp
|
import androidx.compose.ui.unit.Dp
|
||||||
@@ -699,13 +698,10 @@ fun ModuleItem(
|
|||||||
.fillMaxWidth()
|
.fillMaxWidth()
|
||||||
.clip(MaterialTheme.shapes.medium)
|
.clip(MaterialTheme.shapes.medium)
|
||||||
.clickable(
|
.clickable(
|
||||||
enabled = (module.enabled && !module.remove && (module.hasWebUi || module.hasActionScript)),
|
enabled = (module.enabled && !module.remove && (module.hasWebUi)),
|
||||||
onClick = {
|
onClick = {
|
||||||
if (module.hasWebUi) {
|
if (module.hasWebUi) {
|
||||||
onClick(module)
|
onClick(module)
|
||||||
} else if (module.hasActionScript) {
|
|
||||||
navigator.navigate(ExecuteModuleActionScreenDestination(module.dirId))
|
|
||||||
viewModel.markNeedRefresh()
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
@@ -716,7 +712,6 @@ fun ModuleItem(
|
|||||||
) {
|
) {
|
||||||
val context = LocalContext.current
|
val context = LocalContext.current
|
||||||
val prefs = context.getSharedPreferences("settings", Context.MODE_PRIVATE)
|
val prefs = context.getSharedPreferences("settings", Context.MODE_PRIVATE)
|
||||||
val useLagacyUI = prefs.getBoolean("use_legacyui", false)
|
|
||||||
|
|
||||||
val useBanner = prefs.getBoolean("use_banner", true)
|
val useBanner = prefs.getBoolean("use_banner", true)
|
||||||
|
|
||||||
@@ -791,7 +786,6 @@ fun ModuleItem(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
Column {
|
Column {
|
||||||
val textDecoration = if (!module.remove) null else TextDecoration.LineThrough
|
|
||||||
val interactionSource = remember { MutableInteractionSource() }
|
val interactionSource = remember { MutableInteractionSource() }
|
||||||
|
|
||||||
var developerOptionsEnabled by rememberSaveable {
|
var developerOptionsEnabled by rememberSaveable {
|
||||||
@@ -833,19 +827,9 @@ fun ModuleItem(
|
|||||||
contentColor = MaterialTheme.colorScheme.onSecondaryContainer
|
contentColor = MaterialTheme.colorScheme.onSecondaryContainer
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
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()
|
|
||||||
else
|
|
||||||
com.dergoogler.mmrl.ui.component.LabelItemDefaults.style.copy(
|
|
||||||
containerColor = MaterialTheme.colorScheme.errorContainer,
|
|
||||||
contentColor = MaterialTheme.colorScheme.onErrorContainer
|
|
||||||
)
|
|
||||||
)
|
|
||||||
if (module.remove) {
|
if (module.remove) {
|
||||||
LabelItem(
|
LabelItem(
|
||||||
text = stringResource(R.string.uninstalled),
|
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
|
||||||
@@ -882,15 +866,6 @@ fun ModuleItem(
|
|||||||
)
|
)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
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
|
|
||||||
)
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -901,24 +876,21 @@ fun ModuleItem(
|
|||||||
fontSize = MaterialTheme.typography.titleMedium.fontSize,
|
fontSize = MaterialTheme.typography.titleMedium.fontSize,
|
||||||
fontWeight = FontWeight.SemiBold,
|
fontWeight = FontWeight.SemiBold,
|
||||||
lineHeight = MaterialTheme.typography.bodySmall.lineHeight,
|
lineHeight = MaterialTheme.typography.bodySmall.lineHeight,
|
||||||
fontFamily = MaterialTheme.typography.titleMedium.fontFamily,
|
fontFamily = MaterialTheme.typography.titleMedium.fontFamily
|
||||||
textDecoration = textDecoration,
|
|
||||||
)
|
)
|
||||||
|
|
||||||
Text(
|
Text(
|
||||||
text = "$moduleVersion: ${module.version}",
|
text = "$moduleVersion: ${module.version}",
|
||||||
fontSize = MaterialTheme.typography.bodySmall.fontSize,
|
fontSize = MaterialTheme.typography.bodySmall.fontSize,
|
||||||
lineHeight = MaterialTheme.typography.bodySmall.lineHeight,
|
lineHeight = MaterialTheme.typography.bodySmall.lineHeight,
|
||||||
fontFamily = MaterialTheme.typography.bodySmall.fontFamily,
|
fontFamily = MaterialTheme.typography.bodySmall.fontFamily
|
||||||
textDecoration = textDecoration
|
|
||||||
)
|
)
|
||||||
|
|
||||||
Text(
|
Text(
|
||||||
text = "$moduleAuthor: ${module.author}",
|
text = "$moduleAuthor: ${module.author}",
|
||||||
fontSize = MaterialTheme.typography.bodySmall.fontSize,
|
fontSize = MaterialTheme.typography.bodySmall.fontSize,
|
||||||
lineHeight = MaterialTheme.typography.bodySmall.lineHeight,
|
lineHeight = MaterialTheme.typography.bodySmall.lineHeight,
|
||||||
fontFamily = MaterialTheme.typography.bodySmall.fontFamily,
|
fontFamily = MaterialTheme.typography.bodySmall.fontFamily
|
||||||
textDecoration = textDecoration
|
|
||||||
)
|
)
|
||||||
|
|
||||||
if (developerOptionsEnabled) {
|
if (developerOptionsEnabled) {
|
||||||
@@ -927,24 +899,21 @@ fun ModuleItem(
|
|||||||
text = "$moduleId: ${module.id}",
|
text = "$moduleId: ${module.id}",
|
||||||
fontSize = MaterialTheme.typography.bodySmall.fontSize,
|
fontSize = MaterialTheme.typography.bodySmall.fontSize,
|
||||||
lineHeight = MaterialTheme.typography.bodySmall.lineHeight,
|
lineHeight = MaterialTheme.typography.bodySmall.lineHeight,
|
||||||
fontFamily = MaterialTheme.typography.bodySmall.fontFamily,
|
fontFamily = MaterialTheme.typography.bodySmall.fontFamily
|
||||||
textDecoration = textDecoration
|
|
||||||
)
|
)
|
||||||
|
|
||||||
Text(
|
Text(
|
||||||
text = "$moduleVersionCode: ${module.versionCode}",
|
text = "$moduleVersionCode: ${module.versionCode}",
|
||||||
fontSize = MaterialTheme.typography.bodySmall.fontSize,
|
fontSize = MaterialTheme.typography.bodySmall.fontSize,
|
||||||
lineHeight = MaterialTheme.typography.bodySmall.lineHeight,
|
lineHeight = MaterialTheme.typography.bodySmall.lineHeight,
|
||||||
fontFamily = MaterialTheme.typography.bodySmall.fontFamily,
|
fontFamily = MaterialTheme.typography.bodySmall.fontFamily
|
||||||
textDecoration = textDecoration
|
|
||||||
)
|
)
|
||||||
|
|
||||||
Text(
|
Text(
|
||||||
text = if (module.updateJson.isNotEmpty()) "$moduleUpdateJson: ${module.updateJson}" else "$moduleUpdateJson: $moduleUpdateJsonEmpty",
|
text = if (module.updateJson.isNotEmpty()) "$moduleUpdateJson: ${module.updateJson}" else "$moduleUpdateJson: $moduleUpdateJsonEmpty",
|
||||||
fontSize = MaterialTheme.typography.bodySmall.fontSize,
|
fontSize = MaterialTheme.typography.bodySmall.fontSize,
|
||||||
lineHeight = MaterialTheme.typography.bodySmall.lineHeight,
|
lineHeight = MaterialTheme.typography.bodySmall.lineHeight,
|
||||||
fontFamily = MaterialTheme.typography.bodySmall.fontFamily,
|
fontFamily = MaterialTheme.typography.bodySmall.fontFamily
|
||||||
textDecoration = textDecoration
|
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -973,14 +942,9 @@ fun ModuleItem(
|
|||||||
lineHeight = MaterialTheme.typography.bodySmall.lineHeight,
|
lineHeight = MaterialTheme.typography.bodySmall.lineHeight,
|
||||||
fontWeight = MaterialTheme.typography.bodySmall.fontWeight,
|
fontWeight = MaterialTheme.typography.bodySmall.fontWeight,
|
||||||
overflow = TextOverflow.Ellipsis,
|
overflow = TextOverflow.Ellipsis,
|
||||||
maxLines = 4,
|
maxLines = 4
|
||||||
textDecoration = textDecoration
|
|
||||||
)
|
)
|
||||||
|
|
||||||
Spacer(modifier = Modifier.height(16.dp))
|
|
||||||
|
|
||||||
HorizontalDivider(thickness = Dp.Hairline)
|
|
||||||
|
|
||||||
Spacer(modifier = Modifier.height(12.dp))
|
Spacer(modifier = Modifier.height(12.dp))
|
||||||
|
|
||||||
Row(
|
Row(
|
||||||
@@ -999,7 +963,7 @@ fun ModuleItem(
|
|||||||
) {
|
) {
|
||||||
Icon(
|
Icon(
|
||||||
modifier = Modifier.size(20.dp),
|
modifier = Modifier.size(20.dp),
|
||||||
imageVector = Icons.Outlined.PlayArrow,
|
imageVector = Icons.Outlined.Terminal,
|
||||||
contentDescription = null
|
contentDescription = null
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
@@ -1007,22 +971,6 @@ fun ModuleItem(
|
|||||||
Spacer(modifier = Modifier.weight(0.1f, true))
|
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
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Spacer(modifier = Modifier.weight(1f, true))
|
Spacer(modifier = Modifier.weight(1f, true))
|
||||||
|
|
||||||
if (updateUrl.isNotEmpty()) {
|
if (updateUrl.isNotEmpty()) {
|
||||||
|
|||||||
Reference in New Issue
Block a user