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 @@ -34,9 +34,10 @@ fun CourseCard(
postId: Int,
title: String,
createdAt: String,
isLiked: Boolean,
isLiked: Boolean? = null, // 저장한 루트에서만 사용
isPublic: Boolean? = null, // 기록한 루트에서만 사용
onClickItem: () -> Unit,
onClickLike: (Boolean) -> Unit,
onClickLike: ((Boolean) -> Unit)? = null, // null이면 클릭 불가
petName: String,
modifier: Modifier = Modifier,
representativeImageUrl: String? = null,
Expand Down Expand Up @@ -127,21 +128,6 @@ fun CourseCard(
.clip(CircleShape),
contentScale = ContentScale.Crop
)
} else {
Box(
modifier = Modifier
.size(40.dp)
.clip(CircleShape)
.background(PawKeyTheme.colors.gray200),
contentAlignment = Alignment.Center
) {
Icon(
imageVector = ImageVector.vectorResource(id = R.drawable.ic_heart_default),
contentDescription = null,
tint = PawKeyTheme.colors.gray400,
modifier = Modifier.size(20.dp)
)
}
}

Spacer(modifier = Modifier.width(10.dp))
Expand Down Expand Up @@ -170,15 +156,32 @@ fun CourseCard(

Spacer(modifier = Modifier.weight(1f))

Icon(
imageVector = if (isLiked)
ImageVector.vectorResource(id = R.drawable.ic_heart_filled)
else
ImageVector.vectorResource(id = R.drawable.ic_heart_default),
contentDescription = "좋아요",
tint = Color.Unspecified,
modifier = Modifier.clickable { onClickLike(!isLiked) } //클릭하면 외부에 알려줌
)
when {
isLiked != null -> {
Icon(
imageVector = if (isLiked)
ImageVector.vectorResource(id = R.drawable.ic_heart_filled)
else
ImageVector.vectorResource(id = R.drawable.ic_heart_default),
contentDescription = "좋아요",
tint = Color.Unspecified,
modifier = Modifier.clickable {
onClickLike?.invoke(!isLiked)
}
)
}

isPublic != null -> {
Icon(
imageVector = if (isPublic)
ImageVector.vectorResource(id = R.drawable.ic_eye_filled_valid)
else
ImageVector.vectorResource(id = R.drawable.ic_eye_filled_invalid),
contentDescription = "공개여부",
tint = Color.Unspecified
)
}
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@ data class ArchivedDto(
val createdAt: String,
@SerialName("isLike")
val isLike: Boolean,
@SerialName("isPublic")
val isPublic: Boolean,
@SerialName("isMine")
val isMine: Boolean,
@SerialName("title")
val title: String,
@SerialName("representativeImageUrl")
Expand All @@ -43,7 +47,9 @@ data class ArchivedDto(
representativeImageUrl = representativeImageUrl ?: "",
routeId = routeId.toLong(),
writer = listOf(writer.toEntity()),
descriptionTags = descriptionTags
descriptionTags = descriptionTags,
isPublic = isPublic,
isMine = isMine
)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@ data class SavedDto(
val createdAt: String,
@SerialName("isLike")
val isLike: Boolean,
@SerialName("isPublic")
val isPublic: Boolean,
@SerialName("isMine")
val isMine: Boolean,
@SerialName("title")
val title: String,
@SerialName("representativeImageUrl")
Expand All @@ -46,7 +50,9 @@ data class SavedDto(
representativeImageUrl = representativeImageUrl ?: "",
routeId = routeId,
writer = writer.toEntity(),
descriptionTags = descriptionTags
descriptionTags = descriptionTags,
isPublic = true,
isMine = true
)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@ data class ArchivedListEntity(
val representativeImageUrl: String,
val routeId: Long,
val writer: List<WriterEntity>,
val descriptionTags: List<String>
val descriptionTags: List<String>,
val isPublic: Boolean,
val isMine: Boolean
)

data class WriterEntity(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@ data class SavedListEntity(
val representativeImageUrl: String,
val routeId: Int,
val writer: SavedWriterEntity,
val descriptionTags: List<String>
val descriptionTags: List<String>,
val isPublic: Boolean,
val isMine: Boolean
)
data class SavedWriterEntity(
val userId: Int,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,10 +73,10 @@ fun ArchivedCourseListScreen(
petName = item.writer.first().petName,
petProfileImageUrl = item.writer.first().petProfileImageUrl,
descriptionTags = item.descriptionTags,
isLiked = item.isLiked,
isLiked = null,
isPublic = item.isPublic, // 눈아이콘만 표시
onClickItem = navigateNext,
onClickLike = {}

onClickLike = null
)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,13 @@ fun MyPageRoute(

LaunchedEffect(Unit) {
viewModel.getUserProfiles(userId = userId.first())
viewModel.getMyPagePetProfiles(userId = userId.first())
viewModel.getPetProfiles(userId = userId.first())
}
// LaunchedEffect(Unit) {
// val userId = 2 // ← 임시 테스트용
// viewModel.getUserProfiles(userId = userId)
// viewModel.getPetProfiles(userId = userId)
// }

MyPageScreen(
state = state.value,
Expand Down Expand Up @@ -107,7 +112,11 @@ fun MyPageScreen(
PetCard(
name = state.petName,
age = state.petAge,
gender = state.petGender,
gender = if (state.petGender == "M") {
"남아"
} else {
"여아"
},
tags = state.petTags,
walkCount = state.walkCount,
totalDistance = state.totalDistance,
Expand Down Expand Up @@ -164,7 +173,7 @@ fun PetCard(
gender: String,
tags: List<String>,
image: String,
walkCount: String,
walkCount: Int,
totalDistance: String,
navigatePetProfile: () -> Unit,
modifier: Modifier = Modifier
Expand Down Expand Up @@ -261,7 +270,7 @@ fun PetCard(
) {
Text("산책 횟수", style = PawKeyTheme.typography.caption12Sb1)
Text(
walkCount,
text = "${walkCount}회",
style = PawKeyTheme.typography.head20Sb,
color = PawKeyTheme.colors.green500
)
Expand Down Expand Up @@ -358,7 +367,7 @@ private fun MyPageScreenPreview() {
petAge = "12세",
petGender = "여아",
petTags = listOf("조금 느긋해요", "#오토바이소리", "#대형견"),
walkCount = "7회",
walkCount = 7,
totalDistance = "14km"
),
paddingValues = PaddingValues(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,13 +62,19 @@ fun PetProfileScreen(
energyLevel: String,
socialLevel: String
) {
// 여기서 바로 가공
val displayGender = when (gender.uppercase()) {
"M" -> "남아"
"F" -> "여아"
else -> gender
}

Column(
modifier = modifier
.fillMaxSize()
.padding(horizontal = 20.dp)
) {
TopBar(title = "반려견 프로필",
onBackClick = { navigateUp() })
TopBar(title = "반려견 프로필", onBackClick = navigateUp)

Spacer(modifier = Modifier.height(40.dp))

Expand All @@ -92,11 +98,9 @@ fun PetProfileScreen(

Spacer(modifier = Modifier.height(36.dp))

// 정보 항목
PetProfileItem(label = "이름", value = name)
PetProfileItem(label = "성별", value = gender)
PetProfileItem(label = "성별", value = displayGender)

// 중성화 여부 (단일 텍스트)
Text(
text = "중성화했어요",
style = PawKeyTheme.typography.caption12Sb2,
Expand All @@ -107,7 +111,6 @@ fun PetProfileScreen(
PetProfileItem(label = "견종", value = breed)
PetProfileItem(label = "나이", value = age)

// 성향
Text(
text = "성향",
style = PawKeyTheme.typography.body14Sb,
Expand Down Expand Up @@ -158,28 +161,22 @@ fun PetProfileScreen(
Spacer(modifier = Modifier.weight(1f))
}
}

@Composable
fun PetProfileItem(
label: String,
value: String,
modifier: Modifier = Modifier
value: String
) {
Column(modifier = modifier.padding(vertical = 8.dp)) {
Column(modifier = Modifier.padding(start = 16.dp, bottom = 8.dp)) {
Text(
text = label,
style = PawKeyTheme.typography.body14Sb,
modifier = Modifier.padding(start = 16.dp)
style = PawKeyTheme.typography.body14R,
color = PawKeyTheme.colors.gray600
)
Text(
text = value,
style = PawKeyTheme.typography.head18Sb,
color = PawKeyTheme.colors.black
)
if (value.isNotEmpty()) {
Spacer(modifier = Modifier.height(4.dp))
Text(
text = value,
style = PawKeyTheme.typography.head18Sb,
color = PawKeyTheme.colors.green500,
modifier = Modifier.padding(start = 16.dp)
)
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import androidx.compose.foundation.layout.*
import androidx.compose.foundation.lazy.LazyColumn
import androidx.compose.foundation.lazy.itemsIndexed
import androidx.compose.runtime.Composable
import androidx.compose.runtime.LaunchedEffect
import androidx.compose.ui.Modifier
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
Expand All @@ -13,8 +14,10 @@ import androidx.lifecycle.compose.collectAsStateWithLifecycle
import com.paw.key.core.designsystem.component.CourseCard
import com.paw.key.core.designsystem.component.TopBar
import com.paw.key.core.designsystem.theme.PawKeyTheme
import com.paw.key.core.util.PreferenceDataStore
import com.paw.key.presentation.ui.mypage.state.SavedListState
import com.paw.key.presentation.ui.mypage.viewmodel.SavedListViewModel
import kotlinx.coroutines.flow.first

@Composable
fun SavedCourseRoute(
Expand All @@ -24,6 +27,11 @@ fun SavedCourseRoute(
viewModel: SavedListViewModel = hiltViewModel()
) {
val state = viewModel.state.collectAsStateWithLifecycle()
val userId = PreferenceDataStore.getUserId()
// LaunchedEffect(Unit) {
// viewModel.getSavedList(userId = userId.first())
// }


SavedCourseListScreen(
state = state.value,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import androidx.compose.runtime.Immutable
val petGender: String = "여아",
val petImageUrl: String = "",
val petTags: List<String> = listOf("조금 느긋해요", "#오토바이소리", "#대형견"),
val walkCount: String = "7회",
val walkCount: Int = 0,
val totalDistance: String = "14km"
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ class MyPageViewModel @Inject constructor(
}
}

fun getMyPagePetProfiles(userId: Int) {
fun getPetProfiles(userId: Int) {
viewModelScope.launch {
petProfileRepository.getPetProfiles(userId)
.onSuccess {
Expand All @@ -51,7 +51,8 @@ class MyPageViewModel @Inject constructor(
petAge = it.first().age.toString(),
petGender = it.first().gender,
petImageUrl = it.first().imageUrl,
petTags = it.first().traits.map { trait -> trait.category }
petTags = it.first().traits.map { trait -> trait.option},
walkCount = it.first().walkCount
)
}.onFailure {
_sideEffect.emit(MyPageSideEffect.ShowSnackBar("펫 프로필 불러오기 실패"))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ class PetProfileViewModel @Inject constructor(
gender = result.first().gender,
breed = result.first().breed,
age = result.first().age.toString(),
energyLevel = result.first().traits.first().category,
energyLevel = result.first().traits.first().option,
socialLevel = result.first().traits.first().option
)
}
Expand Down
Loading