Skip to content

Commit

Permalink
Adding comments documentation for the TUIChip
Browse files Browse the repository at this point in the history
  • Loading branch information
Younes-Charfaoui committed Jul 10, 2023
1 parent 9df6bb6 commit 12fcce4
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ class UIComponentListActivity : ComponentActivity() {
TUICheckBoxRow(
checked = status.value,
enabled = true,
icon = TarkaIcons.CheckMark,
icon = TarkaIcons.CheckMark20Filled,
title = "TUICheckBoxRow",
style = TitleWithDescription("Description")
) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package com.tarkalabs.uicomponents.components

import android.util.Log
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.wrapContentWidth
import androidx.compose.material3.AssistChip
Expand Down Expand Up @@ -33,15 +34,47 @@ import com.tarkalabs.uicomponents.models.TarkaIcon
import com.tarkalabs.uicomponents.models.TarkaIcons
import com.tarkalabs.uicomponents.theme.TUITheme


/**
* Represents a generic chip type. The ChipType superclass serves as a generic base for the different chip types in the sealed class hierarchy.
*/
sealed class ChipType {
/**
* Represents an assist chip type for TUIChip.
*
* @param content The optional leading content for the chip.
*/
data class Assist(val content: ChipLeadingContent? = null) : ChipType()

/**
* Represents an input chip type for TUIChip.
*
* @param content The optional leading content for the chip.
* @param showTrailingDismiss Whether to show a dismiss icon as a trailing icon.
* @param containerColor The color of the chip's container. If null, the default color from the theme will be used.
*/
data class Input(
val content: ChipLeadingContent? = null,
val showTrailingDismiss: Boolean = false,
val containerColor : Color? = null
) : ChipType()

/**
* Represents a suggestion chip type for TUIChip.
*
* @param image The optional image for the chip.
*/
data class Suggestion(val image: TarkaIcon? = null) : ChipType()

/**
* Represents a filter chip type for TUIChip.
*
* @param selected Whether the filter is selected.
* @param showLeadingCheck Whether to show a check icon as a leading icon.
* @param showTrailingDismiss Whether to show a dismiss icon as a trailing icon.
* @param showTrailingCaret Whether to show a caret icon as a trailing icon.
* @param badgeCount The badge count to display on the chip.
*/
data class Filter(
val selected: Boolean = false,
val showLeadingCheck: Boolean = false,
Expand Down Expand Up @@ -202,8 +235,19 @@ data class TUIChipTags(
)

@Preview @Composable fun TUIChipPreview() {
TUIChip(type = ChipType.Input(showTrailingDismiss = true,
containerColor = TUITheme.colors.surfaceVariant),
label = "Something",
onClick = { Log.e("TAG_CHIP", "TUIChipPreview: TAG_CLICKED") })

Column {
TUIChip(
type = ChipType.Input(showTrailingDismiss = true, containerColor = TUITheme.colors.surfaceVariant),
label = "Something",
onClick = { Log.e("TAG_CHIP", "TUIChipPreview: TAG_CLICKED") }
)

TUIChip(
type = ChipType.Assist(),
label = "Something",
onClick = { Log.e("TAG_CHIP", "TUIChipPreview: TAG_CLICKED") }
)
}

}

0 comments on commit 12fcce4

Please sign in to comment.