diff --git a/Projects/Features/LiveStreamFeature/Sources/Chating/Views/ChatInputField.swift b/Projects/Features/LiveStreamFeature/Sources/Chating/Views/ChatInputField.swift index 8cc787d4..f229cfc4 100644 --- a/Projects/Features/LiveStreamFeature/Sources/Chating/Views/ChatInputField.swift +++ b/Projects/Features/LiveStreamFeature/Sources/Chating/Views/ChatInputField.swift @@ -130,6 +130,13 @@ final class ChatInputField: BaseView { heartButton.addTarget(self, action: #selector(didTapHeartButton), for: .touchUpInside) } + override func hitTest(_ point: CGPoint, with event: UIEvent?) -> UIView? { + if heartButton.bounds.insetBy(dx: -30, dy: -30).contains(point) { + return heartButton + } + return super.hitTest(point, with: event) + } + @objc private func didTapHeartButton() { let generator = UIImpactFeedbackGenerator(style: .light) @@ -142,7 +149,6 @@ final class ChatInputField: BaseView { self?.heartLayer.birthRate = 0 } layer.addSublayer(heartLayer) - } } diff --git a/Projects/Features/LiveStreamFeature/Sources/Chating/Views/ChattingListView.swift b/Projects/Features/LiveStreamFeature/Sources/Chating/Views/ChattingListView.swift index 36129bf1..3c9ff8f5 100644 --- a/Projects/Features/LiveStreamFeature/Sources/Chating/Views/ChattingListView.swift +++ b/Projects/Features/LiveStreamFeature/Sources/Chating/Views/ChattingListView.swift @@ -65,7 +65,6 @@ final class ChattingListView: BaseView { titleLabel.font = .setFont(.body1()) chatListView.backgroundColor = .clear - chatListView.keyboardDismissMode = .onDrag chatListView.allowsSelection = false chatListView.separatorStyle = .none @@ -106,8 +105,10 @@ final class ChattingListView: BaseView { } override func setupActions() { + let tapGesture: UITapGestureRecognizer = UITapGestureRecognizer(target: self, action: #selector(dismissKeyboard)) + self.addGestureRecognizer(tapGesture) + $isScrollFixed - .debounce(for: .milliseconds(50), scheduler: DispatchQueue.main) .sink { [weak self] in self?.updateRecentChatButtonConstraint(isHidden: $0) } @@ -135,24 +136,27 @@ final class ChattingListView: BaseView { } private func scrollToBottom() { - let lastRowIndex = chatListView.numberOfRows(inSection: 0) - 1 - guard lastRowIndex >= 0, - let indexPath = lastIndexPath() else { return } + guard let indexPath = lastIndexPath() else { return } chatListView.scrollToRow(at: indexPath, at: .bottom, animated: true) } private func updateRecentChatButtonConstraint(isHidden: Bool) { UIView.animate(withDuration: 0.2) { if isHidden { - NSLayoutConstraint.activate(self.recentChatButtonHideConstraints) NSLayoutConstraint.deactivate(self.recentChatButtonShowConstraints) + NSLayoutConstraint.activate(self.recentChatButtonHideConstraints) } else { - NSLayoutConstraint.activate(self.recentChatButtonShowConstraints) NSLayoutConstraint.deactivate(self.recentChatButtonHideConstraints) + NSLayoutConstraint.activate(self.recentChatButtonShowConstraints) } self.layoutIfNeeded() } } + + @objc + private func dismissKeyboard() { + endEditing(true) + } } extension ChattingListView { @@ -176,7 +180,7 @@ extension ChattingListView: ChatInputFieldAction { } extension ChattingListView: UITableViewDelegate { - func scrollViewDidScroll(_ scrollView: UIScrollView) { + func scrollViewDidEndDecelerating(_ scrollView: UIScrollView) { guard let lastIndexPath = lastIndexPath(), let indexPathList = chatListView.indexPathsForVisibleRows else { return } isScrollFixed = indexPathList.contains(lastIndexPath) diff --git a/Projects/Features/LiveStreamFeature/Sources/Player/ViewControllers/LiveStreamViewController.swift b/Projects/Features/LiveStreamFeature/Sources/Player/ViewControllers/LiveStreamViewController.swift index 93a83186..a63cffb2 100644 --- a/Projects/Features/LiveStreamFeature/Sources/Player/ViewControllers/LiveStreamViewController.swift +++ b/Projects/Features/LiveStreamFeature/Sources/Player/ViewControllers/LiveStreamViewController.swift @@ -159,6 +159,7 @@ public final class LiveStreamViewController: BaseViewController