Skip to content

Commit

Permalink
Merge pull request #204 from tarkalabs/raja/titlenotavailablestyle
Browse files Browse the repository at this point in the history
feature: Title with NotAvailable Style introduced in TextRow
  • Loading branch information
rajajawahar authored Feb 29, 2024
2 parents 1e19163 + 0679842 commit bff480c
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 17 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.tarkalabs.tarkaui.components

import android.util.Log
import androidx.annotation.StringRes
import androidx.compose.foundation.background
import androidx.compose.foundation.clickable
import androidx.compose.foundation.layout.Box
Expand All @@ -25,10 +26,12 @@ import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.platform.testTag
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.components.TextRowStyle.Title
import com.tarkalabs.tarkaui.components.TextRowStyle.TitleWithDescription
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
Expand Down Expand Up @@ -72,6 +75,7 @@ import com.tarkalabs.tarkaui.theme.TUITheme
* )
*
*/

@Composable fun TUITextRow(
modifier: Modifier = Modifier,
title: String,
Expand All @@ -85,8 +89,8 @@ import com.tarkalabs.tarkaui.theme.TUITheme
onButtonClick: () -> Unit = {},
onInfoIconClick: (() -> Unit)? = {},
onTextRowClick: (() -> Unit)? = null,
menuItemList: List<TUIPopUpMenuItem>? = null,
onMenuItemClick: ((TUIPopUpMenuItem) -> Unit)? = null,
menuItemList: List<TUIPopUpMenu>? = null,
onMenuItemClick: ((TUIPopUpMenu) -> Unit)? = null,
paddingValues: PaddingValues = PaddingValues(),
tags: TUITextRowTags = TUITextRowTags()
) {
Expand All @@ -109,6 +113,10 @@ import com.tarkalabs.tarkaui.theme.TUITheme
is Title -> {
TUITextRowTitle(title)
}

is TitleWithNotAvailable -> {
TUITextRowTitleWithNotAvailable(title, style)
}
}

}
Expand Down Expand Up @@ -164,7 +172,7 @@ import com.tarkalabs.tarkaui.theme.TUITheme
) {
menuItemList?.forEach { item ->
TUIMobileOverlayMenuItem(
title = item.title,
title = stringResource(id = item.title),
isSelected = false,
style = MobileOverlayMenuItemStyle.Title,
onMobileOverlayMenuItemClick = {
Expand All @@ -191,29 +199,42 @@ private fun TUITextRowTitle(title: String) {
)
}

@Composable
private fun TUITextRowTitleWithDescription(title: String, style: TitleWithDescription) {
@Composable private fun TUITextRowTitleWithDescription(title: String, style: TitleWithDescription) {
Text(
text = title,
style = TUITheme.typography.body8,
color = TUITheme.colors.onSurface.copy(alpha = 0.7f)
)
Text(
text = style.description, style = TUITheme.typography.body7, color = TUITheme.colors.onSurface
)
}

@Composable private fun TUITextRowTitleWithNotAvailable(
title: String, style: TitleWithNotAvailable
) {
Text(
text = title,
style = TUITheme.typography.body8,
color = TUITheme.colors.onSurface.copy(alpha = 0.7f)
)
Text(
text = style.description,
text = style.text,
style = TUITheme.typography.body7,
color = TUITheme.colors.onSurface
color = TUITheme.colors.utilityDisabledContent
)
}

sealed class TextRowStyle {
data class TitleWithDescription(val description: String) : TextRowStyle()
data class TitleWithNotAvailable(val text: String) : TextRowStyle()
object Title : TextRowStyle()
}

data class TUIPopUpMenuItem(
val title: String,
val icon: TarkaIcon,
)
interface TUIPopUpMenu {
@get:StringRes val title: Int
val icon: TarkaIcon
}

data class TUITextRowTags(
val parentTag: String = "TUITextRow",
Expand All @@ -226,10 +247,22 @@ data class TUITextRowTags(
@Preview(showBackground = true)
@Composable
fun TUITextRowPreview() {
TUITextRow(title = "Title",
style = Title,
infoIcon = TarkaIcons.Regular.ChevronRight20,
onTextRowClick = {
Log.d("TAG", "TUITextRowPreview: ")
}, onInfoIconClick = null)
Column {

TUITextRow(
title = "Title",
style = Title,
infoIcon = TarkaIcons.Regular.ChevronRight20,
onTextRowClick = {
Log.d("TAG", "TUITextRowPreview: ")
},
onInfoIconClick = null
)

TUITextRow(
title = "Title", style = TitleWithNotAvailable("Not Available"), onTextRowClick = {
Log.d("TAG", "TUITextRowPreview: ")
}, onInfoIconClick = null
)
}
}
1 change: 1 addition & 0 deletions tarka-ui/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<resources>
<string name="image_thumbnail">Image ThumbNail</string>
<string name="video_thumbnail">Video ThumbNail</string>
<string name="not_availble">Not Available</string>
</resources>

0 comments on commit bff480c

Please sign in to comment.