-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
a8bc9fb
commit 2e84a90
Showing
4 changed files
with
131 additions
and
67 deletions.
There are no files selected for viewing
4 changes: 4 additions & 0 deletions
4
feature/home/src/main/java/com/boostcamp/mapisode/home/ai/RecommendationIntent.kt
This file contains 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,6 +1,10 @@ | ||
package com.boostcamp.mapisode.home.ai | ||
|
||
import com.boostcamp.mapisode.home.common.OptionType | ||
import com.boostcamp.mapisode.ui.base.UiIntent | ||
|
||
sealed class RecommendationIntent : UiIntent { | ||
data class OptionClick(val optionId: OptionType) : RecommendationIntent() | ||
data object ShowMapType : RecommendationIntent() | ||
data object ShowListType : RecommendationIntent() | ||
} |
This file contains 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
9 changes: 8 additions & 1 deletion
9
feature/home/src/main/java/com/boostcamp/mapisode/home/ai/RecommendationState.kt
This file contains 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,7 +1,14 @@ | ||
package com.boostcamp.mapisode.home.ai | ||
|
||
import com.boostcamp.mapisode.home.common.OptionType | ||
import com.boostcamp.mapisode.home.common.ResultEpisode | ||
import com.boostcamp.mapisode.home.common.ResultViewType | ||
import com.boostcamp.mapisode.ui.base.UiState | ||
|
||
data class RecommendationState ( | ||
val a:Int = 0 | ||
val type: OptionType = OptionType.NONE, | ||
val isOptionSelected: Boolean = false, | ||
val resultViewType: ResultViewType = ResultViewType.LIST_VIEW, | ||
val resultEpisodes: List<ResultEpisode> = emptyList(), | ||
|
||
) : UiState |
46 changes: 40 additions & 6 deletions
46
feature/home/src/main/java/com/boostcamp/mapisode/home/ai/RecommendationViewmodel.kt
This file contains 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,17 +1,51 @@ | ||
package com.boostcamp.mapisode.home.ai | ||
|
||
import com.boostcamp.mapisode.home.common.OptionType | ||
import com.boostcamp.mapisode.home.common.ResultViewType | ||
import com.boostcamp.mapisode.ui.base.BaseViewModel | ||
import dagger.hilt.android.lifecycle.HiltViewModel | ||
import timber.log.Timber | ||
import javax.inject.Inject | ||
|
||
@HiltViewModel | ||
class RecommendationViewmodel @Inject constructor( | ||
|
||
) : | ||
BaseViewModel<RecommendationIntent, RecommendationState, RecommendationSideEffect>( | ||
RecommendationState(), | ||
) { | ||
override fun onIntent(intent: RecommendationIntent) { | ||
) : BaseViewModel<RecommendationIntent, RecommendationState, RecommendationSideEffect>( | ||
RecommendationState(), | ||
) { | ||
override fun onIntent(intent: RecommendationIntent) { | ||
when (intent) { | ||
is RecommendationIntent.OptionClick -> handleOptionClick(intent.optionId) | ||
RecommendationIntent.ShowListType -> showListType() | ||
RecommendationIntent.ShowMapType -> showMapType() | ||
} | ||
} | ||
|
||
} | ||
private fun handleOptionClick(type: OptionType) { | ||
intent { | ||
copy( | ||
type = type, | ||
isOptionSelected = true, | ||
) | ||
} | ||
} | ||
|
||
private fun showListType() { | ||
Timber.e("ResultViewType.LIST_VIEW") | ||
intent { | ||
copy( | ||
resultViewType = ResultViewType.LIST_VIEW, | ||
) | ||
} | ||
} | ||
|
||
private fun showMapType() { | ||
|
||
Timber.e("ResultViewType.MAP_VIEW") | ||
intent { | ||
copy( | ||
resultViewType = ResultViewType.MAP_VIEW, | ||
) | ||
} | ||
} | ||
} |