Skip to content
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] #169 - 캐릭터 상세 뷰 API 연결 #171

Merged
merged 33 commits into from
Sep 17, 2024
Merged

[Feat] #169 - 캐릭터 상세 뷰 API 연결 #171

merged 33 commits into from
Sep 17, 2024

Conversation

codeJiwon
Copy link
Collaborator

@codeJiwon codeJiwon commented Sep 8, 2024

🌴 작업한 브랜치

✅ 작업한 내용

  • 캐릭터 상세 정보 조회 API 연결
  • 캐릭터 모션 목록 조회 API 연결

고민되었던 부분

캐릭터 모션 목록 API에 셀의 mainColor와 subColor가 있었다면 CharacterDetailCell에 바로 값을 받아올 수 있었는데, 캐릭터 상세 정보 조회 API에 있어서 고민이 됐다.
CharacterViewController의 getCharacterDetailInfo() 함수에서 서버에서 넘겨주는 값을 가져오는데, 셀의 mainColor, subColor를 func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {} 안에서 configureCellColor 함수를 통해 CharacterDetailCell로 넘겨주고 싶었다.

해결 방법

따라서 characterMainColorCode, characterSubColorCode 전역 변수를 생성하고 getCharacterDetailInfo() 에서 서버에서 받아온 값을 전역 변수에 넣은 후 CharacterDetailCell로 넘겨주었다.

//CharacterDetailViewController.swift
private var characterMainColorCode: String?
private var characterSubColorCode: String?

func getCharacterDetailInfo() {
        NetworkService.shared.characterDetailService.getAcquiredCharacterInfo(characterId: characterId) { response in
            switch response {
            case .success(let characterDetailResponse):
                guard let characterData = characterDetailResponse?.data else { return }
                
                self.characterMainColorCode = characterData.characterMainColorCode
                self.characterSubColorCode = characterData.characterSubColorCode
}

func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
        let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "CharacterDetailCell", for: indexPath) as! CharacterDetailCell
        
        if let mainColor = self.characterMainColorCode, let subColor = self.characterSubColorCode {
            cell.configureCellColor(mainColor: mainColor, subColor: subColor)
        }
        return cell
}
//CharacterDetailCell.swift
func configureCellColor(mainColor: String, subColor: String){
        contentView.backgroundColor = UIColor(hex: mainColor)
        containerView.backgroundColor = UIColor(hex: subColor)
}

❗️PR Point

🚨서버의 모션 이미지 링크가 다 빈 링크여서 이미지를 불러올 수가 없다. 로그 찍었을 때 이미지 링크는 제대로 불러와진다.

질문

왜 스크롤 내리면 네비게이션 바가 계속 있지..?

📸 스크린샷

캐릭터 상세 정보 조회 API 연결 캐릭터 모션 목록 조회 API 연결
KakaoTalk_Photo_2024-09-09-04-59-16 KakaoTalk_Photo_2024-09-09-05-07-00
설명

@codeJiwon codeJiwon self-assigned this Sep 8, 2024
@codeJiwon codeJiwon linked an issue Sep 8, 2024 that may be closed by this pull request
1 task
Copy link
Collaborator

@Johyerin Johyerin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

서버연결하시느라 고생하셨습니다!

스크롤 시 백버튼이 사라지지 않는 것은 커스텀 버튼 hidden 로직을 따로 구현해주지 않아서인데, 디자인분들과 상의해서 스크롤 시 hidden 처리를 할 것인지, 혹은 스크롤 영역을 조절할 것인지 회의 때 논의해보면 좋을 것 같아요~~!

Copy link
Contributor

@nolanMinsung nolanMinsung left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

캐릭터 상세 뷰에서 API가 동작하는 점 확인했습니다 😁
아직 캐릭터 선택 뷰는 구현하지 않은 상황인 거죠?
추후 구현하면 더 완벽해질 것 같습니다!
수고 많으셨습니다! 👍

다만 브랜치(이슈)와 관련 없는 목적의 코드가 너무 많습니다.
대표적으로, 뷰의 코너에 곡률 반경을 설정하는 메서드인 roundCorners 메서드를 적용하는 코드만 10개가 넘습니다.
확장 구현한 메서드를 적극적으로 사용하여 반복된 코드를 줄이는 점 좋습니다!
그러나, 브랜치의 이름을 다시 확인해보시면 알겠지만 해당 브랜치는 "캐릭터 상세 뷰의 API를 연결"하는 것이 주 목적인 브랜치입니다.
리뷰하는 사람들의 입장에서, 브랜치의 목적을 벗어난 코드가 많아질 경우 다소 헷갈릴 수 있습니다.
(한 두 개 정도여서 새 브랜치를 생성하기 애매한 경우는 괜찮지만 그 수가 많아질 경우...)

이러한 코드가 많아질 경우, 관련한 이슈 및 브랜치를 별도로 생성하여 코드를 수정하면 훨씬 깔끔하고 효율적인 작업이 가능할 것 같다는 의견 남깁니다! :)

@codeJiwon codeJiwon merged commit 9ac433f into main Sep 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Feat] 획득 캐릭터 상세 API 연결
3 participants