From 761da1dce9e12b03711e69d102dcd1430a9b42a5 Mon Sep 17 00:00:00 2001 From: jeongdung-eo Date: Fri, 13 Jan 2023 20:07:00 +0900 Subject: [PATCH] =?UTF-8?q?[ADD]=20#84=20-=20=EC=BA=98=EB=A6=B0=EB=8D=94?= =?UTF-8?q?=20=EC=BD=94=EB=93=9C=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../AchievementViewController.swift | 39 ++++++++++++++++++- 1 file changed, 37 insertions(+), 2 deletions(-) diff --git a/NotToDo/NotToDo/Presentation/AchievementScene/ViewControllers/AchievementViewController.swift b/NotToDo/NotToDo/Presentation/AchievementScene/ViewControllers/AchievementViewController.swift index d17e4ed..35a24de 100644 --- a/NotToDo/NotToDo/Presentation/AchievementScene/ViewControllers/AchievementViewController.swift +++ b/NotToDo/NotToDo/Presentation/AchievementScene/ViewControllers/AchievementViewController.swift @@ -14,6 +14,8 @@ final class AchievementViewController: UIViewController { // MARK: - Properties + var dataSource: [String: Int] = [:] + var shouldHideMissionView: Bool? { didSet { guard let shouldHideMissionView = self.shouldHideMissionView else { return } @@ -77,6 +79,10 @@ extension AchievementViewController { $0.layer.borderWidth = 1 $0.layer.borderColor = UIColor.nottodoGray2?.cgColor $0.calendar.delegate = self + /* */ + $0.calendar.dataSource = self + $0.calendar.register(MissionCalendarDayCell.self, forCellReuseIdentifier: String(describing: MissionCalendarDayCell.self)) + } bottomLabel.do { $0.text = I18N.statistcisBottomMessage @@ -236,14 +242,43 @@ extension AchievementViewController { } } -extension AchievementViewController: FSCalendarDelegate, FSCalendarDataSource { +extension AchievementViewController: FSCalendarDelegate { func calendarCurrentPageDidChange(_ calendar: FSCalendar) { calendarView.calendar.reloadData() reloadMonthData() calendarView.headerLabel.text = calendarView.dateFormatter.string(from: calendar.currentPage) } - func calendar(_ calendar: FSCalendar, shouldSelect date: Date, at monthPosition: FSCalendarMonthPosition) -> Bool { return false } } + +extension AchievementViewController: FSCalendarDataSource { + + // 서버에서 넘어온 dateString이랑 이 메서드의 date를 잘 매칭시켜줘야 함 + // date 매칭된 것에 맞게 데이터를 넘겨줘야 함 + func calendar(_ calendar: FSCalendar, cellFor date: Date, at position: FSCalendarMonthPosition) -> FSCalendarCell { + let cell = calendar.dequeueReusableCell(withIdentifier: String(describing: MissionCalendarDayCell.self), for: date, at: position) as! MissionCalendarDayCell + + // MARK: 서버에서 넘어온 값에 따라 셀 상태 변화시켜주기 + // Date : Int(Enum) + /* + NotToDoCalendarCell에 가보면 Enum이 보일 것임 + 프로젝트 상황에 따라 적절하게 바꿔서 사용하기 + + 현재는 5개의 case가 있음 + - none, step1, step2, step3, bordered + + case에 따라서 backgroundColor 변화시키는 식으로 구현되어 있는데 UI 디테일을 살리고 싶으면 + 그냥 case에 따라 이미지를 넣는 것이 더 쉬움 + */ + + // 캘린더 셀 설정해주는 코드 : CollectionViewCell이랑 동일하게 생각하면 됨 + cell.configure(.bordered) + return cell + } +} + +extension AchievementViewController: FSCalendarDelegateAppearance { + +}