mirror of
https://github.com/amir1376/ab-download-manager.git
synced 2025-02-20 11:43:24 +08:00
improve proxy settings page
This commit is contained in:
parent
e16055941a
commit
9eb141ae8a
@ -1,6 +1,6 @@
|
||||
package com.abdownloadmanager.desktop.pages.settings.configurable.widgets
|
||||
|
||||
import androidx.compose.animation.AnimatedContent
|
||||
import androidx.compose.animation.core.animateDpAsState
|
||||
import androidx.compose.foundation.*
|
||||
import androidx.compose.foundation.layout.*
|
||||
import androidx.compose.foundation.shape.CircleShape
|
||||
@ -31,6 +31,7 @@ import ir.amirab.util.compose.StringSource
|
||||
import ir.amirab.util.compose.asStringSource
|
||||
import ir.amirab.util.compose.resources.myStringResource
|
||||
import ir.amirab.util.desktop.DesktopUtils
|
||||
import ir.amirab.util.ifThen
|
||||
|
||||
|
||||
@Composable
|
||||
@ -170,6 +171,19 @@ private fun ProxyEditDialog(
|
||||
.verticalScroll(rememberScrollState())
|
||||
) {
|
||||
Accordion(
|
||||
wrapItem = { item, content ->
|
||||
val selected = item == mode
|
||||
Box(
|
||||
Modifier.ifThen(selected) {
|
||||
Modifier
|
||||
.clip(shape)
|
||||
.border(1.dp, myColors.onBackground / 0.15f, shape)
|
||||
.background(myColors.background / 25)
|
||||
}
|
||||
) {
|
||||
content()
|
||||
}
|
||||
},
|
||||
possibleValues = ProxyMode.usableValues(),
|
||||
selectedItem = mode,
|
||||
renderHeader = {
|
||||
@ -180,22 +194,39 @@ private fun ProxyEditDialog(
|
||||
.clip(shape)
|
||||
.clickable { setMode(it) }
|
||||
.padding(8.dp)
|
||||
.padding(
|
||||
animateDpAsState(
|
||||
if (selected) 4.dp else 0.dp
|
||||
).value
|
||||
)
|
||||
) {
|
||||
RadioButton(
|
||||
value = selected,
|
||||
onValueChange = {},
|
||||
)
|
||||
Spacer(Modifier.width(8.dp))
|
||||
Text(it.asStringSource().rememberString())
|
||||
Text(
|
||||
text = it.asStringSource().rememberString(),
|
||||
fontSize = if (selected) {
|
||||
myTextSizes.lg
|
||||
} else {
|
||||
myTextSizes.base
|
||||
},
|
||||
fontWeight = if (selected) {
|
||||
FontWeight.Bold
|
||||
} else {
|
||||
null
|
||||
}
|
||||
)
|
||||
}
|
||||
},
|
||||
renderContent = {
|
||||
val cm = Modifier
|
||||
.fillMaxWidth()
|
||||
.clip(shape)
|
||||
.border(1.dp, myColors.onBackground / 0.15f, shape)
|
||||
.background(myColors.background / 25)
|
||||
.padding(8.dp)
|
||||
.padding(
|
||||
vertical = 12.dp,
|
||||
horizontal = 16.dp
|
||||
)
|
||||
when (it) {
|
||||
ProxyMode.Direct -> {
|
||||
|
||||
@ -383,7 +414,7 @@ private fun RenderManualConfig(
|
||||
Row {
|
||||
Text(myStringResource(Res.string.proxy_do_not_use_proxy_for))
|
||||
Spacer(Modifier.width(8.dp))
|
||||
com.abdownloadmanager.shared.ui.widget.Help(
|
||||
Help(
|
||||
myStringResource(Res.string.proxy_do_not_use_proxy_for_description)
|
||||
)
|
||||
}
|
||||
@ -510,13 +541,14 @@ private fun ProxyMode.asStringSource(): StringSource {
|
||||
private fun <T> Accordion(
|
||||
possibleValues: List<T>,
|
||||
selectedItem: T,
|
||||
wrapItem: @Composable (T, @Composable () -> Unit) -> Unit = { _, content -> content() },
|
||||
renderHeader: @Composable (T) -> Unit,
|
||||
renderContent: @Composable (T) -> Unit,
|
||||
) {
|
||||
Column {
|
||||
possibleValues.forEach {
|
||||
wrapItem(it) {
|
||||
ExpandableItem(
|
||||
modifier = Modifier,
|
||||
isExpanded = selectedItem == it,
|
||||
header = {
|
||||
renderHeader(it)
|
||||
@ -527,4 +559,5 @@ private fun <T> Accordion(
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user