Make requested changes from @zhongwuzw

This commit is contained in:
Nathan Tannar
2018-08-21 14:29:53 -07:00
parent b82aeec995
commit 00909055be
5 changed files with 99 additions and 44 deletions
@@ -182,24 +182,6 @@ final class AdvancedExampleViewController: ChatViewController {
messagesCollectionView.scrollToBottom(animated: true)
}
func isLastSectionVisible() -> Bool {
let lastIndexPath = IndexPath(item: 0, section: messageList.count - 1)
let frame = messagesCollectionView.layoutAttributesForItem(at: lastIndexPath)?.frame ?? .zero
var rect = messagesCollectionView.convert(frame, to: view)
// substract 100 to make the "visible" area of a cell bigger
rect.origin.y -= 100
var visibleRect = CGRect(x: messagesCollectionView.bounds.origin.x, y: messagesCollectionView.bounds.origin.y, width:
messagesCollectionView.bounds.size.width, height:
messagesCollectionView.bounds.size.height - messagesCollectionView.contentInset.bottom)
visibleRect = messagesCollectionView.convert(visibleRect, to: view)
return visibleRect.contains(rect)
}
private func makeButton(named: String) -> InputBarButtonItem {
return InputBarButtonItem()
.configure {