File tree Expand file tree Collapse file tree 4 files changed +15
-7
lines changed
presentation/src/main/java/com/threegap/bitnagil/presentation/routinelist Expand file tree Collapse file tree 4 files changed +15
-7
lines changed Original file line number Diff line number Diff line change @@ -22,6 +22,7 @@ import androidx.lifecycle.compose.collectAsStateWithLifecycle
2222import com.threegap.bitnagil.designsystem.BitnagilTheme
2323import com.threegap.bitnagil.designsystem.component.block.BitnagilTopBar
2424import com.threegap.bitnagil.presentation.common.flow.collectAsEffect
25+ import com.threegap.bitnagil.presentation.common.toast.GlobalBitnagilToast
2526import com.threegap.bitnagil.presentation.routinelist.component.template.DeleteConfirmBottomSheet
2627import com.threegap.bitnagil.presentation.routinelist.component.template.EditConfirmBottomSheet
2728import com.threegap.bitnagil.presentation.routinelist.component.template.EmptyRoutineListView
@@ -44,10 +45,9 @@ fun RoutineListScreenContainer(
4445
4546 viewModel.sideEffectFlow.collectAsEffect { sideEffect ->
4647 when (sideEffect) {
48+ is RoutineListSideEffect .ShowToast -> GlobalBitnagilToast .showCheck(sideEffect.message)
4749 is RoutineListSideEffect .NavigateToBack -> navigateToBack()
48- is RoutineListSideEffect .NavigateToAddRoutine -> {
49- navigateToAddRoutine()
50- }
50+ is RoutineListSideEffect .NavigateToAddRoutine -> navigateToAddRoutine()
5151 is RoutineListSideEffect .NavigateToEditRoutine -> {
5252 navigateToEditRoutine(sideEffect.routineId, sideEffect.updateRoutineFromNowDate)
5353 }
Original file line number Diff line number Diff line change @@ -103,6 +103,14 @@ class RoutineListViewModel @Inject constructor(
103103 }
104104 null
105105 }
106+
107+ is RoutineListIntent .OnSuccessDeletedRoutine -> {
108+ sendSideEffect(RoutineListSideEffect .ShowToast (" 삭제가 완료되었습니다." ))
109+ state.copy(
110+ isLoading = false ,
111+ deleteConfirmBottomSheetVisible = false ,
112+ )
113+ }
106114 }
107115
108116 return newState
@@ -133,8 +141,7 @@ class RoutineListViewModel @Inject constructor(
133141 viewModelScope.launch {
134142 deleteRoutineUseCase(selectedRoutine.routineId).fold(
135143 onSuccess = {
136- sendIntent(RoutineListIntent .HideDeleteConfirmBottomSheet )
137- sendIntent(RoutineListIntent .UpdateLoading (false ))
144+ sendIntent(RoutineListIntent .OnSuccessDeletedRoutine )
138145 },
139146 onFailure = {
140147 Log .e(" RoutineListViewModel" , " 루틴 삭제 실패: ${it.message} " )
@@ -150,8 +157,7 @@ class RoutineListViewModel @Inject constructor(
150157 viewModelScope.launch {
151158 deleteRoutineForDayUseCase(selectedRoutine.routineId).fold(
152159 onSuccess = {
153- sendIntent(RoutineListIntent .HideDeleteConfirmBottomSheet )
154- sendIntent(RoutineListIntent .UpdateLoading (false ))
160+ sendIntent(RoutineListIntent .OnSuccessDeletedRoutine )
155161 },
156162 onFailure = {
157163 Log .e(" RoutineListViewModel" , " 루틴 삭제 실패: ${it.message} " )
Original file line number Diff line number Diff line change @@ -15,4 +15,5 @@ sealed class RoutineListIntent : MviIntent {
1515 data object OnRegisterRoutineClick : RoutineListIntent ()
1616 data object OnApplyTodayClick : RoutineListIntent ()
1717 data object OnApplyTomorrowClick : RoutineListIntent ()
18+ data object OnSuccessDeletedRoutine : RoutineListIntent ()
1819}
Original file line number Diff line number Diff line change @@ -6,4 +6,5 @@ sealed interface RoutineListSideEffect : MviSideEffect {
66 data object NavigateToBack : RoutineListSideEffect
77 data object NavigateToAddRoutine : RoutineListSideEffect
88 data class NavigateToEditRoutine (val routineId : String , val updateRoutineFromNowDate : Boolean ) : RoutineListSideEffect
9+ data class ShowToast (val message : String ) : RoutineListSideEffect
910}
You can’t perform that action at this time.
0 commit comments