feat(ui): show product images in list/detail
Build Android app / Build (push) Has been cancelled
Build iOS app / Build (push) Has been cancelled
Template Cleanup / Template Cleanup (push) Has been cancelled

This commit is contained in:
xiaobai committed 2026-03-04 16:25:06 +08:00
1 parent 035d396eaf
commit 575c26eaf5
3 files changed
+24 -7

No files matched your search

@@ -43,6 +43,7 @@ import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.clip
import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.unit.dp
import coil3.compose.AsyncImage
import com.example.minishop.cart.CartItem
import com.example.minishop.cart.CartRepository
import com.example.minishop.checkout.CheckoutService
@@ -247,6 +248,7 @@ private fun ProductListScreen(
items(products) { p ->
ElevatedCard(onClick = { onClick(p) }, modifier = Modifier.fillMaxWidth()) {
Column(Modifier.padding(12.dp), verticalArrangement = Arrangement.spacedBy(8.dp)) {
ProductCover(p.imageUrl)
Row(Modifier.fillMaxWidth(), horizontalArrangement = Arrangement.SpaceBetween) {
Text(p.title, style = MaterialTheme.typography.titleMedium, fontWeight = FontWeight.SemiBold)
PriceTag(p.price)
@@ -297,6 +299,7 @@ private fun ProductDetailScreen(
shape = RoundedCornerShape(14.dp)
) {
Column(Modifier.padding(14.dp), verticalArrangement = Arrangement.spacedBy(10.dp)) {
ProductCover(product.imageUrl)
Text(product.title, style = MaterialTheme.typography.headlineSmall, fontWeight = FontWeight.Bold)
PriceTag(product.price)
Text(product.description)
@@ -382,6 +385,18 @@ private fun CartScreen(
}
}
@Composable
private fun ProductCover(url: String) {
AsyncImage(
model = if (url.isNotBlank()) url else "https://picsum.photos/seed/fallback/600/360",
contentDescription = null,
modifier = Modifier
.fillMaxWidth()
.height(150.dp)
.clip(RoundedCornerShape(12.dp))
)
}
@Composable
private fun SmallOpButton(text: String, onClick: () -> Unit) {
OutlinedButton(onClick = onClick) {