From bc7cb866432949006ece7892d97d7ee56ec31aab Mon Sep 17 00:00:00 2001 From: AmirHossein Abdolmotallebi Date: Fri, 22 Nov 2024 02:19:55 +0330 Subject: [PATCH] improve help icon in settings --- .../settings/configurable/widgets/Shared.kt | 31 ++++++++++--------- 1 file changed, 17 insertions(+), 14 deletions(-) diff --git a/desktop/app/src/main/kotlin/com/abdownloadmanager/desktop/pages/settings/configurable/widgets/Shared.kt b/desktop/app/src/main/kotlin/com/abdownloadmanager/desktop/pages/settings/configurable/widgets/Shared.kt index 1cd9808a..22d2f501 100644 --- a/desktop/app/src/main/kotlin/com/abdownloadmanager/desktop/pages/settings/configurable/widgets/Shared.kt +++ b/desktop/app/src/main/kotlin/com/abdownloadmanager/desktop/pages/settings/configurable/widgets/Shared.kt @@ -33,7 +33,6 @@ import androidx.compose.ui.window.Popup import androidx.compose.ui.window.rememberComponentRectPositionProvider - @Composable fun RenderSpinner( possibleValues: List, @@ -70,8 +69,7 @@ fun RenderSpinner( .border(borderWidth, borderColor, shape) .clickable(enabled = enabled) { isOpen = true - } - , + }, horizontalArrangement = Arrangement.SpaceBetween ) { WithContentAlpha(1f) { @@ -117,8 +115,7 @@ fun RenderSpinner( .clickable(onClick = { isOpen = false onSelect(p) - }) - , + }), verticalAlignment = Alignment.CenterVertically, ) { val selected = p == value @@ -135,7 +132,7 @@ fun RenderSpinner( Spacer( Modifier.width(borderWidth) ) - if(selected){ + if (selected) { MyIcon(MyIcons.check, null, Modifier.padding(4.dp).size(12.dp)) } } @@ -180,10 +177,14 @@ fun TitleAndDescription( cfg.title.rememberString(), fontSize = myTextSizes.base, fontWeight = FontWeight.Bold, + modifier = Modifier.weight(1f, false) ) if (cfg.description.rememberString().isNotBlank()) { Spacer(Modifier.size(4.dp)) - Help(cfg) + Help( + Modifier.align(Alignment.Top), + cfg + ) } } if (describe) { @@ -193,8 +194,9 @@ fun TitleAndDescription( } val describeContent = describedStringSource.rememberString() if (describeContent.isNotBlank()) { - WithContentAlpha(0.75f){ - Text(describeContent, + WithContentAlpha(0.75f) { + Text( + describeContent, fontSize = myTextSizes.base, ) } @@ -224,7 +226,7 @@ fun isConfigEnabled(): Boolean { fun ConfigurationWrapper( configurable: Configurable<*>, groupInfo: ConfigGroupInfo? = null, - content: @Composable () -> Unit + content: @Composable () -> Unit, ) { val enabled by configurable.enabled.collectAsState() val visible by configurable.visible.collectAsState() @@ -295,19 +297,20 @@ fun ConfigTemplate( @Composable private fun Help( + modifier: Modifier = Modifier, cfg: Configurable<*>, -){ +) { var showHelpContent by remember { mutableStateOf(false) } val onRequestCloseShowHelpContent = { showHelpContent = false } - Column { + Column(modifier) { MyIcon( MyIcons.question, "Hint", Modifier .clip(CircleShape) - .clickable{ + .clickable { showHelpContent = !showHelpContent } .border( @@ -321,7 +324,7 @@ private fun Help( .size(12.dp), tint = myColors.onSurface, ) - if (showHelpContent){ + if (showHelpContent) { Popup( popupPositionProvider = rememberComponentRectPositionProvider( anchor = Alignment.TopCenter,