-
Notifications
You must be signed in to change notification settings - Fork 37
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #663 from OneBusAway/tweaks
Adopt readableContentGuides to OBAListView
- Loading branch information
Showing
4 changed files
with
51 additions
and
18 deletions.
There are no files selected for viewing
31 changes: 31 additions & 0 deletions
31
OBAKit/Controls/ListView/NSCollectionLayoutSection+ReadableContentGuide.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
// | ||
// NSCollectionLayoutSection+ReadableContentGuide.swift | ||
// OBAKit | ||
// | ||
// Created by Alan Chu on 4/7/23. | ||
// | ||
|
||
import Foundation | ||
|
||
extension NSCollectionLayoutSection { | ||
/// `NSCollectionLayoutSection.list` with content insets set to the Readable Content Guide. | ||
@MainActor static func readableContentGuideList( | ||
using configuration: UICollectionLayoutListConfiguration, | ||
layoutEnvironment: NSCollectionLayoutEnvironment | ||
) -> NSCollectionLayoutSection { | ||
let section = self.list(using: configuration, layoutEnvironment: layoutEnvironment) | ||
|
||
// Change the section's content insets reference to the readable content. | ||
// This changes the way that the insets in the section's contentInsets property are interpreted. | ||
section.contentInsetsReference = .readableContent | ||
|
||
// Zero out the default leading/trailing contentInsets, but preserve the default top/bottom values. | ||
// This ensures each section will be inset horizontally exactly to the readable content width. | ||
var contentInsets = section.contentInsets | ||
contentInsets.leading = 0 | ||
contentInsets.trailing = 0 | ||
section.contentInsets = contentInsets | ||
|
||
return section | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters