-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
update flow layout section controller
- Loading branch information
1 parent
6ab82ff
commit 6c8df36
Showing
8 changed files
with
63 additions
and
68 deletions.
There are no files selected for viewing
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
48 changes: 48 additions & 0 deletions
48
SectionKit/Sources/SectionController/FlowLayout/BaseFlowLayoutSectionController.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,48 @@ | ||
import UIKit | ||
|
||
/// This is a foundational implementation of `FlowLayoutSectionController`, implementing the flow layout delegate while inheriting from the `BaseSectionController`. | ||
@MainActor | ||
open class BaseFlowLayoutSectionController: BaseSectionController, | ||
SectionFlowDelegate, | ||
FlowLayoutSectionController { | ||
open var flowDelegate: SectionFlowDelegate? { self } | ||
|
||
// MARK: - SectionFlowDelegate | ||
|
||
open func sizeForItem( | ||
at indexPath: SectionIndexPath, | ||
using layout: UICollectionViewLayout, | ||
in context: CollectionViewContext | ||
) -> CGSize { | ||
(layout as? UICollectionViewFlowLayout)?.itemSize ?? CGSize(width: 50, height: 50) | ||
} | ||
|
||
open func inset(using layout: UICollectionViewLayout, in context: CollectionViewContext) -> UIEdgeInsets { | ||
(layout as? UICollectionViewFlowLayout)?.sectionInset ?? .zero | ||
} | ||
|
||
open func minimumLineSpacing(using layout: UICollectionViewLayout, in context: CollectionViewContext) -> CGFloat { | ||
(layout as? UICollectionViewFlowLayout)?.minimumLineSpacing ?? 10 | ||
} | ||
|
||
open func minimumInteritemSpacing( | ||
using layout: UICollectionViewLayout, | ||
in context: CollectionViewContext | ||
) -> CGFloat { | ||
(layout as? UICollectionViewFlowLayout)?.minimumInteritemSpacing ?? 10 | ||
} | ||
|
||
open func referenceSizeForHeader( | ||
using layout: UICollectionViewLayout, | ||
in context: CollectionViewContext | ||
) -> CGSize { | ||
(layout as? UICollectionViewFlowLayout)?.headerReferenceSize ?? .zero | ||
} | ||
|
||
open func referenceSizeForFooter( | ||
using layout: UICollectionViewLayout, | ||
in context: CollectionViewContext | ||
) -> CGSize { | ||
(layout as? UICollectionViewFlowLayout)?.footerReferenceSize ?? .zero | ||
} | ||
} |
File renamed without changes.
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
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