diff --git a/NotToDo/NotToDo/Network/API/Achieve/AchieveAPI.swift b/NotToDo/NotToDo/Network/API/Achieve/AchieveAPI.swift index 3792c79..c67bcb7 100644 --- a/NotToDo/NotToDo/Network/API/Achieve/AchieveAPI.swift +++ b/NotToDo/NotToDo/Network/API/Achieve/AchieveAPI.swift @@ -51,7 +51,7 @@ final class AchieveAPI { self.missionStatisticsData = try response.map(GeneralArrayResponse?.self) guard let situationStatisticsData = self.missionStatisticsData else { return } completion(self.missionStatisticsData) - } catch (let err) { + } catch let err { print(err.localizedDescription, 500) } case .failure(let err): @@ -62,26 +62,7 @@ final class AchieveAPI { } // MARK: - GET - -// func getAchieveCalendar(month: String, completion: @escaping (GeneralResponse?) -> Void) { -// achieveProvider.request(.achieveCalendar(month: month)) { result in -// switch result { -// case .success(let response): -// do { -// self.achieveCalendarData = try response.map(GeneralResponse?.self) -// guard let achieveCalendarData = self.achieveCalendarData else { return } -// completion(self.achieveCalendarData) -// } catch (let err) { -// print(err.localizedDescription, 500) -// } -// case .failure(let err): -// print(err.localizedDescription) -// completion(nil) -// } -// } -// } - - + func getAchieveCalendar(month: String, completion: @escaping (NetworkResult) -> Void) { achieveProvider.request(.achieveCalendar(month: month)) { response in switch response { diff --git a/NotToDo/NotToDo/Network/DataModel/Achieve/AchieveCalendarResponseDTO.swift b/NotToDo/NotToDo/Network/DataModel/Achieve/AchieveCalendarResponseDTO.swift index 05fef48..9a12629 100644 --- a/NotToDo/NotToDo/Network/DataModel/Achieve/AchieveCalendarResponseDTO.swift +++ b/NotToDo/NotToDo/Network/DataModel/Achieve/AchieveCalendarResponseDTO.swift @@ -22,8 +22,8 @@ struct AchieveCalendarResponseDTO: Codable { } } - func convert() -> [Date:Int] { + func convert() -> [Date: Int] { guard let date = self.toDate(dateString: actionDate) else { return [:]} - return [date:count] + return [date: count] } } diff --git a/NotToDo/NotToDo/Presentation/AchievementScene/ViewControllers/AchievementViewController.swift b/NotToDo/NotToDo/Presentation/AchievementScene/ViewControllers/AchievementViewController.swift index aa6d639..c3e79d6 100644 --- a/NotToDo/NotToDo/Presentation/AchievementScene/ViewControllers/AchievementViewController.swift +++ b/NotToDo/NotToDo/Presentation/AchievementScene/ViewControllers/AchievementViewController.swift @@ -22,7 +22,6 @@ final class AchievementViewController: UIViewController { } } - // MARK: - UI Components private lazy var scrollView = UIScrollView() @@ -42,7 +41,6 @@ final class AchievementViewController: UIViewController { var missionList: [MissionStatistcsResponseDTO] = [] var dataSource: [String: Int] = [:] - // MARK: - View Life Cycle override func viewWillAppear(_ animated: Bool) { @@ -283,4 +281,3 @@ extension AchievementViewController: FSCalendarDataSource { return cell } } - diff --git a/NotToDo/NotToDo/Presentation/AchievementScene/Views/CustomCalendarView.swift b/NotToDo/NotToDo/Presentation/AchievementScene/Views/CustomCalendarView.swift index 9934fa9..cef6537 100644 --- a/NotToDo/NotToDo/Presentation/AchievementScene/Views/CustomCalendarView.swift +++ b/NotToDo/NotToDo/Presentation/AchievementScene/Views/CustomCalendarView.swift @@ -25,7 +25,7 @@ class CustomCalendar: UIView { private lazy var today: Date = { return Date() }() lazy var dateFormatter = DateFormatter() var monthData: [AchieveCalendarResponseDTO] = [] - var monthCalendarClosure: ((_ month:String) -> Void)? + var monthCalendarClosure: ((_ month: String) -> Void)? // MARK: - View Life Cycle @@ -99,7 +99,6 @@ extension CustomCalendar { } } - private func calendarText() { calendar.calendarHeaderView.isHidden = true calendar.calendarWeekdayView.weekdayLabels[0].text = "일" diff --git a/NotToDo/NotToDo/Presentation/HomeScene/Cells/HomeCalendarCollectionViewCell.swift b/NotToDo/NotToDo/Presentation/HomeScene/Cells/HomeCalendarCollectionViewCell.swift index e67118e..2003e74 100644 --- a/NotToDo/NotToDo/Presentation/HomeScene/Cells/HomeCalendarCollectionViewCell.swift +++ b/NotToDo/NotToDo/Presentation/HomeScene/Cells/HomeCalendarCollectionViewCell.swift @@ -13,14 +13,10 @@ import Then final class HomeCalendarCollectionViewCell: UICollectionViewCell { - // TODO: 해당 데이터 가지고 셀 각각에 데이터 뿌려주면 될듯 - // 딕셔너리나 배열 적절하게 선택해서 사용하기 -> 배열이 더 익숙하니까 배열 사용하는 것이 더 편할 것임 - // 아마 서버에서 [날짜(String), Int] 값을 배열 형태로 같이 넘겨줄 것 같은데 그거 가지고 사용하면 됨 - var dataSource: [String: Int] = [:] - // MARK: - Properties static let identifier = "HomeCalendarCollectionViewCell" + var dataSource: [String: Int] = [:] // MARK: - UI Components @@ -102,25 +98,8 @@ extension HomeCalendarCollectionViewCell { extension HomeCalendarCollectionViewCell: 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 }