mirror of
https://gitlab.linphone.org/BC/public/linphone-iphone.git
synced 2026-01-24 22:58:13 +00:00
Reload collectionView when new message is received
This commit is contained in:
parent
e4eff6aba9
commit
b079d12f0a
3 changed files with 27 additions and 2 deletions
|
|
@ -104,6 +104,31 @@ class ChatConversationTableViewSwift: UIViewController, UICollectionViewDataSour
|
|||
}
|
||||
}
|
||||
|
||||
func scrollToBottom(){
|
||||
self.collectionView.scrollToItem(at: IndexPath(item: 0, section: 0), at: .bottom, animated: true)
|
||||
}
|
||||
|
||||
func refreshData(){
|
||||
let indexBottom = self.collectionView.indexPathsForVisibleItems.sorted().first?.row
|
||||
let offset = self.collectionView.contentOffset
|
||||
print("MultilineMessageCell configure \(offset) \(indexBottom)")
|
||||
collectionView.reloadData()
|
||||
self.collectionView.scrollToItem(at: IndexPath(row: indexBottom! + 1, section: 0), at: .top, animated: false)
|
||||
|
||||
/*
|
||||
DispatchQueue.main.asyncAfter(deadline: .now() + 0.05) {
|
||||
let offsetIndex = self.collectionView.contentOffset
|
||||
print("MultilineMessageCell configure \(offsetIndex)")
|
||||
self.collectionView.setContentOffset(CGPoint(x: self.collectionView.contentOffset.x, y: self.collectionView.contentOffset.y + offset.y + 10), animated: false)
|
||||
}
|
||||
*/
|
||||
|
||||
//self.collectionView.scrollToItem(at: IndexPath(item: 1, section: 0), at: .bottom, animated: false)
|
||||
//DispatchQueue.main.asyncAfter(deadline: .now() + 0.05) {
|
||||
// self.scrollToBottom()
|
||||
//}
|
||||
}
|
||||
|
||||
// MARK: - UICollectionViewDataSource -
|
||||
func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
|
||||
let cell = collectionView.dequeueReusableCell(withReuseIdentifier: MultilineMessageCell.reuseId, for: indexPath) as! MultilineMessageCell
|
||||
|
|
|
|||
|
|
@ -168,6 +168,8 @@ class ChatConversationViewSwift: BackActionsNavigationView, PHPickerViewControll
|
|||
self.tableController.scrollBadge!.isHidden = false
|
||||
self.tableController.scrollBadge!.text = "\(ChatConversationViewModel.sharedModel.unread_msg+1)"
|
||||
}
|
||||
|
||||
self.tableControllerSwift.refreshData()
|
||||
}
|
||||
|
||||
ChatConversationViewModel.sharedModel.stateChanged.observe { state in
|
||||
|
|
|
|||
|
|
@ -1175,7 +1175,6 @@ class MultilineMessageCell: UICollectionViewCell, UICollectionViewDataSource, UI
|
|||
|
||||
downloadContentCollection[indexTransferProgress]!.downloadButtonLabel.isHidden = true
|
||||
downloadContentCollection[indexTransferProgress]!.circularProgressBarView.isHidden = false
|
||||
//downloadContentCollection[indexTransferProgress]!.downloadProgressBar.isHidden = false
|
||||
}
|
||||
|
||||
DispatchQueue.main.async(execute: { [self] in
|
||||
|
|
@ -1189,7 +1188,6 @@ class MultilineMessageCell: UICollectionViewCell, UICollectionViewDataSource, UI
|
|||
indexTransferProgress = -1
|
||||
} else {
|
||||
downloadContentCollection[indexTransferProgress]!.setUpCircularProgressBarView(toValue: p)
|
||||
//downloadContentCollection[indexTransferProgress]!.downloadProgressBar.setProgress(p, animated: true)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue