From c5a25eecf10dc230d042e379700f49ca030f3a47 Mon Sep 17 00:00:00 2001 From: Shadowfacts Date: Sun, 15 Jan 2023 12:45:41 -0500 Subject: [PATCH] Fix row separators not being inset to readable content width --- .../Explore/TrendingStatusesViewController.swift | 6 +++++- .../Profile/ProfileStatusesViewController.swift | 10 +++++++++- Tusker/Screens/Timeline/TimelineViewController.swift | 7 ++++++- 3 files changed, 20 insertions(+), 3 deletions(-) diff --git a/Tusker/Screens/Explore/TrendingStatusesViewController.swift b/Tusker/Screens/Explore/TrendingStatusesViewController.swift index 8b98ed4e..95b97fc9 100644 --- a/Tusker/Screens/Explore/TrendingStatusesViewController.swift +++ b/Tusker/Screens/Explore/TrendingStatusesViewController.swift @@ -60,7 +60,11 @@ class TrendingStatusesViewController: UIViewController { } return config } - let layout = UICollectionViewCompositionalLayout.list(using: config) + let layout = UICollectionViewCompositionalLayout { sectionIndex, environment in + let section = NSCollectionLayoutSection.list(using: config, layoutEnvironment: environment) + section.contentInsetsReference = .readableContent + return section + } view = UICollectionView(frame: .zero, collectionViewLayout: layout) collectionView.delegate = self collectionView.dragDelegate = self diff --git a/Tusker/Screens/Profile/ProfileStatusesViewController.swift b/Tusker/Screens/Profile/ProfileStatusesViewController.swift index 4458d83a..506e5537 100644 --- a/Tusker/Screens/Profile/ProfileStatusesViewController.swift +++ b/Tusker/Screens/Profile/ProfileStatusesViewController.swift @@ -80,7 +80,15 @@ class ProfileStatusesViewController: UIViewController, TimelineLikeCollectionVie } return config } - let layout = UICollectionViewCompositionalLayout.list(using: config) + let layout = UICollectionViewCompositionalLayout { [unowned self] sectionIndex, environment in + if case .header = dataSource.sectionIdentifier(for: sectionIndex) { + return .list(using: .init(appearance: .plain), layoutEnvironment: environment) + } else { + let section = NSCollectionLayoutSection.list(using: config, layoutEnvironment: environment) + section.contentInsetsReference = .readableContent + return section + } + } view = UICollectionView(frame: .zero, collectionViewLayout: layout) collectionView.delegate = self collectionView.dragDelegate = self diff --git a/Tusker/Screens/Timeline/TimelineViewController.swift b/Tusker/Screens/Timeline/TimelineViewController.swift index 4c1ac563..b5737552 100644 --- a/Tusker/Screens/Timeline/TimelineViewController.swift +++ b/Tusker/Screens/Timeline/TimelineViewController.swift @@ -87,7 +87,12 @@ class TimelineViewController: UIViewController, TimelineLikeCollectionViewContro } return config } - let layout = UICollectionViewCompositionalLayout.list(using: config) + // 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) + section.contentInsetsReference = .readableContent + return section + } collectionView = UICollectionView(frame: .zero, collectionViewLayout: layout) collectionView.delegate = self collectionView.dragDelegate = self