-
Notifications
You must be signed in to change notification settings - Fork 16
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Feat] #153- 출석 조회하기 API 연결 #157
The head ref may contain hidden characters: "#153-\uCD9C\uC11D\uC870\uD68C\uD558\uAE30-API\uC5F0\uACB0"
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
수고하셨습니다~~!!
// promise(.success(AttendanceScheduleModel(type: "HAS_ATTENDANCE", | ||
// location: "단국대학교 혜당관", | ||
// name: "3차 세미나", | ||
// startDate: "2023-04-06T14:14:00", endDate: "2023-04-06T18:00:00", message: "", | ||
// attendances: [TodayAttendanceModel(status: "ATTENDANCE", attendedAt: "2023-04-13T14:12:09"), | ||
// TodayAttendanceModel(status: "ABSENT", attendedAt: | ||
// "2023-04-13T14:10:04")]))) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
이 친구들은 토큰 받아오면 없어질 예정이겠죠..?
|
||
import Foundation | ||
|
||
public struct AttendanceScheduleModel: Codable, Hashable { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hashable을 채택한 이유가 궁금합니다!
image: DSKitAsset.Assets.opStateAttendance.image, | ||
date: "4월 \(indexPath.row*7+1)일") | ||
updateTableviewHeight() | ||
cell.setData(model: attendanceModelList[safe: indexPath.row]!) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
여기서 강제 언래핑을 한거라면 굳이 safe를 사용할 필요가 없을 것 같아요..!
.store(in: self.cancelBag) | ||
|
||
output.$scoreModel | ||
.sink { model in |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
여기도 weak self 필요할 것 같아요!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
수고 많으셨습니다!
private func convertDateString(_ dateString: String) -> String? { | ||
let dateFormatter = DateFormatter() | ||
dateFormatter.dateFormat = "yyyy-MM-dd'T'HH:mm:ss" | ||
guard let date = dateFormatter.date(from: dateString) else { return nil } | ||
|
||
dateFormatter.dateFormat = "M월 d일 EEEE H:mm" | ||
dateFormatter.locale = Locale(identifier: "ko_KR") | ||
dateFormatter.timeZone = TimeZone(identifier: "Asia/Seoul") | ||
return dateFormatter.string(from: date) | ||
} | ||
|
||
func formatTimeInterval(startDate: String, endDate: String) -> String? { | ||
let dateFormatter = DateFormatter() | ||
dateFormatter.dateFormat = "M월 d일 EEEE HH:mm" | ||
|
||
guard let startDateObject = dateFormatter.date(from: startDate), | ||
let endDateObject = dateFormatter.date(from: endDate) else { return nil } | ||
|
||
let formattedStartDate = dateFormatter.string(from: startDateObject) | ||
|
||
dateFormatter.dateFormat = "HH:mm" | ||
let formattedEndDate = dateFormatter.string(from: endDateObject) | ||
|
||
return "\(formattedStartDate) ~ \(formattedEndDate)" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
요부분은 Core에 Extension으로 빼줘도 좋을 것 같아요~
fetchedSchedule.asDriver() | ||
.sink(receiveValue: { model in | ||
if model.type != SessionType.noSession.rawValue { | ||
self.sceneType = .scheduledDay | ||
guard let convertedStartDate = self.convertDateString(model.startDate), | ||
let convertedEndDate = self.convertDateString(model.endDate) else { return } | ||
|
||
let newModel = AttendanceScheduleModel(type: model.type, | ||
location: model.location, | ||
name: model.name, | ||
startDate: convertedStartDate, | ||
endDate: convertedEndDate, | ||
message: model.message, | ||
attendances: model.attendances) | ||
output.scheduleModel = newModel | ||
} else { | ||
self.sceneType = .unscheduledDay | ||
output.scheduleModel = model | ||
} | ||
}) | ||
.store(in: cancelBag) | ||
|
||
fetchedScore.asDriver() | ||
.sink(receiveValue: { model in | ||
output.scoreModel = model | ||
}) | ||
.store(in: cancelBag) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
요부분에서 fetchedSchedule과 fetchedScore의 순서가 서로에게 미치는 영향이 없을까요??
만약 순서가 중요하다면, viewDidload publisher를 받아서 한 번의 useCase 함수 호출만 하고, repository에서 flatMap을 통해 서버 호출을 순서대로 할 수 있어요!
let attributedString = NSMutableAttributedString(string: mainText + pointedText + subText) | ||
|
||
attributedString.addAttributes([NSAttributedString.Key.font: UIFont.Main.body0, | ||
NSAttributedString.Key.foregroundColor: UIColor.white], | ||
range: NSRange(location: 0, length: mainText.count)) | ||
|
||
attributedString.addAttributes([NSAttributedString.Key.font: UIFont.Main.headline1, | ||
NSAttributedString.Key.foregroundColor: DSKitAsset.Colors.purple40.color], | ||
range: NSRange(location: mainText.count, length: pointedText.count)) | ||
|
||
attributedString.addAttributes([NSAttributedString.Key.font: UIFont.Main.body0, | ||
NSAttributedString.Key.foregroundColor: UIColor.white], | ||
range: NSRange(location: mainText.count + pointedText.count, length: subText.count)) | ||
|
||
currentScoreLabel.attributedText = attributedString |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
attributedString을 사용하는 부분이 많아서 나중에 모듈을 따로 만들어도 될 것 같네용~
private func bindViewModels() { | ||
let input = ShowAttendanceViewModel.Input() | ||
|
||
let input = ShowAttendanceViewModel.Input(viewDidLoad: viewdidload.asDriver(), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
요기서 viewDidload.asDriver 말고 Driver.just를 사용하면 PublishSubject를 사용하지 않아도 됩니다!
if self.viewModel.sceneType == .scheduledDay { | ||
self.sceneType = .scheduledDay | ||
self.setScheduledData(model) | ||
self.headerScheduleView.updateLayout(.scheduledDay) | ||
} else { | ||
self.sceneType = .unscheduledDay | ||
self.headerScheduleView.updateLayout(.unscheduledDay) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sceneType은 viewModel에만 두고, viewController에서는 연산 프로퍼티로 get만 가능하게 하는 것이 어떨까요?
viewModel과 VC의 sceneType 모두를 관리하는 것보다 viewModel의 sceneType만 사용하는 것이 관리하기에 편하고, SSOT를 지킬 수 있을 것 같아요..!
리뷰 반영은 따로 하고 머지 먼저 진행하겠습니다 !! 🙇🏻♀️ |
🌴 PR 요약
🌱 작업한 브랜치
🌱 PR Point
📌 참고 사항
📸 스크린샷
📮 관련 이슈