manager: show default value for app profile.
This commit is contained in:
@@ -14,6 +14,7 @@ fun SwitchItem(
|
|||||||
title: String,
|
title: String,
|
||||||
summary: String? = null,
|
summary: String? = null,
|
||||||
checked: Boolean,
|
checked: Boolean,
|
||||||
|
enabled: Boolean = true,
|
||||||
onCheckedChange: (Boolean) -> Unit
|
onCheckedChange: (Boolean) -> Unit
|
||||||
) {
|
) {
|
||||||
ListItem(
|
ListItem(
|
||||||
@@ -24,7 +25,7 @@ fun SwitchItem(
|
|||||||
{ Icon(icon, title) }
|
{ Icon(icon, title) }
|
||||||
},
|
},
|
||||||
trailingContent = {
|
trailingContent = {
|
||||||
Switch(checked = checked, onCheckedChange = onCheckedChange)
|
Switch(checked = checked, enabled = enabled, onCheckedChange = onCheckedChange)
|
||||||
},
|
},
|
||||||
supportingContent = {
|
supportingContent = {
|
||||||
if (summary != null) {
|
if (summary != null) {
|
||||||
|
|||||||
@@ -19,6 +19,7 @@ import me.weishu.kernelsu.ui.component.SwitchItem
|
|||||||
fun AppProfileConfig(
|
fun AppProfileConfig(
|
||||||
modifier: Modifier = Modifier,
|
modifier: Modifier = Modifier,
|
||||||
fixedName: Boolean,
|
fixedName: Boolean,
|
||||||
|
enabled: Boolean,
|
||||||
profile: Natives.Profile,
|
profile: Natives.Profile,
|
||||||
onProfileChange: (Natives.Profile) -> Unit,
|
onProfileChange: (Natives.Profile) -> Unit,
|
||||||
) {
|
) {
|
||||||
@@ -33,7 +34,12 @@ fun AppProfileConfig(
|
|||||||
|
|
||||||
SwitchItem(
|
SwitchItem(
|
||||||
title = stringResource(R.string.profile_unmount_modules),
|
title = stringResource(R.string.profile_unmount_modules),
|
||||||
checked = profile.umountModules,
|
checked = if (enabled) {
|
||||||
|
profile.umountModules
|
||||||
|
} else {
|
||||||
|
Natives.isDefaultUmountModules()
|
||||||
|
},
|
||||||
|
enabled = enabled,
|
||||||
onCheckedChange = { onProfileChange(profile.copy(umountModules = it)) }
|
onCheckedChange = { onProfileChange(profile.copy(umountModules = it)) }
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
@@ -43,7 +49,7 @@ fun AppProfileConfig(
|
|||||||
@Composable
|
@Composable
|
||||||
private fun AppProfileConfigPreview() {
|
private fun AppProfileConfigPreview() {
|
||||||
var profile by remember { mutableStateOf(Natives.Profile("")) }
|
var profile by remember { mutableStateOf(Natives.Profile("")) }
|
||||||
AppProfileConfig(fixedName = true, profile = profile) {
|
AppProfileConfig(fixedName = true, enabled = false, profile = profile) {
|
||||||
profile = it
|
profile = it
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -125,7 +125,7 @@ private fun AppProfileInner(
|
|||||||
profile: Natives.Profile,
|
profile: Natives.Profile,
|
||||||
onProfileChange: (Natives.Profile) -> Unit,
|
onProfileChange: (Natives.Profile) -> Unit,
|
||||||
) {
|
) {
|
||||||
val isRootGranted = profile.allowSu
|
val isRootGranted = profile.allowSu
|
||||||
|
|
||||||
Column(modifier = modifier) {
|
Column(modifier = modifier) {
|
||||||
ListItem(
|
ListItem(
|
||||||
@@ -156,9 +156,11 @@ private fun AppProfileInner(
|
|||||||
Mode.Default -> {
|
Mode.Default -> {
|
||||||
onProfileChange(profile.copy(rootUseDefault = true))
|
onProfileChange(profile.copy(rootUseDefault = true))
|
||||||
}
|
}
|
||||||
|
|
||||||
Mode.Template -> {
|
Mode.Template -> {
|
||||||
onProfileChange(profile.copy(rootUseDefault = false))
|
onProfileChange(profile.copy(rootUseDefault = false))
|
||||||
}
|
}
|
||||||
|
|
||||||
else -> {
|
else -> {
|
||||||
onProfileChange(profile.copy(rootUseDefault = false))
|
onProfileChange(profile.copy(rootUseDefault = false))
|
||||||
}
|
}
|
||||||
@@ -199,13 +201,13 @@ private fun AppProfileInner(
|
|||||||
var mode by rememberSaveable { mutableStateOf(Mode.Default) }
|
var mode by rememberSaveable { mutableStateOf(Mode.Default) }
|
||||||
ProfileBox(mode, false) { mode = it }
|
ProfileBox(mode, false) { mode = it }
|
||||||
Crossfade(targetState = mode, label = "") { currentMode ->
|
Crossfade(targetState = mode, label = "") { currentMode ->
|
||||||
if (currentMode == Mode.Custom) {
|
val modifyEnabled = currentMode == Mode.Custom
|
||||||
AppProfileConfig(
|
AppProfileConfig(
|
||||||
fixedName = true,
|
fixedName = true,
|
||||||
profile = profile,
|
profile = profile,
|
||||||
onProfileChange = onProfileChange
|
enabled = modifyEnabled,
|
||||||
)
|
onProfileChange = onProfileChange
|
||||||
}
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user