Skip to content

Commit

Permalink
Merge pull request #181 from tarkalabs/nilesh/tuiTagchanges
Browse files Browse the repository at this point in the history
  • Loading branch information
rajajawahar authored Jan 31, 2024
2 parents c889226 + 480ef3a commit 78fa537
Show file tree
Hide file tree
Showing 3 changed files with 81 additions and 30 deletions.
2 changes: 1 addition & 1 deletion tarkaui/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ publishing {
run {
groupId = "com.tarkalabs"
artifactId = getLibraryArtifactId()
version = "1.0.3"
version = "1.0.4"
artifact("$buildDir/outputs/aar/${getLibraryArtifactId()}-release.aar")
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import androidx.compose.ui.tooling.preview.Preview
import com.tarkalabs.tarkaicons.MoreHorizontal24
import com.tarkalabs.tarkaicons.TarkaIcon
import com.tarkalabs.tarkaicons.TarkaIcons
import com.tarkalabs.tarkaicons.Warning12
import com.tarkalabs.uicomponents.components.TagSize.S
import com.tarkalabs.uicomponents.components.base.IconButtonStyle.GHOST
import com.tarkalabs.uicomponents.components.base.TUIIconButton
Expand Down Expand Up @@ -67,32 +68,34 @@ import com.tarkalabs.uicomponents.theme.TUITheme
TUITag(
title = tag.title,
tagSize = S,
tagType = TagType.LOW,
tags = TUITagTestTags(parentTag = tag.title)
tagType = tag.tagType,
tags = TUITagTestTags(parentTag = tags.primaryTag),
trailingIcon = tag.icon
) { tag.onClick() }
HorizontalSpacer(space = 8)
}
secondaryTag?.let { tag ->
TUITag(
title = tag.title,
tagSize = S,
tagType = TagType.LOW,
tags = TUITagTestTags(parentTag = tag.title)
tagType = tag.tagType,
tags = TUITagTestTags(parentTag = tags.secondaryTag),
trailingIcon = tag.icon
) { tag.onClick() }
HorizontalSpacer(space = 8)
}
teritaryTag?.let { tag ->
TUITag(
title = tag.title,
tagSize = S,
tagType = TagType.LOW,
tags = TUITagTestTags(parentTag = tag.title)
tagType = tag.tagType,
tags = TUITagTestTags(parentTag = tags.trailingIconTag),
trailingIcon = tag.icon
) { tag.onClick() }
HorizontalSpacer(space = 8)
}
}
if ((primaryTag != null || secondaryTag != null || teritaryTag != null) &&
!title.isNullOrEmpty()) {
if ((primaryTag != null || secondaryTag != null || teritaryTag != null) && !title.isNullOrEmpty()) {
VerticalSpacer(space = 8)
}
title?.let {
Expand All @@ -117,10 +120,16 @@ import com.tarkalabs.uicomponents.theme.TUITheme
data class TUICardHeaderTags(
val parentTag: String = "TUICardHeader",
val trailingIconTag: String = "TUICardHeader_trailingIconTag",
val primaryTag: String = "TUICardHeadePrimaryTagr",
val secondaryTag: String = "TUICardHeaderSecondaryTag",
val teritaryTag: String = "TUICardHeaderTeritaryTag",
)

data class TUICardTag(
val title: String, val onClick: () -> Unit
val title: String?,
val tagType: TagType = TagType.defaultStyle,
val icon : TarkaIcon? = null,
val onClick: () -> Unit
)

@Preview @Composable fun TUICardHeaderPreview() {
Expand All @@ -134,12 +143,30 @@ data class TUICardTag(
)
VerticalSpacer(space = 16)
TUICardHeader(
primaryTag = TUICardTag(title = "Tag One", onClick = {}),
primaryTag = TUICardTag(
title = "Tag One", onClick = {}, tagType = TagType.CUSTOM(
bgContentColor = TUITheme.colors.warning,
titleColor = TUITheme.colors.onWarning,
iconTint = TUITheme.colors.onWarning,
),
icon = TarkaIcons.Regular.Warning12
),
trailingIcon = TarkaIcons.Filled.MoreHorizontal24.copy(tintColor = TUITheme.colors.secondary)
)
VerticalSpacer(space = 16)
TUICardHeader(
title = "Pump Repair Pump",
primaryTag = TUICardTag(
title = null, onClick = {}, tagType = TagType.CUSTOM(
bgContentColor = TUITheme.colors.warning,
titleColor = TUITheme.colors.onWarning,
iconTint = TUITheme.colors.onWarning,
),
icon = TarkaIcons.Regular.Warning12
),
trailingIcon = TarkaIcons.Filled.MoreHorizontal24.copy(tintColor = TUITheme.colors.secondary)
)
VerticalSpacer(space = 16)
TUICardHeader(title = "Pump Repair Pump",
primaryTag = TUICardTag(title = "Tag 1", onClick = {}),
secondaryTag = TUICardTag(title = "Tag 2", onClick = {}),
teritaryTag = TUICardTag(title = "Tag 3", onClick = {}),
Expand All @@ -162,8 +189,7 @@ data class TUICardTag(
trailingIcon = TarkaIcons.Filled.MoreHorizontal24.copy(tintColor = TUITheme.colors.secondary)
)
VerticalSpacer(space = 16)
TUICardHeader(
title = "Pump Repair Pump",
TUICardHeader(title = "Pump Repair Pump",
primaryTag = TUICardTag(title = "Tag 1", onClick = {}),
secondaryTag = TUICardTag(title = "Tag 2", onClick = {}),
teritaryTag = TUICardTag(title = "Tag 3", onClick = {}),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ fun TUITag(
tagSize: TagSize = M,
tagType: TagType = TagType.defaultStyle,
leadingIcon: TarkaIcon? = null,
title: String,
title: String?,
trailingIcon: TarkaIcon? = null,
tags: TUITagTestTags = TUITagTestTags(),
onClick: () -> Unit,
Expand Down Expand Up @@ -135,9 +135,9 @@ fun TUITag(

Surface(
modifier = modifier
.clip(RoundedCornerShape(size = 4.dp))
.testTag(tags.parentTag)
.clickable { onClick.invoke() },
.clip(RoundedCornerShape(size = 4.dp))
.testTag(tags.parentTag)
.clickable { onClick.invoke() },
color = backgroundColor
) {
Box(modifier = Modifier.padding(contentPadding)) {
Expand All @@ -154,21 +154,21 @@ fun TUITag(
tint = iconTint ?: Color.Transparent

)
HorizontalSpacer(horizontalSpace)
}

Text(
modifier = Modifier.wrapContentSize(),
text = title,
color = titleColor,
style = titleStyle,
maxLines = 1,
)

trailingIcon?.let {

title?.let {
HorizontalSpacer(horizontalSpace)
Text(
modifier = Modifier.wrapContentSize(),
text = it,
color = titleColor,
style = titleStyle,
maxLines = 1,
)
HorizontalSpacer(horizontalSpace)
}

trailingIcon?.let {
Icon(
modifier = iconModifier,
painter = painterResource(id = trailingIcon.iconRes),
Expand Down Expand Up @@ -203,7 +203,7 @@ sealed class TagType {
}

data class TUITagTestTags(
val parentTag: String = "Tag",
val parentTag: String = "Tag"
)

@Composable
Expand Down Expand Up @@ -533,6 +533,31 @@ fun TUITagPreview() {
tagSize = L,
onClick = {},
)
VerticalSpacer(15)

TUITag(
title = null,
tagType = CUSTOM(
bgContentColor = TUITheme.colors.warning,
titleColor = TUITheme.colors.onWarning,
iconTint = TUITheme.colors.onWarning,
),
tagSize = L,
onClick = {},
trailingIcon = TarkaIcons.Regular.Warning12
)
VerticalSpacer(space = 10)
TUITag(
title = null,
tagType = CUSTOM(
bgContentColor = TUITheme.colors.warning,
titleColor = TUITheme.colors.onWarning,
iconTint = TUITheme.colors.onWarning,
),
tagSize = L,
onClick = {},
leadingIcon = TarkaIcons.Regular.Warning12
)

}

Expand Down

0 comments on commit 78fa537

Please sign in to comment.