Skip to content

Commit 92560b0

Browse files
authored
merge #108 -> develop
[Mod/#108] ux edit
2 parents df18885 + f58f80f commit 92560b0

File tree

10 files changed

+465
-188
lines changed

10 files changed

+465
-188
lines changed

app/src/main/java/com/paw/key/core/designsystem/component/CourseCard.kt

Lines changed: 22 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package com.paw.key.core.designsystem.component
22

33
import androidx.compose.foundation.Image
44
import androidx.compose.foundation.background
5+
import androidx.compose.foundation.clickable
56
import androidx.compose.foundation.layout.*
67
import androidx.compose.foundation.shape.CircleShape
78
import 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
}

app/src/main/java/com/paw/key/presentation/ui/course/entire/tab/map/List/TabListScreen.kt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,9 @@ fun TabListScreen(
132132
petProfileImageUrl = post.writer.petProfileImageUrl,
133133
descriptionTags = post.descriptionTags,
134134
isLiked = post.isLike,
135+
onClickLike = { isLiked ->
136+
viewModel.toggleLike(post.postId, isLiked)
137+
},
135138
onClickItem = { navigateToDetail() }
136139
)
137140
}

app/src/main/java/com/paw/key/presentation/ui/course/entire/tab/map/List/viewmodel/TapListViewModel.kt

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,38 @@ class TapListViewModel @Inject constructor(
9090
_state.update { it.copy(selectedSortOption = option) }
9191
}
9292

93+
fun toggleLike(postId: Int, isLiked: Boolean) {
94+
viewModelScope.launch {
95+
_state.update { currentState ->
96+
val updatedPostsResult = currentState.postsResult?.let { postsResult ->
97+
postsResult.copy(
98+
posts = postsResult.posts.map { post ->
99+
if (post.postId == postId) {
100+
post.copy(isLike = isLiked)
101+
} else {
102+
post
103+
}
104+
}
105+
)
106+
}
107+
108+
// val updatedCourseList = currentState.courseList.map { course ->
109+
// if (course.postId == postId) {
110+
// // ArchivedListEntity의 실제 프로퍼티명에 맞게 수정
111+
// // isLiked 대신 isLike 또는 liked 등의 프로퍼티를 확인하고 사용
112+
// course.copy(isLike = isLiked) // 또는 course.copy(liked = isLiked)
113+
// } else {
114+
// course
115+
// }
116+
// }
117+
118+
currentState.copy(
119+
postsResult = updatedPostsResult,
120+
// courseList = updatedCourseList
121+
)
122+
}
123+
}
124+
}
93125
fun updateMood(option: String) {
94126
_state.update {
95127
it.copy(

0 commit comments

Comments
 (0)