Skip to content

Commit ca6deec

Browse files
committed
[NDGL-69] feature: FollowTravel 및 FollowPlaceDetail 연결
1 parent 2a7cdf9 commit ca6deec

3 files changed

Lines changed: 52 additions & 7 deletions

File tree

feature/travel/src/main/java/com/yapp/ndgl/feature/travel/followtravel/FollowTravelContract.kt

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,10 @@ package com.yapp.ndgl.feature.travel.followtravel
33
import com.yapp.ndgl.core.base.UiIntent
44
import com.yapp.ndgl.core.base.UiSideEffect
55
import com.yapp.ndgl.core.base.UiState
6+
import com.yapp.ndgl.feature.travel.model.AlternativePlace
67
import com.yapp.ndgl.feature.travel.model.OpeningHours
78
import com.yapp.ndgl.feature.travel.model.PlaceType
9+
import com.yapp.ndgl.feature.travel.model.TipContent
810
import com.yapp.ndgl.feature.travel.model.TransportSegment
911
import kotlin.time.Duration
1012

@@ -66,11 +68,21 @@ data class TravelPlace(
6668
val googleMapsUri: String?,
6769
val placeType: PlaceType,
6870
val transportToNext: TransportSegment? = null,
71+
val travelerTips: List<String> = emptyList(),
72+
val alternativePlaces: List<AlternativePlace> = emptyList(),
6973
)
7074

7175
sealed interface FollowTravelIntent : UiIntent {
7276
data class SelectDay(val day: Int) : FollowTravelIntent
7377
data object ClickFollowTravel : FollowTravelIntent
78+
data class ClickPlaceItem(val place: TravelPlace) : FollowTravelIntent
7479
}
7580

76-
sealed interface FollowTravelSideEffect : UiSideEffect
81+
sealed interface FollowTravelSideEffect : UiSideEffect {
82+
data class NavigateToFollowPlaceDetail(
83+
val placeId: String,
84+
val tipContent: TipContent?,
85+
val alternativePlaces: List<AlternativePlace>?,
86+
) :
87+
FollowTravelSideEffect
88+
}

feature/travel/src/main/java/com/yapp/ndgl/feature/travel/followtravel/FollowTravelScreen.kt

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -41,25 +41,33 @@ import com.yapp.ndgl.feature.travel.followtravel.component.ContentCard
4141
import com.yapp.ndgl.feature.travel.followtravel.component.PlaceItem
4242
import com.yapp.ndgl.feature.travel.followtravel.component.TransportSegment
4343
import com.yapp.ndgl.feature.travel.followtravel.component.TravelMap
44+
import com.yapp.ndgl.feature.travel.model.AlternativePlace
45+
import com.yapp.ndgl.feature.travel.model.TipContent
4446
import kotlinx.collections.immutable.toPersistentList
4547

4648
@Composable
4749
internal fun FollowTravelRoute(
4850
viewModel: FollowTravelViewModel = hiltViewModel(),
4951
navigateBack: () -> Unit,
5052
navigateToDatePicker: (Int) -> Unit,
53+
navigateToFollowPlaceDetail:
54+
(placeId: String, tipContent: TipContent?, alternativePlaces: List<AlternativePlace>?) -> Unit,
5155
) {
5256
val state by viewModel.collectAsState()
5357

54-
// TODO viewModel.collectSideEffect { sideEffect -> }
58+
viewModel.collectSideEffect { sideEffect ->
59+
when (sideEffect) {
60+
is FollowTravelSideEffect.NavigateToFollowPlaceDetail ->
61+
navigateToFollowPlaceDetail(sideEffect.placeId, sideEffect.tipContent, sideEffect.alternativePlaces)
62+
}
63+
}
5564

5665
FollowTravelScreen(
5766
state = state,
5867
clickBackButton = navigateBack,
5968
selectDay = { viewModel.onIntent(FollowTravelIntent.SelectDay(it)) },
60-
clickFollowTravel = {
61-
navigateToDatePicker(state.days)
62-
},
69+
clickFollowTravel = { navigateToDatePicker(state.days) },
70+
clickPlaceItem = { place -> viewModel.onIntent(FollowTravelIntent.ClickPlaceItem(place)) },
6371
)
6472
}
6573

