Skip to content

Commit

Permalink
Fix Switch
Browse files Browse the repository at this point in the history
  • Loading branch information
yasanglass committed Feb 28, 2024
1 parent fa4d0ac commit a2276ed
Showing 1 changed file with 7 additions and 11 deletions.
18 changes: 7 additions & 11 deletions concrete/src/main/kotlin/glass/yasan/concrete/component/Switch.kt
Original file line number Diff line number Diff line change
Expand Up @@ -14,32 +14,30 @@ import androidx.compose.material3.Switch as Material3Switch
@Composable
public fun Switch(
title: String,
checked: Boolean,
checked: Boolean?,
modifier: Modifier = Modifier,
description: String? = null,
onCheckedChange: (Boolean) -> Unit,
enabled: Boolean = true,
) {
Switch(
title = title,
checked = checked,
checked = checked ?: false,
modifier = modifier,
description = description,
onCheckedChange = onCheckedChange,
enabled = enabled,
enabled = checked != null,
)
}

@Composable
public fun Switch(
title: String,
checked: Boolean?,
checked: Boolean,
modifier: Modifier = Modifier,
description: String? = null,
onCheckedChange: (Boolean) -> Unit,
enabled: Boolean = true,
) {
val enabled = checked != null

Preference(
title = {
Text(
Expand All @@ -59,13 +57,11 @@ public fun Switch(
},
modifier = modifier
.clickable(enabled = enabled) {
checked?.let {
onCheckedChange(!it)
}
onCheckedChange(!checked)
},
end = {
Material3Switch(
checked = checked ?: false,
checked = checked,
onCheckedChange = onCheckedChange,
enabled = enabled,
)
Expand Down

0 comments on commit a2276ed

Please sign in to comment.