feat(ui): image cards with local fallback drawable
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:30:16 +08:00
1 parent 575c26eaf5
commit 5e2eb56658
2 files changed
+34 -8

No files matched your search

@@ -41,6 +41,8 @@ import androidx.compose.runtime.setValue
import androidx.compose.ui.Alignment import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.clip import androidx.compose.ui.draw.clip
import androidx.compose.ui.layout.ContentScale
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.text.font.FontWeight import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.unit.dp import androidx.compose.ui.unit.dp
import coil3.compose.AsyncImage import coil3.compose.AsyncImage
@@ -387,14 +389,29 @@ private fun CartScreen(
@Composable @Composable
private fun ProductCover(url: String) { private fun ProductCover(url: String) {
AsyncImage( if (url.isNotBlank()) {
model = if (url.isNotBlank()) url else "https://picsum.photos/seed/fallback/600/360", AsyncImage(
contentDescription = null, model = url,
modifier = Modifier contentDescription = null,
.fillMaxWidth() modifier = Modifier
.height(150.dp) .fillMaxWidth()
.clip(RoundedCornerShape(12.dp)) .height(150.dp)
) .clip(RoundedCornerShape(12.dp)),
contentScale = ContentScale.Crop,
error = painterResource(id = R.drawable.course_cover_default),
fallback = painterResource(id = R.drawable.course_cover_default)
)
} else {
androidx.compose.foundation.Image(
painter = painterResource(id = R.drawable.course_cover_default),
contentDescription = null,
modifier = Modifier
.fillMaxWidth()
.height(150.dp)
.clip(RoundedCornerShape(12.dp)),
contentScale = ContentScale.Crop
)
}
} }
@Composable @Composable
@@ -0,0 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle">
<corners android:radius="12dp" />
<gradient
android:angle="45"
android:startColor="#4F46E5"
android:centerColor="#0EA5E9"
android:endColor="#06B6D4" />
</shape>