Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
80 changes: 51 additions & 29 deletions manager/app/src/main/java/me/weishu/kernelsu/ui/component/Dialog.kt
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,16 @@ import android.view.ViewGroup
import android.widget.TextView
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.WindowInsets
import androidx.compose.foundation.layout.WindowInsetsSides
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.only
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.systemBars
import androidx.compose.foundation.layout.width
import androidx.compose.foundation.layout.windowInsetsPadding
import androidx.compose.foundation.layout.wrapContentHeight
import androidx.compose.runtime.Composable
import androidx.compose.runtime.MutableState
Expand All @@ -29,6 +33,7 @@ import androidx.compose.runtime.saveable.rememberSaveable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.toArgb
import androidx.compose.ui.layout.Layout
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.unit.dp
Expand Down Expand Up @@ -411,42 +416,59 @@ private fun ConfirmDialog(
showDialog: MutableState<Boolean>
) {
SuperDialog(
modifier = Modifier.windowInsetsPadding(WindowInsets.systemBars.only(WindowInsetsSides.Top)),
show = showDialog,
title = visuals.title,
onDismissRequest = {
showDialog.value = false
},
content = {
Column {
visuals.content?.let {
if (visuals.isMarkdown) {
MarkdownContent(content = visuals.content!!)
} else {
Text(text = visuals.content!!)
Layout(
content = {
visuals.content?.let {
if (visuals.isMarkdown) {
MarkdownContent(content = visuals.content!!)
} else {
Text(text = visuals.content!!)
}
}
Row(
horizontalArrangement = Arrangement.SpaceBetween,
modifier = Modifier.padding(top = 12.dp)
) {
TextButton(
text = visuals.dismiss ?: stringResource(id = android.R.string.cancel),
onClick = {
dismiss()
showDialog.value = false
},
modifier = Modifier.weight(1f)
)
Spacer(Modifier.width(20.dp))
TextButton(
text = visuals.confirm ?: stringResource(id = android.R.string.ok),
onClick = {
confirm()
showDialog.value = false
},
modifier = Modifier.weight(1f),
colors = ButtonDefaults.textButtonColorsPrimary()
)
}
}
Row(
horizontalArrangement = Arrangement.SpaceBetween,
modifier = Modifier.padding(top = 12.dp)
) {
TextButton(
text = visuals.dismiss ?: stringResource(id = android.R.string.cancel),
onClick = {
dismiss()
showDialog.value = false
},
modifier = Modifier.weight(1f)
)
Spacer(Modifier.width(20.dp))
TextButton(
text = visuals.confirm ?: stringResource(id = android.R.string.ok),
onClick = {
confirm()
showDialog.value = false
},
modifier = Modifier.weight(1f),
colors = ButtonDefaults.textButtonColorsPrimary()
)
) { measurables, constraints ->
if (measurables.size != 2) {
val button = measurables[0].measure(constraints)
layout(constraints.maxWidth, button.height) {
button.place(0, 0)
}
} else {
val button = measurables[1].measure(constraints)
val lazyList = measurables[0].measure(constraints.copy(maxHeight = constraints.maxHeight - button.height))
layout(constraints.maxWidth, lazyList.height + button.height) {
lazyList.place(0, 0)
button.place(0, lazyList.height)
}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,6 @@ fun TemplateConfig(
onProfileChange: (Natives.Profile) -> Unit
) {
var expanded by remember { mutableStateOf(false) }
var template by rememberSaveable {
mutableStateOf(profile.rootTemplate ?: "")
}
val profileTemplates = listAppProfileTemplates()
val noTemplates = profileTemplates.isEmpty()

Expand All @@ -56,6 +53,8 @@ fun TemplateConfig(
onClick = onManageTemplate,
)
} else {
var template by rememberSaveable { mutableStateOf(profile.rootTemplate ?: profileTemplates[0]) }

Column {
SuperDropdown(
title = stringResource(R.string.profile_template),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,6 @@ private fun AppProfileInner(
Column(
modifier = Modifier.padding(bottom = 12.dp)
) {
//SmallTitle(text = stringResource(R.string.profile))
if (current) {
val initialMode = if (profile.rootUseDefault) {
Mode.Default
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -673,7 +673,7 @@ fun ModuleItem(
)
}
Switch(
modifier = Modifier,
enabled = !module.update,
checked = module.enabled,
onCheckedChange = onCheckChanged
)
Expand Down
Loading