Skip to content

Commit 7015739

Browse files
authored
Merge pull request #291 from boostcampwm-2024/hotfix/keyboard
hotfix 채팅관련 문제 해결
2 parents 209ad7d + 91bcc5a commit 7015739

File tree

3 files changed

+20
-9
lines changed

3 files changed

+20
-9
lines changed

Projects/Features/LiveStreamFeature/Sources/Chating/Views/ChatInputField.swift

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,13 @@ final class ChatInputField: BaseView {
133133
heartButton.addTarget(self, action: #selector(didTapHeartButton), for: .touchUpInside)
134134
}
135135

136+
override func hitTest(_ point: CGPoint, with event: UIEvent?) -> UIView? {
137+
if heartButton.bounds.insetBy(dx: -30, dy: -30).contains(point) {
138+
return heartButton
139+
}
140+
return super.hitTest(point, with: event)
141+
}
142+
136143
@objc
137144
private func didTapHeartButton() {
138145
let generator = UIImpactFeedbackGenerator(style: .light)
@@ -145,7 +152,6 @@ final class ChatInputField: BaseView {
145152
self?.heartLayer.birthRate = 0
146153
}
147154
layer.addSublayer(heartLayer)
148-
149155
}
150156
}
151157

Projects/Features/LiveStreamFeature/Sources/Chating/Views/ChattingListView.swift

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,6 @@ final class ChattingListView: BaseView {
6666
titleLabel.font = .setFont(.body1())
6767

6868
chatListView.backgroundColor = .clear
69-
chatListView.keyboardDismissMode = .onDrag
7069
chatListView.allowsSelection = false
7170
chatListView.separatorStyle = .none
7271

@@ -107,8 +106,10 @@ final class ChattingListView: BaseView {
107106
}
108107

109108
override func setupActions() {
109+
let tapGesture: UITapGestureRecognizer = UITapGestureRecognizer(target: self, action: #selector(dismissKeyboard))
110+
self.addGestureRecognizer(tapGesture)
111+
110112
$isScrollFixed
111-
.debounce(for: .milliseconds(50), scheduler: DispatchQueue.main)
112113
.sink { [weak self] in
113114
self?.updateRecentChatButtonConstraint(isHidden: $0)
114115
}
@@ -136,24 +137,27 @@ final class ChattingListView: BaseView {
136137
}
137138

138139
private func scrollToBottom() {
139-
let lastRowIndex = chatListView.numberOfRows(inSection: 0) - 1
140-
guard lastRowIndex >= 0,
141-
let indexPath = lastIndexPath() else { return }
140+
guard let indexPath = lastIndexPath() else { return }
142141
chatListView.scrollToRow(at: indexPath, at: .bottom, animated: true)
143142
}
144143

145144
private func updateRecentChatButtonConstraint(isHidden: Bool) {
146145
UIView.animate(withDuration: 0.2) {
147146
if isHidden {
148-
NSLayoutConstraint.activate(self.recentChatButtonHideConstraints)
149147
NSLayoutConstraint.deactivate(self.recentChatButtonShowConstraints)
148+
NSLayoutConstraint.activate(self.recentChatButtonHideConstraints)
150149
} else {
151-
NSLayoutConstraint.activate(self.recentChatButtonShowConstraints)
152150
NSLayoutConstraint.deactivate(self.recentChatButtonHideConstraints)
151+
NSLayoutConstraint.activate(self.recentChatButtonShowConstraints)
153152
}
154153
self.layoutIfNeeded()
155154
}
156155
}
156+
157+
@objc
158+
private func dismissKeyboard() {
159+
endEditing(true)
160+
}
157161
}
158162

159163
extension ChattingListView {
@@ -177,7 +181,7 @@ extension ChattingListView: ChatInputFieldAction {
177181
}
178182

179183
extension ChattingListView: UITableViewDelegate {
180-
func scrollViewDidScroll(_ scrollView: UIScrollView) {
184+
func scrollViewDidEndDecelerating(_ scrollView: UIScrollView) {
181185
guard let lastIndexPath = lastIndexPath(),
182186
let indexPathList = chatListView.indexPathsForVisibleRows else { return }
183187
isScrollFixed = indexPathList.contains(lastIndexPath)

Projects/Features/LiveStreamFeature/Sources/Player/ViewControllers/LiveStreamViewController.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,7 @@ public final class LiveStreamViewController: BaseViewController<LiveStreamViewMo
159159
.sink { [weak self] flag in
160160
guard let self else { return }
161161
self.playerView.playerControlViewAlphaAnimalation(flag)
162+
view.endEditing(true)
162163
}
163164
.store(in: &subscription)
164165

0 commit comments

Comments
 (0)