From 21bb3a1d735e9d3b39721bdf712471389c675e31 Mon Sep 17 00:00:00 2001 From: Raja Jawahar Date: Sat, 9 Mar 2024 12:42:52 +0530 Subject: [PATCH 1/7] MaxWidth set to MinimumWidth --- .../tarkaui/components/TUITextRow.kt | 36 ++++++++++++++----- 1 file changed, 27 insertions(+), 9 deletions(-) diff --git a/tarka-ui/src/main/java/com/tarkalabs/tarkaui/components/TUITextRow.kt b/tarka-ui/src/main/java/com/tarkalabs/tarkaui/components/TUITextRow.kt index 26b509f2..c3389453 100644 --- a/tarka-ui/src/main/java/com/tarkalabs/tarkaui/components/TUITextRow.kt +++ b/tarka-ui/src/main/java/com/tarkalabs/tarkaui/components/TUITextRow.kt @@ -1,8 +1,8 @@ package com.tarkalabs.tarkaui.components import android.util.Log -import androidx.compose.foundation.Canvas import androidx.annotation.StringRes +import androidx.compose.foundation.Canvas import androidx.compose.foundation.background import androidx.compose.foundation.clickable import androidx.compose.foundation.layout.Box @@ -32,6 +32,7 @@ import androidx.compose.ui.res.painterResource import androidx.compose.ui.res.stringResource import androidx.compose.ui.tooling.preview.Preview import androidx.compose.ui.unit.dp +import com.tarkalabs.tarkaui.R import com.tarkalabs.tarkaui.components.TextRowStyle.DateStyle import com.tarkalabs.tarkaui.components.TextRowStyle.Title import com.tarkalabs.tarkaui.components.TextRowStyle.TitleWithDescription @@ -39,9 +40,11 @@ import com.tarkalabs.tarkaui.components.TextRowStyle.TitleWithNotAvailable import com.tarkalabs.tarkaui.components.base.IconButtonStyle.GHOST import com.tarkalabs.tarkaui.components.base.TUIIconButton import com.tarkalabs.tarkaui.components.base.TUIIconButtonTags +import com.tarkalabs.tarkaui.icons.Call24 import com.tarkalabs.tarkaui.icons.Circle24 import com.tarkalabs.tarkaui.icons.TarkaIcon import com.tarkalabs.tarkaui.icons.TarkaIcons +import com.tarkalabs.tarkaui.icons.Voicemail24 import com.tarkalabs.tarkaui.theme.TUITheme /** @@ -188,7 +191,7 @@ import com.tarkalabs.tarkaui.theme.TUITheme expanded = false onMenuItemClick?.invoke(item) }, - modifier = Modifier.width(160.dp), + modifier = Modifier.defaultMinSize(minWidth = 160.dp), leadingContent = MobileOverlayMenuItemLeadingContentType.Icon(item.icon) ) } @@ -330,14 +333,29 @@ data class TUITextRowTags( ) @Preview(showBackground = true) -@Composable -fun TUITextRowPreview() { +@Composable fun TUITextRowPreview() { TUITextRow( title = "Duration", style = DateStyle( - "Jan 20 3000 friday march 32", - "Jan 20 3000 friday march 32" - ), onTextRowClick = { - Log.d("TAG", "TUITextRowPreview: ") - }, onInfoIconClick = null + "Jan 20 3000 friday march 32", "Jan 20 3000 friday march 32" + ), onTextRowClick = { + Log.d("TAG", "TUITextRowPreview: ") + }, onInfoIconClick = null ) +} + +enum class PersonMenu : TUIPopUpMenu { + + CALL { + override val icon: TarkaIcon + get() = TarkaIcons.Regular.Call24 + override val title: Int + get() = R.string.image_thumbnail + }, + + EMAIL { + override val icon: TarkaIcon + get() = TarkaIcons.Regular.Voicemail24 + override val title: Int + get() = R.string.video_thumbnail + } } \ No newline at end of file From ee6c9cfd41d3f19ce90e5f4c8ec7ed089a87d67b Mon Sep 17 00:00:00 2001 From: Raja Jawahar Date: Sat, 9 Mar 2024 12:44:46 +0530 Subject: [PATCH 2/7] TUINavigationRow Size updated properly --- .../java/com/tarkalabs/tarkaui/components/TUINavigationRows.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tarka-ui/src/main/java/com/tarkalabs/tarkaui/components/TUINavigationRows.kt b/tarka-ui/src/main/java/com/tarkalabs/tarkaui/components/TUINavigationRows.kt index b91b4862..925a87d1 100644 --- a/tarka-ui/src/main/java/com/tarkalabs/tarkaui/components/TUINavigationRows.kt +++ b/tarka-ui/src/main/java/com/tarkalabs/tarkaui/components/TUINavigationRows.kt @@ -60,8 +60,8 @@ import com.tarkalabs.tarkaui.theme.TUITheme ) { Row(modifier = modifier .clickable { onClick() } - .padding(8.dp) .defaultMinSize(minHeight = 40.dp) + .padding(8.dp) .testTag(tags.parentTag), verticalAlignment = Alignment.CenterVertically) { if (leadingIcon != null) Icon( modifier = Modifier From 3e49c377fd265810401242f64bdf49655487a16a Mon Sep 17 00:00:00 2001 From: Raja Jawahar Date: Sat, 9 Mar 2024 12:45:03 +0530 Subject: [PATCH 3/7] Additional Style updated in TUIBadge --- .../tarkalabs/tarkaui/components/TUIChip.kt | 18 +++-- .../tarkaui/components/base/TUIBadge.kt | 76 +++++++++++++++---- .../components/card/TUISelectionCard.kt | 11 +-- 3 files changed, 78 insertions(+), 27 deletions(-) diff --git a/tarka-ui/src/main/java/com/tarkalabs/tarkaui/components/TUIChip.kt b/tarka-ui/src/main/java/com/tarkalabs/tarkaui/components/TUIChip.kt index 1fc2aaa5..d3884f36 100644 --- a/tarka-ui/src/main/java/com/tarkalabs/tarkaui/components/TUIChip.kt +++ b/tarka-ui/src/main/java/com/tarkalabs/tarkaui/components/TUIChip.kt @@ -27,22 +27,23 @@ import androidx.compose.ui.res.painterResource import androidx.compose.ui.tooling.preview.Preview import androidx.compose.ui.unit.Dp import androidx.compose.ui.unit.dp -import com.tarkalabs.tarkaui.icons.ArrowSort20 -import com.tarkalabs.tarkaui.icons.CaretDown20 -import com.tarkalabs.tarkaui.icons.Checkmark20 -import com.tarkalabs.tarkaui.icons.Dismiss20 -import com.tarkalabs.tarkaui.icons.TarkaIcon -import com.tarkalabs.tarkaui.icons.TarkaIcons import com.tarkalabs.tarkaui.components.ChipLeadingContent.Icon import com.tarkalabs.tarkaui.components.ChipLeadingContent.Image import com.tarkalabs.tarkaui.components.ChipType.Filter import com.tarkalabs.tarkaui.components.base.AvatarSize.XS import com.tarkalabs.tarkaui.components.base.AvatarType +import com.tarkalabs.tarkaui.components.base.BadgeStyle import com.tarkalabs.tarkaui.components.base.IconButtonSize.M import com.tarkalabs.tarkaui.components.base.IconButtonStyle.GHOST import com.tarkalabs.tarkaui.components.base.TUIAvatar import com.tarkalabs.tarkaui.components.base.TUIBadge import com.tarkalabs.tarkaui.components.base.TUIIconButton +import com.tarkalabs.tarkaui.icons.ArrowSort20 +import com.tarkalabs.tarkaui.icons.CaretDown20 +import com.tarkalabs.tarkaui.icons.Checkmark20 +import com.tarkalabs.tarkaui.icons.Dismiss20 +import com.tarkalabs.tarkaui.icons.TarkaIcon +import com.tarkalabs.tarkaui.icons.TarkaIcons import com.tarkalabs.tarkaui.theme.TUITheme /** @@ -240,7 +241,10 @@ enum class ChipSize(val size: Dp) { } } else null) if (type.badgeCount != null) { - TUIBadge(count = type.badgeCount, modifier = Modifier.align(Alignment.TopEnd)) + TUIBadge( + style = BadgeStyle.Count(count = type.badgeCount), + modifier = Modifier.align(Alignment.TopEnd) + ) } } } diff --git a/tarka-ui/src/main/java/com/tarkalabs/tarkaui/components/base/TUIBadge.kt b/tarka-ui/src/main/java/com/tarkalabs/tarkaui/components/base/TUIBadge.kt index eb369d8a..220cec76 100644 --- a/tarka-ui/src/main/java/com/tarkalabs/tarkaui/components/base/TUIBadge.kt +++ b/tarka-ui/src/main/java/com/tarkalabs/tarkaui/components/base/TUIBadge.kt @@ -1,18 +1,33 @@ package com.tarkalabs.tarkaui.components.base +import androidx.compose.foundation.background +import androidx.compose.foundation.layout.Box +import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.defaultMinSize +import androidx.compose.foundation.layout.padding +import androidx.compose.foundation.layout.wrapContentSize +import androidx.compose.foundation.shape.CircleShape import androidx.compose.material3.ExperimentalMaterial3Api +import androidx.compose.material3.Icon import androidx.compose.material3.Text import androidx.compose.runtime.Composable +import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier +import androidx.compose.ui.draw.clip import androidx.compose.ui.graphics.Color import androidx.compose.ui.platform.testTag +import androidx.compose.ui.res.painterResource +import androidx.compose.ui.text.style.TextAlign import androidx.compose.ui.tooling.preview.Preview import androidx.compose.ui.unit.Dp import androidx.compose.ui.unit.dp +import com.tarkalabs.tarkaui.components.VerticalSpacer import com.tarkalabs.tarkaui.components.base.BadgeSize.L import com.tarkalabs.tarkaui.components.base.BadgeSize.M import com.tarkalabs.tarkaui.components.base.BadgeSize.S +import com.tarkalabs.tarkaui.icons.ErrorCircle12 +import com.tarkalabs.tarkaui.icons.TarkaIcon +import com.tarkalabs.tarkaui.icons.TarkaIcons import com.tarkalabs.tarkaui.theme.TUITheme enum class BadgeSize(val size: Dp) { @@ -21,6 +36,11 @@ enum class BadgeSize(val size: Dp) { L(24.dp) } +sealed class BadgeStyle { + data class Icon(val icon: TarkaIcon) : BadgeStyle() + data class Count(val count: Int = 0) : BadgeStyle() +} + /** * Below TUIBadge() defines a reusable composable function which can be used to create an Badge with various sizes which takes couple of parameters * @param count The Count to be displayed on the badge. @@ -31,34 +51,52 @@ enum class BadgeSize(val size: Dp) { * TUIBadge(count = 3,badgeSize = M) * */ -@OptIn(ExperimentalMaterial3Api::class) @Composable fun TUIBadge( modifier: Modifier = Modifier, - count: Int? = null, + style: BadgeStyle = BadgeStyle.Count(), badgeSize: BadgeSize = M, tags: TUIBadgeTags = TUIBadgeTags(), color: Color = TUITheme.colors.error ) { - when (badgeSize) { - S -> 0.dp - M -> 4.dp - L -> 8.dp - } + val textStyle = when (badgeSize) { S, M -> TUITheme.typography.button8 L -> TUITheme.typography.button7 } - androidx.compose.material3.Badge( - containerColor = color, + + Box( modifier = modifier .defaultMinSize(minWidth = badgeSize.size, minHeight = badgeSize.size) .testTag(tags.parentTag) + .clip(CircleShape) + .background(color), + contentAlignment = Alignment.Center, ) { - if (count != null) Text( - text = count.toString(), - style = textStyle, - color = TUITheme.colors.onTertiary, - ) + when (style) { + is BadgeStyle.Count -> { + if (style.count != 0) { + Text( + modifier = Modifier + .padding(horizontal = 2.dp) + .align(Alignment.Center), + textAlign = TextAlign.Center, + text = style.count.toString(), + style = textStyle, + color = TUITheme.colors.onTertiary, + ) + } + } + + is BadgeStyle.Icon -> { + Icon( + modifier = Modifier + .defaultMinSize(minHeight = 10.dp, minWidth = 10.dp) + .wrapContentSize(), + painter = painterResource(id = style.icon.iconRes), + contentDescription = style.icon.contentDescription + ) + } + } } } @@ -67,5 +105,13 @@ data class TUIBadgeTags( ) @Preview(showBackground = true) @Composable fun BadgePreview() { - TUIBadge(count = 40, badgeSize = M) + Column(horizontalAlignment = Alignment.CenterHorizontally) { + TUIBadge(style = BadgeStyle.Count(4), badgeSize = M) + VerticalSpacer(space = 8) + TUIBadge( + style = BadgeStyle.Icon(TarkaIcons.Regular.ErrorCircle12), + badgeSize = M, + color = TUITheme.colors.warning + ) + } } diff --git a/tarka-ui/src/main/java/com/tarkalabs/tarkaui/components/card/TUISelectionCard.kt b/tarka-ui/src/main/java/com/tarkalabs/tarkaui/components/card/TUISelectionCard.kt index 9f2ba258..ceb16d0c 100644 --- a/tarka-ui/src/main/java/com/tarkalabs/tarkaui/components/card/TUISelectionCard.kt +++ b/tarka-ui/src/main/java/com/tarkalabs/tarkaui/components/card/TUISelectionCard.kt @@ -22,16 +22,17 @@ import androidx.compose.ui.semantics.semantics import androidx.compose.ui.semantics.testTagsAsResourceId import androidx.compose.ui.tooling.preview.Preview import androidx.compose.ui.unit.dp +import com.tarkalabs.tarkaui.components.VerticalSpacer +import com.tarkalabs.tarkaui.components.base.BadgeStyle +import com.tarkalabs.tarkaui.components.base.TUIBadge +import com.tarkalabs.tarkaui.components.card.SecondaryDetailsStyle.ERROR +import com.tarkalabs.tarkaui.components.card.SecondaryDetailsStyle.NORMAL import com.tarkalabs.tarkaui.icons.CheckmarkCircle24 import com.tarkalabs.tarkaui.icons.ChevronRight24 import com.tarkalabs.tarkaui.icons.Person24 import com.tarkalabs.tarkaui.icons.TarkaIcon import com.tarkalabs.tarkaui.icons.TarkaIcons.Filled import com.tarkalabs.tarkaui.icons.TarkaIcons.Regular -import com.tarkalabs.tarkaui.components.VerticalSpacer -import com.tarkalabs.tarkaui.components.card.SecondaryDetailsStyle.ERROR -import com.tarkalabs.tarkaui.components.card.SecondaryDetailsStyle.NORMAL -import com.tarkalabs.tarkaui.components.base.TUIBadge import com.tarkalabs.tarkaui.theme.TUITheme enum class SecondaryDetailsStyle { @@ -157,7 +158,7 @@ fun TUISelectionCard( .align(Alignment.CenterVertically) .padding(start = 16.dp) .testTag(tags.badgeTag), - count = badgeCount, + style = BadgeStyle.Count(count = badgeCount), color = TUITheme.colors.tertiary ) } From 0e10704194ce172217b512c4ff10f3b86c0e9f81 Mon Sep 17 00:00:00 2001 From: Raja Jawahar Date: Sat, 9 Mar 2024 13:24:41 +0530 Subject: [PATCH 4/7] Additional spacing added in trailing side for TUIMobileOverLayMenuItem --- .../components/TUIMobileOverlayMenuItem.kt | 23 ++++++++++++------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/tarka-ui/src/main/java/com/tarkalabs/tarkaui/components/TUIMobileOverlayMenuItem.kt b/tarka-ui/src/main/java/com/tarkalabs/tarkaui/components/TUIMobileOverlayMenuItem.kt index 23455e7e..7b1fbbb8 100644 --- a/tarka-ui/src/main/java/com/tarkalabs/tarkaui/components/TUIMobileOverlayMenuItem.kt +++ b/tarka-ui/src/main/java/com/tarkalabs/tarkaui/components/TUIMobileOverlayMenuItem.kt @@ -26,10 +26,6 @@ import androidx.compose.ui.platform.testTag import androidx.compose.ui.res.painterResource import androidx.compose.ui.tooling.preview.Preview import androidx.compose.ui.unit.dp -import com.tarkalabs.tarkaui.icons.AddCircle24 -import com.tarkalabs.tarkaui.icons.ChevronRight20 -import com.tarkalabs.tarkaui.icons.TarkaIcon -import com.tarkalabs.tarkaui.icons.TarkaIcons import com.tarkalabs.tarkaui.components.MobileOverlayMenuItemLeadingContentType.StatusIndicator import com.tarkalabs.tarkaui.components.MobileOverlayMenuItemStyle.Title import com.tarkalabs.tarkaui.components.MobileOverlayMenuItemStyle.TitleWithDescription @@ -37,6 +33,10 @@ import com.tarkalabs.tarkaui.components.MobileOverlayMenuItemTrailingContentType import com.tarkalabs.tarkaui.components.MobileOverlayMenuItemTrailingContentType.SubMobileOverlayMenu import com.tarkalabs.tarkaui.extentions.maxHeight import com.tarkalabs.tarkaui.extentions.maxWidth +import com.tarkalabs.tarkaui.icons.AddCircle24 +import com.tarkalabs.tarkaui.icons.ChevronRight20 +import com.tarkalabs.tarkaui.icons.TarkaIcon +import com.tarkalabs.tarkaui.icons.TarkaIcons import com.tarkalabs.tarkaui.theme.TUITheme sealed class MobileOverlayMenuItemLeadingContentType { @@ -84,7 +84,9 @@ sealed class MobileOverlayMenuItemStyle { val leadingIconLambda: @Composable () -> Unit = if (leadingContent != null && style is Title) { { - val leadingContentModifier = Modifier.padding(start = 16.dp, end = 8.dp).testTag(tags.leadingContentTag) + val leadingContentModifier = Modifier + .padding(start = 16.dp, end = 8.dp) + .testTag(tags.leadingContentTag) when (leadingContent) { is MobileOverlayMenuItemLeadingContentType.Icon -> Icon( painter = painterResource(id = leadingContent.icon.iconRes), @@ -161,9 +163,11 @@ sealed class MobileOverlayMenuItemStyle { horizontalArrangement = Arrangement.SpaceBetween, ) { leadingIconLambda() - Column(modifier = Modifier - .weight(1f) - .padding(vertical = 8.dp)) { + Column( + modifier = Modifier + .weight(1f) + .padding(vertical = 8.dp) + ) { when (style) { Title -> TUIMobileOverlayMenuItemTitle(title) is TitleWithDescription -> TUIMenuItemTitleWithDescription( @@ -171,6 +175,9 @@ sealed class MobileOverlayMenuItemStyle { ) } } + if (trailingContentLambda == null) { + HorizontalSpacer(space = 8) + } trailingContentLambda?.invoke() } } From b2565fc5010075e15fa9c5089769af70ecdde652 Mon Sep 17 00:00:00 2001 From: Raja Jawahar Date: Tue, 12 Mar 2024 11:20:00 +0530 Subject: [PATCH 5/7] Version bumped to 1.1.7 --- tarka-ui/build.gradle.kts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tarka-ui/build.gradle.kts b/tarka-ui/build.gradle.kts index 0dc300d2..276a705a 100644 --- a/tarka-ui/build.gradle.kts +++ b/tarka-ui/build.gradle.kts @@ -66,7 +66,7 @@ publishing { run { groupId = "com.tarkalabs" artifactId = getLibraryArtifactId() - version = "1.1.6" + version = "1.1.7" artifact("$buildDir/outputs/aar/tarka-ui-release.aar") } } From a89822b2be2ab668713cd3c767de62a3e35a92b7 Mon Sep 17 00:00:00 2001 From: Mahendran Date: Tue, 12 Mar 2024 15:02:50 +0530 Subject: [PATCH 6/7] compilation issues resolved --- .../java/com/tarkalabs/uicomponents/TUIEmailFieldTest.kt | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/tarka-ui/src/androidTest/java/com/tarkalabs/uicomponents/TUIEmailFieldTest.kt b/tarka-ui/src/androidTest/java/com/tarkalabs/uicomponents/TUIEmailFieldTest.kt index 787275de..f0a1d770 100644 --- a/tarka-ui/src/androidTest/java/com/tarkalabs/uicomponents/TUIEmailFieldTest.kt +++ b/tarka-ui/src/androidTest/java/com/tarkalabs/uicomponents/TUIEmailFieldTest.kt @@ -42,9 +42,7 @@ class TUIEmailFieldTest { title = "To", emailAddressList = emailList, trailingIcon = Regular.AddCircle24, - onItemRemoved = { position -> - - }, + onItemRemoved = {}, trailingIconClick = { }, @@ -83,9 +81,7 @@ class TUIEmailFieldTest { title = "To", emailAddressList = emailList, trailingIcon = Regular.AddCircle24, - onItemRemoved = { position -> - - }, + onItemRemoved = {}, trailingIconClick = trailingIconClick, onItemAdd = { emailList.add(it) From fdbde9143b03596a629588158765afa2500e6b4e Mon Sep 17 00:00:00 2001 From: Mahendran Date: Tue, 12 Mar 2024 15:06:17 +0530 Subject: [PATCH 7/7] ScreenShot Test & UI Test Included for TUIBadge latest changes. --- ...st__testBadgeWithCount_darkTheme_false.png | Bin 0 -> 1597 bytes ...est__testBadgeWithCount_darkTheme_true.png | Bin 0 -> 1357 bytes ...est__testBadgeWithIcon_darkTheme_false.png | Bin 0 -> 2483 bytes ...Test__testBadgeWithIcon_darkTheme_true.png | Bin 0 -> 2287 bytes .../tarkalabs/uicomponents/TUIBadgeTest.kt | 33 ++++++++++++++++-- .../screenshots/TUIBadgeScreenShotTest.kt | 10 +++--- .../tarkaui/components/base/TUIBadge.kt | 2 ++ 7 files changed, 38 insertions(+), 7 deletions(-) create mode 100644 tarka-ui/screenshots/debug/screenshots-default/com.tarkalabs.uicomponents.screenshots.TUIBadgeScreenShotTest__testBadgeWithCount_darkTheme_false.png create mode 100644 tarka-ui/screenshots/debug/screenshots-default/com.tarkalabs.uicomponents.screenshots.TUIBadgeScreenShotTest__testBadgeWithCount_darkTheme_true.png create mode 100644 tarka-ui/screenshots/debug/screenshots-default/com.tarkalabs.uicomponents.screenshots.TUIBadgeScreenShotTest__testBadgeWithIcon_darkTheme_false.png create mode 100644 tarka-ui/screenshots/debug/screenshots-default/com.tarkalabs.uicomponents.screenshots.TUIBadgeScreenShotTest__testBadgeWithIcon_darkTheme_true.png diff --git a/tarka-ui/screenshots/debug/screenshots-default/com.tarkalabs.uicomponents.screenshots.TUIBadgeScreenShotTest__testBadgeWithCount_darkTheme_false.png b/tarka-ui/screenshots/debug/screenshots-default/com.tarkalabs.uicomponents.screenshots.TUIBadgeScreenShotTest__testBadgeWithCount_darkTheme_false.png new file mode 100644 index 0000000000000000000000000000000000000000..e291aecc945586840b31adec663d0628ca75325f GIT binary patch literal 1597 zcmV-D2EzG?P)Px#1am@3R0s$N2z&@+hyVZu=Sf6CR9J=0nSD$XcNoXNzoUiru7bP{!773xVGJE{ zAx?1#>RiN^I5in_iQ;^j;>&dCTq4FSM5dYBoNhCkjG%MVsLR}BFVRVYFeh`02y8H^ zD56kGE2UQorQH4~J-EI|uchEOY0}?w&+mCYdG7aicjW$qMvmh+a2y9-9ESld5C9+q z_A*|-1-7yZU3K?hZfrtNn-0B3BLIM+X-GnYAyq~rAbtXvnQ5qOsSaHy!Ev>f->*4QbSOsb`;(OFeH+-5NvB0d+z@pbXBn^6H2FC6E zKvW)m(Pb+rTUzeXni-b49Q5Q#{WB9l+u0vbGj}nn(q2PlYC2RKx1+0GC78XTi!&gf zLSFeEuTUri^y-^_=5&(kd&l9w@KmLpdd-BlzxS6-L7nk6_HJf49wDC3~l_KQz zMWS-CH!47Rdf>3XgUi z#_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index e8930b71..02a1b33d 100644 --- a/tarka-ui/src/androidTest/java/com/tarkalabs/uicomponents/TUIBadgeTest.kt +++ b/tarka-ui/src/androidTest/java/com/tarkalabs/uicomponents/TUIBadgeTest.kt @@ -3,9 +3,14 @@ package com.tarkalabs.uicomponents import androidx.compose.ui.test.assertIsDisplayed import androidx.compose.ui.test.junit4.createComposeRule import androidx.compose.ui.test.onNodeWithTag +import androidx.compose.ui.test.onNodeWithText import com.tarkalabs.tarkaui.components.base.BadgeSize.L +import com.tarkalabs.tarkaui.components.base.BadgeStyle import com.tarkalabs.tarkaui.components.base.TUIBadge import com.tarkalabs.tarkaui.components.base.TUIBadgeTags +import com.tarkalabs.tarkaui.icons.Symbols16 +import com.tarkalabs.tarkaui.icons.TarkaIcon +import com.tarkalabs.tarkaui.icons.TarkaIcons import org.junit.Rule import org.junit.Test @@ -14,12 +19,34 @@ class TUIBadgeTest { private val tags = TUIBadgeTags(parentTag = "testTag") - @Test fun badge_Displayed() { + @Test fun text_badge_Displayed() { composeTestRule.setContent { TUIBadge( - badgeSize = L, tags = tags, count = 299 + badgeSize = L, tags = tags, style = BadgeStyle.Count(299) ) } - composeTestRule.onNodeWithTag(tags.parentTag).assertIsDisplayed() + composeTestRule.onNodeWithText("299").assertIsDisplayed() + composeTestRule.onNodeWithTag(tags.iconTag).assertDoesNotExist() } + + + @Test fun icon_badge_Displayed() { + composeTestRule.setContent { + TUIBadge( + badgeSize = L, tags = tags, style = BadgeStyle.Icon(TarkaIcons.Regular.Symbols16) + ) + } + composeTestRule.onNodeWithTag(tags.iconTag).assertIsDisplayed() + } + + @Test fun empty_badge_Displayed() { + composeTestRule.setContent { + TUIBadge( + badgeSize = L, tags = tags + ) + } + composeTestRule.onNodeWithTag(tags.iconTag).assertDoesNotExist() + composeTestRule.onNodeWithTag(tags.parentTag).assertExists() + } + } \ No newline at end of file diff --git a/tarka-ui/src/androidTest/java/com/tarkalabs/uicomponents/screenshots/TUIBadgeScreenShotTest.kt b/tarka-ui/src/androidTest/java/com/tarkalabs/uicomponents/screenshots/TUIBadgeScreenShotTest.kt index a8356441..b1098ce9 100644 --- a/tarka-ui/src/androidTest/java/com/tarkalabs/uicomponents/screenshots/TUIBadgeScreenShotTest.kt +++ b/tarka-ui/src/androidTest/java/com/tarkalabs/uicomponents/screenshots/TUIBadgeScreenShotTest.kt @@ -1,8 +1,10 @@ package com.tarkalabs.uicomponents.screenshots import com.tarkalabs.tarkaui.components.base.BadgeSize.M -import com.tarkalabs.tarkaui.components.base.BadgeSize.S +import com.tarkalabs.tarkaui.components.base.BadgeStyle import com.tarkalabs.tarkaui.components.base.TUIBadge +import com.tarkalabs.tarkaui.icons.Info20 +import com.tarkalabs.tarkaui.icons.TarkaIcons import org.junit.Test import org.junit.runner.RunWith import org.junit.runners.Parameterized @@ -27,10 +29,10 @@ open class TUIBadgeScreenShotTest( } @Test fun test_badge_with_count() = compareScreenshotFor(darkTheme, "_testBadgeWithCount_$testName") { - TUIBadge(count = 2, badgeSize = M) + TUIBadge(style = BadgeStyle.Count(2), badgeSize = M) } - @Test fun test_badge_with_out_count() = compareScreenshotFor(darkTheme, "_testBadgeWithoutCount_$testName") { - TUIBadge(badgeSize = S) + @Test fun test_badge_with_icon() = compareScreenshotFor(darkTheme, "_testBadgeWithIcon_$testName") { + TUIBadge(style = BadgeStyle.Icon(TarkaIcons.Regular.Info20), badgeSize = M) } } \ No newline at end of file diff --git a/tarka-ui/src/main/java/com/tarkalabs/tarkaui/components/base/TUIBadge.kt b/tarka-ui/src/main/java/com/tarkalabs/tarkaui/components/base/TUIBadge.kt index 220cec76..e7fbe34b 100644 --- a/tarka-ui/src/main/java/com/tarkalabs/tarkaui/components/base/TUIBadge.kt +++ b/tarka-ui/src/main/java/com/tarkalabs/tarkaui/components/base/TUIBadge.kt @@ -90,6 +90,7 @@ sealed class BadgeStyle { is BadgeStyle.Icon -> { Icon( modifier = Modifier + .testTag(tags.iconTag) .defaultMinSize(minHeight = 10.dp, minWidth = 10.dp) .wrapContentSize(), painter = painterResource(id = style.icon.iconRes), @@ -102,6 +103,7 @@ sealed class BadgeStyle { data class TUIBadgeTags( val parentTag: String = "TUIBadge", + val iconTag: String = "BadgeIcon", ) @Preview(showBackground = true) @Composable fun BadgePreview() {