Skip to content

Feature/#254 선물하기 상세 UI 구현#270

Merged
wngus4296 merged 20 commits intodevelopfrom
feature/#254-present-detail-UI
Jul 10, 2024
Merged

Feature/#254 선물하기 상세 UI 구현#270
wngus4296 merged 20 commits intodevelopfrom
feature/#254-present-detail-UI

Conversation

@wngus4296
Copy link
Copy Markdown
Collaborator

작업한 내용

현재는 공연 상세 -> 예매하기 -> 티켓 선택 했을 때 바로 선물하기 detail로 들어가도록 구현해두었어요.
나중에 공연 상세 하단 선물하기/예매하기 버튼 구현하면 수정하겠습니다~!

  • 결제하기 상세랑 비슷해서 view를 재사용했어요. 메세지 카드 + 공연 및 티켓 정보는 새로 작업했습니다!
  • textView의 lineheight 지정하는 함수를 새로 만들었어요. 기존의 setLineSpacing 대신 사용하면 될 것 같습니다. <- 요건 제가 차차 수정할게요~!
  • asset의 accentColor를 .Orange01 색으로 변경해뒀어요 (기존에 설정 안되어있어서 커서가 blue로 뜨고 있어서..!)
    • accentColor를 orange로 바꾸면서 새로 작업한 메시지 카드뷰에 커서가 잘 안보여서 이 부분만 tintColor를 white로 변경했습니다!

스크린샷

메시지 카드 뷰 입력창 버튼 활성화 & policy
RPReplay_Final1720519574 RPReplay_Final1720519620 RPReplay_Final1720519638

관련 이슈

@wngus4296 wngus4296 self-assigned this Jul 9, 2024
Copy link
Copy Markdown
Collaborator

@longlivedrgn longlivedrgn left a comment

Choose a reason for hiding this comment

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

주현 고생했어!!~! 코멘트 같이 고민해보면 좋을 거 몇개만 달았어!💪

Comment on lines +128 to +146

extension SelectCardView: UICollectionViewDataSource {

func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
return 10
}

func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
guard let cell = collectionView.dequeueReusableCell(withReuseIdentifier: CardImageCollectionViewCell.className, for: indexPath) as? CardImageCollectionViewCell else { return UICollectionViewCell() }

if indexPath.item == 0 {
cell.isSelected = true
collectionView.selectItem(at: indexPath, animated: false, scrollPosition: .init())
}
// cell.setData(with: "")
return cell
}

}
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

주현 요거 아래와 같은 오류가 있는거 같아!
뭔가 다시 dequeue되면서 index가 0인걸로 select가 되는 거 같더라구!

사실 지금은 서버 통해서 image 받는 받는 게 따로 없어서 그런 거 같긴한데, rxswift를 활용하니까 cell deque하는 코드는 아래와 같이 바꿔도 괜찮을 거 같아!

Observable
    .bind(to: collectionView.rx
        .items(cellIdentifier: "colorCell", cellType: CollectionViewCell.self)) { index, color, cell in
        cell.label.text = "Good"
    }
    .disposed(by: bag)

또, 맨 위의 문제랑 연관된 거일 수도 있는데, 특정 cell이 select되었을 때는 특정 cell 안에 있는 isSelected 구문을 직접 설정하는 것보다 delegate 메소드로 select된 index의 cell의 색깔을 직접 바꿔주는 것도 좋을 거 같오!

collectionView.rx.itemSelected
    .subscribe(onNext: { index in
        print("\(index.section) \(index.row)")
    })
    .disposed(by: bag)

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

덕분에 셀 재사용 dequeue되면서 저 함수가 계속 호출되는 오류 확인했다!! 고마워 🙏

cell.isSelected = true 

이 코드를 썼던 이유는 초기 설정 값을 주기 위함이었어! 처음 선물하기 상세로 들어갔을 때 카드 이미지의 0번 인덱스가 설정되어있어야 하더라구

그래서 수정하면서 두 가지 방법을 생각했어!

  1. indexPathsForSelectedItems를 사용해서 선택된 item을 배열로 받고 isEmpty일 경우 0번 인덱스를 선택해주기
  2. willDisplayCell을 사용하고 take(1)으로 0번 cell이 생성될 때 딱 한 번만 선택해주기

이 중에서 1번 indexPathsForSelectedItems을 사용하다 보니 cell을 가져오기가 애매하더라고! 그래서 willDisplayCell을 사용해서

self.selectCardView.cardImageCollectionView.rx.willDisplayCell
    .take(1)
    .bind(with: self) { owner, item in
        item.cell.isSelected = true
        owner.selectCardView.cardImageCollectionView.selectItem(at: item.at, animated: false, scrollPosition: .left)
        owner.viewModel.input.selectedImageIndex.accept(item.at.item)
    }
    .disposed(by: self.disposeBag)

이렇게 처리해줬어! item을 프린트 해보니까 cell(item.cell)이랑 indexPath값(item.at)을 가져올 수 있었어 👍

@wngus4296 wngus4296 merged commit a577b5d into develop Jul 10, 2024
@wngus4296 wngus4296 deleted the feature/#254-present-detail-UI branch July 10, 2024 12:45
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.

[FEATURE] 선물하기 정보 입력 화면 UI 구현

2 participants