diff --git a/Classes/Issues/Files/IssueFilesViewController.swift b/Classes/Issues/Files/IssueFilesViewController.swift index 048c0e1d..1f5b19ab 100644 --- a/Classes/Issues/Files/IssueFilesViewController.swift +++ b/Classes/Issues/Files/IssueFilesViewController.swift @@ -101,7 +101,7 @@ ListSingleSectionControllerDelegate { else { return .zero } return CGSize( width: context.insetContainerSize.width, - height: context.insetContainerSize.height - strongSelf.topLayoutGuide.length - strongSelf.bottomLayoutGuide.length + height: context.insetContainerSize.height - strongSelf.view.safeAreaInsets.top - strongSelf.view.safeAreaInsets.bottom ) } let controller = ListSingleSectionController( diff --git a/Classes/Notifications/NoNewNotificationsSectionController.swift b/Classes/Notifications/NoNewNotificationsSectionController.swift index 8a74c72c..b98a47db 100644 --- a/Classes/Notifications/NoNewNotificationsSectionController.swift +++ b/Classes/Notifications/NoNewNotificationsSectionController.swift @@ -13,8 +13,7 @@ import Crashlytics final class NoNewNotificationSectionController: ListSectionController { private let topInset: CGFloat - private let topLayoutGuide: UILayoutSupport - private let bottomLayoutGuide: UILayoutSupport + private let layoutInsets: UIEdgeInsets private let client = NotificationEmptyMessageClient() enum State { @@ -24,10 +23,9 @@ final class NoNewNotificationSectionController: ListSectionController { } private var state: State = .loading - init(topInset: CGFloat, topLayoutGuide: UILayoutSupport, bottomLayoutGuide: UILayoutSupport) { + init(topInset: CGFloat, layoutInsets: UIEdgeInsets) { self.topInset = topInset - self.topLayoutGuide = topLayoutGuide - self.bottomLayoutGuide = bottomLayoutGuide + self.layoutInsets = layoutInsets super.init() client.fetch { [weak self] (result) in self?.handleFinished(result) @@ -37,7 +35,7 @@ final class NoNewNotificationSectionController: ListSectionController { override func sizeForItem(at index: Int) -> CGSize { guard let size = collectionContext?.containerSize else { fatalError("Missing context") } - return CGSize(width: size.width, height: size.height - topInset - topLayoutGuide.length - bottomLayoutGuide.length) + return CGSize(width: size.width, height: size.height - topInset - layoutInsets.top - layoutInsets.bottom) } override func cellForItem(at index: Int) -> UICollectionViewCell { diff --git a/Classes/Notifications/NotificationsViewController.swift b/Classes/Notifications/NotificationsViewController.swift index 02af9f35..ab1b2d8b 100644 --- a/Classes/Notifications/NotificationsViewController.swift +++ b/Classes/Notifications/NotificationsViewController.swift @@ -307,8 +307,7 @@ FlatCacheListener { func emptySectionController(listAdapter: ListAdapter) -> ListSectionController { return NoNewNotificationSectionController( topInset: 0, - topLayoutGuide: topLayoutGuide, - bottomLayoutGuide: bottomLayoutGuide + layoutInsets: view.safeAreaInsets ) } diff --git a/Classes/Repository/Empty/RepositoryEmptyResultsSectionController.swift b/Classes/Repository/Empty/RepositoryEmptyResultsSectionController.swift index 33a9090f..0b62a5f0 100644 --- a/Classes/Repository/Empty/RepositoryEmptyResultsSectionController.swift +++ b/Classes/Repository/Empty/RepositoryEmptyResultsSectionController.swift @@ -11,21 +11,19 @@ import IGListKit final class RepositoryEmptyResultsSectionController: ListSectionController { let topInset: CGFloat - let topLayoutGuide: UILayoutSupport - let bottomLayoutGuide: UILayoutSupport + let layoutInsets: UIEdgeInsets let type: RepositoryEmptyResultsType - init(topInset: CGFloat, topLayoutGuide: UILayoutSupport, bottomLayoutGuide: UILayoutSupport, type: RepositoryEmptyResultsType) { + init(topInset: CGFloat, layoutInsets: UIEdgeInsets, type: RepositoryEmptyResultsType) { self.topInset = topInset - self.topLayoutGuide = topLayoutGuide - self.bottomLayoutGuide = bottomLayoutGuide + self.layoutInsets = layoutInsets self.type = type super.init() } override func sizeForItem(at index: Int) -> CGSize { guard let size = collectionContext?.containerSize else { fatalError("Missing context") } - return CGSize(width: size.width, height: size.height - topInset - topLayoutGuide.length - bottomLayoutGuide.length) + return CGSize(width: size.width, height: size.height - topInset - layoutInsets.top - layoutInsets.bottom) } override func cellForItem(at index: Int) -> UICollectionViewCell { diff --git a/Classes/Repository/RepositoryCodeDirectoryViewController.swift b/Classes/Repository/RepositoryCodeDirectoryViewController.swift index 25a77894..b652d0ae 100644 --- a/Classes/Repository/RepositoryCodeDirectoryViewController.swift +++ b/Classes/Repository/RepositoryCodeDirectoryViewController.swift @@ -121,7 +121,7 @@ ListSingleSectionControllerDelegate { else { return .zero } return CGSize( width: context.containerSize.width, - height: context.containerSize.height - strongSelf.topLayoutGuide.length - strongSelf.bottomLayoutGuide.length + height: context.containerSize.height - strongSelf.view.safeAreaInsets.top - strongSelf.view.safeAreaInsets.bottom ) }) } diff --git a/Classes/Repository/RepositoryIssuesViewController.swift b/Classes/Repository/RepositoryIssuesViewController.swift index e408cc59..b2c24f7a 100644 --- a/Classes/Repository/RepositoryIssuesViewController.swift +++ b/Classes/Repository/RepositoryIssuesViewController.swift @@ -112,8 +112,7 @@ SearchBarSectionControllerDelegate { } return RepositoryEmptyResultsSectionController( topInset: 0, - topLayoutGuide: topLayoutGuide, - bottomLayoutGuide: bottomLayoutGuide, + layoutInsets: view.safeAreaInsets, type: empty ) } diff --git a/Classes/Repository/RepositoryOverviewViewController.swift b/Classes/Repository/RepositoryOverviewViewController.swift index 54f364e6..56b7bb6a 100644 --- a/Classes/Repository/RepositoryOverviewViewController.swift +++ b/Classes/Repository/RepositoryOverviewViewController.swift @@ -76,8 +76,7 @@ BaseListViewControllerDataSource { func emptySectionController(listAdapter: ListAdapter) -> ListSectionController { return RepositoryEmptyResultsSectionController( topInset: 0, - topLayoutGuide: topLayoutGuide, - bottomLayoutGuide: bottomLayoutGuide, + layoutInsets: view.safeAreaInsets, type: .readme ) } diff --git a/Classes/Search/SearchNoResultsSectionController.swift b/Classes/Search/SearchNoResultsSectionController.swift index 9ee237de..1f8b1345 100644 --- a/Classes/Search/SearchNoResultsSectionController.swift +++ b/Classes/Search/SearchNoResultsSectionController.swift @@ -11,19 +11,17 @@ import IGListKit final class SearchNoResultsSectionController: ListSectionController { let topInset: CGFloat - let topLayoutGuide: UILayoutSupport - let bottomLayoutGuide: UILayoutSupport - - init(topInset: CGFloat, topLayoutGuide: UILayoutSupport, bottomLayoutGuide: UILayoutSupport) { + let layoutInsets: UIEdgeInsets + + init(topInset: CGFloat, layoutInsets: UIEdgeInsets) { self.topInset = topInset - self.topLayoutGuide = topLayoutGuide - self.bottomLayoutGuide = bottomLayoutGuide + self.layoutInsets = layoutInsets super.init() } override func sizeForItem(at index: Int) -> CGSize { guard let size = collectionContext?.containerSize else { fatalError("Missing context") } - return CGSize(width: size.width, height: size.height - topInset - topLayoutGuide.length - bottomLayoutGuide.length) + return CGSize(width: size.width, height: size.height - topInset - layoutInsets.top - layoutInsets.bottom) } override func cellForItem(at index: Int) -> UICollectionViewCell { diff --git a/Classes/Search/SearchViewController.swift b/Classes/Search/SearchViewController.swift index b2805bdd..aac0f1f1 100644 --- a/Classes/Search/SearchViewController.swift +++ b/Classes/Search/SearchViewController.swift @@ -159,10 +159,10 @@ SearchResultSectionControllerDelegate { let controlHeight = Styles.Sizes.tableCellHeight if object === noResultsKey { + return SearchNoResultsSectionController( topInset: controlHeight, - topLayoutGuide: topLayoutGuide, - bottomLayoutGuide: bottomLayoutGuide + layoutInsets: view.safeAreaInsets ) } else if object === recentHeaderKey { return SearchRecentHeaderSectionController(delegate: self) diff --git a/Classes/Systems/ScrollViewKeyboardAdjuster.swift b/Classes/Systems/ScrollViewKeyboardAdjuster.swift index 1d7b0c02..d80e2e6f 100644 --- a/Classes/Systems/ScrollViewKeyboardAdjuster.swift +++ b/Classes/Systems/ScrollViewKeyboardAdjuster.swift @@ -50,7 +50,7 @@ final class ScrollViewKeyboardAdjuster { let converted = viewController.view.convert(frame, from: nil) let intersection = converted.intersection(frame) - let bottomInset = intersection.height - viewController.bottomLayoutGuide.length + let bottomInset = intersection.height - viewController.view.safeAreaInsets.bottom inset.bottom = bottomInset