From 288f3ab3d4ab32ebba453edbdbaf17f2daacd464 Mon Sep 17 00:00:00 2001 From: yungu0010 Date: Fri, 13 Jan 2023 15:33:44 +0900 Subject: [PATCH 1/2] =?UTF-8?q?[FIX]=20#86=20-=20=EC=82=AD=EC=A0=9C?= =?UTF-8?q?=ED=95=98=EA=B8=B0=20=ED=9B=84=20collectionView=20reload()?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Common/ActionSheet/ActionSheetViewController.swift | 7 ++++--- .../HomeScene/ViewControllers/HomeViewController.swift | 3 ++- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/NotToDo/NotToDo/Presentation/Common/ActionSheet/ActionSheetViewController.swift b/NotToDo/NotToDo/Presentation/Common/ActionSheet/ActionSheetViewController.swift index 8051ede..6d5f15e 100644 --- a/NotToDo/NotToDo/Presentation/Common/ActionSheet/ActionSheetViewController.swift +++ b/NotToDo/NotToDo/Presentation/Common/ActionSheet/ActionSheetViewController.swift @@ -101,8 +101,10 @@ extension ActionSheetViewController { private func requestDeleteMission(id: Int) { HomeAPI.shared.deleteMission(id: id) { [weak self] response in - guard self != nil else { return } + guard let self = self else { return } guard response != nil else { return } + self.delegate?.reloadMissionData() + self.dismiss(animated: true) } } @@ -123,8 +125,7 @@ extension ActionSheetViewController { @objc private func deleteButtonDidTap() { requestDeleteMission(id: id) - delegate?.reloadMissionData() - self.dismiss(animated: true) + } @objc private func choiceFinishButtonDidTap() { diff --git a/NotToDo/NotToDo/Presentation/HomeScene/ViewControllers/HomeViewController.swift b/NotToDo/NotToDo/Presentation/HomeScene/ViewControllers/HomeViewController.swift index 1d55bda..25b5319 100644 --- a/NotToDo/NotToDo/Presentation/HomeScene/ViewControllers/HomeViewController.swift +++ b/NotToDo/NotToDo/Presentation/HomeScene/ViewControllers/HomeViewController.swift @@ -56,7 +56,7 @@ extension HomeViewController: ActionSheetViewDelegate { func reloadMissionData() { requestWeeklyMissoinAPI(startDate: "2023-01-23") requestDailyMissionAPI(date: "2023-01-25") - homeView.homeCollectionView.reloadData() + } } @@ -186,6 +186,7 @@ extension HomeViewController: UICollectionViewDataSource { actionSheetViewController.modalPresentationStyle = .overFullScreen actionSheetViewController.modalTransitionStyle = .crossDissolve actionSheetViewController.id = missionId + actionSheetViewController.delegate = self actionSheetViewController.situation = self?.missionList[indexPath.row].situation ?? "" actionSheetViewController.mission = self?.missionList[indexPath.row].title ?? "" self?.present(actionSheetViewController, animated: true) From f4e97bb916f9135f089a7893ed15bff22b8fe132 Mon Sep 17 00:00:00 2001 From: yungu0010 Date: Fri, 13 Jan 2023 16:00:11 +0900 Subject: [PATCH 2/2] =?UTF-8?q?[FEAT]=20#86=20-=20=EC=84=A0=ED=83=9D?= =?UTF-8?q?=ED=95=9C=20=EB=82=A0=EC=A7=9C=EC=9D=98=20=EC=9D=BC=EB=B3=84=20?= =?UTF-8?q?=EB=82=AB=ED=88=AC=EB=91=90=20=EB=A6=AC=EC=8A=A4=ED=8A=B8=20?= =?UTF-8?q?=EC=A1=B0=ED=9A=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../HomeCalendarCollectionViewCell.swift | 6 ------ .../ViewControllers/HomeViewController.swift | 20 +++++++++++++++++-- 2 files changed, 18 insertions(+), 8 deletions(-) diff --git a/NotToDo/NotToDo/Presentation/HomeScene/Cells/HomeCalendarCollectionViewCell.swift b/NotToDo/NotToDo/Presentation/HomeScene/Cells/HomeCalendarCollectionViewCell.swift index 4243e0d..6cc1d53 100644 --- a/NotToDo/NotToDo/Presentation/HomeScene/Cells/HomeCalendarCollectionViewCell.swift +++ b/NotToDo/NotToDo/Presentation/HomeScene/Cells/HomeCalendarCollectionViewCell.swift @@ -70,8 +70,6 @@ extension HomeCalendarCollectionViewCell { $0.collectionView.snp.makeConstraints { $0.edges.equalToSuperview() } - $0.delegate = self - $0.dataSource = self } } @@ -86,7 +84,3 @@ extension HomeCalendarCollectionViewCell { } } } - -extension HomeCalendarCollectionViewCell: FSCalendarDataSource, FSCalendarDelegate { - -} diff --git a/NotToDo/NotToDo/Presentation/HomeScene/ViewControllers/HomeViewController.swift b/NotToDo/NotToDo/Presentation/HomeScene/ViewControllers/HomeViewController.swift index 25b5319..885620a 100644 --- a/NotToDo/NotToDo/Presentation/HomeScene/ViewControllers/HomeViewController.swift +++ b/NotToDo/NotToDo/Presentation/HomeScene/ViewControllers/HomeViewController.swift @@ -9,6 +9,7 @@ import UIKit import SnapKit import Then +import FSCalendar final class HomeViewController: UIViewController { @@ -17,6 +18,8 @@ final class HomeViewController: UIViewController { var missionList: [DailyMissionResponseDTO] = [] var banner: BannerResponseDTO? var missionId: Int? + private var clickedDay: String? + private let dateFormatter = DateFormatter() // MARK: - UI Components @@ -55,7 +58,7 @@ extension HomeViewController: CheckboxToolTipDelegate { extension HomeViewController: ActionSheetViewDelegate { func reloadMissionData() { requestWeeklyMissoinAPI(startDate: "2023-01-23") - requestDailyMissionAPI(date: "2023-01-25") + requestDailyMissionAPI(date: clickedDay ?? "") } } @@ -69,6 +72,11 @@ extension HomeViewController: UICollectionViewDelegate { $0.refreshControl?.addTarget(self, action: #selector(handleRefreshControl), for: .valueChanged) } + + dateFormatter.do { + $0.locale = Locale(identifier: "ko_KR") + $0.dateFormat = "yyyy-MM-dd" + } } private func setAddTarget() { @@ -95,7 +103,7 @@ extension HomeViewController: UICollectionViewDelegate { } private func requestDailyMissionAPI(date: String) { - HomeAPI.shared.getDailyMission(date: "2023-01-25") { [weak self] result in + HomeAPI.shared.getDailyMission(date: date) { [weak self] result in switch result { case let .success(data): guard let data = data as? [DailyMissionResponseDTO] else { return } @@ -162,6 +170,7 @@ extension HomeViewController: UICollectionViewDataSource { switch indexPath.section { case 0: guard let cell = collectionView.dequeueReusableCell(withReuseIdentifier: HomeCalendarCollectionViewCell.identifier, for: indexPath) as? HomeCalendarCollectionViewCell else { return UICollectionViewCell() } + cell.calendar.delegate = self return cell default: if missionList.isEmpty { @@ -272,3 +281,10 @@ extension HomeViewController: UICollectionViewDelegateFlowLayout { } } } + +extension HomeViewController: FSCalendarDelegate { + func calendar(_ calendar: FSCalendar, didSelect date: Date, at monthPosition: FSCalendarMonthPosition) { + clickedDay = dateFormatter.string(from: date) + requestDailyMissionAPI(date: clickedDay ?? "") + } +}