Skip to content

Commit f0f5ce4

Browse files
committed
refactor: turn actor tile into a card
1 parent a45c5d4 commit f0f5ce4

File tree

1 file changed

+30
-21
lines changed
  • dataconnect/app/src/main/java/com/google/firebase/example/dataconnect/ui/components

1 file changed

+30
-21
lines changed

dataconnect/app/src/main/java/com/google/firebase/example/dataconnect/ui/components/ActorsList.kt

Lines changed: 30 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package com.google.firebase.example.dataconnect.ui.components
22

33
import androidx.compose.foundation.clickable
44
import androidx.compose.foundation.layout.Column
5+
import androidx.compose.foundation.layout.Row
56
import androidx.compose.foundation.layout.Spacer
67
import androidx.compose.foundation.layout.fillMaxWidth
78
import androidx.compose.foundation.layout.height
@@ -11,6 +12,7 @@ import androidx.compose.foundation.layout.sizeIn
1112
import androidx.compose.foundation.lazy.LazyRow
1213
import androidx.compose.foundation.lazy.items
1314
import androidx.compose.foundation.shape.CircleShape
15+
import androidx.compose.material3.Card
1416
import androidx.compose.material3.MaterialTheme
1517
import androidx.compose.material3.Text
1618
import androidx.compose.runtime.Composable
@@ -22,7 +24,7 @@ import androidx.compose.ui.text.style.TextOverflow
2224
import androidx.compose.ui.unit.dp
2325
import coil.compose.AsyncImage
2426

25-
val ACTOR_CARD_SIZE = 80.dp
27+
val ACTOR_CARD_SIZE = 64.dp
2628

2729
/**
2830
* Used to represent an actor in a list UI
@@ -68,31 +70,38 @@ fun ActorTile(
6870
actor: Actor,
6971
onActorClicked: (actorId: String) -> Unit
7072
) {
71-
Column(
72-
horizontalAlignment = Alignment.CenterHorizontally,
73+
Card(
7374
modifier = Modifier
74-
.sizeIn(
75-
maxWidth = ACTOR_CARD_SIZE,
76-
maxHeight = ACTOR_CARD_SIZE + 32.dp
77-
)
78-
.padding(4.dp)
75+
.padding(end = 8.dp)
7976
.clickable {
8077
onActorClicked(actor.id)
8178
}
8279
) {
83-
AsyncImage(
84-
model = actor.imageUrl,
85-
contentDescription = null,
86-
contentScale = ContentScale.Crop,
80+
Row(
81+
verticalAlignment = Alignment.CenterVertically,
8782
modifier = Modifier
88-
.size(ACTOR_CARD_SIZE)
89-
.clip(CircleShape)
90-
)
91-
Text(
92-
text = actor.name,
93-
style = MaterialTheme.typography.bodyLarge,
94-
maxLines = 1,
95-
overflow = TextOverflow.Ellipsis
96-
)
83+
.sizeIn(
84+
maxWidth = 160.dp,
85+
maxHeight = ACTOR_CARD_SIZE + 16.dp
86+
)
87+
.padding(8.dp)
88+
.fillMaxWidth()
89+
) {
90+
AsyncImage(
91+
model = actor.imageUrl,
92+
contentDescription = null,
93+
contentScale = ContentScale.Crop,
94+
modifier = Modifier
95+
.padding(end = 8.dp)
96+
.size(ACTOR_CARD_SIZE)
97+
.clip(CircleShape)
98+
)
99+
Text(
100+
text = actor.name,
101+
style = MaterialTheme.typography.bodyLarge,
102+
maxLines = 2,
103+
overflow = TextOverflow.Ellipsis,
104+
)
105+
}
97106
}
98107
}

0 commit comments

Comments
 (0)