diff --git a/src/main/kotlin/com/looker/droidify/ui/compose/pages/app_detail/components/LinkType.kt b/src/main/kotlin/com/looker/droidify/ui/compose/pages/app_detail/components/LinkItem.kt similarity index 61% rename from src/main/kotlin/com/looker/droidify/ui/compose/pages/app_detail/components/LinkType.kt rename to src/main/kotlin/com/looker/droidify/ui/compose/pages/app_detail/components/LinkItem.kt index 24f8b5a3..960c0c1c 100644 --- a/src/main/kotlin/com/looker/droidify/ui/compose/pages/app_detail/components/LinkType.kt +++ b/src/main/kotlin/com/looker/droidify/ui/compose/pages/app_detail/components/LinkItem.kt @@ -1,58 +1,63 @@ package com.looker.droidify.ui.compose.pages.app_detail.components -import androidx.annotation.DrawableRes -import androidx.annotation.StringRes -import androidx.compose.foundation.background -import androidx.compose.foundation.clickable -import androidx.compose.foundation.layout.* +import android.net.Uri +import androidx.compose.foundation.ExperimentalFoundationApi +import androidx.compose.foundation.combinedClickable +import androidx.compose.foundation.layout.Arrangement +import androidx.compose.foundation.layout.Column +import androidx.compose.foundation.layout.Row +import androidx.compose.foundation.layout.fillMaxWidth +import androidx.compose.foundation.layout.padding +import androidx.compose.foundation.layout.wrapContentSize import androidx.compose.material3.Icon import androidx.compose.material3.MaterialTheme 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.res.painterResource -import androidx.compose.ui.res.stringResource import androidx.compose.ui.text.style.TextOverflow import androidx.compose.ui.tooling.preview.Preview import androidx.compose.ui.unit.dp import com.looker.droidify.R +import com.looker.droidify.entity.LinkType import com.looker.droidify.ui.compose.theme.AppTheme +@OptIn(ExperimentalFoundationApi::class) @Composable fun LinkItem( modifier: Modifier = Modifier, linkType: LinkType, - onClick: (String) -> Unit = {} + onClick: (Uri?) -> Unit = {}, + onLongClick: (Uri?) -> Unit = {} ) { Row( modifier = modifier .fillMaxWidth() - .clickable { onClick(linkType.text) } - .clip(MaterialTheme.shapes.large) - .background(MaterialTheme.colorScheme.surface) - .padding(8.dp), + .combinedClickable( + onClick = { onClick(linkType.link) }, + onLongClick = { onLongClick(linkType.link) }) + .padding(vertical = 8.dp), horizontalArrangement = Arrangement.spacedBy(8.dp), verticalAlignment = Alignment.CenterVertically ) { Icon( painter = painterResource(id = linkType.iconResId), - contentDescription = stringResource(id = linkType.titleResId) + contentDescription = linkType.title ) Column( modifier = Modifier.wrapContentSize() ) { Text( - text = stringResource(id = linkType.titleResId), + text = linkType.title, softWrap = true, overflow = TextOverflow.Ellipsis, maxLines = 1, style = MaterialTheme.typography.titleMedium ) Text( - text = linkType.text, + text = linkType.link.toString(), style = MaterialTheme.typography.bodySmall, overflow = TextOverflow.Ellipsis, maxLines = 2, @@ -62,16 +67,12 @@ fun LinkItem( } } -data class LinkType( - @DrawableRes val iconResId: Int, @StringRes val titleResId: Int, val text: String = "" -) - @Preview @Composable fun LinkItemPreview() { AppTheme(blackTheme = false) { LinkItem( - linkType = LinkType(R.drawable.ic_email, R.string.author_email, "Looker") + linkType = LinkType(R.drawable.ic_email, "R.string.author_email") ) } } \ No newline at end of file