From 6c5c263f4206de86de7e24868651e92bf60e56f8 Mon Sep 17 00:00:00 2001 From: Bryan Keller Date: Thu, 30 Oct 2025 16:03:12 -0700 Subject: [PATCH 1/3] Make verticalLayoutDirection configurable after initialization --- MagazineLayout/Public/MagazineLayout.swift | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/MagazineLayout/Public/MagazineLayout.swift b/MagazineLayout/Public/MagazineLayout.swift index 83576e3..1d61b0e 100755 --- a/MagazineLayout/Public/MagazineLayout.swift +++ b/MagazineLayout/Public/MagazineLayout.swift @@ -30,24 +30,21 @@ public final class MagazineLayout: UICollectionViewLayout { /// - flipsHorizontallyInOppositeLayoutDirection: Indicates whether the horizontal coordinate /// system is automatically flipped at appropriate times. In practice, this is used to support /// right-to-left layout. - /// - verticalLayoutDirection: The vertical layout direction of items in the collection view. This property changes the - /// behavior of scroll-position-preservation when performing batch updates or when the collection view's bounds changes. - public init( - flipsHorizontallyInOppositeLayoutDirection: Bool = true, - verticalLayoutDirection: MagazineLayoutVerticalLayoutDirection = .topToBottom) - { + public init(flipsHorizontallyInOppositeLayoutDirection: Bool = true) { _flipsHorizontallyInOppositeLayoutDirection = flipsHorizontallyInOppositeLayoutDirection - self.verticalLayoutDirection = verticalLayoutDirection super.init() } required init?(coder aDecoder: NSCoder) { _flipsHorizontallyInOppositeLayoutDirection = true - verticalLayoutDirection = .topToBottom super.init(coder: aDecoder) } // MARK: Public + + /// The vertical layout direction of items in the collection view. This property changes the behavior of + /// scroll-position-preservation when performing batch updates or when the collection view's bounds changes. + public var verticalLayoutDirection = MagazineLayoutVerticalLayoutDirection.topToBottom override public class var layoutAttributesClass: AnyClass { return MagazineLayoutCollectionViewLayoutAttributes.self From 45cc86978234f76dc88e8ce2af2c058029e1d737 Mon Sep 17 00:00:00 2001 From: Bryan Keller Date: Thu, 30 Oct 2025 16:14:46 -0700 Subject: [PATCH 2/3] Update ContentInsetAdjustingContentOffsetTests.swift --- Tests/ContentInsetAdjustingContentOffsetTests.swift | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/Tests/ContentInsetAdjustingContentOffsetTests.swift b/Tests/ContentInsetAdjustingContentOffsetTests.swift index 71da29f..8ab05d0 100644 --- a/Tests/ContentInsetAdjustingContentOffsetTests.swift +++ b/Tests/ContentInsetAdjustingContentOffsetTests.swift @@ -19,7 +19,7 @@ import XCTest final class ContentInsetAdjustingContentOffsetTests: XCTestCase { func testContentOffsetIsNotAdjustedForTopInsetChangeWithToTopBottomLayout() { - let layout = MagazineLayout(verticalLayoutDirection: .topToBottom) + let layout = MagazineLayout() let collectionView = StubCollectionView( frame: .zero, collectionViewLayout: layout) @@ -33,7 +33,8 @@ final class ContentInsetAdjustingContentOffsetTests: XCTestCase { } func testContentOffsetIsAdjustedForTopInsetChangeWithBottomToTopLayout() { - let layout = MagazineLayout(verticalLayoutDirection: .bottomToTop) + let layout = MagazineLayout() + layout.verticalLayoutDirection = .bottomToTop let collectionView = StubCollectionView( frame: .zero, collectionViewLayout: layout) @@ -47,7 +48,8 @@ final class ContentInsetAdjustingContentOffsetTests: XCTestCase { } func testContentOffsetIsAdjustedForBottomInsetChangeWithBottomToTopLayout() { - let layout = MagazineLayout(verticalLayoutDirection: .bottomToTop) + let layout = MagazineLayout() + layout.verticalLayoutDirection = .bottomToTop let collectionView = StubCollectionView( frame: .zero, collectionViewLayout: layout) @@ -61,7 +63,8 @@ final class ContentInsetAdjustingContentOffsetTests: XCTestCase { } func testContentOffsetIsAdjustedForTopAndBottomInsetChangesWithBottomToTopLayout() { - let layout = MagazineLayout(verticalLayoutDirection: .bottomToTop) + let layout = MagazineLayout() + layout.verticalLayoutDirection = .bottomToTop let collectionView = StubCollectionView( frame: .zero, collectionViewLayout: layout) From db791a9c80decc23256b49c459728a8fa81d6769 Mon Sep 17 00:00:00 2001 From: Bryan Keller Date: Thu, 30 Oct 2025 16:17:55 -0700 Subject: [PATCH 3/3] Update MagazineLayout.swift --- MagazineLayout/Public/MagazineLayout.swift | 1 - 1 file changed, 1 deletion(-) diff --git a/MagazineLayout/Public/MagazineLayout.swift b/MagazineLayout/Public/MagazineLayout.swift index 1d61b0e..efb68bc 100755 --- a/MagazineLayout/Public/MagazineLayout.swift +++ b/MagazineLayout/Public/MagazineLayout.swift @@ -841,7 +841,6 @@ public final class MagazineLayout: UICollectionViewLayout { // MARK: Private private let _flipsHorizontallyInOppositeLayoutDirection: Bool - private let verticalLayoutDirection: MagazineLayoutVerticalLayoutDirection private lazy var modelState: ModelState = { return ModelState(currentVisibleBoundsProvider: { [weak self] in