Skip to content

Commit

Permalink
improve help icon in settings
Browse files Browse the repository at this point in the history
  • Loading branch information
amir1376 committed Nov 21, 2024
1 parent cc134bd commit bc7cb86
Showing 1 changed file with 17 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ import androidx.compose.ui.window.Popup
import androidx.compose.ui.window.rememberComponentRectPositionProvider



@Composable
fun <T> RenderSpinner(
possibleValues: List<T>,
Expand Down Expand Up @@ -70,8 +69,7 @@ fun <T> RenderSpinner(
.border(borderWidth, borderColor, shape)
.clickable(enabled = enabled) {
isOpen = true
}
,
},
horizontalArrangement = Arrangement.SpaceBetween
) {
WithContentAlpha(1f) {
Expand Down Expand Up @@ -117,8 +115,7 @@ fun <T> RenderSpinner(
.clickable(onClick = {
isOpen = false
onSelect(p)
})
,
}),
verticalAlignment = Alignment.CenterVertically,
) {
val selected = p == value
Expand All @@ -135,7 +132,7 @@ fun <T> RenderSpinner(
Spacer(
Modifier.width(borderWidth)
)
if(selected){
if (selected) {
MyIcon(MyIcons.check, null, Modifier.padding(4.dp).size(12.dp))
}
}
Expand Down Expand Up @@ -180,10 +177,14 @@ fun <T> 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) {
Expand All @@ -193,8 +194,9 @@ fun <T> TitleAndDescription(
}
val describeContent = describedStringSource.rememberString()
if (describeContent.isNotBlank()) {
WithContentAlpha(0.75f){
Text(describeContent,
WithContentAlpha(0.75f) {
Text(
describeContent,
fontSize = myTextSizes.base,
)
}
Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -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(
Expand All @@ -321,7 +324,7 @@ private fun Help(
.size(12.dp),
tint = myColors.onSurface,
)
if (showHelpContent){
if (showHelpContent) {
Popup(
popupPositionProvider = rememberComponentRectPositionProvider(
anchor = Alignment.TopCenter,
Expand Down

0 comments on commit bc7cb86

Please sign in to comment.