Skip to content

Commit

Permalink
Merge branch 'main' into kve/add-some-changes-to-on-change
Browse files Browse the repository at this point in the history
  • Loading branch information
kyleve authored Jan 23, 2021
2 parents 29aac15 + 86af8b2 commit fd8dd7b
Show file tree
Hide file tree
Showing 5 changed files with 103 additions and 39 deletions.
23 changes: 9 additions & 14 deletions BlueprintUILists/Sources/BlueprintHeaderFooterContent.swift
Original file line number Diff line number Diff line change
Expand Up @@ -119,24 +119,19 @@ public extension BlueprintHeaderFooterContent
views.pressed.element = self.pressedBackground?.wrapInBlueprintEnvironmentFrom(environment: info.environment)
}

static func createReusableContentView(frame: CGRect) -> ContentView
{
let view = BlueprintView(frame: frame)
view.backgroundColor = .clear

return view
static func createReusableContentView(frame: CGRect) -> ContentView {
self.newBlueprintView(with: frame)
}

static func createReusableBackgroundView(frame: CGRect) -> BackgroundView
{
let view = BlueprintView(frame: frame)
view.backgroundColor = .clear
return view
static func createReusableBackgroundView(frame: CGRect) -> BackgroundView {
self.newBlueprintView(with: frame)
}

static func createReusablePressedBackgroundView(frame: CGRect) -> PressedBackgroundView {
self.newBlueprintView(with: frame)
}

static func createReusablePressedBackgroundView(frame: CGRect) -> PressedBackgroundView
{
private static func newBlueprintView(with frame : CGRect) -> BlueprintView {
let view = BlueprintView(frame: frame)
view.backgroundColor = .clear

Expand Down
23 changes: 11 additions & 12 deletions BlueprintUILists/Sources/BlueprintItemContent.swift
Original file line number Diff line number Diff line change
Expand Up @@ -131,24 +131,23 @@ public extension BlueprintItemContent
}

/// Creates the `BlueprintView` used to render the content of the item.
static func createReusableContentView(frame: CGRect) -> ContentView
{
let view = BlueprintView(frame: frame)
view.backgroundColor = .clear

return view
static func createReusableContentView(frame: CGRect) -> ContentView {
self.newBlueprintView(with: frame)
}

/// Creates the `BlueprintView` used to render the background of the item.
static func createReusableBackgroundView(frame: CGRect) -> BackgroundView
{
static func createReusableBackgroundView(frame: CGRect) -> BackgroundView {
self.newBlueprintView(with: frame)
}

static func createReusableSelectedBackgroundView(frame: CGRect) -> SelectedBackgroundView {
self.newBlueprintView(with: frame)
}

private static func newBlueprintView(with frame : CGRect) -> BlueprintView {
let view = BlueprintView(frame: frame)
view.backgroundColor = .clear

return view
}

static func createReusableSelectedBackgroundView(frame: CGRect) -> SelectedBackgroundView {
self.createReusableBackgroundView(frame: frame)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ final class CustomLayoutsViewController : UIViewController
self.gridOn.toggle()

if self.gridOn {
self.listView.set(layout: .grid_experimental(), animated: true)
self.listView.set(layout: .experimental_grid(), animated: true)
} else {
self.listView.set(layout: .demoLayout, animated: true)
}
Expand Down
86 changes: 78 additions & 8 deletions ListableUI/Sources/Layout/Grid/GridListLayout.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@

import Foundation

public extension LayoutDescription
extension LayoutDescription
{
static func grid_experimental(_ configure : @escaping (inout GridAppearance) -> () = { _ in }) -> Self
public static func experimental_grid(_ configure : @escaping (inout GridAppearance) -> () = { _ in }) -> Self
{
GridListLayout.describe(appearance: configure)
}
Expand Down Expand Up @@ -133,6 +133,76 @@ public struct GridAppearance : ListLayoutAppearance
}


extension GridAppearance {

public struct ItemLayout : ItemLayoutsValue {

public static var defaultValue: Self {
.init()
}

public init() {

}
}


public struct HeaderFooterLayout : HeaderFooterLayoutsValue {

public var width : CustomWidth

public static var defaultValue: Self {
.init()
}

public init(
width : CustomWidth = .default
) {
self.width = width
}
}


public struct SectionLayout : SectionLayoutsValue {

public var width : CustomWidth

public static var defaultValue: Self {
.init()
}

public init(
width : CustomWidth = .default
) {
self.width = width
}
}
}


extension ItemLayouts {
public var grid : GridAppearance.ItemLayout {
get { self[GridAppearance.ItemLayout.self] }
set { self[GridAppearance.ItemLayout.self] = newValue }
}
}


extension HeaderFooterLayouts {
public var grid : GridAppearance.HeaderFooterLayout {
get { self[GridAppearance.HeaderFooterLayout.self] }
set { self[GridAppearance.HeaderFooterLayout.self] = newValue }
}
}

extension SectionLayouts {
public var grid : GridAppearance.SectionLayout {
get { self[GridAppearance.SectionLayout.self] }
set { self[GridAppearance.SectionLayout.self] = newValue }
}
}


final class GridListLayout : ListLayout
{
typealias LayoutAppearance = GridAppearance
Expand Down Expand Up @@ -222,7 +292,7 @@ final class GridListLayout : ListLayout
performLayout(for: self.content.header) { header in
let hasListHeader = self.content.header.isPopulated

let position = header.layouts.table.width.position(with: viewSize, defaultWidth: rootWidth)
let position = header.layouts.grid.width.position(with: viewSize, defaultWidth: rootWidth)

let measureInfo = Sizing.MeasureInfo(
sizeConstraint: CGSize(width: position.width, height: .greatestFiniteMagnitude),
Expand Down Expand Up @@ -257,7 +327,7 @@ final class GridListLayout : ListLayout

self.content.sections.forEachWithIndex { sectionIndex, isLast, section in

let sectionPosition = section.layouts.table.width.position(with: viewSize, defaultWidth: rootWidth)
let sectionPosition = section.layouts.grid.width.position(with: viewSize, defaultWidth: rootWidth)

//
// Section Header
Expand All @@ -267,7 +337,7 @@ final class GridListLayout : ListLayout
let hasSectionFooter = section.footer.isPopulated

performLayout(for: section.header) { header in
let width = header.layouts.table.width.merge(with: section.layouts.table.width)
let width = header.layouts.grid.width.merge(with: section.layouts.grid.width)
let position = width.position(with: viewSize, defaultWidth: sectionPosition.width)

let measureInfo = Sizing.MeasureInfo(
Expand Down Expand Up @@ -315,7 +385,7 @@ final class GridListLayout : ListLayout
//

performLayout(for: section.footer) { footer in
let width = footer.layouts.table.width.merge(with: section.layouts.table.width)
let width = footer.layouts.grid.width.merge(with: section.layouts.grid.width)
let position = width.position(with: viewSize, defaultWidth: sectionPosition.width)

let measureInfo = Sizing.MeasureInfo(
Expand Down Expand Up @@ -357,7 +427,7 @@ final class GridListLayout : ListLayout
performLayout(for: self.content.footer) { footer in
let hasFooter = footer.isPopulated

let position = footer.layouts.table.width.position(with: viewSize, defaultWidth: rootWidth)
let position = footer.layouts.grid.width.position(with: viewSize, defaultWidth: rootWidth)

let measureInfo = Sizing.MeasureInfo(
sizeConstraint: CGSize(width: position.width, height: .greatestFiniteMagnitude),
Expand All @@ -383,7 +453,7 @@ final class GridListLayout : ListLayout

performLayout(for: self.content.overscrollFooter) { footer in

let position = footer.layouts.table.width.position(with: viewSize, defaultWidth: rootWidth)
let position = footer.layouts.grid.width.position(with: viewSize, defaultWidth: rootWidth)

let measureInfo = Sizing.MeasureInfo(
sizeConstraint: CGSize(width: position.width, height: .greatestFiniteMagnitude),
Expand Down
8 changes: 4 additions & 4 deletions Podfile.lock
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
PODS:
- BlueprintUI (0.19.0)
- BlueprintUICommonControls (0.19.0):
- BlueprintUI (0.20.0)
- BlueprintUICommonControls (0.20.0):
- BlueprintUI
- BlueprintUILists (0.14.2):
- BlueprintUI
Expand Down Expand Up @@ -43,8 +43,8 @@ EXTERNAL SOURCES:
:path: Internal Pods/Snapshot/Snapshot.podspec

SPEC CHECKSUMS:
BlueprintUI: 0a86c26f7f51bfc8dd37ead2c41d53b72995d318
BlueprintUICommonControls: c177a134b6112a7e08db91b893f0164f49a75a25
BlueprintUI: d26766f3e006d1f9348cba6a7f15efc64da74cb3
BlueprintUICommonControls: b7b6a10581203f4bd6283c9d2a9b810d513d804b
BlueprintUILists: afcc5b470731c70d1c2952ee4c24e6bcd566a2bd
EnglishDictionary: f03968b9382ddc5c8dd63535efbf783c6cd45f1c
ListableUI: 40e95b6299084145f04b421353612efbf9f50672
Expand Down

0 comments on commit fd8dd7b

Please sign in to comment.