-
Notifications
You must be signed in to change notification settings - Fork 1
[NDGL-89] 내 여행 탭 구현 #25
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 changes: 8 additions & 0 deletions
8
data/travel/src/main/java/com/yapp/ndgl/data/travel/api/UserTravelApi.kt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,10 +1,18 @@ | ||
| package com.yapp.ndgl.data.travel.api | ||
|
|
||
| import com.yapp.ndgl.data.core.model.BaseResponse | ||
| import com.yapp.ndgl.data.travel.model.UpcomingTravelList | ||
| import com.yapp.ndgl.data.travel.model.UpcomingTravelResponse | ||
| import retrofit2.http.GET | ||
| import retrofit2.http.Query | ||
|
|
||
| interface UserTravelApi { | ||
| @GET("/api/v1/travels/upcoming") | ||
| suspend fun getUpcomingTravel(): BaseResponse<UpcomingTravelResponse> | ||
|
|
||
| @GET("/api/v1/travels/upcoming/list") | ||
| suspend fun getUpcomingTravelList( | ||
| @Query("page") page: Int? = null, | ||
| @Query("size") size: Int? = null, | ||
| ): BaseResponse<UpcomingTravelList> | ||
| } |
28 changes: 28 additions & 0 deletions
28
data/travel/src/main/java/com/yapp/ndgl/data/travel/model/UpcomingTravelList.kt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,28 @@ | ||
| package com.yapp.ndgl.data.travel.model | ||
|
|
||
| import com.yapp.ndgl.data.core.serializer.LocalDateSerializer | ||
| import kotlinx.serialization.Serializable | ||
| import java.time.LocalDate | ||
|
|
||
| @Serializable | ||
| data class UpcomingTravelList( | ||
| val content: List<UpcomingTravel>, | ||
| val hasNext: Boolean, | ||
| ) { | ||
| @Serializable | ||
| data class UpcomingTravel( | ||
| val id: Long, | ||
| val title: String, | ||
| val country: String, | ||
| val city: String, | ||
| @Serializable(with = LocalDateSerializer::class) | ||
| val startDate: LocalDate, | ||
| @Serializable(with = LocalDateSerializer::class) | ||
| val endDate: LocalDate, | ||
| val nights: Int, | ||
| val days: Int, | ||
| val templateId: Long, | ||
| val thumbnail: String? = null, | ||
| val profileImage: String? = null, | ||
| ) | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
93 changes: 93 additions & 0 deletions
93
feature/travel/src/main/java/com/yapp/ndgl/feature/travel/mytravel/MyTravelContract.kt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,93 @@ | ||
| package com.yapp.ndgl.feature.travel.mytravel | ||
|
|
||
| import androidx.compose.runtime.Immutable | ||
| import androidx.compose.runtime.Stable | ||
| import com.yapp.ndgl.core.base.UiIntent | ||
| import com.yapp.ndgl.core.base.UiSideEffect | ||
| import com.yapp.ndgl.core.base.UiState | ||
| import com.yapp.ndgl.data.travel.model.PlaceCategory | ||
| import com.yapp.ndgl.data.travel.model.ProgramType | ||
| import kotlinx.collections.immutable.ImmutableList | ||
| import kotlinx.collections.immutable.persistentListOf | ||
| import java.time.LocalDate | ||
|
|
||
| @Immutable | ||
| data class MyTravelState( | ||
| val upcomingTravel: UpcomingTravel? = null, | ||
| val upcomingTravels: ImmutableList<UpcomingTravelItem> = persistentListOf(), | ||
| val recommendedTravels: ImmutableList<RecommendedTravel> = persistentListOf(), | ||
| ) : UiState { | ||
| @Stable | ||
| sealed class UpcomingTravel { | ||
| abstract val travelId: Long | ||
| abstract val title: String | ||
| abstract val startDate: LocalDate | ||
| abstract val endDate: LocalDate | ||
|
|
||
| @Immutable | ||
| data class Upcoming( | ||
| override val travelId: Long, | ||
| override val title: String, | ||
| override val startDate: LocalDate, | ||
| override val endDate: LocalDate, | ||
| val imageUrl: String, | ||
| val dDay: Int, | ||
| ) : UpcomingTravel() | ||
|
|
||
| @Immutable | ||
| data class InProgress( | ||
| override val travelId: Long, | ||
| override val title: String, | ||
| override val startDate: LocalDate, | ||
| override val endDate: LocalDate, | ||
| val dayCount: Int, | ||
| val currentPlace: TravelPlace? = null, | ||
| ) : UpcomingTravel() | ||
| } | ||
|
|
||
| @Immutable | ||
| data class TravelPlace( | ||
| val placeId: String, | ||
| val category: PlaceCategory, | ||
| val estimatedDuration: Int, | ||
| val name: String, | ||
| val thumbnailUrl: String, | ||
|
coderabbitai[bot] marked this conversation as resolved.
|
||
| ) | ||
|
|
||
| @Immutable | ||
| data class UpcomingTravelItem( | ||
| val travelId: Long, | ||
| val title: String, | ||
| val startDate: LocalDate, | ||
| val endDate: LocalDate, | ||
| val imageUrl: String, | ||
| val dDay: Int, | ||
| ) | ||
|
|
||
| @Immutable | ||
| data class RecommendedTravel( | ||
| val travelId: Long, | ||
| val title: String, | ||
| val country: String, | ||
| val city: String, | ||
| val nights: Int, | ||
| val days: Int, | ||
| val programName: String, | ||
| val programType: ProgramType, | ||
| val thumbnailUrl: String, | ||
| ) | ||
| } | ||
|
|
||
| sealed interface MyTravelIntent : UiIntent { | ||
| data class ClickTravel(val travelId: Long) : MyTravelIntent | ||
| data class ClickTravelDetail(val travelId: Long) : MyTravelIntent | ||
| data class ClickPlaceDetail(val placeId: String) : MyTravelIntent | ||
| data object ClickFindNewTravel : MyTravelIntent | ||
| } | ||
|
|
||
| sealed interface MyTravelSideEffect : UiSideEffect { | ||
| data class NavigateToFollowTravel(val travelId: Long, val days: Int) : MyTravelSideEffect | ||
| data class NavigateToTravelDetail(val travelId: Long) : MyTravelSideEffect | ||
| data class NavigateToTravelPlace(val placeId: String) : MyTravelSideEffect | ||
| data object NavigateToPopularTravelList : MyTravelSideEffect | ||
| } | ||
154 changes: 154 additions & 0 deletions
154
feature/travel/src/main/java/com/yapp/ndgl/feature/travel/mytravel/MyTravelScreen.kt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,154 @@ | ||
| package com.yapp.ndgl.feature.travel.mytravel | ||
|
|
||
| import androidx.compose.foundation.background | ||
| import androidx.compose.foundation.layout.Arrangement | ||
| import androidx.compose.foundation.layout.PaddingValues | ||
| import androidx.compose.foundation.layout.fillMaxSize | ||
| import androidx.compose.foundation.layout.fillMaxWidth | ||
| import androidx.compose.foundation.layout.padding | ||
| import androidx.compose.foundation.layout.statusBarsPadding | ||
| import androidx.compose.foundation.lazy.LazyColumn | ||
| import androidx.compose.material3.Scaffold | ||
| import androidx.compose.runtime.Composable | ||
| import androidx.compose.runtime.getValue | ||
| import androidx.compose.ui.Alignment | ||
| import androidx.compose.ui.Modifier | ||
| import androidx.compose.ui.tooling.preview.Preview | ||
| import androidx.compose.ui.unit.dp | ||
| import androidx.hilt.lifecycle.viewmodel.compose.hiltViewModel | ||
| import com.yapp.ndgl.core.ui.R | ||
| import com.yapp.ndgl.core.ui.designsystem.NDGLNavigationBar | ||
| import com.yapp.ndgl.core.ui.designsystem.NDGLNavigationBarAttr.TextAlignType | ||
| import com.yapp.ndgl.core.ui.designsystem.NDGLNavigationIcon | ||
| import com.yapp.ndgl.core.ui.theme.NDGLTheme | ||
|
|
||
| @Composable | ||
| internal fun MyTravelRoute( | ||
| viewModel: MyTravelViewModel = hiltViewModel(), | ||
| navigateToFollowTravel: (Long, Int) -> Unit, | ||
| navigateToTravelDetail: (Long) -> Unit, | ||
| navigateToTravelPlace: (String) -> Unit, | ||
| ) { | ||
| val state by viewModel.collectAsState() | ||
|
|
||
| MyTravelScreen( | ||
| state = state, | ||
| onTravelClick = { travelId -> | ||
| viewModel.onIntent(MyTravelIntent.ClickTravelDetail(travelId = travelId)) | ||
| }, | ||
| onPlaceClick = { placeId -> | ||
| viewModel.onIntent(MyTravelIntent.ClickPlaceDetail(placeId = placeId)) | ||
| }, | ||
| onNewTravelFindClick = { | ||
| viewModel.onIntent(MyTravelIntent.ClickFindNewTravel) | ||
| }, | ||
| onTravelTemplateClick = { travelId -> | ||
| viewModel.onIntent((MyTravelIntent.ClickTravel(travelId = travelId))) | ||
| }, | ||
| ) | ||
|
|
||
| viewModel.collectSideEffect { sideEffect -> | ||
| when (sideEffect) { | ||
| is MyTravelSideEffect.NavigateToFollowTravel -> navigateToFollowTravel( | ||
| sideEffect.travelId, | ||
| sideEffect.days, | ||
| ) | ||
|
|
||
| is MyTravelSideEffect.NavigateToTravelDetail -> navigateToTravelDetail( | ||
| sideEffect.travelId, | ||
| ) | ||
|
|
||
| is MyTravelSideEffect.NavigateToTravelPlace -> navigateToTravelPlace( | ||
| sideEffect.placeId, | ||
| ) | ||
|
|
||
| MyTravelSideEffect.NavigateToPopularTravelList -> { | ||
| // FIXME: navigate to popular travel list | ||
| } | ||
| } | ||
| } | ||
| } | ||
|
|
||
| @Composable | ||
| private fun MyTravelScreen( | ||
| state: MyTravelState, | ||
| onTravelClick: (Long) -> Unit, | ||
| onPlaceClick: (String) -> Unit, | ||
| onNewTravelFindClick: () -> Unit, | ||
| onTravelTemplateClick: (Long) -> Unit, | ||
| ) { | ||
| Scaffold( | ||
| modifier = Modifier.fillMaxSize(), | ||
| topBar = { | ||
| NDGLNavigationBar( | ||
| textAlignType = TextAlignType.START, | ||
| modifier = Modifier | ||
| .fillMaxWidth() | ||
| .background(color = NDGLTheme.colors.white) | ||
| .statusBarsPadding(), | ||
| trailingContents = { | ||
| NDGLNavigationIcon( | ||
| icon = R.drawable.ic_28_search, | ||
| onClick = { /* FIXME: 홈 검색 */ }, | ||
| ) | ||
| NDGLNavigationIcon( | ||
| icon = R.drawable.ic_28_settings, | ||
| onClick = { /* FIXME: 설정 */ }, | ||
| ) | ||
| }, | ||
| ) | ||
| }, | ||
| ) { innerPadding -> | ||
| LazyColumn( | ||
| modifier = Modifier | ||
| .padding(innerPadding) | ||
| .fillMaxSize(), | ||
| contentPadding = PaddingValues( | ||
| top = 20.dp, | ||
| bottom = 100.dp, | ||
| ), | ||
| verticalArrangement = Arrangement.spacedBy(40.dp), | ||
| horizontalAlignment = Alignment.CenterHorizontally, | ||
| ) { | ||
| if (state.upcomingTravel != null) { | ||
| item { | ||
| UpcomingTravelCardSection( | ||
| modifier = Modifier.fillMaxWidth(), | ||
| upcomingTravel = state.upcomingTravel, | ||
| onTravelClick = onTravelClick, | ||
| onPlaceClick = onPlaceClick, | ||
| ) | ||
| } | ||
| } | ||
| item { | ||
| UpcomingTravelListSection( | ||
| upcomingTravels = state.upcomingTravels, | ||
| onUserTravelClick = onTravelClick, | ||
| onNewTravelFindClick = onNewTravelFindClick, | ||
| ) | ||
| } | ||
| if (state.recommendedTravels.isNotEmpty()) { | ||
| item { | ||
| RecommendedTravelSection( | ||
| recommendedTravels = state.recommendedTravels, | ||
| onTravelTemplateClick = onTravelTemplateClick, | ||
| ) | ||
| } | ||
| } | ||
| } | ||
| } | ||
| } | ||
|
|
||
| @Preview(showBackground = true) | ||
| @Composable | ||
| private fun MyTravelScreenPreview() { | ||
| NDGLTheme { | ||
| MyTravelScreen( | ||
| state = MyTravelState(), | ||
| onTravelClick = {}, | ||
| onPlaceClick = {}, | ||
| onNewTravelFindClick = {}, | ||
| onTravelTemplateClick = {}, | ||
| ) | ||
| } | ||
| } | ||
|
coderabbitai[bot] marked this conversation as resolved.
|
||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.