From ebc127c921bb08c242b5c0727bb77f58100d4e5e Mon Sep 17 00:00:00 2001 From: Shadowfacts Date: Sat, 9 Sep 2023 10:56:11 -0400 Subject: [PATCH] Add readable content inset to certain screens --- .../AccountFollowsListViewController.swift | 8 +++++++- .../Screens/Account List/AccountListViewController.swift | 8 +++++++- .../StatusActionAccountListCollectionViewController.swift | 6 +++++- Tusker/Screens/Timeline/TimelineViewController.swift | 6 +++--- 4 files changed, 22 insertions(+), 6 deletions(-) diff --git a/Tusker/Screens/Account Follows/AccountFollowsListViewController.swift b/Tusker/Screens/Account Follows/AccountFollowsListViewController.swift index a747de10..15615f35 100644 --- a/Tusker/Screens/Account Follows/AccountFollowsListViewController.swift +++ b/Tusker/Screens/Account Follows/AccountFollowsListViewController.swift @@ -54,7 +54,13 @@ class AccountFollowsListViewController: UIViewController, CollectionViewControll } return config } - let layout = UICollectionViewCompositionalLayout.list(using: config) + let layout = UICollectionViewCompositionalLayout { sectionIndex, environment in + let section = NSCollectionLayoutSection.list(using: config, layoutEnvironment: environment) + if UIDevice.current.userInterfaceIdiom == .pad || UIDevice.current.userInterfaceIdiom == .mac { + section.contentInsetsReference = .readableContent + } + return section + } view = UICollectionView(frame: .zero, collectionViewLayout: layout) collectionView.delegate = self collectionView.dragDelegate = self diff --git a/Tusker/Screens/Account List/AccountListViewController.swift b/Tusker/Screens/Account List/AccountListViewController.swift index 5a14d24b..8fe63a98 100644 --- a/Tusker/Screens/Account List/AccountListViewController.swift +++ b/Tusker/Screens/Account List/AccountListViewController.swift @@ -33,7 +33,13 @@ class AccountListViewController: UIViewController, CollectionViewController { override func loadView() { var config = UICollectionLayoutListConfiguration(appearance: .grouped) config.backgroundColor = .appGroupedBackground - let layout = UICollectionViewCompositionalLayout.list(using: config) + let layout = UICollectionViewCompositionalLayout { sectionIndex, environment in + let section = NSCollectionLayoutSection.list(using: config, layoutEnvironment: environment) + if UIDevice.current.userInterfaceIdiom == .pad || UIDevice.current.userInterfaceIdiom == .mac { + section.contentInsetsReference = .readableContent + } + return section + } view = UICollectionView(frame: .zero, collectionViewLayout: layout) collectionView.delegate = self collectionView.dragDelegate = self diff --git a/Tusker/Screens/Status Action Account List/StatusActionAccountListCollectionViewController.swift b/Tusker/Screens/Status Action Account List/StatusActionAccountListCollectionViewController.swift index a18f236e..409ef835 100644 --- a/Tusker/Screens/Status Action Account List/StatusActionAccountListCollectionViewController.swift +++ b/Tusker/Screens/Status Action Account List/StatusActionAccountListCollectionViewController.swift @@ -71,7 +71,11 @@ class StatusActionAccountListCollectionViewController: UIViewController, Collect config.trailingSwipeActionsConfigurationProvider = { [unowned self] in (collectionView.cellForItem(at: $0) as? TimelineStatusCollectionViewCell)?.trailingSwipeActions() } - return NSCollectionLayoutSection.list(using: config, layoutEnvironment: environment) + let section = NSCollectionLayoutSection.list(using: config, layoutEnvironment: environment) + if UIDevice.current.userInterfaceIdiom == .pad || UIDevice.current.userInterfaceIdiom == .mac { + section.contentInsetsReference = .readableContent + } + return section case .accounts: return NSCollectionLayoutSection.list(using: accountsConfig, layoutEnvironment: environment) } diff --git a/Tusker/Screens/Timeline/TimelineViewController.swift b/Tusker/Screens/Timeline/TimelineViewController.swift index 9d5e6023..9c7bcf11 100644 --- a/Tusker/Screens/Timeline/TimelineViewController.swift +++ b/Tusker/Screens/Timeline/TimelineViewController.swift @@ -110,9 +110,9 @@ class TimelineViewController: UIViewController, TimelineLikeCollectionViewContro // just setting layout.configuration.contentInsetsReference doesn't work with UICollectionViewCompositionalLayout.list let layout = UICollectionViewCompositionalLayout { sectionIndex, environment in let section = NSCollectionLayoutSection.list(using: config, layoutEnvironment: environment) -// if UIDevice.current.userInterfaceIdiom == .pad || UIDevice.current.userInterfaceIdiom == .mac { -// section.contentInsetsReference = .readableContent -// } + if UIDevice.current.userInterfaceIdiom == .pad || UIDevice.current.userInterfaceIdiom == .mac { + section.contentInsetsReference = .readableContent + } return section } collectionView = UICollectionView(frame: .zero, collectionViewLayout: layout)