-
Notifications
You must be signed in to change notification settings - Fork 1
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
Showing
5 changed files
with
93 additions
and
15 deletions.
There are no files selected for viewing
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
5 changes: 5 additions & 0 deletions
5
feature/src/main/java/com/terning/feature/filtering/filteringtwo/FilteringTwoSideEffect.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 |
---|---|---|
@@ -0,0 +1,5 @@ | ||
package com.terning.feature.filtering.filteringtwo | ||
|
||
sealed class FilteringTwoSideEffect { | ||
data object NavigateUp : FilteringTwoSideEffect() | ||
} |
6 changes: 6 additions & 0 deletions
6
feature/src/main/java/com/terning/feature/filtering/filteringtwo/FilteringTwoState.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 |
---|---|---|
@@ -0,0 +1,6 @@ | ||
package com.terning.feature.filtering.filteringtwo | ||
|
||
data class FilteringTwoState( | ||
val isButtonValid: Boolean = false, | ||
val workingPeriod: Int = -1 | ||
) |
33 changes: 33 additions & 0 deletions
33
feature/src/main/java/com/terning/feature/filtering/filteringtwo/FilteringTwoViewModel.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 |
---|---|---|
@@ -0,0 +1,33 @@ | ||
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 | ||
import kotlinx.coroutines.flow.StateFlow | ||
import kotlinx.coroutines.flow.asSharedFlow | ||
import kotlinx.coroutines.flow.asStateFlow | ||
import kotlinx.coroutines.launch | ||
|
||
class FilteringTwoViewModel : ViewModel(){ | ||
|
||
private val _state: MutableStateFlow<FilteringTwoState> = MutableStateFlow(FilteringTwoState()) | ||
val state: StateFlow<FilteringTwoState> get() = _state.asStateFlow() | ||
|
||
private val _sideEffects = MutableSharedFlow<FilteringTwoSideEffect>() | ||
val sideEffects: SharedFlow<FilteringTwoSideEffect> get() = _sideEffects.asSharedFlow() | ||
|
||
fun updateButtonValidation() { | ||
_state.value = _state.value.copy(isButtonValid = true) | ||
} | ||
|
||
fun updateWorkingPeriod(workingPeriod: Int) { | ||
_state.value = _state.value.copy(workingPeriod = workingPeriod) | ||
} | ||
|
||
fun navigateUp() = | ||
viewModelScope.launch { _sideEffects.emit(FilteringTwoSideEffect.NavigateUp) } | ||
} |
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