-
Notifications
You must be signed in to change notification settings - Fork 6
[Feat] #229 - 코스 상세 스크랩 부분 API 변경으로 인한 코드 추가 구현, 코스 발견 이벤트 추가 작업을 하였습니다. #231
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] #229 - 코스 상세 스크랩 부분 API 변경으로 인한 코드 추가 구현, 코스 발견 이벤트 추가 작업을 하였습니다. #231
The head ref may contain hidden characters: "#229--\uCF54\uC2A4\uBC1C\uACAC-\uC11C\uBC84-API-\uBD80\uBD84-\uC218\uC815"
Conversation
API에서 스크랩 카운트를 주는 과정해서, UI 업데이트가 필요하였는데 그 부분을 변경하였습니다.
코스 상세 -> 코스 발견으로 나올때 마라톤 Cell도 추천 코스처럼 수정되게 기능을 구현 하였습니다.
| delegate?.didUpdateScrapState(publicCourseId: publicCourseId, isScrapped: !sender.isSelected) /// 코스 발견 UI Update 부분 | ||
| marathonDelegate?.didMarathonUpdateScrapState(publicCourseId: publicCourseId, isScrapped: !sender.isSelected) // 마라톤 코스 UI Update 부분 |
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.
스크랩 버튼 누를때 델리게이트를 두번 전달하는군요.. 확인했습니다 ~
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.
아무래도, 코스 상세에서 이벤트 전달을 해주는 것이
- 추천 코스
- 마라톤 코스
인데, 어차피 서로 독립적인 부분이라 저렇게 선언해도 괜찮을 것 같다고 판단하였습니다.
여기서 "서로 독립적이다" 라는 말은
마라톤 Cell에 있는 코스와, 추천 코스에 있는 코스들은 겹치지 않는다 라고 기획 측에서 말을 해주었기에 독립적이라고 하였습니다.
| self.likeButton.isSelected.toggle() | ||
| self.scrapCount = data.scrapCount | ||
| self.scrapCountLabel.text = "\(self.scrapCount)" |
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.
서버 통신에서 조금 바뀌었다고 했는데
원래는 scrap 개수가 response로 안넘어왔는데 지금은 넘어오고 그걸 사용하는 건가요?!
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.
맞아요
원래 +1 , -1 이런 식으로 그냥 단순한 방법으로 해결했었는데, 서버에서 scrapCount를 넘겨주니까 쉽게 해결할 수 있었어요!
| extension MarathonMapCollectionViewCell: MarathonCourseDelegate { | ||
| func didMarathonUpdateScrapState(publicCourseId: Int, isScrapped: Bool) { | ||
| print("✅ 1. 마라톤 델리게이트 들어오는가 🫶🏻") | ||
| if let index = marathonCourseList.firstIndex(where: { $0.id == publicCourseId }) { | ||
| marathonCourseList[index].scrap = isScrapped | ||
| marathonReloadCellForCourse(publicCourseId: publicCourseId) | ||
| print("✅ 4. ‼️MarathonMapCollectionViewCell에서 작업 완료") | ||
| } | ||
| } | ||
| } | ||
|
|
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.
이 부분이 코스 발견쪽에 구현되면 marathonCourseList에 대한 접근이
cell.marathonCourseList 이런식으로 접근해야해서 cell 안에 구현해준건가요?
어떤 포인트에서 코스 발견에 구현을 해야 하나, 마라톤 Cell에 구현을 해야 고민 했는지 궁금합니다 ~
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 한 marathonCourseList을 public으로 바꿔야 할뿐더러, cell.marathonCourseList 이런 식으로 접근하는 게 좋은 코드가 아닌 것 같아서 Cell 내부에서 delegate 처리해 주었습니다~
따라서 delegate를 채택을 아래처럼 하였습니다.
courseDetailVC.marathonDelegate = marathonCell
513sojin
left a comment
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.
답글 달아둔 부분 전부 확인했습니다 ~ 고생하셨어용
🌱 작업한 내용
코스 발견 마라톤 Cell 부분코스 상세 -> 코스 발견 으로 이동하면서, 스크랩 수가 실시간으로 적용 되는 작업🌱 PR Point
코스 발견에 구현을 해야 하나,마라톤 Cell에 구현을 해야 고민하다가 Cell 내부에 기능 구현을 하였는데, 이 부분 한번 보시길 바랍니다.GA 브랜치에서 작업을 하고 있어서 지금은 무시해 주시면 됩니다.📸 스크린샷
영상에 마우스 포인터와 함께 변경된 점을 UI로 녹화하였으니 참고 바랍니다.
📮 관련 이슈