Skip to content

Commit 3965182

Browse files
authored
Feat: 루틴 수정 후 토스트 메시지 표시 (#T3-208)
1 parent de8a12d commit 3965182

File tree

4 files changed

+25
-0
lines changed

4 files changed

+25
-0
lines changed

Projects/Presentation/Sources/Common/Extension/Notification+.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,5 @@ import Foundation
1010
extension Notification.Name {
1111
static let showRecommendedRoutineToast = Notification.Name("showRecommendedRoutineToast")
1212
static let showDeletedRoutineToast = Notification.Name("showDeletedRoutineToast")
13+
static let showUpdatedRoutineToast = Notification.Name("showUpdatedRoutineToast")
1314
}

Projects/Presentation/Sources/RoutineCreation/View/RoutineCreationViewController.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,7 @@ final class RoutineCreationViewController: BaseViewController<RoutineCreationVie
155155
viewModel.action(input: .showRecommendedRoutineToastMessageView)
156156
}
157157
} else {
158+
viewModel.action(input: .showUpdateRoutineToastMessageView)
158159
self.navigationController?.popViewController(animated: true)
159160
}
160161
},

Projects/Presentation/Sources/RoutineCreation/ViewModel/RoutineCreationViewModel.swift

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ final class RoutineCreationViewModel: ViewModel {
3434
case configureExecution(type: ExecutionTime)
3535
case registerRoutine
3636
case showRecommendedRoutineToastMessageView
37+
case showUpdateRoutineToastMessageView
3738
}
3839

3940
struct Output {
@@ -111,6 +112,8 @@ final class RoutineCreationViewModel: ViewModel {
111112
periodEndSubject.send(date)
112113
case .showRecommendedRoutineToastMessageView:
113114
showRecommendedRoutineToastMessageView()
115+
case .showUpdateRoutineToastMessageView:
116+
showUpdatedRoutineToastMessageView()
114117
}
115118

116119
updateIsRoutineValid()
@@ -291,4 +294,13 @@ final class RoutineCreationViewModel: ViewModel {
291294
userInfo: nil)
292295
}
293296
}
297+
298+
private func showUpdatedRoutineToastMessageView() {
299+
DispatchQueue.main.asyncAfter(deadline: .now() + 0.6) {
300+
NotificationCenter.default.post(
301+
name: .showUpdatedRoutineToast,
302+
object: nil,
303+
userInfo: nil)
304+
}
305+
}
294306
}

Projects/Presentation/Sources/RoutineList/View/RoutineListViewController.swift

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ final class RoutineListViewController: BaseViewController<RoutineListViewModel>
3030
private let routineStackView = UIStackView()
3131
private var routineCardViews: [String: RoutineCardView] = [:]
3232
private let deleteToastMessage: String = "삭제가 완료되었습니다."
33+
private let updateToastMessage: String = "루틴 수정이 완료되었습니다."
3334
private var toastMessageView = ToastView(message: "")
3435
private var dimmedView: UIView?
3536
private var cancellables: Set<AnyCancellable>
@@ -149,6 +150,16 @@ final class RoutineListViewController: BaseViewController<RoutineListViewModel>
149150
self.toastMessageView.showToastMessageView(message: deleteToastMessage)
150151
}
151152
.store(in: &cancellables)
153+
154+
NotificationCenter.default.publisher(for: .showUpdatedRoutineToast)
155+
.receive(on: DispatchQueue.main)
156+
.sink { [weak self] _ in
157+
guard let self else { return }
158+
self.viewModel.action(input: .fetchRoutineList)
159+
self.viewModel.action(input: .fetchDailyRoutine)
160+
self.toastMessageView.showToastMessageView(message: updateToastMessage)
161+
}
162+
.store(in: &cancellables)
152163
}
153164

154165
private func updateRoutineStackView(routines: [Routine]) {

0 commit comments

Comments
 (0)