diff --git a/common/src/commonMain/kotlin/org/hisp/dhis/common/screens/ChipsScreen.kt b/common/src/commonMain/kotlin/org/hisp/dhis/common/screens/ChipsScreen.kt index fa2a6a6ea..38ed5046a 100644 --- a/common/src/commonMain/kotlin/org/hisp/dhis/common/screens/ChipsScreen.kt +++ b/common/src/commonMain/kotlin/org/hisp/dhis/common/screens/ChipsScreen.kt @@ -1,14 +1,19 @@ package org.hisp.dhis.common.screens import androidx.compose.runtime.Composable +import androidx.compose.runtime.getValue +import androidx.compose.runtime.mutableStateOf +import androidx.compose.runtime.remember +import androidx.compose.runtime.setValue import org.hisp.dhis.mobile.ui.designsystem.component.Chip import org.hisp.dhis.mobile.ui.designsystem.component.ColumnComponentContainer @Composable fun ChipsScreen() { ColumnComponentContainer(title = "Filter Chips") { - Chip(label = "Label", selected = true) - Chip(label = "Label", selected = false) + var isSelected by remember { mutableStateOf(false) } + Chip(label = "Label", selected = isSelected, onSelected = { isSelected = it }) + Chip(label = "Label", selected = !isSelected, onSelected = { isSelected = !it }) } ColumnComponentContainer(title = "With badges") { Chip(label = "Label", selected = true, badge = "3") diff --git a/designsystem/src/commonMain/kotlin/org/hisp/dhis/mobile/ui/designsystem/component/Chip.kt b/designsystem/src/commonMain/kotlin/org/hisp/dhis/mobile/ui/designsystem/component/Chip.kt index 4cd6a4c03..104de8c18 100644 --- a/designsystem/src/commonMain/kotlin/org/hisp/dhis/mobile/ui/designsystem/component/Chip.kt +++ b/designsystem/src/commonMain/kotlin/org/hisp/dhis/mobile/ui/designsystem/component/Chip.kt @@ -35,20 +35,15 @@ fun Chip( ) { Box(modifier = modifier) { CompositionLocalProvider(LocalRippleTheme provides Ripple.CustomDHISRippleTheme) { - var isSelected by remember { mutableStateOf(selected) } - FilterChip( - onClick = { - isSelected = !isSelected - onSelected?.invoke(isSelected) - }, + onClick = { onSelected?.invoke(!selected) }, label = { Text(label) }, - selected = isSelected, + selected = selected, colors = FilterChipDefaults.filterChipColors( containerColor = SurfaceColor.SurfaceBright, selectedContainerColor = SurfaceColor.Container, ), - leadingIcon = if (isSelected) { + leadingIcon = if (selected) { { Icon( imageVector = Icons.Filled.Done,