Skip to content

Commit

Permalink
Feat : 업로드한 이미지가 있을 시 와인 노트 목록에 일러스트 대신 표시
Browse files Browse the repository at this point in the history
  • Loading branch information
DongChyeon committed Nov 6, 2024
1 parent 7ba52b0 commit 45e8921
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
)
Expand All @@ -39,6 +41,7 @@ fun TastingNote.toDomain() = TastingNote(
public = this.public,
userNickname = this.userNickname,
noteDate = this.noteDate,
thumbnail = this.thumbnail,
varietal = this.varietal
)

Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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()
) {
Expand All @@ -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)
)
}
}

}
Expand Down

0 comments on commit 45e8921

Please sign in to comment.