Skip to content

Commit

Permalink
Merge pull request #59 from RakuyoKit/feature/2024-07-13-2
Browse files Browse the repository at this point in the history
Feature/2024-07-13-2
  • Loading branch information
rakuyoMo authored Jul 13, 2024
2 parents 56925d7 + df9703e commit 76384a3
Show file tree
Hide file tree
Showing 7 changed files with 49 additions and 51 deletions.
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

0 comments on commit 76384a3

Please sign in to comment.