From 278d274ec671d8d6075fadca3f58f0fa7e609f75 Mon Sep 17 00:00:00 2001 From: LEE YOU BIN Date: Sat, 7 Sep 2024 10:15:01 +0900 Subject: [PATCH] =?UTF-8?q?[FEAT/#218]=20=ED=95=A8=EC=88=98=20=ED=95=A9?= =?UTF-8?q?=EC=B9=98=EA=B8=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../filtering/filteringone/FilteringOneRoute.kt | 3 +-- .../filteringone/FilteringOneViewModel.kt | 11 +++++------ .../filtering/filteringtwo/FilteringTwoRoute.kt | 3 +-- .../filteringtwo/FilteringTwoViewModel.kt | 15 ++++++--------- 4 files changed, 13 insertions(+), 19 deletions(-) diff --git a/feature/src/main/java/com/terning/feature/filtering/filteringone/FilteringOneRoute.kt b/feature/src/main/java/com/terning/feature/filtering/filteringone/FilteringOneRoute.kt index 1d3dd595f..930e81fb7 100644 --- a/feature/src/main/java/com/terning/feature/filtering/filteringone/FilteringOneRoute.kt +++ b/feature/src/main/java/com/terning/feature/filtering/filteringone/FilteringOneRoute.kt @@ -53,8 +53,7 @@ fun FilteringOneRoute( FilteringOneScreen( name = name, onButtonClick = { index -> - viewModel.updateGrade(index) - viewModel.updateButtonValidation() + viewModel.updateGradeAndButton(index) }, onNextClick = onNextClick, navigateUp = viewModel::navigateUp, diff --git a/feature/src/main/java/com/terning/feature/filtering/filteringone/FilteringOneViewModel.kt b/feature/src/main/java/com/terning/feature/filtering/filteringone/FilteringOneViewModel.kt index 214b0447d..93829d006 100644 --- a/feature/src/main/java/com/terning/feature/filtering/filteringone/FilteringOneViewModel.kt +++ b/feature/src/main/java/com/terning/feature/filtering/filteringone/FilteringOneViewModel.kt @@ -18,12 +18,11 @@ class FilteringOneViewModel : ViewModel() { private val _sideEffects = MutableSharedFlow() val sideEffects: SharedFlow get() = _sideEffects.asSharedFlow() - fun updateButtonValidation() { - _state.value = _state.value.copy(isButtonValid = true) - } - - fun updateGrade(grade: Int) { - _state.value = _state.value.copy(grade = grade) + fun updateGradeAndButton(grade: Int) { + _state.value = _state.value.copy( + grade = grade, + isButtonValid = true + ) } fun navigateUp() = diff --git a/feature/src/main/java/com/terning/feature/filtering/filteringtwo/FilteringTwoRoute.kt b/feature/src/main/java/com/terning/feature/filtering/filteringtwo/FilteringTwoRoute.kt index 3b00778d0..21361bdb5 100644 --- a/feature/src/main/java/com/terning/feature/filtering/filteringtwo/FilteringTwoRoute.kt +++ b/feature/src/main/java/com/terning/feature/filtering/filteringtwo/FilteringTwoRoute.kt @@ -55,8 +55,7 @@ fun FilteringTwoRoute( onNextClick = onNextClick, navigateUp = viewModel::navigateUp, onButtonClick = { index -> - viewModel.updateWorkingPeriod(index) - viewModel.updateButtonValidation() + viewModel.updateWorkingPeriodAndButton(index) }, buttonState = state.isButtonValid, workingPeriod = state.workingPeriod, diff --git a/feature/src/main/java/com/terning/feature/filtering/filteringtwo/FilteringTwoViewModel.kt b/feature/src/main/java/com/terning/feature/filtering/filteringtwo/FilteringTwoViewModel.kt index 3dc4c8afd..2076a5221 100644 --- a/feature/src/main/java/com/terning/feature/filtering/filteringtwo/FilteringTwoViewModel.kt +++ b/feature/src/main/java/com/terning/feature/filtering/filteringtwo/FilteringTwoViewModel.kt @@ -2,8 +2,6 @@ package com.terning.feature.filtering.filteringtwo import androidx.lifecycle.ViewModel import androidx.lifecycle.viewModelScope -import com.terning.feature.filtering.filteringone.FilteringOneSideEffect -import com.terning.feature.filtering.filteringone.FilteringOneState import kotlinx.coroutines.flow.MutableSharedFlow import kotlinx.coroutines.flow.MutableStateFlow import kotlinx.coroutines.flow.SharedFlow @@ -12,7 +10,7 @@ import kotlinx.coroutines.flow.asSharedFlow import kotlinx.coroutines.flow.asStateFlow import kotlinx.coroutines.launch -class FilteringTwoViewModel : ViewModel(){ +class FilteringTwoViewModel : ViewModel() { private val _state: MutableStateFlow = MutableStateFlow(FilteringTwoState()) val state: StateFlow get() = _state.asStateFlow() @@ -20,12 +18,11 @@ class FilteringTwoViewModel : ViewModel(){ private val _sideEffects = MutableSharedFlow() val sideEffects: SharedFlow get() = _sideEffects.asSharedFlow() - fun updateButtonValidation() { - _state.value = _state.value.copy(isButtonValid = true) - } - - fun updateWorkingPeriod(workingPeriod: Int) { - _state.value = _state.value.copy(workingPeriod = workingPeriod) + fun updateWorkingPeriodAndButton(workingPeriod: Int) { + _state.value = _state.value.copy( + workingPeriod = workingPeriod, + isButtonValid = true + ) } fun navigateUp() =