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] #38 - 로딩 스피너 구현 #40

Merged
merged 1 commit into from
Jan 12, 2024
Merged

Conversation

yeonsu0-0
Copy link
Collaborator

👻 PULL REQUEST

💻 작업한 내용

  • UIRefreshControl을 사용해 홈 뷰에서 pull down 시 로딩 스피너가 나오도록 구현했습니다.

💡 참고사항

private func setRefreshControll() {
refreshControl.addTarget(self, action: #selector(refreshPost), for: .valueChanged)
homeCollectionView.refreshControl = refreshControl
refreshControl.backgroundColor = .donGray1
}
@objc
func refreshPost() {
DispatchQueue.main.async {
// ✅ 서버 통신 영역
//
}
self.homeCollectionView.reloadData()
self.perform(#selector(self.finishedRefreshing), with: nil, afterDelay: 0.1)
}
@objc
func finishedRefreshing() {
refreshControl.endRefreshing()
}

📸 스크린샷

기능 스크린샷
GIF

📟 관련 이슈

}



@objc func showToast(_ notification: Notification) {
if let showToast = notification.userInfo?["showToast"] as? Bool {
if showToast == true {

Choose a reason for hiding this comment

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

아래는 코드 패치에 대한 간단한 코드 리뷰입니다. 버그 위험과/또는 개선 제안 사항을 환영합니다:

  1. refreshControl 변수는 "UIRefreshControl"의 인스턴스를 나타내며, 새로고침 기능을 제공합니다.
  2. setRefreshControll() 메서드가 추가되어 해당 뷰 컨트롤러에서 리프레시 컨트롤을 설정하고 있습니다.
  3. refreshPost() 메서드는 refreshControl의 valueChanged 이벤트와 연결됩니다. 서버 통신 영역에 관련 코드가 필요할 것입니다.
  4. finishedRefreshing() 메서드는 리프레시가 완료되었을 때 호출되며, refreshControl.endRefreshing()을 호출하여 리프레시를 종료합니다.

개선 제안:

  • refreshPost() 메서드에서 비동기 서버 통신 부분이 필요합니다. 현재 주석 처리되어 있으므로 해당 영역에 적절한 서버 통신 로직을 추가해야 합니다.
  • finishedRefreshing() 메서드에서 perform(:with:afterDelay:) 메서드 대신 디스패치 큐를 사용하여 UI 업데이트를 지연시키는 방식을 고려해 볼 수 있습니다. 예를 들어, DispatchQueue.main.asyncAfter(deadline: .now() + 0.1)를 사용하여 지정된 지연 시간 이후에 refreshControl.endRefreshing()을 호출할 수 있습니다.

위의 제안사항 및 코드 리뷰는 해당 코드 조각의 한 부분에 대한 내용입니다. 컨트롤러의 다른 부분에서 발생할 수 있는 다른 문제나 개선점은 살펴볼 수 없으므로 전반적인 코드 품질과 일관성을 위해 전체 코드를 고려하는 것이 중요합니다.

Copy link
Member

@boogios boogios left a comment

Choose a reason for hiding this comment

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

P3
새로고침 와우네요~!! 미쳤다ㅏ 수고하셨습니다!!!

Copy link
Collaborator

@Heyjooo Heyjooo left a comment

Choose a reason for hiding this comment

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

p3
짱 수고하셨숩니다 쇽샥할게여 ~~

@yeonsu0-0 yeonsu0-0 merged commit c490054 into develop Jan 12, 2024
1 check passed
@yeonsu0-0 yeonsu0-0 deleted the feat/#38-loadingSpinner branch January 12, 2024 08:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Feat] 홈 collectionView 로딩 스피너 구현
3 participants