From 0679842ca1bcffb92546988d7432027c65c0ff66 Mon Sep 17 00:00:00 2001 From: Raja Jawahar Date: Wed, 28 Feb 2024 14:44:47 +0530 Subject: [PATCH] TUIPopUpMenu style introduced --- .../tarkaui/components/TUITextRow.kt | 67 ++++++++++++++----- tarka-ui/src/main/res/values/strings.xml | 1 + 2 files changed, 51 insertions(+), 17 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 0251f861..073cdbf1 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,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 @@ -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 @@ -72,6 +75,7 @@ import com.tarkalabs.tarkaui.theme.TUITheme * ) * */ + @Composable fun TUITextRow( modifier: Modifier = Modifier, title: String, @@ -85,8 +89,8 @@ import com.tarkalabs.tarkaui.theme.TUITheme onButtonClick: () -> Unit = {}, onInfoIconClick: (() -> Unit)? = {}, onTextRowClick: (() -> Unit)? = null, - menuItemList: List? = null, - onMenuItemClick: ((TUIPopUpMenuItem) -> Unit)? = null, + menuItemList: List? = null, + onMenuItemClick: ((TUIPopUpMenu) -> Unit)? = null, paddingValues: PaddingValues = PaddingValues(), tags: TUITextRowTags = TUITextRowTags() ) { @@ -109,6 +113,10 @@ import com.tarkalabs.tarkaui.theme.TUITheme is Title -> { TUITextRowTitle(title) } + + is TitleWithNotAvailable -> { + TUITextRowTitleWithNotAvailable(title, style) + } } } @@ -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 = { @@ -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", @@ -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 + ) + } } \ No newline at end of file diff --git a/tarka-ui/src/main/res/values/strings.xml b/tarka-ui/src/main/res/values/strings.xml index 90fa1767..b4d8a0e2 100644 --- a/tarka-ui/src/main/res/values/strings.xml +++ b/tarka-ui/src/main/res/values/strings.xml @@ -1,4 +1,5 @@ Image ThumbNail Video ThumbNail + Not Available \ No newline at end of file