Skip to content

Commit

Permalink
[FIX] #84 - 컨벤션, 코드 수정
Browse files Browse the repository at this point in the history
  • Loading branch information
jeongdung-eo committed Jan 13, 2023
1 parent ea34596 commit 3d60355
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 50 deletions.
23 changes: 2 additions & 21 deletions NotToDo/NotToDo/Network/API/Achieve/AchieveAPI.swift
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ final class AchieveAPI {
self.missionStatisticsData = try response.map(GeneralArrayResponse<MissionStatistcsResponseDTO>?.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):
Expand All @@ -62,26 +62,7 @@ final class AchieveAPI {
}

// MARK: - GET

// func getAchieveCalendar(month: String, completion: @escaping (GeneralResponse<AchieveCalendarResponse>?) -> Void) {
// achieveProvider.request(.achieveCalendar(month: month)) { result in
// switch result {
// case .success(let response):
// do {
// self.achieveCalendarData = try response.map(GeneralResponse<AchieveCalendarResponse>?.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<Any>) -> Void) {
achieveProvider.request(.achieveCalendar(month: month)) { response in
switch response {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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]
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ final class AchievementViewController: UIViewController {
}
}


// MARK: - UI Components

private lazy var scrollView = UIScrollView()
Expand All @@ -42,7 +41,6 @@ final class AchievementViewController: UIViewController {
var missionList: [MissionStatistcsResponseDTO] = []
var dataSource: [String: Int] = [:]


// MARK: - View Life Cycle

override func viewWillAppear(_ animated: Bool) {
Expand Down Expand Up @@ -283,4 +281,3 @@ extension AchievementViewController: FSCalendarDataSource {
return cell
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -99,7 +99,6 @@ extension CustomCalendar {
}
}


private func calendarText() {
calendar.calendarHeaderView.isHidden = true
calendar.calendarWeekdayView.weekdayLabels[0].text = ""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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
}
Expand Down

0 comments on commit 3d60355

Please sign in to comment.