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
|
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.*
|
||||||
import androidx.compose.foundation.layout.*
|
import androidx.compose.foundation.layout.*
|
||||||
import androidx.compose.foundation.shape.CircleShape
|
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.asStringSource
|
||||||
import ir.amirab.util.compose.resources.myStringResource
|
import ir.amirab.util.compose.resources.myStringResource
|
||||||
import ir.amirab.util.desktop.DesktopUtils
|
import ir.amirab.util.desktop.DesktopUtils
|
||||||
|
import ir.amirab.util.ifThen
|
||||||
|
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
@ -170,6 +171,19 @@ private fun ProxyEditDialog(
|
|||||||
.verticalScroll(rememberScrollState())
|
.verticalScroll(rememberScrollState())
|
||||||
) {
|
) {
|
||||||
Accordion(
|
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(),
|
possibleValues = ProxyMode.usableValues(),
|
||||||
selectedItem = mode,
|
selectedItem = mode,
|
||||||
renderHeader = {
|
renderHeader = {
|
||||||
@ -180,22 +194,39 @@ private fun ProxyEditDialog(
|
|||||||
.clip(shape)
|
.clip(shape)
|
||||||
.clickable { setMode(it) }
|
.clickable { setMode(it) }
|
||||||
.padding(8.dp)
|
.padding(8.dp)
|
||||||
|
.padding(
|
||||||
|
animateDpAsState(
|
||||||
|
if (selected) 4.dp else 0.dp
|
||||||
|
).value
|
||||||
|
)
|
||||||
) {
|
) {
|
||||||
RadioButton(
|
RadioButton(
|
||||||
value = selected,
|
value = selected,
|
||||||
onValueChange = {},
|
onValueChange = {},
|
||||||
)
|
)
|
||||||
Spacer(Modifier.width(8.dp))
|
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 = {
|
renderContent = {
|
||||||
val cm = Modifier
|
val cm = Modifier
|
||||||
.fillMaxWidth()
|
.fillMaxWidth()
|
||||||
.clip(shape)
|
.padding(
|
||||||
.border(1.dp, myColors.onBackground / 0.15f, shape)
|
vertical = 12.dp,
|
||||||
.background(myColors.background / 25)
|
horizontal = 16.dp
|
||||||
.padding(8.dp)
|
)
|
||||||
when (it) {
|
when (it) {
|
||||||
ProxyMode.Direct -> {
|
ProxyMode.Direct -> {
|
||||||
|
|
||||||
@ -383,7 +414,7 @@ private fun RenderManualConfig(
|
|||||||
Row {
|
Row {
|
||||||
Text(myStringResource(Res.string.proxy_do_not_use_proxy_for))
|
Text(myStringResource(Res.string.proxy_do_not_use_proxy_for))
|
||||||
Spacer(Modifier.width(8.dp))
|
Spacer(Modifier.width(8.dp))
|
||||||
com.abdownloadmanager.shared.ui.widget.Help(
|
Help(
|
||||||
myStringResource(Res.string.proxy_do_not_use_proxy_for_description)
|
myStringResource(Res.string.proxy_do_not_use_proxy_for_description)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
@ -510,21 +541,23 @@ private fun ProxyMode.asStringSource(): StringSource {
|
|||||||
private fun <T> Accordion(
|
private fun <T> Accordion(
|
||||||
possibleValues: List<T>,
|
possibleValues: List<T>,
|
||||||
selectedItem: T,
|
selectedItem: T,
|
||||||
|
wrapItem: @Composable (T, @Composable () -> Unit) -> Unit = { _, content -> content() },
|
||||||
renderHeader: @Composable (T) -> Unit,
|
renderHeader: @Composable (T) -> Unit,
|
||||||
renderContent: @Composable (T) -> Unit,
|
renderContent: @Composable (T) -> Unit,
|
||||||
) {
|
) {
|
||||||
Column {
|
Column {
|
||||||
possibleValues.forEach {
|
possibleValues.forEach {
|
||||||
ExpandableItem(
|
wrapItem(it) {
|
||||||
modifier = Modifier,
|
ExpandableItem(
|
||||||
isExpanded = selectedItem == it,
|
isExpanded = selectedItem == it,
|
||||||
header = {
|
header = {
|
||||||
renderHeader(it)
|
renderHeader(it)
|
||||||
},
|
},
|
||||||
body = {
|
body = {
|
||||||
renderContent(it)
|
renderContent(it)
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user