Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import androidx.compose.ui.graphics.vector.ImageVector
import androidx.compose.ui.layout.ContentScale
import androidx.compose.ui.platform.LocalConfiguration
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.res.vectorResource
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
Expand All @@ -32,20 +33,15 @@ fun CourseCard(
postId: Long,
title: String,
createdAt: String,
representativeImageUrl: String,
petName: String,
petProfileImageUrl: String,
descriptionTags: List<String>,
isLiked: Boolean,
onClickItem: () -> Unit,
modifier: Modifier = Modifier
petName: String,
modifier: Modifier = Modifier,
date: String,
representativeImageUrl: String? = null, // 추가
petProfileImageUrl: String? = null, // 추가
descriptionTags: List<String> = emptyList(), // 추가
onCLickItem: () -> Unit,
modifier: Modifier = Modifier,
isShared: Boolean = false,
isRecord: Boolean = false
) {
Expand Down Expand Up @@ -175,8 +171,8 @@ fun CourseCard(
color = Color.White
)
Spacer(modifier = Modifier.width(8.dp))

Text(
text = createdAt,
text = formatDate(date), // 포맷된 날짜 사용
style = PawKeyTheme.typography.caption12R,
color = PawKeyTheme.colors.gray100
Expand Down Expand Up @@ -227,7 +223,11 @@ fun CourseCardPreview() {
petProfileImageUrl = "https://pawkey-server.com/profile.jpg",
descriptionTags = listOf("이륜차 거의 없음", "물그릇 비치", "쉴 곳 있음"),
isLiked = true,
onClickItem = {}
onCLickItem = {},
onClickItem = {},
date = "2025/07/16",
isShared = true,
isRecord = true,
)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,9 @@ import com.paw.key.domain.model.entity.archivedlist.WriterEntity
import kotlinx.serialization.SerialName
import kotlinx.serialization.Serializable

@Serializable
data class ArchivedListResponseDto(
@SerialName("code")
val code: String,
@SerialName("message")
val message: String,
@SerialName("data")
val data: ArchivedListResponseDataDto
)

@Serializable
data class ArchivedListResponseDataDto(
@SerialName("posts")
val posts: List<ArchivedDto>
) {
fun toEntity() = ArchivedListPostsEntity(
Expand All @@ -38,7 +29,7 @@ data class ArchivedDto(
@SerialName("representativeImageUrl")
val representativeImageUrl: String? = null,
@SerialName("routeId")
val routeId: String,
val routeId: Int,
@SerialName("writer")
val writer: WriterDto,
@SerialName("descriptionTags")
Expand All @@ -50,6 +41,7 @@ data class ArchivedDto(
isLiked = isLike,
title = title,
representativeImageUrl = representativeImageUrl ?: "",
routeId = routeId.toLong(),
writer = listOf(writer.toEntity()),
descriptionTags = descriptionTags
)
Expand All @@ -64,7 +56,7 @@ data class WriterDto(
@SerialName("petProfileImageUrl")
val petProfileImageUrl: String
) {
fun toEntity() = WriterEntity (
fun toEntity() = WriterEntity(
userId = userId.toLong(),
petName = petName,
petProfileImageUrl = petProfileImageUrl
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@ class ArchivedListDataSource @Inject constructor(
private val archivedListService: ArchivedListService
) {
suspend fun getArchivedList(userId: Int) = archivedListService.getArchivedList(userId)
}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package com.paw.key.data.service

import com.paw.key.data.dto.response.ArchivedListResponseDataDto
import com.paw.key.data.dto.response.ArchivedListResponseDto
import com.paw.key.data.dto.response.BaseResponse
import retrofit2.http.GET
import retrofit2.http.Header
Expand All @@ -10,6 +9,5 @@ interface ArchivedListService {
@GET("users/me/posts")
suspend fun getArchivedList(
@Header("X-USER-ID") userId: Int
): ArchivedListResponseDto

}
): BaseResponse<ArchivedListResponseDataDto>
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,11 @@ data class ArchivedListEntity(
val isLiked: Boolean,
val title: String,
val representativeImageUrl: String,
val routeId: Long,
val writer: List<WriterEntity>,
val descriptionTags: List<String>
)

data class WriterEntity(
val userId: Long,
val petName: String,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,8 +132,14 @@ fun TabListScreen(
petProfileImageUrl = post.writer.petProfileImageUrl,
descriptionTags = post.descriptionTags,
isRecord = post.isLike,
postId = post.postId.toLong(),
createdAt = post.createdAt,
isLiked = post.isLike,
onCLickItem = {
navigateToDetail()
},
onClickItem = {
//showBottomSheet = true
}
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,10 @@ fun HomeScreen(
descriptionTags = listOf("이륜차 거의 없음", "물그릇 비치", "쉴 곳 있음"),
onClickItem = {},
isLiked = true,
postId = 1L
postId = 1L,
onCLickItem = {},
isRecord = true,
date = "년도/월/일"
)
Spacer(modifier = Modifier.height(48.dp))
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,9 @@ fun ArchivedCourseListScreen(
petProfileImageUrl = item.writer.first().petProfileImageUrl,
descriptionTags = item.descriptionTags,
isLiked = item.isLiked,
onClickItem = navigateNext
onClickItem = navigateNext,
onCLickItem = navigateNext,
date = item.createdAt
)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,10 @@ fun SavedCourseListScreen(
petProfileImageUrl = item.writer.first().petProfileImageUrl,
descriptionTags = item.descriptionTags,
isLiked = item.isLiked,
onClickItem = navigateNext
onClickItem = navigateNext,
onCLickItem = {},
isRecord = true,
date = "년도/월/일"
)
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
package com.paw.key.presentation.ui.mypage.state

import androidx.compose.runtime.Immutable
import com.paw.key.domain.model.entity.archivedlist.ArchivedListEntity
import com.paw.key.domain.model.entity.savedlist.SavedListEntity

@Immutable
data class SavedListState(
val courseList: List<SavedListEntity> = emptyList()
val courseList: List<ArchivedListEntity> = emptyList()
)

//@Immutable
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import android.util.Log
import androidx.lifecycle.ViewModel
import androidx.lifecycle.viewModelScope
import com.paw.key.core.designsystem.component.CourseCard
import com.paw.key.domain.repository.ArchivedListRepository
import com.paw.key.domain.repository.SavedListRepository
import com.paw.key.presentation.ui.mypage.state.MyPageSideEffect
import com.paw.key.presentation.ui.mypage.state.PetProfileSideEffect.NavigateNext
Expand All @@ -20,7 +21,7 @@ import javax.inject.Inject

@HiltViewModel
class SavedListViewModel @Inject constructor(
private val savedListRepository: SavedListRepository
private val savedListRepository: ArchivedListRepository
) : ViewModel() {

private val _state = MutableStateFlow(SavedListState())
Expand All @@ -31,15 +32,12 @@ class SavedListViewModel @Inject constructor(

fun getSavedList(userId: Int) {
viewModelScope.launch {
savedListRepository.getSavedList(userId)
savedListRepository.getArchivedList(userId)
.onSuccess { result ->
Log.d("SavedListViewModel", "저장한 게시물 불러오기 성공: $result")
Log.d("SavedListViewModel", "총 ${result.size}개")

_sideEffect.emit(SavedListSideEffect.ShowSnackBar("SavedList 불러오기 성공 (${result.size}개)"))

_state.update {
it.copy(courseList = result)
it.copy(
courseList = result.posts
)
}
}
.onFailure { e ->
Expand Down