forked from mirrors/linphone-iphone
Change when receive isComposing event
Fix minor bugs
This commit is contained in:
parent
43375e2ab1
commit
9d9b54ded3
3 changed files with 18 additions and 15 deletions
|
|
@ -29,6 +29,8 @@ class ChatConversationTableViewModel: ControlsViewModel {
|
|||
|
||||
var messageListToDelete : [EventLog] = []
|
||||
|
||||
var isComposing = MutableLiveData<Bool>(false)
|
||||
|
||||
override init() {
|
||||
super.init()
|
||||
}
|
||||
|
|
|
|||
|
|
@ -61,6 +61,15 @@ class ChatConversationTableViewSwift: UIViewController, UICollectionViewDataSour
|
|||
self.collectionView.reloadData()
|
||||
}
|
||||
|
||||
ChatConversationTableViewModel.sharedModel.isComposing.observe { isComposing in
|
||||
if isComposing! {
|
||||
let isDisplayingBottomOfTable = self.collectionView.contentOffset.y >= (self.collectionView.contentSize.height - self.collectionView.bounds.height + self.collectionView.contentInset.bottom) - 40
|
||||
if isDisplayingBottomOfTable {
|
||||
self.scrollToBottom(animated: true)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
collectionView.isUserInteractionEnabled = true
|
||||
}
|
||||
|
|
@ -93,15 +102,9 @@ class ChatConversationTableViewSwift: UIViewController, UICollectionViewDataSour
|
|||
|
||||
(collectionView.collectionViewLayout as! UICollectionViewFlowLayout).estimatedItemSize = UICollectionViewFlowLayout.automaticSize
|
||||
(collectionView.collectionViewLayout as! UICollectionViewFlowLayout).minimumLineSpacing = 2
|
||||
|
||||
//collectionView.transform = CGAffineTransform(scaleX: 1, y: -1)
|
||||
}
|
||||
|
||||
override func viewWillAppear(_ animated: Bool) {
|
||||
collectionView.reloadData()
|
||||
}
|
||||
|
||||
override func viewDidAppear(_ animated: Bool) {
|
||||
createFloatingButton()
|
||||
if ChatConversationTableViewModel.sharedModel.getNBMessages() > 0 {
|
||||
scrollToBottom(animated: false)
|
||||
|
|
@ -116,8 +119,12 @@ class ChatConversationTableViewSwift: UIViewController, UICollectionViewDataSour
|
|||
}
|
||||
|
||||
func scrollToBottom(animated: Bool){
|
||||
|
||||
collectionView.reloadData()
|
||||
self.collectionView.scrollToItem(at: IndexPath(item: ChatConversationTableViewModel.sharedModel.getNBMessages()-1, section: 0), at: .bottom, animated: false)
|
||||
let isDisplayingBottomOfTable = collectionView.contentOffset.y >= (collectionView.contentSize.height - collectionView.bounds.height + collectionView.contentInset.bottom) - 20
|
||||
if !isDisplayingBottomOfTable {
|
||||
self.collectionView.scrollToItem(at: IndexPath(item: ChatConversationTableViewModel.sharedModel.getNBMessages()-1, section: 0), at: .bottom, animated: false)
|
||||
}
|
||||
//Scroll twice because collection view doesn't have time to calculate cell size
|
||||
DispatchQueue.main.asyncAfter(deadline: .now() + 0.2) {
|
||||
self.collectionView.scrollToItem(at: IndexPath(item: ChatConversationTableViewModel.sharedModel.getNBMessages()-1, section: 0), at: .bottom, animated: animated)
|
||||
|
|
@ -212,8 +219,6 @@ class ChatConversationTableViewSwift: UIViewController, UICollectionViewDataSour
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
//cell.contentView.transform = CGAffineTransform(scaleX: 1, y: -1)
|
||||
return cell
|
||||
}
|
||||
|
||||
|
|
@ -440,12 +445,6 @@ class ChatConversationTableViewSwift: UIViewController, UICollectionViewDataSour
|
|||
return (previewItems[index] as QLPreviewItem?)!
|
||||
}
|
||||
|
||||
func previewControllerDidDismiss(_ controller: QLPreviewController) {
|
||||
if afterPreviewIndex > -1 {
|
||||
//collectionView.scrollToItem(at: IndexPath(row: afterPreviewIndex, section: 0), at: .centeredVertically, animated: false)
|
||||
}
|
||||
}
|
||||
|
||||
func onImageClick(chatMessage: ChatMessage, index: Int) {
|
||||
|
||||
let state = chatMessage.state
|
||||
|
|
|
|||
|
|
@ -152,6 +152,8 @@ class ChatConversationViewSwift: BackActionsNavigationView, PHPickerViewControll
|
|||
ChatConversationViewModel.sharedModel.isComposing.observe { compose in
|
||||
if((compose! && self.isComposingView.isHidden)||(!compose! && !self.isComposingView.isHidden)){
|
||||
self.setComposingVisible(compose!, withDelay: 0.3)
|
||||
|
||||
ChatConversationTableViewModel.sharedModel.isComposing.value = compose
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue