Skip to content

Commit 4da3ce2

Browse files
authored
merge #94 -> develop
[Mod/#94] 지역관리 및 디테일 수정, 상세보기 api 연동
2 parents 3431788 + deddb37 commit 4da3ce2

File tree

10 files changed

+76
-20
lines changed

10 files changed

+76
-20
lines changed

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

Lines changed: 35 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package com.paw.key.core.designsystem.component
22

3+
import android.util.Log
34
import androidx.compose.foundation.background
45
import androidx.compose.foundation.clickable
56
import androidx.compose.foundation.layout.Arrangement
@@ -19,6 +20,7 @@ import androidx.compose.material3.HorizontalDivider
1920
import androidx.compose.material3.Icon
2021
import androidx.compose.material3.Text
2122
import androidx.compose.runtime.Composable
23+
import androidx.compose.runtime.LaunchedEffect
2224
import androidx.compose.runtime.mutableStateOf
2325
import androidx.compose.runtime.remember
2426
import androidx.compose.ui.Alignment
@@ -54,18 +56,23 @@ fun CourseDetail(
5456
totalReviewCount : Int,
5557
walkingImageUrls : List<String>,
5658

57-
5859
onImageClick: (String) -> Unit,
5960
modifier: Modifier = Modifier
6061
) {
62+
val context = LocalContext.current
6163
val isLiked = remember { mutableStateOf(false) }
64+
LaunchedEffect(routeMapImageUrl) {
65+
Log.d("LaunchedEffect", "LaunchedEffect: $routeMapImageUrl")
66+
Log.d("LaunchedEffect", "LaunchedEffect: $walkingImageUrls")
67+
Log.d("LaunchedEffect", "LaunchedEffect: $petProfileImage")
68+
}
6269

6370
Column(
6471
modifier = modifier
6572
.fillMaxWidth()
6673
) {
6774
AsyncImage(
68-
model = ImageRequest.Builder(LocalContext.current)
75+
model = ImageRequest.Builder(context)
6976
.data(routeMapImageUrl)
7077
.crossfade(true)
7178
.build(),
@@ -122,7 +129,7 @@ fun CourseDetail(
122129
.padding(vertical = 12.dp)
123130
) {
124131
AsyncImage(
125-
model = ImageRequest.Builder(LocalContext.current)
132+
model = ImageRequest.Builder(context)
126133
.data(petProfileImage)
127134
.crossfade(true)
128135
.build(),
@@ -190,7 +197,7 @@ fun CourseDetail(
190197
) {
191198
items(walkingImageUrls.size) { index ->
192199
AsyncImage(
193-
model = ImageRequest.Builder(LocalContext.current)
200+
model = ImageRequest.Builder(context)
194201
.data(walkingImageUrls[index])
195202
.crossfade(true)
196203
.build(),
@@ -317,7 +324,31 @@ fun CourseDetailPreview() {
317324
petProfileImage = "https://pawkey-server.com/image/profile.png",
318325
routeMapImageUrl = "https://pawkey-server.com/image/map.png",
319326
categoryTop3 = listOf(
327+
CategoryTop3Entity(
328+
rank = 1,
329+
optionText = "산책로가 어쩌구 저꾸",
330+
percentage = 42,
331+
categoryName = "산책로가 어쩌구 저꾸",
332+
categoryOptionId = 1,
333+
categoryId = 2
334+
),
335+
CategoryTop3Entity(
336+
rank = 2,
337+
optionText = "산책로가 어쩌구 저꾸",
338+
percentage = 37,
339+
categoryName = "산책로가 어쩌구 저꾸",
340+
categoryOptionId = 1,
341+
categoryId = 2
320342
),
343+
CategoryTop3Entity(
344+
rank = 3,
345+
optionText = "산책로가 어쩌구 저꾸",
346+
percentage = 35,
347+
categoryName = "산책로가 어쩌구 저꾸",
348+
categoryOptionId = 1,
349+
categoryId = 2
350+
)
351+
),
321352
totalReviewCount = 42,
322353
walkingImageUrls = listOf(
323354
"https://pawkey-server.com/image/walk1.jpg",

app/src/main/java/com/paw/key/data/dto/response/walklist/WalkReviewDetailResponseDto.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ data class WalkReviewDetailResponseDto(
4343
regionName = regionName,
4444
createdAt = createdAt,
4545
routeMapImageUrl = routeMapImageUrl,
46+
walkingImageUrls = walkingImageUrls
4647
)
4748
}
4849
}

app/src/main/java/com/paw/key/data/service/walklist/WalkListDetailService.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,6 @@ interface WalkListDetailService {
1717
@GET("posts/{routeId}/reviews/top")
1818
suspend fun getWalkReviewSummary(
1919
@Header("X-USER-ID") userId: Int,
20-
@Path("postId") postId: Int
20+
@Path("routeId") routeId: Int
2121
): BaseResponse<WalkReviewSummaryResponseDto>
2222
}

app/src/main/java/com/paw/key/domain/model/entity/walklist/WalkListDetailEntity.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ data class WalkListDetailEntity(
1111
val regionName: String,
1212
val createdAt: String,
1313
val routeMapImageUrl: String,
14+
val walkingImageUrls: List<String>
1415
)
1516

1617
data class AuthorInfoEntity(

app/src/main/java/com/paw/key/presentation/ui/home/HomeLocationSettingScreen.kt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ fun HomeLocationSettingScreen(
168168
enabled = isFormValid,
169169
onClick = {
170170
if (isFormValid) {
171-
viewModel.patchRegion(
171+
/*viewModel.patchRegion(
172172
userId = 2,
173173
onSuccess = {
174174
val selectedDongId = state.selectedDongId
@@ -177,7 +177,8 @@ fun HomeLocationSettingScreen(
177177
onFailure = { message ->
178178
Log.e("HomeScreen", "지역 설정 실패: $message")
179179
}
180-
)
180+
)*/
181+
navigateNext(state.selectedDongId)
181182
}
182183
}
183184
)

app/src/main/java/com/paw/key/presentation/ui/home/HomeScreen.kt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,6 @@ private fun HomeScreenPreview() {
5555
navigateHomeLocationSetting = {}
5656
)
5757
}
58-
5958
}
6059

6160
@Composable

app/src/main/java/com/paw/key/presentation/ui/main/PawKeyNavHost.kt

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,12 @@ fun PawKeyNavHost(
6565
homeLocationSettingNavGraph(
6666
paddingValues = paddingValues,
6767
navigateUp = navigator::navigateUp,
68-
navigateNext = navigator::navigateRegional,
68+
navigateNext = {
69+
navigator.navigateRegional(
70+
regionId = it,
71+
navOptions = null
72+
)
73+
},
6974
navigateHomeLocationSetting = navigator::navigateHomeLocationSetting,
7075
modifier = modifier,
7176
)

app/src/main/java/com/paw/key/presentation/ui/mypage/viewmodel/ArchivedDetailViewModel.kt

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,11 +41,11 @@ class ArchivedDetailViewModel @Inject constructor(
4141
regionName = result.regionName,
4242
categorySummary = result.categoryTags.categoryOptionSummary,
4343
routeMapImageUrl = result.routeMapImageUrl,
44-
walkingImageUrls = it.walkingImageUrls,
45-
postContent = result.content
44+
walkingImageUrls = result.walkingImageUrls,
45+
postContent = result.content,
46+
petProfileImage = result.authorInfo.petProfileImage,
4647
)
4748
}
48-
Log.d("getWalkDetail", "getWalkDetail: ${result.content}")
4949
}
5050
.onFailure {
5151
Log.e("getWalkDetail", "getWalkDetail: ${it.message}")
@@ -63,7 +63,6 @@ class ArchivedDetailViewModel @Inject constructor(
6363
totalReviewCount = result.totalReviewCount
6464
)
6565
}
66-
6766
Log.d("getWalkTopPopular", "getWalkTopPopular: ${result.categoryTop3}")
6867
}
6968
.onFailure {

app/src/main/java/com/paw/key/presentation/ui/region/RegionalManagementScreen.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ fun RegionalManagementRoute(
6060
LaunchedEffect(Unit) {
6161
Log.e("regregionId", regionId.toString())
6262
viewModel.getRegionGeometry(
63-
X_USER_ID = 2,
63+
userId = 2,
6464
regionId = regionId,
6565
)
6666
}
@@ -96,7 +96,7 @@ fun RegionalManagementRoute(
9696
preRegionName = state.preRegionName,
9797
regionName = state.regionName,
9898
onClickButton = {
99-
viewModel.onChangeRegion()
99+
viewModel.patchRegion(userId = 2, regionId = regionId)
100100
navigateNext()
101101
},
102102
modifier = modifier

app/src/main/java/com/paw/key/presentation/ui/region/viewmodel/RegionViewModel.kt

Lines changed: 24 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import com.kakao.vectormap.LatLng
77
import com.paw.key.core.util.UiState
88
import com.paw.key.core.util.handleError
99
import com.paw.key.domain.repository.RegionRepository
10+
import com.paw.key.domain.repository.home.HomeRegionRepository
1011
import com.paw.key.presentation.ui.region.state.RegionContract
1112
import dagger.hilt.android.lifecycle.HiltViewModel
1213
import kotlinx.coroutines.flow.MutableSharedFlow
@@ -19,7 +20,8 @@ import javax.inject.Inject
1920

2021
@HiltViewModel
2122
class RegionViewModel @Inject constructor(
22-
private val regionRepository: RegionRepository
23+
private val regionRepository: RegionRepository,
24+
private val homeRepository: HomeRegionRepository
2325
) : ViewModel() {
2426
private val _state = MutableStateFlow(RegionContract.RegionState())
2527
val state : StateFlow<RegionContract.RegionState>
@@ -29,8 +31,8 @@ class RegionViewModel @Inject constructor(
2931
val sideEffect : MutableSharedFlow<RegionContract.RegionSideEffect>
3032
get() = _sideEffect
3133

32-
fun getRegionGeometry(X_USER_ID: Int, regionId: Int) = viewModelScope.launch {
33-
regionRepository.getRegionGeometry(X_USER_ID, regionId)
34+
fun getRegionGeometry(userId: Int, regionId: Int) = viewModelScope.launch {
35+
regionRepository.getRegionGeometry(userId, regionId)
3436
.onSuccess { data ->
3537
Log.d("RegionViewModel", "API 응답 성공: $data")
3638
Log.d("RegionViewModel", "geometry type: ${data.geometry.type}")
@@ -83,13 +85,30 @@ class RegionViewModel @Inject constructor(
8385
}
8486
}
8587

86-
fun onChangeRegion() {
88+
fun patchRegion(userId: Int, regionId: Int) = viewModelScope.launch {
89+
homeRepository.patchRegion(userId, regionId)
90+
.onSuccess { data ->
91+
Log.d("RegionViewModel", "API 응답 성공: $data")
92+
_sideEffect.emit(
93+
RegionContract.RegionSideEffect.ShowSnackBar("지역을 ${state.value.selectedRegion ?: "역삼동"}으로 변경했어요.")
94+
)
95+
}
96+
.onFailure { throwable ->
97+
Log.e("RegionViewModel", "API 호출 실패", throwable)
98+
val errorMessage = handleError(throwable)
99+
_sideEffect.emit(
100+
RegionContract.RegionSideEffect.ShowSnackBar(errorMessage)
101+
)
102+
}
103+
}
104+
105+
/*fun onChangeRegion() {
87106
viewModelScope.launch {
88107
_sideEffect.emit(
89108
RegionContract.RegionSideEffect.ShowSnackBar("지역을 ${state.value.selectedRegion ?: "역삼동"}으로 변경했어요.")
90109
)
91110
}
92-
}
111+
}*/
93112
}
94113

95114
private fun flattenCoordinatesToLatLng(

0 commit comments

Comments
 (0)