Skip to content

Conversation

@Siwon-L
Copy link
Member

@Siwon-L Siwon-L commented Dec 3, 2024

💡 요약 및 이슈

hotfix chatting UI 개선

📃 작업내용

  • chatInputField TapGestureRecognizer 제외
  • PlayerControl 애니메이션 시 키보드 내려가는 문제 수정
  • 채팅 스크롤 시 최근 채팅으로 이동 버튼 애니메이션 개선

🙋‍♂️ 리뷰노트

최근 채팅으로 이동 버튼 클릭 시 혹은 높이가 큰 채팅 입력 시 최근 채팅으로 이동 애니메이션이 부자연스러운 문제 발생

최근 채팅으로 이동 버튼 클릭 높이가 큰 채팅 입력

해당 문제의 원인은 scrollViewDidScroll 메서드가 스크롤이 내려가는 애니메이션 중에도 호출되어 버튼 애니메이션이 고장나는 문제로 확인되었습니다.

func scrollViewDidScroll(_ scrollView: UIScrollView) {
    guard let lastIndexPath = lastIndexPath(),
          let indexPathList = chatListView.indexPathsForVisibleRows else { return }
    isScrollFixed = indexPathList.contains(lastIndexPath)
}

위 문제는 해당 PR에서
scrollViewDidScroll -> scrollViewDidEndDecelerating로 수정하면서 해결되었습니다. 하지만, scrollViewDidEndDecelerating 메서드는 사용자가 빠르게 스크롤하면서 생긴 가속도가 멈췄을 때 호출되는 메서드로 만약, 사용자가 천천히 스크롤 할 경우 호출되지 않는 문제가 추가적으로 발생하였습니다.

때문에, 이번 PR에서 scrollViewDidEndDecelerating -> scrollViewDidScroll로 다시 수정 후 기존 스크롤 에니메이션 중 scrollViewDidScroll 메서드가 호출되는 문제를 해결하기 위해 isAnimating를 추가였습니다.

    private var isAnimating = false // 스크롤 에니메이션 중인지 체크하는 변수

    private func scrollToBottom() {
        guard let indexPath = lastIndexPath() else { return }
        isAnimating = true
        chatListView.scrollToRow(at: indexPath, at: .bottom, animated: true)
    }

스크롤 에니메이션이 발생하는 코드 호출 전에 isAnimating = true로 설정하여

    func scrollViewDidScroll(_ scrollView: UIScrollView) {
        guard !isAnimating else { return }
        let offsetMaxY = scrollView.contentSize.height - scrollView.bounds.height
        isScrollFixed = (offsetMaxY - 50...offsetMaxY) ~= scrollView.contentOffset.y || offsetMaxY < scrollView.contentOffset.y
    }

scrollViewDidScroll 내부에서 isAnimating = true 인 경우 다음 작업을 무시하도록 구현하였습니다.

추가로,

    func scrollViewDidEndScrollingAnimation(_ scrollView: UIScrollView) { // 스크롤 에니메이션이 끝나면 호출되는 Delegate 메서드
        isAnimating = false
    }

scrollViewDidEndScrollingAnimation 내부에서 isAnimating = false로 설정하여 애니메이션이 끝난 후 다시 정상 동작하도록 구현하였습니다.

  • 해결된 화면
최근 채팅으로 이동 버튼 클릭 높이가 큰 채팅 입력

✅ PR 체크리스트

  • 이 작업으로 인해 변경이 필요한 문서가 변경되었나요? (e.g. XCConfig, 노션, README)
  • 이 작업을 하고나서 공유해야할 팀원들에게 공유되었나요? (e.g. "API 개발 완료됐어요", "XCConfig 값 추가되었어요")
  • 작업한 코드가 정상적으로 동작하나요?
  • Merge 대상 브랜치가 올바른가요?
  • PR과 관련 없는 작업이 있지는 않나요?

🎸 기타

Copy link
Collaborator

@hyunjuntyler hyunjuntyler 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 +195 to +196
let offsetMaxY = scrollView.contentSize.height - scrollView.bounds.height
isScrollFixed = (offsetMaxY - 50...offsetMaxY) ~= scrollView.contentOffset.y || offsetMaxY < scrollView.contentOffset.y
Copy link
Collaborator

Choose a reason for hiding this comment

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

여기있는 50이라는 값은 어떻게 나온 값인지 궁금합니다!

Copy link
Member Author

Choose a reason for hiding this comment

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

일정 높이 이상 스크롤 시 버튼이 표시되도록 구현했으며, 그 높이를 50으로 설정했습니다. 특별한 기준은 없고, 테스트를 진행한 결과 가장 자연스러운 높이여서 50으로 설정했습니다.

Copy link
Collaborator

Choose a reason for hiding this comment

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

그렇군요 감사합니다 :)

@Siwon-L Siwon-L requested a review from yongbeomkwak December 3, 2024 12:16
@Siwon-L Siwon-L self-assigned this Dec 3, 2024
@Siwon-L Siwon-L added the fix 버그 수정 label Dec 3, 2024
@Siwon-L Siwon-L merged commit 8e32d61 into develop Dec 3, 2024
2 checks passed
@Siwon-L Siwon-L deleted the task/hotfix_chattingUI branch December 3, 2024 15:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

fix 버그 수정

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants