Skip to content

Commit

Permalink
Merge pull request #627 from badoo/fixed_issue_with_scroll_insets
Browse files Browse the repository at this point in the history
Fixed an issue with wrong scroll indicator insets on iOS 13
  • Loading branch information
wiruzx authored Nov 18, 2019
2 parents af4956d + 25dbc3d commit 8fd3106
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 3 deletions.
7 changes: 4 additions & 3 deletions Chatto/Source/ChatController/BaseChatViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,8 @@ open class BaseChatViewController: UIViewController, UICollectionViewDataSource,
collectionView.dataSource = self
collectionView.delegate = self
collectionView.chatto_setContentInsetAdjustment(enabled: false, in: self)

collectionView.chatto_setAutomaticallyAdjustsScrollIndicatorInsets(false)

self.accessoryViewRevealer = AccessoryViewRevealer(collectionView: collectionView)
self.collectionView = collectionView

Expand Down Expand Up @@ -344,12 +345,12 @@ open class BaseChatViewController: UIViewController, UICollectionViewDataSource,
return currentInsets
}()

collectionView.scrollIndicatorInsets = {
collectionView.chatto_setVerticalScrollIndicatorInsets({
var currentInsets = collectionView.scrollIndicatorInsets
currentInsets.bottom = self.layoutConfiguration.scrollIndicatorInsets.bottom + inputHeightWithKeyboard
currentInsets.top = self.topLayoutGuide.length + self.layoutConfiguration.scrollIndicatorInsets.top
return currentInsets
}()
}())

guard shouldUpdateContentOffset else { return }

Expand Down
14 changes: 14 additions & 0 deletions Chatto/Source/Utils.swift
Original file line number Diff line number Diff line change
Expand Up @@ -44,4 +44,18 @@ extension UIScrollView {
viewController.automaticallyAdjustsScrollViewInsets = enabled
#endif
}

func chatto_setAutomaticallyAdjustsScrollIndicatorInsets(_ adjusts: Bool) {
if #available(iOS 13.0, *) {
self.automaticallyAdjustsScrollIndicatorInsets = adjusts
}
}

func chatto_setVerticalScrollIndicatorInsets(_ insets: UIEdgeInsets) {
if #available(iOS 11.1, *) {
self.verticalScrollIndicatorInsets = insets
} else {
self.scrollIndicatorInsets = insets
}
}
}

0 comments on commit 8fd3106

Please sign in to comment.