mirror of
https://github.com/Aviortheking/Neo-Store.git
synced 2025-04-24 03:42:15 +00:00
Update: Complete repository item's layout and add listeners
This commit is contained in:
parent
39f3ab1277
commit
9bf819f319
@ -16,7 +16,7 @@ import androidx.compose.runtime.Composable
|
|||||||
import androidx.compose.runtime.getValue
|
import androidx.compose.runtime.getValue
|
||||||
import androidx.compose.ui.Alignment
|
import androidx.compose.ui.Alignment
|
||||||
import androidx.compose.ui.Modifier
|
import androidx.compose.ui.Modifier
|
||||||
import androidx.compose.ui.text.font.FontWeight
|
import androidx.compose.ui.draw.clip
|
||||||
import androidx.compose.ui.text.style.TextOverflow
|
import androidx.compose.ui.text.style.TextOverflow
|
||||||
import androidx.compose.ui.tooling.preview.Preview
|
import androidx.compose.ui.tooling.preview.Preview
|
||||||
import androidx.compose.ui.unit.dp
|
import androidx.compose.ui.unit.dp
|
||||||
@ -28,27 +28,29 @@ import com.looker.droidify.ui.compose.theme.LocalShapes
|
|||||||
fun RepositoryItem(
|
fun RepositoryItem(
|
||||||
modifier: Modifier = Modifier,
|
modifier: Modifier = Modifier,
|
||||||
repository: Repository,
|
repository: Repository,
|
||||||
onClick: () -> Unit,
|
onClick: (Repository) -> Unit = {},
|
||||||
onLongClick: (() -> Unit) = {}
|
onLongClick: (Repository) -> Unit = {}
|
||||||
) {
|
) {
|
||||||
val backgroundColor by animateColorAsState(
|
val backgroundColor by animateColorAsState(
|
||||||
targetValue = if (repository.enabled) MaterialTheme.colorScheme.surfaceVariant
|
targetValue = if (repository.enabled) MaterialTheme.colorScheme.primaryContainer
|
||||||
else MaterialTheme.colorScheme.background
|
else MaterialTheme.colorScheme.background
|
||||||
)
|
)
|
||||||
|
|
||||||
Surface(
|
Surface(
|
||||||
modifier = modifier
|
modifier = modifier
|
||||||
|
.padding(horizontal = 8.dp, vertical = 4.dp)
|
||||||
.fillMaxWidth()
|
.fillMaxWidth()
|
||||||
|
.clip(RoundedCornerShape(LocalShapes.current.large))
|
||||||
.combinedClickable(
|
.combinedClickable(
|
||||||
onClick = onClick,
|
onClick = { onClick(repository) },
|
||||||
onLongClick = onLongClick
|
onLongClick = { onLongClick(repository) }
|
||||||
),
|
),
|
||||||
color = backgroundColor,
|
color = backgroundColor,
|
||||||
shape = RoundedCornerShape(LocalShapes.current.large)
|
shape = RoundedCornerShape(LocalShapes.current.large)
|
||||||
) {
|
) {
|
||||||
Row(
|
Row(
|
||||||
modifier = Modifier.padding(
|
modifier = Modifier.padding(
|
||||||
horizontal = 8.dp,
|
horizontal = 12.dp,
|
||||||
vertical = 16.dp
|
vertical = 16.dp
|
||||||
),
|
),
|
||||||
horizontalArrangement = Arrangement.SpaceBetween,
|
horizontalArrangement = Arrangement.SpaceBetween,
|
||||||
@ -75,20 +77,21 @@ private fun RepositoryItemText(
|
|||||||
repositoryDescription: String?
|
repositoryDescription: String?
|
||||||
) {
|
) {
|
||||||
Column(
|
Column(
|
||||||
modifier = modifier,
|
modifier = modifier.fillMaxWidth(0.9f),
|
||||||
horizontalAlignment = Alignment.Start,
|
horizontalAlignment = Alignment.Start,
|
||||||
verticalArrangement = Arrangement.spacedBy(16.dp)
|
verticalArrangement = Arrangement.spacedBy(8.dp)
|
||||||
) {
|
) {
|
||||||
Text(
|
Text(
|
||||||
text = repositoryName,
|
text = repositoryName,
|
||||||
style = MaterialTheme.typography.titleMedium,
|
style = MaterialTheme.typography.titleMedium,
|
||||||
fontWeight = FontWeight.SemiBold
|
maxLines = 1
|
||||||
)
|
)
|
||||||
repositoryDescription?.let {
|
repositoryDescription?.let {
|
||||||
Text(
|
Text(
|
||||||
text = it,
|
text = it,
|
||||||
style = MaterialTheme.typography.bodyMedium,
|
style = MaterialTheme.typography.bodyMedium,
|
||||||
overflow = TextOverflow.Ellipsis
|
overflow = TextOverflow.Ellipsis,
|
||||||
|
maxLines = 1
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user