diff --git a/Projects/Presentation/Sources/Home/View/Component/DateView.swift b/Projects/Presentation/Sources/Home/View/Component/DateView.swift index be36374..6e24b81 100644 --- a/Projects/Presentation/Sources/Home/View/Component/DateView.swift +++ b/Projects/Presentation/Sources/Home/View/Component/DateView.swift @@ -124,7 +124,7 @@ final class DateView: UIView { self.isSelected = isSelected } - func updateAllCompleted() { - allCompletedIcon.isHidden.toggle() + func updateAllCompleted(isCompleted: Bool) { + allCompletedIcon.isHidden = !isCompleted } } diff --git a/Projects/Presentation/Sources/Home/View/Component/WeekView.swift b/Projects/Presentation/Sources/Home/View/Component/WeekView.swift index e49d770..60d105f 100644 --- a/Projects/Presentation/Sources/Home/View/Component/WeekView.swift +++ b/Projects/Presentation/Sources/Home/View/Component/WeekView.swift @@ -91,7 +91,7 @@ final class WeekView: UIView { let isAllCompleted = allCompletedDates.contains(date) if isAllCompleted { - dateView.updateAllCompleted() + dateView.updateAllCompleted(isCompleted: true) } dateView.didTapDateButton = { [weak self] date in self?.selectDate(date: date) @@ -109,7 +109,9 @@ final class WeekView: UIView { self.allCompletedDates = allCompletedDates for dateView in dateViews { if allCompletedDates.contains(dateView.key) { - dateView.value.updateAllCompleted() + dateView.value.updateAllCompleted(isCompleted: true) + } else { + dateView.value.updateAllCompleted(isCompleted: false) } } } diff --git a/Projects/Presentation/Sources/Home/View/HomeViewController.swift b/Projects/Presentation/Sources/Home/View/HomeViewController.swift index 31c8de3..5e3a6be 100644 --- a/Projects/Presentation/Sources/Home/View/HomeViewController.swift +++ b/Projects/Presentation/Sources/Home/View/HomeViewController.swift @@ -74,6 +74,7 @@ final class HomeViewController: BaseViewController { // routineView private let emptyView = HomeEmptyView() + private let refreshControl = UIRefreshControl() private let routineHeaderView = UIView() private let routineListLabel = UILabel() private let routineListButton = UIButton() @@ -181,6 +182,12 @@ final class HomeViewController: BaseViewController { self.navigationController?.pushViewController(routineCreationView, animated: true) } + routineScrollView.refreshControl = refreshControl + refreshControl.addTarget( + self, + action: #selector(pullToRoutineRefresh), + for: .valueChanged) + routineListLabel.text = "루틴 리스트" routineListLabel.font = BitnagilFont(style: .body2, weight: .semiBold).font routineListLabel.textColor = BitnagilColor.gray60 @@ -433,6 +440,7 @@ final class HomeViewController: BaseViewController { .receive(on: DispatchQueue.main) .sink { [weak self] routines in self?.updateRoutineView(routines: routines) + self?.routineScrollView.refreshControl?.endRefreshing() self?.hideIndicatorView() } .store(in: &cancellables) @@ -635,6 +643,10 @@ final class HomeViewController: BaseViewController { emotionRegistrationViewController.hidesBottomBarWhenPushed = true navigationController?.pushViewController(emotionRegistrationViewController, animated: true) } + + @objc private func pullToRoutineRefresh() { + viewModel.action(input: .refreshDailyRoutine) + } } // MARK: WeekViewDelegate diff --git a/Projects/Presentation/Sources/RoutineCreation/View/RoutineCreationViewController.swift b/Projects/Presentation/Sources/RoutineCreation/View/RoutineCreationViewController.swift index 9431abf..c67a153 100644 --- a/Projects/Presentation/Sources/RoutineCreation/View/RoutineCreationViewController.swift +++ b/Projects/Presentation/Sources/RoutineCreation/View/RoutineCreationViewController.swift @@ -146,19 +146,6 @@ final class RoutineCreationViewController: BaseViewController let executionTimePublisher: AnyPublisher let isRoutineValid: AnyPublisher + let routineCreationResultPublisher: AnyPublisher let networkErrorPublisher: AnyPublisher<(() -> Void)?, Never> } @@ -55,6 +56,7 @@ final class RoutineCreationViewModel: ViewModel { private let periodEndSubject = CurrentValueSubject(nil) private let executionTimeSubject = CurrentValueSubject(.init(startAt: nil)) private let checkRoutinePublisher = CurrentValueSubject(false) + private let routineCreationResultSubject = PassthroughSubject() private let routineUseCase: RoutineUseCaseProtocol private let networkRetryHandler: NetworkRetryHandler private let recommenededRoutineUseCase: RecommendedRoutineUseCaseProtocol @@ -82,6 +84,7 @@ final class RoutineCreationViewModel: ViewModel { .map { $0.startAt } .eraseToAnyPublisher(), isRoutineValid: checkRoutinePublisher.eraseToAnyPublisher(), + routineCreationResultPublisher: routineCreationResultSubject.eraseToAnyPublisher(), networkErrorPublisher: networkRetryHandler.networkErrorActionSubject.eraseToAnyPublisher()) updateIsRoutineValid() @@ -302,8 +305,10 @@ final class RoutineCreationViewModel: ViewModel { try await routineUseCase.saveRoutine(routine: routine) + routineCreationResultSubject.send(true) networkRetryHandler.clearRetryState() } catch { + routineCreationResultSubject.send(false) networkRetryHandler.handleNetworkError(error) { [weak self] in self?.registerRoutine() }