From dcfe06fbdd7de2fd1e13b0d046e121c58878203b Mon Sep 17 00:00:00 2001 From: "DESKTOP-M49RTHN\\cthuc" Date: Tue, 7 May 2024 12:59:41 +0200 Subject: [PATCH 1/6] add: [ANDROAPP-6097] assist chip created and added to chips screen --- .../dhis/common/screens/others/ChipsScreen.kt | 21 ++++++ .../ui/designsystem/component/AssistChip.kt | 71 +++++++++++++++++++ 2 files changed, 92 insertions(+) create mode 100644 designsystem/src/commonMain/kotlin/org/hisp/dhis/mobile/ui/designsystem/component/AssistChip.kt diff --git a/common/src/commonMain/kotlin/org/hisp/dhis/common/screens/others/ChipsScreen.kt b/common/src/commonMain/kotlin/org/hisp/dhis/common/screens/others/ChipsScreen.kt index ebc03034b..1d3880b78 100644 --- a/common/src/commonMain/kotlin/org/hisp/dhis/common/screens/others/ChipsScreen.kt +++ b/common/src/commonMain/kotlin/org/hisp/dhis/common/screens/others/ChipsScreen.kt @@ -2,12 +2,16 @@ package org.hisp.dhis.common.screens.others import androidx.compose.foundation.layout.Spacer import androidx.compose.foundation.layout.size +import androidx.compose.material.icons.Icons +import androidx.compose.material.icons.filled.Search +import androidx.compose.material3.Icon 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 androidx.compose.ui.Modifier +import org.hisp.dhis.mobile.ui.designsystem.component.AssistChip import org.hisp.dhis.mobile.ui.designsystem.component.ColumnComponentContainer import org.hisp.dhis.mobile.ui.designsystem.component.FilterChip import org.hisp.dhis.mobile.ui.designsystem.component.InputChip @@ -58,5 +62,22 @@ fun ChipsScreen() { SubTitle("Filter Chips With badges") FilterChip(label = "Label", selected = true, badge = "3") FilterChip(label = "Label", selected = false, badge = "3") + Spacer(Modifier.size(Spacing.Spacing18)) + + + SubTitle("Assist Chips") + //var isSelected5 by remember { mutableStateOf(false) } + AssistChip(label = "Label", /*state = AssistChipState.PRESSED,*/ onClick = { }) + AssistChip( + label = "Label", + icon = { + Icon( + imageVector = Icons.Filled.Search, + contentDescription = "search icon", + ) + },/*state = AssistChipState.PRESSED,*/ + onClick = { } + ) + Spacer(Modifier.size(Spacing.Spacing18)) } } diff --git a/designsystem/src/commonMain/kotlin/org/hisp/dhis/mobile/ui/designsystem/component/AssistChip.kt b/designsystem/src/commonMain/kotlin/org/hisp/dhis/mobile/ui/designsystem/component/AssistChip.kt new file mode 100644 index 000000000..80e69d2ed --- /dev/null +++ b/designsystem/src/commonMain/kotlin/org/hisp/dhis/mobile/ui/designsystem/component/AssistChip.kt @@ -0,0 +1,71 @@ +package org.hisp.dhis.mobile.ui.designsystem.component + +import androidx.compose.foundation.layout.Box +import androidx.compose.foundation.layout.offset +import androidx.compose.material.ripple.LocalRippleTheme +import androidx.compose.material3.AssistChip +import androidx.compose.material3.AssistChipDefaults +import androidx.compose.material3.ExperimentalMaterial3Api +import androidx.compose.material3.Text +import androidx.compose.runtime.Composable +import androidx.compose.runtime.CompositionLocalProvider +import androidx.compose.runtime.getValue +import androidx.compose.runtime.mutableStateOf +import androidx.compose.runtime.remember +import androidx.compose.runtime.setValue +import androidx.compose.ui.Alignment +import androidx.compose.ui.Modifier +import androidx.compose.ui.layout.onSizeChanged +import androidx.compose.ui.unit.IntOffset +import org.hisp.dhis.mobile.ui.designsystem.theme.Outline +import org.hisp.dhis.mobile.ui.designsystem.theme.Ripple +import org.hisp.dhis.mobile.ui.designsystem.theme.SurfaceColor +import org.hisp.dhis.mobile.ui.designsystem.theme.TextColor + +@OptIn(ExperimentalMaterial3Api::class) +@Composable +fun AssistChip( + modifier: Modifier = Modifier, + label: String, + icon: @Composable (() -> Unit)? = null, + //state: AssistChipState, + enabled: Boolean = true, + onClick: (() -> Unit), + badge: String? = null, +) { + Box(modifier = modifier) { + CompositionLocalProvider(LocalRippleTheme provides Ripple.CustomDHISRippleTheme()) { + AssistChip( + onClick = { onClick.invoke() }, + label = { Text(label, color = TextColor.OnSurfaceVariant) }, + enabled = enabled, + colors = AssistChipDefaults.assistChipColors( + containerColor = SurfaceColor.SurfaceBright, + labelColor = SurfaceColor.Container, + leadingIconContentColor = TextColor.OnSurfaceVariant + ), + border = AssistChipDefaults.assistChipBorder( + borderColor = Outline.Dark, + ), + leadingIcon = { + icon?.invoke() + } + + ) + } + badge?.let { + var offset by remember { mutableStateOf(IntOffset(0, 0)) } + Badge( + modifier = Modifier + .align(Alignment.TopEnd) + .onSizeChanged { offset = IntOffset(it.width / 3, it.height / 3) } + .offset { offset }, + text = badge, + ) + } + } +} + +enum class AssistChipState { + PRESSED +} \ No newline at end of file From 51e2e11bf586cf82d4f6d791fd304533f62db0ea Mon Sep 17 00:00:00 2001 From: "DESKTOP-M49RTHN\\cthuc" Date: Fri, 10 May 2024 10:42:37 +0200 Subject: [PATCH 2/6] update: [ANDROAPP-6097] Styles updated, samples with badges added --- .../dhis/common/screens/others/ChipsScreen.kt | 32 +++++++++++++++++-- .../ui/designsystem/component/AssistChip.kt | 31 +++++++++++------- 2 files changed, 49 insertions(+), 14 deletions(-) diff --git a/common/src/commonMain/kotlin/org/hisp/dhis/common/screens/others/ChipsScreen.kt b/common/src/commonMain/kotlin/org/hisp/dhis/common/screens/others/ChipsScreen.kt index 1d3880b78..e54453dbc 100644 --- a/common/src/commonMain/kotlin/org/hisp/dhis/common/screens/others/ChipsScreen.kt +++ b/common/src/commonMain/kotlin/org/hisp/dhis/common/screens/others/ChipsScreen.kt @@ -4,6 +4,8 @@ import androidx.compose.foundation.layout.Spacer import androidx.compose.foundation.layout.size import androidx.compose.material.icons.Icons import androidx.compose.material.icons.filled.Search +import androidx.compose.material3.AssistChipDefaults +import androidx.compose.material3.FilterChipDefaults import androidx.compose.material3.Icon import androidx.compose.runtime.Composable import androidx.compose.runtime.getValue @@ -67,17 +69,43 @@ fun ChipsScreen() { SubTitle("Assist Chips") //var isSelected5 by remember { mutableStateOf(false) } - AssistChip(label = "Label", /*state = AssistChipState.PRESSED,*/ onClick = { }) + AssistChip( + label = "Label", + onClick = { } + ) AssistChip( label = "Label", icon = { Icon( imageVector = Icons.Filled.Search, contentDescription = "search icon", + modifier = Modifier + .size(AssistChipDefaults.IconSize) ) - },/*state = AssistChipState.PRESSED,*/ + }, onClick = { } ) Spacer(Modifier.size(Spacing.Spacing18)) + + + SubTitle("Assist Chips With badges") + AssistChip( + label = "Label", + icon = { + Icon( + imageVector = Icons.Filled.Search, + contentDescription = "search icon", + modifier = Modifier + .size(AssistChipDefaults.IconSize) + ) + }, + onClick = {}, + badge = "2" + ) + AssistChip( + label = "Label", + onClick = {}, + badge = "4" + ) } } diff --git a/designsystem/src/commonMain/kotlin/org/hisp/dhis/mobile/ui/designsystem/component/AssistChip.kt b/designsystem/src/commonMain/kotlin/org/hisp/dhis/mobile/ui/designsystem/component/AssistChip.kt index 80e69d2ed..766f9bb60 100644 --- a/designsystem/src/commonMain/kotlin/org/hisp/dhis/mobile/ui/designsystem/component/AssistChip.kt +++ b/designsystem/src/commonMain/kotlin/org/hisp/dhis/mobile/ui/designsystem/component/AssistChip.kt @@ -1,5 +1,7 @@ package org.hisp.dhis.mobile.ui.designsystem.component +import androidx.compose.foundation.interaction.MutableInteractionSource +import androidx.compose.foundation.interaction.collectIsPressedAsState import androidx.compose.foundation.layout.Box import androidx.compose.foundation.layout.offset import androidx.compose.material.ripple.LocalRippleTheme @@ -28,25 +30,34 @@ fun AssistChip( modifier: Modifier = Modifier, label: String, icon: @Composable (() -> Unit)? = null, - //state: AssistChipState, enabled: Boolean = true, onClick: (() -> Unit), badge: String? = null, ) { + + val interactionSource = remember { MutableInteractionSource() } + val isPressed by interactionSource.collectIsPressedAsState() + Box(modifier = modifier) { CompositionLocalProvider(LocalRippleTheme provides Ripple.CustomDHISRippleTheme()) { AssistChip( onClick = { onClick.invoke() }, label = { Text(label, color = TextColor.OnSurfaceVariant) }, enabled = enabled, - colors = AssistChipDefaults.assistChipColors( - containerColor = SurfaceColor.SurfaceBright, - labelColor = SurfaceColor.Container, - leadingIconContentColor = TextColor.OnSurfaceVariant - ), + colors = if (isPressed) { + AssistChipDefaults.assistChipColors( + containerColor = SurfaceColor.Container, + leadingIconContentColor = TextColor.OnSurfaceVariant + ) + } else { + AssistChipDefaults.assistChipColors( + containerColor = SurfaceColor.SurfaceBright, + leadingIconContentColor = TextColor.OnSurfaceVariant + ) + }, border = AssistChipDefaults.assistChipBorder( - borderColor = Outline.Dark, - ), + borderColor = Outline.Dark, + ), leadingIcon = { icon?.invoke() } @@ -64,8 +75,4 @@ fun AssistChip( ) } } -} - -enum class AssistChipState { - PRESSED } \ No newline at end of file From 443f7614669d76a23af7293af2e0aa62e404869b Mon Sep 17 00:00:00 2001 From: "DESKTOP-M49RTHN\\cthuc" Date: Fri, 10 May 2024 11:55:53 +0200 Subject: [PATCH 3/6] updated: [ANDROAPP-6097] Documentation added --- .../mobile/ui/designsystem/component/AssistChip.kt | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/designsystem/src/commonMain/kotlin/org/hisp/dhis/mobile/ui/designsystem/component/AssistChip.kt b/designsystem/src/commonMain/kotlin/org/hisp/dhis/mobile/ui/designsystem/component/AssistChip.kt index 766f9bb60..76475f62b 100644 --- a/designsystem/src/commonMain/kotlin/org/hisp/dhis/mobile/ui/designsystem/component/AssistChip.kt +++ b/designsystem/src/commonMain/kotlin/org/hisp/dhis/mobile/ui/designsystem/component/AssistChip.kt @@ -8,6 +8,7 @@ import androidx.compose.material.ripple.LocalRippleTheme import androidx.compose.material3.AssistChip import androidx.compose.material3.AssistChipDefaults import androidx.compose.material3.ExperimentalMaterial3Api +import androidx.compose.material3.FilterChip import androidx.compose.material3.Text import androidx.compose.runtime.Composable import androidx.compose.runtime.CompositionLocalProvider @@ -24,6 +25,18 @@ import org.hisp.dhis.mobile.ui.designsystem.theme.Ripple import org.hisp.dhis.mobile.ui.designsystem.theme.SurfaceColor import org.hisp.dhis.mobile.ui.designsystem.theme.TextColor +/** + * DHIS2 [AssistChip] button with custom icon slot. + * wraps Material 3 [AssistChip]. + * AssistChips are used to trigger actions. + * @param label: the text to be shown. + * @param icon: custom leading icon to be shown, use AssistChipDefaults in the + * Icon composable modifier to set the size of the icon. + * @param enabled: controls the enabled state. "False" will disabled the component + * @param modifier: optional [Modifier]. + * @param onClick: Will be called when the user taps the chip. + * @param badge: the text to be displayed within the badge. + */ @OptIn(ExperimentalMaterial3Api::class) @Composable fun AssistChip( From 636cfed2489847e452ffe8c698575126c4476330 Mon Sep 17 00:00:00 2001 From: "DESKTOP-M49RTHN\\cthuc" Date: Fri, 10 May 2024 12:09:31 +0200 Subject: [PATCH 4/6] update: [ANDROAPP-6097] code formatted --- .../dhis/common/screens/others/ChipsScreen.kt | 17 +++++++---------- .../ui/designsystem/component/AssistChip.kt | 16 +++++++--------- 2 files changed, 14 insertions(+), 19 deletions(-) diff --git a/common/src/commonMain/kotlin/org/hisp/dhis/common/screens/others/ChipsScreen.kt b/common/src/commonMain/kotlin/org/hisp/dhis/common/screens/others/ChipsScreen.kt index e54453dbc..da5dc682e 100644 --- a/common/src/commonMain/kotlin/org/hisp/dhis/common/screens/others/ChipsScreen.kt +++ b/common/src/commonMain/kotlin/org/hisp/dhis/common/screens/others/ChipsScreen.kt @@ -5,7 +5,6 @@ import androidx.compose.foundation.layout.size import androidx.compose.material.icons.Icons import androidx.compose.material.icons.filled.Search import androidx.compose.material3.AssistChipDefaults -import androidx.compose.material3.FilterChipDefaults import androidx.compose.material3.Icon import androidx.compose.runtime.Composable import androidx.compose.runtime.getValue @@ -66,12 +65,11 @@ fun ChipsScreen() { FilterChip(label = "Label", selected = false, badge = "3") Spacer(Modifier.size(Spacing.Spacing18)) - SubTitle("Assist Chips") - //var isSelected5 by remember { mutableStateOf(false) } + // var isSelected5 by remember { mutableStateOf(false) } AssistChip( label = "Label", - onClick = { } + onClick = { }, ) AssistChip( label = "Label", @@ -80,14 +78,13 @@ fun ChipsScreen() { imageVector = Icons.Filled.Search, contentDescription = "search icon", modifier = Modifier - .size(AssistChipDefaults.IconSize) + .size(AssistChipDefaults.IconSize), ) }, - onClick = { } + onClick = { }, ) Spacer(Modifier.size(Spacing.Spacing18)) - SubTitle("Assist Chips With badges") AssistChip( label = "Label", @@ -96,16 +93,16 @@ fun ChipsScreen() { imageVector = Icons.Filled.Search, contentDescription = "search icon", modifier = Modifier - .size(AssistChipDefaults.IconSize) + .size(AssistChipDefaults.IconSize), ) }, onClick = {}, - badge = "2" + badge = "2", ) AssistChip( label = "Label", onClick = {}, - badge = "4" + badge = "4", ) } } diff --git a/designsystem/src/commonMain/kotlin/org/hisp/dhis/mobile/ui/designsystem/component/AssistChip.kt b/designsystem/src/commonMain/kotlin/org/hisp/dhis/mobile/ui/designsystem/component/AssistChip.kt index 76475f62b..74bbd8677 100644 --- a/designsystem/src/commonMain/kotlin/org/hisp/dhis/mobile/ui/designsystem/component/AssistChip.kt +++ b/designsystem/src/commonMain/kotlin/org/hisp/dhis/mobile/ui/designsystem/component/AssistChip.kt @@ -8,7 +8,6 @@ import androidx.compose.material.ripple.LocalRippleTheme import androidx.compose.material3.AssistChip import androidx.compose.material3.AssistChipDefaults import androidx.compose.material3.ExperimentalMaterial3Api -import androidx.compose.material3.FilterChip import androidx.compose.material3.Text import androidx.compose.runtime.Composable import androidx.compose.runtime.CompositionLocalProvider @@ -47,7 +46,6 @@ fun AssistChip( onClick: (() -> Unit), badge: String? = null, ) { - val interactionSource = remember { MutableInteractionSource() } val isPressed by interactionSource.collectIsPressedAsState() @@ -60,20 +58,20 @@ fun AssistChip( colors = if (isPressed) { AssistChipDefaults.assistChipColors( containerColor = SurfaceColor.Container, - leadingIconContentColor = TextColor.OnSurfaceVariant + leadingIconContentColor = TextColor.OnSurfaceVariant, ) } else { AssistChipDefaults.assistChipColors( containerColor = SurfaceColor.SurfaceBright, - leadingIconContentColor = TextColor.OnSurfaceVariant + leadingIconContentColor = TextColor.OnSurfaceVariant, ) - }, + }, border = AssistChipDefaults.assistChipBorder( - borderColor = Outline.Dark, - ), + borderColor = Outline.Dark, + ), leadingIcon = { icon?.invoke() - } + }, ) } @@ -88,4 +86,4 @@ fun AssistChip( ) } } -} \ No newline at end of file +} From 82f0d68523e5174db03e6622c7e59a285144e8c0 Mon Sep 17 00:00:00 2001 From: "DESKTOP-M49RTHN\\cthuc" Date: Tue, 14 May 2024 14:19:03 +0200 Subject: [PATCH 5/6] add: [ANDROAPP-6097] snapshot test added --- .../mobile/ui/designsystem/AssistChipTest.kt | 45 +++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 designsystem/src/androidUnitTest/kotlin/org/hisp/dhis/mobile/ui/designsystem/AssistChipTest.kt diff --git a/designsystem/src/androidUnitTest/kotlin/org/hisp/dhis/mobile/ui/designsystem/AssistChipTest.kt b/designsystem/src/androidUnitTest/kotlin/org/hisp/dhis/mobile/ui/designsystem/AssistChipTest.kt new file mode 100644 index 000000000..e4f791f5c --- /dev/null +++ b/designsystem/src/androidUnitTest/kotlin/org/hisp/dhis/mobile/ui/designsystem/AssistChipTest.kt @@ -0,0 +1,45 @@ +package org.hisp.dhis.mobile.ui.designsystem + +import androidx.compose.foundation.layout.padding +import androidx.compose.foundation.layout.size +import androidx.compose.material.icons.Icons +import androidx.compose.material.icons.filled.Search +import androidx.compose.material3.AssistChipDefaults +import androidx.compose.material3.Icon +import androidx.compose.ui.Modifier +import org.hisp.dhis.mobile.ui.designsystem.component.AssistChip +import org.hisp.dhis.mobile.ui.designsystem.component.ColumnComponentContainer +import org.hisp.dhis.mobile.ui.designsystem.theme.Spacing +import org.junit.Rule +import org.junit.Test + +class AssistChipTest { + @get:Rule + val paparazzi = paparazzi() + + @Test + fun launchAssistChip() { + paparazzi.snapshot { + ColumnComponentContainer(modifier = Modifier.padding(Spacing.Spacing10)) { + AssistChip( + label = "Label", + icon = { + Icon( + imageVector = Icons.Filled.Search, + contentDescription = "search icon", + modifier = Modifier + .size(AssistChipDefaults.IconSize), + ) + }, + onClick = {}, + badge = "3" + ) + AssistChip( + label = "Label", + onClick = {}, + badge = "3" + ) + } + } + } +} \ No newline at end of file From 08b45f50e31d065e6905417c1ccaa478a5b348c6 Mon Sep 17 00:00:00 2001 From: "DESKTOP-M49RTHN\\cthuc" Date: Tue, 14 May 2024 15:06:30 +0200 Subject: [PATCH 6/6] add: [ANDROAPP-6097] Unit test added --- ...tChipTest.kt => AssistChipSanpshotTest.kt} | 8 ++-- .../ui/designsystem/component/AssistChip.kt | 14 +++++-- .../designsystem/component/AssistChipTest.kt | 39 +++++++++++++++++++ 3 files changed, 54 insertions(+), 7 deletions(-) rename designsystem/src/androidUnitTest/kotlin/org/hisp/dhis/mobile/ui/designsystem/{AssistChipTest.kt => AssistChipSanpshotTest.kt} (93%) create mode 100644 designsystem/src/desktopTest/kotlin/org/hisp/dhis/mobile/ui/designsystem/component/AssistChipTest.kt diff --git a/designsystem/src/androidUnitTest/kotlin/org/hisp/dhis/mobile/ui/designsystem/AssistChipTest.kt b/designsystem/src/androidUnitTest/kotlin/org/hisp/dhis/mobile/ui/designsystem/AssistChipSanpshotTest.kt similarity index 93% rename from designsystem/src/androidUnitTest/kotlin/org/hisp/dhis/mobile/ui/designsystem/AssistChipTest.kt rename to designsystem/src/androidUnitTest/kotlin/org/hisp/dhis/mobile/ui/designsystem/AssistChipSanpshotTest.kt index e4f791f5c..bc2f15d29 100644 --- a/designsystem/src/androidUnitTest/kotlin/org/hisp/dhis/mobile/ui/designsystem/AssistChipTest.kt +++ b/designsystem/src/androidUnitTest/kotlin/org/hisp/dhis/mobile/ui/designsystem/AssistChipSanpshotTest.kt @@ -13,7 +13,7 @@ import org.hisp.dhis.mobile.ui.designsystem.theme.Spacing import org.junit.Rule import org.junit.Test -class AssistChipTest { +class AssistChipSanpshotTest { @get:Rule val paparazzi = paparazzi() @@ -32,14 +32,14 @@ class AssistChipTest { ) }, onClick = {}, - badge = "3" + badge = "3", ) AssistChip( label = "Label", onClick = {}, - badge = "3" + badge = "3", ) } } } -} \ No newline at end of file +} diff --git a/designsystem/src/commonMain/kotlin/org/hisp/dhis/mobile/ui/designsystem/component/AssistChip.kt b/designsystem/src/commonMain/kotlin/org/hisp/dhis/mobile/ui/designsystem/component/AssistChip.kt index 74bbd8677..384a53955 100644 --- a/designsystem/src/commonMain/kotlin/org/hisp/dhis/mobile/ui/designsystem/component/AssistChip.kt +++ b/designsystem/src/commonMain/kotlin/org/hisp/dhis/mobile/ui/designsystem/component/AssistChip.kt @@ -18,6 +18,7 @@ import androidx.compose.runtime.setValue import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier import androidx.compose.ui.layout.onSizeChanged +import androidx.compose.ui.platform.testTag import androidx.compose.ui.unit.IntOffset import org.hisp.dhis.mobile.ui.designsystem.theme.Outline import org.hisp.dhis.mobile.ui.designsystem.theme.Ripple @@ -49,11 +50,17 @@ fun AssistChip( val interactionSource = remember { MutableInteractionSource() } val isPressed by interactionSource.collectIsPressedAsState() - Box(modifier = modifier) { + Box(modifier = Modifier) { CompositionLocalProvider(LocalRippleTheme provides Ripple.CustomDHISRippleTheme()) { AssistChip( onClick = { onClick.invoke() }, - label = { Text(label, color = TextColor.OnSurfaceVariant) }, + label = { + Text( + label, + color = TextColor.OnSurfaceVariant, + ) + }, + modifier = modifier, enabled = enabled, colors = if (isPressed) { AssistChipDefaults.assistChipColors( @@ -81,7 +88,8 @@ fun AssistChip( modifier = Modifier .align(Alignment.TopEnd) .onSizeChanged { offset = IntOffset(it.width / 3, it.height / 3) } - .offset { offset }, + .offset { offset } + .testTag("ASSIST_CHIP_BADGE"), text = badge, ) } diff --git a/designsystem/src/desktopTest/kotlin/org/hisp/dhis/mobile/ui/designsystem/component/AssistChipTest.kt b/designsystem/src/desktopTest/kotlin/org/hisp/dhis/mobile/ui/designsystem/component/AssistChipTest.kt new file mode 100644 index 000000000..a9eda1a57 --- /dev/null +++ b/designsystem/src/desktopTest/kotlin/org/hisp/dhis/mobile/ui/designsystem/component/AssistChipTest.kt @@ -0,0 +1,39 @@ +package org.hisp.dhis.mobile.ui.designsystem.component + +import androidx.compose.foundation.layout.size +import androidx.compose.material.icons.Icons +import androidx.compose.material.icons.filled.Search +import androidx.compose.material3.AssistChipDefaults +import androidx.compose.material3.Icon +import androidx.compose.ui.Modifier +import androidx.compose.ui.test.junit4.createComposeRule +import androidx.compose.ui.test.onNodeWithTag +import org.junit.Rule +import org.junit.Test + +class AssistChipTest { + + @get:Rule + val rule = createComposeRule() + + @Test + fun assistChipShouldDisplayBadges() { + rule.setContent { + AssistChip( + label = "Label", + icon = { + Icon( + imageVector = Icons.Filled.Search, + contentDescription = "search icon", + modifier = Modifier + .size(AssistChipDefaults.IconSize), + ) + }, + onClick = {}, + badge = "2", + ) + } + + rule.onNodeWithTag("ASSIST_CHIP_BADGE").assertExists() + } +}