@@ -69,6 +77,7 @@ private fun FollowTravelScreen(
6977
clickBackButton: () -> Unit,
7078
selectDay: (Int) -> Unit,
7179
clickFollowTravel: () -> Unit,
80+
clickPlaceItem: (TravelPlace) -> Unit,
7281
) {
7382
val tabs = (1..state.days).map { day ->
7483
NDGLChipTabAttr.Tab(
@@ -170,7 +179,7 @@ private fun FollowTravelScreen(
170179
currentPlaces.forEachIndexed { index, place ->
171180
item(key = "place_${place.id}") {
172181
Box(modifier = Modifier.padding(horizontal = 24.dp)) {
173-
PlaceItem(place = place, onClick = {}) // TODO("클릭 시 장소 상세보기 화면")
182+
PlaceItem(place = place, onClick = { clickPlaceItem(place) })
174183
}
175184
}
176185

@@ -227,5 +236,6 @@ private fun FollowTravelScreenPreview() {
227236
clickBackButton = {},
228237
selectDay = {},
229238
clickFollowTravel = {},
239+
clickPlaceItem = {},
230240
)
231241
}

feature/travel/src/main/java/com/yapp/ndgl/feature/travel/followtravel/FollowTravelViewModel.kt

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ import com.yapp.ndgl.core.util.toCountryName
77
import com.yapp.ndgl.data.travel.model.TravelTemplateContentInfo
88
import com.yapp.ndgl.data.travel.model.TravelTemplateItinerary
99
import com.yapp.ndgl.data.travel.repository.TravelTemplateRepository
10+
import com.yapp.ndgl.feature.travel.model.AlternativePlace
11+
import com.yapp.ndgl.feature.travel.model.TipContent
1012
import com.yapp.ndgl.feature.travel.model.TransportSegment
1113
import com.yapp.ndgl.feature.travel.model.toOpeningHours
1214
import com.yapp.ndgl.feature.travel.model.toPlaceType
@@ -74,6 +76,18 @@ class FollowTravelViewModel @AssistedInject constructor(
7476
is FollowTravelIntent.ClickFollowTravel -> {
7577
// TODO: Handle follow
7678
}
79+
80+
is FollowTravelIntent.ClickPlaceItem -> {
81+
postSideEffect(
82+
FollowTravelSideEffect.NavigateToFollowPlaceDetail(
83+
placeId = intent.place.googlePlaceId,
84+
tipContent = intent.place.travelerTips.takeIf { it.isNotEmpty() }?.let {
85+
TipContent(creatorName = state.value.contentInfo.videoInfo.creatorName, tips = it)
86+
},
87+
alternativePlaces = intent.place.alternativePlaces.takeIf { it.isNotEmpty() },
88+
),
89+
)
90+
}
7791
}
7892
}
7993

@@ -84,7 +98,7 @@ class FollowTravelViewModel @AssistedInject constructor(
8498
id = item.id,
8599
day = item.day,
86100
sequence = item.sequence,
87-
estimatedDuration = (item.estimatedDuration ?: 0).minutes,
101+
estimatedDuration = (item.estimatedDuration).minutes,
88102
googlePlaceId = item.place.googlePlaceId,
89103
thumbnail = item.place.thumbnail,
90104
latitude = item.place.latitude,
@@ -100,6 +114,15 @@ class FollowTravelViewModel @AssistedInject constructor(
100114
distance = ((nextItem.distanceKm ?: 0.0) * 1000).toInt(),
101115
)
102116
},
117+
travelerTips = item.travelerTips.orEmpty(),
118+
alternativePlaces = item.planB.orEmpty().map { planB ->
119+
AlternativePlace(
120+
id = "",
121+
name = planB.name,
122+
thumbnail = planB.feature ?: "",
123+
placeType = item.place.category.toPlaceType(),
124+
)
125+
},
103126
)
104127
},
105128
)

0 commit comments

Comments
 (0)