From 45e892145d2a1965fc71032062e7d60741bbf6f0 Mon Sep 17 00:00:00 2001 From: dongchyeon Date: Thu, 7 Nov 2024 01:40:06 +0900 Subject: [PATCH] =?UTF-8?q?Feat=20:=20=EC=97=85=EB=A1=9C=EB=93=9C=ED=95=9C?= =?UTF-8?q?=20=EC=9D=B4=EB=AF=B8=EC=A7=80=EA=B0=80=20=EC=9E=88=EC=9D=84=20?= =?UTF-8?q?=EC=8B=9C=20=EC=99=80=EC=9D=B8=20=EB=85=B8=ED=8A=B8=20=EB=AA=A9?= =?UTF-8?q?=EB=A1=9D=EC=97=90=20=EC=9D=BC=EB=9F=AC=EC=8A=A4=ED=8A=B8=20?= =?UTF-8?q?=EB=8C=80=EC=8B=A0=20=ED=91=9C=EC=8B=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../network/model/response/TastingNote.kt | 3 + .../teamwiney/notecollection/NoteScreen.kt | 1 + .../notecollection/components/NoteWineCard.kt | 61 ++++++++++++++----- 3 files changed, 50 insertions(+), 15 deletions(-) diff --git a/data/src/main/java/com/teamwiney/data/network/model/response/TastingNote.kt b/data/src/main/java/com/teamwiney/data/network/model/response/TastingNote.kt index c7b9946..dbb6c95 100644 --- a/data/src/main/java/com/teamwiney/data/network/model/response/TastingNote.kt +++ b/data/src/main/java/com/teamwiney/data/network/model/response/TastingNote.kt @@ -24,6 +24,8 @@ data class TastingNote( val userNickname: String, @SerializedName("noteDate") val noteDate: String, + @SerializedName("thumbnail") + val thumbnail: String?, @SerializedName("public") val public: Boolean ) @@ -39,6 +41,7 @@ fun TastingNote.toDomain() = TastingNote( public = this.public, userNickname = this.userNickname, noteDate = this.noteDate, + thumbnail = this.thumbnail, varietal = this.varietal ) diff --git a/feature/note/src/main/java/com/teamwiney/notecollection/NoteScreen.kt b/feature/note/src/main/java/com/teamwiney/notecollection/NoteScreen.kt index 0b2796c..66916b1 100644 --- a/feature/note/src/main/java/com/teamwiney/notecollection/NoteScreen.kt +++ b/feature/note/src/main/java/com/teamwiney/notecollection/NoteScreen.kt @@ -174,6 +174,7 @@ fun NoteScreen( name = it.name, origin = it.country, starRating = it.starRating, + thumbnail = it.thumbnail, onClick = { val isShared = false appState.navigate("${NoteDestinations.NOTE_DETAIL}?id=${it.id}&isShared=$isShared") diff --git a/feature/note/src/main/java/com/teamwiney/notecollection/components/NoteWineCard.kt b/feature/note/src/main/java/com/teamwiney/notecollection/components/NoteWineCard.kt index 9bf0644..2f23aa4 100644 --- a/feature/note/src/main/java/com/teamwiney/notecollection/components/NoteWineCard.kt +++ b/feature/note/src/main/java/com/teamwiney/notecollection/components/NoteWineCard.kt @@ -28,7 +28,9 @@ import androidx.compose.ui.draw.clip import androidx.compose.ui.geometry.Offset import androidx.compose.ui.graphics.Brush import androidx.compose.ui.graphics.Color +import androidx.compose.ui.graphics.FilterQuality import androidx.compose.ui.layout.ContentScale +import androidx.compose.ui.platform.LocalContext import androidx.compose.ui.res.painterResource import androidx.compose.ui.text.TextStyle import androidx.compose.ui.text.buildAnnotatedString @@ -37,6 +39,8 @@ import androidx.compose.ui.text.style.TextOverflow import androidx.compose.ui.tooling.preview.Preview import androidx.compose.ui.unit.dp import androidx.compose.ui.unit.sp +import coil.compose.AsyncImage +import coil.request.ImageRequest import com.teamwiney.core.common.model.WineType import com.teamwiney.core.common.model.WineType.Companion.convertToNoteType import com.teamwiney.core.design.R @@ -79,8 +83,11 @@ fun NoteWineCard( name: String, origin: String, starRating: Int? = null, + thumbnail: String? = null, onClick: () -> Unit, ) { + val context = LocalContext.current + val (wineName, image, borderColor, gradientCircleColor, circleColor, cardColor) = when (color) { WineType.RED.type -> CardProperties( color, @@ -163,12 +170,33 @@ fun NoteWineCard( ) .background(WineyTheme.colors.background_1) ) { - NoteCardSurface( - modifier = Modifier.fillMaxSize(), - gradientCircleColor = gradientCircleColor, - cardBackgroundAlpha = cardBackgroundAlpha, - circleColor = circleColor - ) + if (thumbnail != null) { + Box { + AsyncImage( + model = ImageRequest.Builder(context) + .data(thumbnail) + .build(), + contentDescription = "NOTE_IMG_URL", + filterQuality = FilterQuality.Low, + contentScale = ContentScale.Crop, + ) + + Box( + modifier = Modifier.background( + color = WineyTheme.colors.gray_900.copy( + alpha = 0.2f + ), + ).matchParentSize() + ) + } + } else { + NoteCardSurface( + modifier = Modifier.fillMaxSize(), + gradientCircleColor = gradientCircleColor, + cardBackgroundAlpha = cardBackgroundAlpha, + circleColor = circleColor + ) + } Column( modifier = Modifier.fillMaxSize() ) { @@ -182,15 +210,18 @@ fun NoteWineCard( ), color = WineyTheme.colors.gray_50, ) - Image( - painter = painterResource(id = image), - contentDescription = "IMG_SPARKL_WINE", - contentScale = ContentScale.FillHeight, - modifier = Modifier - .fillMaxHeight(if (color == WineType.RED.type) 0.9f else 1f) - .align(Alignment.CenterHorizontally) - .offset(y = -10.dp) - ) + + if (thumbnail == null) { + Image( + painter = painterResource(id = image), + contentDescription = "IMG_WINE", + contentScale = ContentScale.FillHeight, + modifier = Modifier + .fillMaxHeight(if (color == WineType.RED.type) 0.9f else 1f) + .align(Alignment.CenterHorizontally) + .offset(y = -10.dp) + ) + } } }