@@ -2,6 +2,7 @@ package com.paw.key.core.designsystem.component
22
33import androidx.compose.foundation.Image
44import androidx.compose.foundation.background
5+ import androidx.compose.foundation.clickable
56import androidx.compose.foundation.layout.*
67import androidx.compose.foundation.shape.CircleShape
78import androidx.compose.foundation.shape.RoundedCornerShape
@@ -35,22 +36,19 @@ fun CourseCard(
3536 createdAt : String ,
3637 isLiked : Boolean ,
3738 onClickItem : () -> Unit ,
39+ onClickLike : (Boolean ) -> Unit ,
3840 petName : String ,
39- representativeImageUrl : String? = null, // 추가
40- petProfileImageUrl : String? = null, // 추가
41- descriptionTags : List <String > = emptyList(), // 추가
4241 modifier : Modifier = Modifier ,
43- isShared : Boolean = false,
44- isRecord : Boolean = false
42+ representativeImageUrl : String? = null,
43+ petProfileImageUrl : String? = null,
44+ descriptionTags : List <String > = emptyList()
4545) {
46- // 날짜 포맷 변환 함수
4746 fun formatDate (dateString : String ): String {
4847 return try {
49- // "2025-07-15T21:27:03.54498" -> "2025/07/15"
50- val datePart = dateString.split(" T" )[0 ] // "2025-07-15"
51- datePart.replace(" -" , " /" ) // "2025/07/15"
48+ val datePart = dateString.split(" T" )[0 ]
49+ datePart.replace(" -" , " /" )
5250 } catch (e: Exception ) {
53- dateString // 실패하면 원본 반환
51+ dateString
5452 }
5553 }
5654
@@ -62,16 +60,12 @@ fun CourseCard(
6260 .background(Color .White , shape = RoundedCornerShape (20 .dp))
6361 .noRippleClickable { onClickItem() }
6462 ) {
65- // 지도 썸네일
6663 Box (
6764 modifier = Modifier
6865 .fillMaxWidth()
6966 .aspectRatio(343f / 172f )
7067 .clip(RoundedCornerShape (10 .dp))
7168 ) {
72-
73-
74- // 서버 이미지 또는 기본 이미지
7569 if (representativeImageUrl != null ) {
7670 AsyncImage (
7771 model = ImageRequest .Builder (LocalContext .current)
@@ -86,7 +80,6 @@ fun CourseCard(
8680 contentScale = ContentScale .Crop
8781 )
8882 } else {
89- // 기본 이미지
9083 Image (
9184 painter = painterResource(id = R .drawable.dummy_map),
9285 contentDescription = null ,
@@ -98,7 +91,6 @@ fun CourseCard(
9891 )
9992 }
10093
101- // 하단 그라데이션 오버레이
10294 Box (
10395 modifier = Modifier
10496 .fillMaxWidth()
@@ -123,7 +115,6 @@ fun CourseCard(
123115 .align(Alignment .BottomStart )
124116 .padding(start = 16 .dp, end = 16 .dp, bottom = 16 .dp)
125117 ) {
126- // 반려견 프로필 이미지
127118 if (petProfileImageUrl != null ) {
128119 AsyncImage (
129120 model = ImageRequest .Builder (LocalContext .current)
@@ -137,7 +128,6 @@ fun CourseCard(
137128 contentScale = ContentScale .Crop
138129 )
139130 } else {
140- // 기본 프로필 이미지
141131 Box (
142132 modifier = Modifier
143133 .size(40 .dp)
@@ -155,6 +145,7 @@ fun CourseCard(
155145 }
156146
157147 Spacer (modifier = Modifier .width(10 .dp))
148+
158149 Column {
159150 Text (
160151 text = title,
@@ -170,39 +161,40 @@ fun CourseCard(
170161 )
171162 Spacer (modifier = Modifier .width(8 .dp))
172163 Text (
173- text = createdAt,
164+ text = formatDate( createdAt) ,
174165 style = PawKeyTheme .typography.caption12R,
175166 color = PawKeyTheme .colors.gray100
176167 )
177168 }
178169 }
170+
179171 Spacer (modifier = Modifier .weight(1f ))
172+
180173 Icon (
181174 imageVector = if (isLiked)
182175 ImageVector .vectorResource(id = R .drawable.ic_heart_filled)
183176 else
184177 ImageVector .vectorResource(id = R .drawable.ic_heart_default),
185178 contentDescription = " 좋아요" ,
186- tint = Color .Unspecified
179+ tint = Color .Unspecified ,
180+ modifier = Modifier .clickable { onClickLike(! isLiked) } // 클릭하면 외부에 알려줌
187181 )
188182 }
189183 }
190184
191185 Spacer (modifier = Modifier .height(12 .dp))
192186
193- // 서버에서 받은 태그들 사용
194187 ChipRow (
195188 tags = descriptionTags,
196- modifier = Modifier
197- .padding(start = 16 .dp, end = 16 .dp)
189+ modifier = Modifier .padding(horizontal = 16 .dp)
198190 )
199191
200192 Spacer (modifier = Modifier .height(12 .dp))
201193
202194 HorizontalDivider (
203195 color = PawKeyTheme .colors.gray50,
204196 thickness = 1 .dp,
205- modifier = Modifier .padding(start = 16 .dp, end = 16 .dp)
197+ modifier = Modifier .padding(horizontal = 16 .dp)
206198 )
207199 }
208200}
@@ -214,13 +206,14 @@ fun CourseCardPreview() {
214206 CourseCard (
215207 postId = 1 ,
216208 title = " 홍대 주변 좋은 산책 코스" ,
217- createdAt = " 2025/07/16" ,
218- representativeImageUrl = " https://pawkey-server.com/image.jpg" ,
209+ createdAt = " 2025-07-16T21:27:03.54498" ,
210+ isLiked = true ,
211+ onClickItem = {},
212+ onClickLike = {},
219213 petName = " 후추" ,
214+ representativeImageUrl = " https://pawkey-server.com/image.jpg" ,
220215 petProfileImageUrl = " https://pawkey-server.com/profile.jpg" ,
221- descriptionTags = listOf (" 이륜차 거의 없음" , " 물그릇 비치" , " 쉴 곳 있음" ),
222- isLiked = true ,
223- onClickItem = {}
216+ descriptionTags = listOf (" 이륜차 거의 없음" , " 물그릇 비치" , " 쉴 곳 있음" )
224217 )
225218 }
226219}
0 commit comments