@@ -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
159163extension ChattingListView {
@@ -177,7 +181,7 @@ extension ChattingListView: ChatInputFieldAction {
177181}
178182
179183extension 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)
0 commit comments