Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,5 @@ import Foundation
extension Notification.Name {
static let showRecommendedRoutineToast = Notification.Name("showRecommendedRoutineToast")
static let showDeletedRoutineToast = Notification.Name("showDeletedRoutineToast")
static let showUpdatedRoutineToast = Notification.Name("showUpdatedRoutineToast")
}
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,7 @@ final class RoutineCreationViewController: BaseViewController<RoutineCreationVie
viewModel.action(input: .showRecommendedRoutineToastMessageView)
}
} else {
viewModel.action(input: .showUpdateRoutineToastMessageView)
self.navigationController?.popViewController(animated: true)
}
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ final class RoutineCreationViewModel: ViewModel {
case configureExecution(type: ExecutionTime)
case registerRoutine
case showRecommendedRoutineToastMessageView
case showUpdateRoutineToastMessageView
}

struct Output {
Expand Down Expand Up @@ -111,6 +112,8 @@ final class RoutineCreationViewModel: ViewModel {
periodEndSubject.send(date)
case .showRecommendedRoutineToastMessageView:
showRecommendedRoutineToastMessageView()
case .showUpdateRoutineToastMessageView:
showUpdatedRoutineToastMessageView()
}

updateIsRoutineValid()
Expand Down Expand Up @@ -291,4 +294,13 @@ final class RoutineCreationViewModel: ViewModel {
userInfo: nil)
}
}

private func showUpdatedRoutineToastMessageView() {
DispatchQueue.main.asyncAfter(deadline: .now() + 0.6) {
NotificationCenter.default.post(
name: .showUpdatedRoutineToast,
object: nil,
userInfo: nil)
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ final class RoutineListViewController: BaseViewController<RoutineListViewModel>
private let routineStackView = UIStackView()
private var routineCardViews: [String: RoutineCardView] = [:]
private let deleteToastMessage: String = "삭제가 완료되었습니다."
private let updateToastMessage: String = "루틴 수정이 완료되었습니다."
private var toastMessageView = ToastView(message: "")
private var dimmedView: UIView?
private var cancellables: Set<AnyCancellable>
Expand Down Expand Up @@ -149,6 +150,16 @@ final class RoutineListViewController: BaseViewController<RoutineListViewModel>
self.toastMessageView.showToastMessageView(message: deleteToastMessage)
}
.store(in: &cancellables)

NotificationCenter.default.publisher(for: .showUpdatedRoutineToast)
.receive(on: DispatchQueue.main)
.sink { [weak self] _ in
guard let self else { return }
self.viewModel.action(input: .fetchRoutineList)
self.viewModel.action(input: .fetchDailyRoutine)
self.toastMessageView.showToastMessageView(message: updateToastMessage)
}
.store(in: &cancellables)
}

private func updateRoutineStackView(routines: [Routine]) {
Expand Down