File tree Expand file tree Collapse file tree
domain/src/main/java/com/threegap/bitnagil/domain/routine Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11package com.threegap.bitnagil.domain.routine.model
22
33data class RoutineToggleState (
4+ val isCompleted : Boolean ,
45 val subRoutinesIsCompleted : List <Boolean >,
5- ) {
6- val isCompleted: Boolean
7- get() = subRoutinesIsCompleted.all { it }
8- }
6+ )
Original file line number Diff line number Diff line change @@ -21,6 +21,7 @@ class ToggleRoutineUseCase @Inject constructor() {
2121 val newSubRoutineStates = subRoutineStates.map { newIsCompleted }
2222
2323 return RoutineToggleState (
24+ isCompleted = newIsCompleted,
2425 subRoutinesIsCompleted = newSubRoutineStates,
2526 )
2627 }
@@ -37,16 +38,17 @@ class ToggleRoutineUseCase @Inject constructor() {
3738 index : Int ,
3839 subRoutineStates : List <Boolean >,
3940 ): RoutineToggleState ? {
40- if (index !in subRoutineStates.indices) {
41- return null
42- }
41+ if (index !in subRoutineStates.indices) return null
4342
4443 val newState = ! subRoutineStates[index]
4544 val newSubRoutineStates = subRoutineStates.toMutableList().apply {
4645 this [index] = newState
4746 }
4847
48+ val allCompleted = newSubRoutineStates.all { it }
49+
4950 return RoutineToggleState (
51+ isCompleted = allCompleted,
5052 subRoutinesIsCompleted = newSubRoutineStates,
5153 )
5254 }
You can’t perform that action at this time.
0 commit comments