Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed an issue with wrong scroll indicator insets on iOS 13 #627

Merged
merged 1 commit into from
Nov 18, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
}
}
}