Skip to content

Commit

Permalink
fix: chips
Browse files Browse the repository at this point in the history
  • Loading branch information
mmmateos committed Sep 26, 2023
1 parent c7ce3df commit 805b90e
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
Original file line number Diff line number Diff line change
@@ -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")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit 805b90e

Please sign in to comment.