Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/2024-07-13-2 #59

Merged
merged 6 commits into from
Jul 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ extension Extendable where Base: Layout.Section {
layoutEnvironment environment: Layout.Environment,
style: Layout.Style,
supplementaryItems: [SupplementaryItem] = [],
decoration: DecorationStyle? = .whiteBackground,
decoration: DecorationStyle? = nil,
edgeInsets: SectionEdgeInsets? = nil
) -> Base {
create(
Expand All @@ -40,18 +40,22 @@ extension Extendable where Base: Layout.Compositional {
public static func custom(
style: Layout.Style,
supplementaryItems: [SupplementaryItem] = [],
decoration: DecorationStyle? = .whiteBackground,
edgeInsets: SectionEdgeInsets? = nil
) -> Self {
Base { _, environment in
decoration: DecorationStyle? = nil,
edgeInsets: SectionEdgeInsets? = nil,
configuration: Layout.CompositionalConfiguration? = nil
) -> Base {
let sectionProvider: Layout.CompositionalSectionProvider = { _, environment in
Layout.Section.rak.custom(
layoutEnvironment: environment,
style: style,
supplementaryItems: supplementaryItems,
decoration: decoration,
edgeInsets: edgeInsets
)
}.rak
}

guard let configuration else { return .init(sectionProvider: sectionProvider) }
return .init(sectionProvider: sectionProvider, configuration: configuration)
}
}

Expand All @@ -62,7 +66,7 @@ extension SectionProviderWrapper {
public static func custom(
style: Layout.Style,
supplementaryItems: [SupplementaryItem] = [],
decoration: DecorationStyle? = .whiteBackground,
decoration: DecorationStyle? = nil,
edgeInsets: SectionEdgeInsets? = nil
) -> Self {
.init {
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ extension Extendable where Base: Layout.Section {
customGroup: Layout.CustomGroupFactory? = nil,
header: SupplementaryItem.Style? = nil,
footer: SupplementaryItem.Style? = nil,
decoration: DecorationStyle? = .whiteBackground,
decoration: DecorationStyle? = nil,
edgeInsets: SectionEdgeInsets? = nil
) -> Base {
custom(
Expand All @@ -50,10 +50,11 @@ extension Extendable where Base: Layout.Compositional {
customGroup: Layout.CustomGroupFactory? = nil,
header: SupplementaryItem.Style? = nil,
footer: SupplementaryItem.Style? = nil,
decoration: DecorationStyle? = .whiteBackground,
edgeInsets: SectionEdgeInsets? = nil
) -> Self {
Base { _, environment in
decoration: DecorationStyle? = nil,
edgeInsets: SectionEdgeInsets? = nil,
configuration: Layout.CompositionalConfiguration? = nil
) -> Base {
let sectionProvider: Layout.CompositionalSectionProvider = { _, environment in
Layout.Section.rak.flow(
layoutEnvironment: environment,
itemSize: itemSize,
Expand All @@ -64,7 +65,10 @@ extension Extendable where Base: Layout.Compositional {
decoration: decoration,
edgeInsets: edgeInsets
)
}.rak
}

guard let configuration else { return .init(sectionProvider: sectionProvider) }
return .init(sectionProvider: sectionProvider, configuration: configuration)
}
}

Expand All @@ -78,7 +82,7 @@ extension SectionProviderWrapper {
customGroup: Layout.CustomGroupFactory? = nil,
header: SupplementaryItem.Style? = nil,
footer: SupplementaryItem.Style? = nil,
decoration: DecorationStyle? = .whiteBackground,
decoration: DecorationStyle? = nil,
edgeInsets: SectionEdgeInsets? = nil
) -> Self {
.init {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,18 +25,14 @@ extension Extendable where Base: Layout.Section {

return .init(group: group).then { section in
section.contentInsets = edgeInsets.edgeInsets
section.decorationItems = createDecorationItems(by: decoration, edgeInsets: edgeInsets)
section.boundarySupplementaryItems = supplementaryItems.map {
createSupplementaryItem(with: $0)
}

if case .flow(_, let behavior, _) = style {
section.orthogonalScrollingBehavior = behavior
}

let decorationItems = createDecorationItems(by: decoration, edgeInsets: edgeInsets)
if decorationItems.isNotEmpty {
section.decorationItems = decorationItems
}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ extension Extendable where Base: Layout.Section {
layoutEnvironment environment: Layout.Environment,
header: SupplementaryItem.Style? = nil,
footer: SupplementaryItem.Style? = nil,
decoration: DecorationStyle? = .whiteBackground,
decoration: DecorationStyle? = nil,
edgeInsets: SectionEdgeInsets
) -> Base {
custom(
Expand All @@ -57,34 +57,42 @@ extension Extendable where Base: Layout.Compositional {
spacing: ListSpacing = .default,
header: SupplementaryItem.Style? = nil,
footer: SupplementaryItem.Style? = nil,
decoration: DecorationStyle? = .whiteBackground
) -> Self {
Base { _, environment in
decoration: DecorationStyle? = nil,
configuration: Layout.CompositionalConfiguration? = nil
) -> Base {
let sectionProvider: Layout.CompositionalSectionProvider = { _, environment in
Layout.Section.rak.list(
layoutEnvironment: environment,
spacing: spacing,
header: header,
footer: footer,
decoration: decoration
)
}.rak
}

guard let configuration else { return .init(sectionProvider: sectionProvider) }
return .init(sectionProvider: sectionProvider, configuration: configuration)
}

public static func list(
header: SupplementaryItem.Style? = nil,
footer: SupplementaryItem.Style? = nil,
decoration: DecorationStyle? = .whiteBackground,
edgeInsets: SectionEdgeInsets
) -> Self {
Base { _, environment in
decoration: DecorationStyle? = nil,
edgeInsets: SectionEdgeInsets,
configuration: Layout.CompositionalConfiguration? = nil
) -> Base {
let sectionProvider: Layout.CompositionalSectionProvider = { _, environment in
Layout.Section.rak.list(
layoutEnvironment: environment,
header: header,
footer: footer,
decoration: decoration,
edgeInsets: edgeInsets
)
}.rak
}

guard let configuration else { return .init(sectionProvider: sectionProvider) }
return .init(sectionProvider: sectionProvider, configuration: configuration)
}
}

Expand Down Expand Up @@ -112,7 +120,7 @@ extension SectionProviderWrapper {
public static func list(
header: SupplementaryItem.Style? = nil,
footer: SupplementaryItem.Style? = nil,
decoration: DecorationStyle? = .whiteBackground,
decoration: DecorationStyle? = nil,
edgeInsets: SectionEdgeInsets
) -> Self {
.init {
Expand Down
6 changes: 5 additions & 1 deletion Sources/Epoxy/CollectionView/Layout/Model/Layout.swift
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,11 @@ public enum Layout {
public typealias Dimension = NSCollectionLayoutDimension

public typealias Compositional = UICollectionViewCompositionalLayout


public typealias CompositionalConfiguration = UICollectionViewCompositionalLayoutConfiguration

public typealias CompositionalSectionProvider = UICollectionViewCompositionalLayoutSectionProvider

public typealias Item = NSCollectionLayoutItem

public typealias GroupCustomItem = NSCollectionLayoutGroupCustomItem
Expand Down
4 changes: 2 additions & 2 deletions Sources/Epoxy/CollectionView/Tools/SectionEdgeInsets.swift
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public enum SectionEdgeInsets {
/// Same spacing as `.insetGrouped` style `UITableView`
///
/// (top: 0, leading: 20, bottom: 35, trailing: 20)
case groupCard(horizontal: CGFloat = 20, bottom: CGFloat = 35)
case groupCard(horizontal: CGFloat = 20, bottom: ListSpacing = .group)

/// Fully customized using `EdgeInsets`.
case custom(RAKCore.EdgeInsets)
Expand Down Expand Up @@ -73,7 +73,7 @@ extension SectionEdgeInsets {
.init(top: top, leading: leading, bottom: bottom, trailing: trailing)

case .groupCard(let horizontal, let bottom):
.init(top: 0, leading: horizontal, bottom: bottom, trailing: horizontal)
.init(top: 0, leading: horizontal, bottom: bottom.spacing, trailing: horizontal)

case .custom(let edge):
edge.directionalEdgeInsets
Expand Down