Skip to content

Commit

Permalink
Merge branch 'main' into spm
Browse files Browse the repository at this point in the history
  • Loading branch information
lickel authored Oct 30, 2021
2 parents 31251a2 + 97a65fd commit ac64356
Show file tree
Hide file tree
Showing 6 changed files with 66 additions and 58 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@

### Changed

- `ListLayout` and its associated types are now public, allowing you to make custom layouts. Note that these APIs are still experimental and subject to change.

### Misc

# Past Releases
Expand Down
12 changes: 6 additions & 6 deletions ListableUI/Sources/Layout/ListLayout/LayoutDescription.swift
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,10 @@ public struct LayoutDescription
}


public extension ListLayout
extension ListLayout
{
/// Creates a new layout description for a list layout, with the provided optional layout configuration.
static func describe(
public static func describe(
appearance : @escaping (inout Self.LayoutAppearance) -> () = { _ in }
) -> LayoutDescription
{
Expand All @@ -70,15 +70,15 @@ public extension ListLayout

extension LayoutDescription
{
struct Configuration<LayoutType:ListLayout> : AnyLayoutDescriptionConfiguration
public struct Configuration<LayoutType:ListLayout> : AnyLayoutDescriptionConfiguration
{
let layoutType : LayoutType.Type
public let layoutType : LayoutType.Type

let configure : (inout LayoutType.LayoutAppearance) -> ()
public let configure : (inout LayoutType.LayoutAppearance) -> ()

// MARK: AnyLayoutDescriptionConfiguration

func createEmptyLayout(
public func createEmptyLayout(
appearance : Appearance,
behavior: Behavior
) -> AnyListLayout
Expand Down
26 changes: 13 additions & 13 deletions ListableUI/Sources/Layout/ListLayout/ListLayout.swift
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public struct ListLayoutLayoutContext {

public var environment : ListEnvironment

init(
public init(
viewBounds : CGRect,
safeAreaInsets : UIEdgeInsets,
environment : ListEnvironment
Expand All @@ -54,13 +54,13 @@ public struct ListLayoutLayoutContext {
}
}

public extension ListLayout
extension ListLayout
{
var direction: LayoutDirection {
public var direction: LayoutDirection {
self.layoutAppearance.direction
}

var stickySectionHeaders: Bool {
public var stickySectionHeaders: Bool {
self.layoutAppearance.stickySectionHeaders
}
}
Expand Down Expand Up @@ -109,9 +109,9 @@ public protocol AnyListLayout : AnyObject
}


public extension AnyListLayout
extension AnyListLayout
{
func setZIndexes()
public func setZIndexes()
{
self.content.header.zIndex = 5

Expand All @@ -129,7 +129,7 @@ public extension AnyListLayout
self.content.overscrollFooter.zIndex = 0
}

func adjust(
public func adjust(
layoutAttributesForReorderingItem attributes : inout ListContentLayoutAttributes,
originalAttributes : ListContentLayoutAttributes,
at indexPath: IndexPath,
Expand All @@ -140,9 +140,9 @@ public extension AnyListLayout
}


public extension AnyListLayout
extension AnyListLayout
{
func visibleContentFrame(for collectionView : UICollectionView) -> CGRect
public func visibleContentFrame(for collectionView : UICollectionView) -> CGRect
{
CGRect(
x: collectionView.contentOffset.x + collectionView.safeAreaInsets.left,
Expand All @@ -154,9 +154,9 @@ public extension AnyListLayout
}


public extension AnyListLayout
extension AnyListLayout
{
func positionStickySectionHeadersIfNeeded(in collectionView : UICollectionView)
public func positionStickySectionHeadersIfNeeded(in collectionView : UICollectionView)
{
guard self.stickySectionHeaders else {
return
Expand All @@ -183,7 +183,7 @@ public extension AnyListLayout
}
}

func updateOverscrollFooterPosition(in collectionView : UICollectionView)
public func updateOverscrollFooterPosition(in collectionView : UICollectionView)
{
guard self.direction == .vertical else {
// Currently only supported for vertical layouts.
Expand All @@ -205,7 +205,7 @@ public extension AnyListLayout
}
}

func adjustPositionsForLayoutUnderflow(in collectionView : UICollectionView)
public func adjustPositionsForLayoutUnderflow(in collectionView : UICollectionView)
{
guard self.direction == .vertical else {
// Currently only supported for vertical layouts.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import Foundation
import UIKit


public struct ListLayoutAttributes : Equatable {
struct ListLayoutAttributes : Equatable {

var contentSize : CGSize

Expand Down
65 changes: 33 additions & 32 deletions ListableUI/Sources/Layout/ListLayout/ListLayoutContent.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,17 @@ import UIKit

public final class ListLayoutContent
{
var contentSize : CGSize
public var contentSize : CGSize

let containerHeader : SupplementaryItemInfo
let header : SupplementaryItemInfo
let footer : SupplementaryItemInfo
public let containerHeader : SupplementaryItemInfo
public let header : SupplementaryItemInfo
public let footer : SupplementaryItemInfo

let overscrollFooter : SupplementaryItemInfo
public let overscrollFooter : SupplementaryItemInfo

let sections : [SectionInfo]
public let sections : [SectionInfo]

var all : [ListLayoutContentItem] {
public var all : [ListLayoutContentItem] {
var all : [ListLayoutContentItem] = []

if header.isPopulated {
Expand Down Expand Up @@ -248,7 +248,7 @@ public final class ListLayoutContent
}


protocol ListLayoutContentItem : AnyObject
public protocol ListLayoutContentItem : AnyObject
{
var size : CGSize { get set }
var x : CGFloat { get set }
Expand All @@ -258,18 +258,18 @@ protocol ListLayoutContentItem : AnyObject
}


public extension ListLayoutContent
extension ListLayoutContent
{
final class SectionInfo
public final class SectionInfo
{
let state : PresentationState.SectionState

let header : SupplementaryItemInfo
let footer : SupplementaryItemInfo
public let header : SupplementaryItemInfo
public let footer : SupplementaryItemInfo

var items : [ItemInfo]
public internal(set) var items : [ItemInfo]

var layouts : SectionLayouts {
public var layouts : SectionLayouts {
self.state.model.layouts
}

Expand Down Expand Up @@ -325,7 +325,7 @@ public extension ListLayoutContent
}
}

final class SupplementaryItemInfo : ListLayoutContentItem
public final class SupplementaryItemInfo : ListLayoutContentItem
{
static func empty(_ kind : SupplementaryKind) -> SupplementaryItemInfo
{
Expand All @@ -339,32 +339,33 @@ public extension ListLayoutContent
let state : AnyPresentationHeaderFooterState?

let kind : SupplementaryKind
let measurer : (Sizing.MeasureInfo) -> CGSize
public let measurer : (Sizing.MeasureInfo) -> CGSize

let isPopulated : Bool
public let isPopulated : Bool

var size : CGSize = .zero
public var size : CGSize = .zero

var x : CGFloat = .zero
public var x : CGFloat = .zero
var pinnedX : CGFloat? = nil

var y : CGFloat = .zero
public var y : CGFloat = .zero
var pinnedY : CGFloat? = nil

var zIndex : Int = 0
public var zIndex : Int = 0

var layouts : HeaderFooterLayouts {
public var layouts : HeaderFooterLayouts {
// TODO: Why the ?? here
self.state?.anyModel.layouts ?? .init()
}

var defaultFrame : CGRect {
public var defaultFrame : CGRect {
CGRect(
origin: CGPoint(x: self.x, y: self.y),
size: self.size
)
}

var visibleFrame : CGRect {
public var visibleFrame : CGRect {
CGRect(
origin: CGPoint(
x: self.pinnedX ?? self.x,
Expand Down Expand Up @@ -398,25 +399,25 @@ public extension ListLayoutContent
}


final class ItemInfo : ListLayoutContentItem
public final class ItemInfo : ListLayoutContentItem
{
let state : AnyPresentationItemState

var indexPath : IndexPath

let insertAndRemoveAnimations : ItemInsertAndRemoveAnimations
let measurer : (Sizing.MeasureInfo) -> CGSize
public let measurer : (Sizing.MeasureInfo) -> CGSize

var position : ItemPosition = .single
public var position : ItemPosition = .single

var size : CGSize = .zero
public var size : CGSize = .zero

var x : CGFloat = .zero
var y : CGFloat = .zero
public var x : CGFloat = .zero
public var y : CGFloat = .zero

var zIndex : Int = 0
public var zIndex : Int = 0

var layouts : ItemLayouts {
public var layouts : ItemLayouts {
self.state.anyModel.layouts
}

Expand Down
17 changes: 11 additions & 6 deletions ListableUI/Sources/Sizing.swift
Original file line number Diff line number Diff line change
Expand Up @@ -134,11 +134,11 @@ extension Sizing
{
public struct MeasureInfo
{
var sizeConstraint : CGSize
var defaultSize : CGSize
var direction : LayoutDirection
public var sizeConstraint : CGSize
public var defaultSize : CGSize
public var direction : LayoutDirection

init(
public init(
sizeConstraint: CGSize,
defaultSize: CGSize,
direction: LayoutDirection
Expand Down Expand Up @@ -332,8 +332,13 @@ public enum CustomWidth : Equatable

public struct Position : Equatable
{
var origin : CGFloat
var width : CGFloat
public var origin : CGFloat
public var width : CGFloat

public init(origin: CGFloat, width: CGFloat) {
self.origin = origin
self.width = width
}
}
}

Expand Down

0 comments on commit ac64356

Please sign in to comment.