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

Replace Bindings w/ SwiftUI-style Coordinator #143

Merged
merged 3 commits into from
May 23, 2020
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
10 changes: 0 additions & 10 deletions BlueprintLists/Sources/BlueprintListsModule.swift

This file was deleted.

13 changes: 13 additions & 0 deletions BlueprintLists/Sources/Exports.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
//
// Exports.swift
// Pods
//
// Created by Kyle Van Essen on 5/19/20.
//

///
/// Import required dependencies when using BlueprintLists.
///

@_exported import BlueprintUI
@_exported import Listable
18 changes: 4 additions & 14 deletions Demo/Demo.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,6 @@
0A58D85123CD3FCF00583C25 /* FlowLayoutViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0A58D85023CD3FCF00583C25 /* FlowLayoutViewController.swift */; };
0A590004236A371600F463DA /* CollectionViewDictionaryDemoViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0A590002236A371600F463DA /* CollectionViewDictionaryDemoViewController.swift */; };
0A81AAD0245F696600656DF7 /* CustomLayoutsViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0A81AACF245F696600656DF7 /* CustomLayoutsViewController.swift */; };
0A8AEF852315F68400CCB7F3 /* are-we-there-yet.png in Resources */ = {isa = PBXBuildFile; fileRef = 0A8AEF7E2315F68400CCB7F3 /* are-we-there-yet.png */; };
0A8AEF862315F68400CCB7F3 /* this-american-life.jpg in Resources */ = {isa = PBXBuildFile; fileRef = 0A8AEF7F2315F68400CCB7F3 /* this-american-life.jpg */; };
0A8AEF872315F68400CCB7F3 /* planet-money.jpg in Resources */ = {isa = PBXBuildFile; fileRef = 0A8AEF802315F68400CCB7F3 /* planet-money.jpg */; };
0A8AEF882315F68400CCB7F3 /* outside-lands.jpg in Resources */ = {isa = PBXBuildFile; fileRef = 0A8AEF812315F68400CCB7F3 /* outside-lands.jpg */; };
0A8AEF892315F68400CCB7F3 /* the-impact.png in Resources */ = {isa = PBXBuildFile; fileRef = 0A8AEF822315F68400CCB7F3 /* the-impact.png */; };
0A8AEF8A2315F68400CCB7F3 /* wait-wait.png in Resources */ = {isa = PBXBuildFile; fileRef = 0A8AEF832315F68400CCB7F3 /* wait-wait.png */; };
0A8AEF8B2315F68400CCB7F3 /* nancy.png in Resources */ = {isa = PBXBuildFile; fileRef = 0A8AEF842315F68400CCB7F3 /* nancy.png */; };
0AAA0EB1236367D000B32F63 /* ItemizationEditorViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0AAA0EB0236367D000B32F63 /* ItemizationEditorViewController.swift */; };
0AB8B0D2237CD47A00CBC434 /* ReorderingViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0AB8B0D1237CD47A00CBC434 /* ReorderingViewController.swift */; };
0AE855512390933100F2E245 /* Test_Targets.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0AE855502390933100F2E245 /* Test_Targets.swift */; };
Expand All @@ -35,6 +28,7 @@
0AEB96E122FBCC1D00341DFF /* Blueprint.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0AEB96D222FBCC1D00341DFF /* Blueprint.swift */; };
0AEB96E222FBCC1D00341DFF /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0AEB96D322FBCC1D00341DFF /* AppDelegate.swift */; };
0AEB96E322FBCC1D00341DFF /* Font.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0AEB96D422FBCC1D00341DFF /* Font.swift */; };
0AF775AA2474D94C0066CFC6 /* CoordinatorViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0AF775A92474D94C0066CFC6 /* CoordinatorViewController.swift */; };
27B4DCE9244F88BE001BA9D9 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 27B4DCE8244F88BE001BA9D9 /* Assets.xcassets */; };
42180BB244DD1F51618E1B34 /* libPods-Test Targets.a in Frameworks */ = {isa = PBXBuildFile; fileRef = C37B21704ABC58A2C22883DB /* libPods-Test Targets.a */; };
C16C0AC6F56D2268011EDFF2 /* libPods-Demo.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 32A40D3FB90881FFA78ACE27 /* libPods-Demo.a */; };
Expand All @@ -53,13 +47,6 @@
0A58D85023CD3FCF00583C25 /* FlowLayoutViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FlowLayoutViewController.swift; sourceTree = "<group>"; };
0A590002236A371600F463DA /* CollectionViewDictionaryDemoViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CollectionViewDictionaryDemoViewController.swift; sourceTree = "<group>"; };
0A81AACF245F696600656DF7 /* CustomLayoutsViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CustomLayoutsViewController.swift; sourceTree = "<group>"; };
0A8AEF7E2315F68400CCB7F3 /* are-we-there-yet.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "are-we-there-yet.png"; sourceTree = "<group>"; };
0A8AEF7F2315F68400CCB7F3 /* this-american-life.jpg */ = {isa = PBXFileReference; lastKnownFileType = image.jpeg; path = "this-american-life.jpg"; sourceTree = "<group>"; };
0A8AEF802315F68400CCB7F3 /* planet-money.jpg */ = {isa = PBXFileReference; lastKnownFileType = image.jpeg; path = "planet-money.jpg"; sourceTree = "<group>"; };
0A8AEF812315F68400CCB7F3 /* outside-lands.jpg */ = {isa = PBXFileReference; lastKnownFileType = image.jpeg; path = "outside-lands.jpg"; sourceTree = "<group>"; };
0A8AEF822315F68400CCB7F3 /* the-impact.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "the-impact.png"; sourceTree = "<group>"; };
0A8AEF832315F68400CCB7F3 /* wait-wait.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "wait-wait.png"; sourceTree = "<group>"; };
0A8AEF842315F68400CCB7F3 /* nancy.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = nancy.png; sourceTree = "<group>"; };
0AAA0EB0236367D000B32F63 /* ItemizationEditorViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ItemizationEditorViewController.swift; sourceTree = "<group>"; };
0AB8B0D1237CD47A00CBC434 /* ReorderingViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ReorderingViewController.swift; sourceTree = "<group>"; };
0AE8554E2390933100F2E245 /* Test Targets.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = "Test Targets.xctest"; sourceTree = BUILT_PRODUCTS_DIR; };
Expand All @@ -75,6 +62,7 @@
0AEB96D222FBCC1D00341DFF /* Blueprint.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Blueprint.swift; sourceTree = "<group>"; };
0AEB96D322FBCC1D00341DFF /* AppDelegate.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = "<group>"; };
0AEB96D422FBCC1D00341DFF /* Font.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Font.swift; sourceTree = "<group>"; };
0AF775A92474D94C0066CFC6 /* CoordinatorViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CoordinatorViewController.swift; sourceTree = "<group>"; };
27B4DCE8244F88BE001BA9D9 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; };
32A40D3FB90881FFA78ACE27 /* libPods-Demo.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-Demo.a"; sourceTree = BUILT_PRODUCTS_DIR; };
C2560A932411830D00F6B31E /* AutoScrollingViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AutoScrollingViewController.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -175,6 +163,7 @@
0A3FFA6C238336870080E0D9 /* InvoicesPaymentScheduleDemoViewController.swift */,
0A58D85023CD3FCF00583C25 /* FlowLayoutViewController.swift */,
0AEA09BC242A941700F9ED0C /* SwipeActionsViewController.swift */,
0AF775A92474D94C0066CFC6 /* CoordinatorViewController.swift */,
);
path = CollectionView;
sourceTree = "<group>";
Expand Down Expand Up @@ -400,6 +389,7 @@
0AEB96E122FBCC1D00341DFF /* Blueprint.swift in Sources */,
0A81AAD0245F696600656DF7 /* CustomLayoutsViewController.swift in Sources */,
0AAA0EB1236367D000B32F63 /* ItemizationEditorViewController.swift in Sources */,
0AF775AA2474D94C0066CFC6 /* CoordinatorViewController.swift in Sources */,
0AEB96E322FBCC1D00341DFF /* Font.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
Expand Down
79 changes: 79 additions & 0 deletions Demo/Sources/CollectionView/CoordinatorViewController.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
//
// CoordinatorViewController.swift
// Demo
//
// Created by Kyle Van Essen on 5/19/20.
// Copyright © 2020 Kyle Van Essen. All rights reserved.
//

import BlueprintLists
import BlueprintUICommonControls


final class CoordinatorViewController : UIViewController
{
let listView = ListView()

override func loadView() {
self.view = self.listView

self.listView.setContent { list in

list += Section(identifier: "section") { section in
section += CoordinatedElement()
section += CoordinatedElement()
section += CoordinatedElement()
}
}
}
}


fileprivate struct CoordinatedElement : BlueprintItemElement, Equatable
{
var string : String = ""

var identifier: Identifier<CoordinatedElement> {
return .init("")
}

func element(with info: ApplyItemElementInfo) -> Element {
return Label(text: self.string)
}

func makeCoordinator(actions: CoordinatorActions, info: CoordinatorInfo) -> Coordinator
{
Coordinator(actions: actions, info: info)
}

final class Coordinator : ItemElementCoordinator
{
typealias ItemElementType = CoordinatedElement

let actions: CoordinatorActions
let info: CoordinatorInfo

var view : View? {
didSet {

}
}

init(actions: CoordinatorActions, info: CoordinatorInfo)
{
self.actions = actions
self.info = info

Timer.scheduledTimer(withTimeInterval: 0.1, repeats: true) { [weak self] timer in
guard let self = self else {
timer.invalidate()
return
}

self.actions.update {
$0.element.string += " \($0.element.string.count)"
}
}
}
}
}
7 changes: 7 additions & 0 deletions Demo/Sources/DemosRootViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,13 @@ public final class DemosRootViewController : UIViewController
onSelect : { _ in
self.push(SwipeActionsViewController())
})

section += Item(
DemoItem(text: "Item Element Coordinator"),
selectionStyle: .tappable,
onSelect : { _ in
self.push(CoordinatorViewController())
})
}

list += Section(identifier: "flow-layout") { section in
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
New
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Result
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
[ViewType1: 0.0, 0.0, 834.0, 1112.0]
[ViewType2: 10.0, 10.0, 50.0, 50.0]
[ViewType3: 15.0, 15.0, 30.0, 30.0]
[ViewType2: 10.0, 10.0, 50.0, 50.0]
[ViewType3: 15.0, 15.0, 30.0, 30.0]
[ViewType2: 10.0, 10.0, 50.0, 50.0]
[ViewType3: 15.0, 15.0, 30.0, 30.0]
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
[ViewType1: 0.0, 0.0, 1024.0, 1366.0]
[ViewType2: 10.0, 10.0, 50.0, 50.0]
[ViewType3: 15.0, 15.0, 30.0, 30.0]
[ViewType2: 10.0, 10.0, 50.0, 50.0]
[ViewType3: 15.0, 15.0, 30.0, 30.0]
[ViewType2: 10.0, 10.0, 50.0, 50.0]
[ViewType3: 15.0, 15.0, 30.0, 30.0]
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
[ViewType1: 0.0, 0.0, 768.0, 1024.0]
[ViewType2: 10.0, 10.0, 50.0, 50.0]
[ViewType3: 15.0, 15.0, 30.0, 30.0]
[ViewType2: 10.0, 10.0, 50.0, 50.0]
[ViewType3: 15.0, 15.0, 30.0, 30.0]
[ViewType2: 10.0, 10.0, 50.0, 50.0]
[ViewType3: 15.0, 15.0, 30.0, 30.0]
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
[ViewType1: 0.0, 0.0, 320.0, 568.0]
[ViewType2: 10.0, 10.0, 50.0, 50.0]
[ViewType3: 15.0, 15.0, 30.0, 30.0]
[ViewType2: 10.0, 10.0, 50.0, 50.0]
[ViewType3: 15.0, 15.0, 30.0, 30.0]
[ViewType2: 10.0, 10.0, 50.0, 50.0]
[ViewType3: 15.0, 15.0, 30.0, 30.0]
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
[ViewType1: 0.0, 0.0, 414.0, 736.0]
[ViewType2: 10.0, 10.0, 50.0, 50.0]
[ViewType3: 15.0, 15.0, 30.0, 30.0]
[ViewType2: 10.0, 10.0, 50.0, 50.0]
[ViewType3: 15.0, 15.0, 30.0, 30.0]
[ViewType2: 10.0, 10.0, 50.0, 50.0]
[ViewType3: 15.0, 15.0, 30.0, 30.0]
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
[ViewType1: 0.0, 0.0, 375.0, 667.0]
[ViewType2: 10.0, 10.0, 50.0, 50.0]
[ViewType3: 15.0, 15.0, 30.0, 30.0]
[ViewType2: 10.0, 10.0, 50.0, 50.0]
[ViewType3: 15.0, 15.0, 30.0, 30.0]
[ViewType2: 10.0, 10.0, 50.0, 50.0]
[ViewType3: 15.0, 15.0, 30.0, 30.0]
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
[ViewType1: 0.0, 0.0, 375.0, 812.0]
[ViewType2: 10.0, 10.0, 50.0, 50.0]
[ViewType3: 15.0, 15.0, 30.0, 30.0]
[ViewType2: 10.0, 10.0, 50.0, 50.0]
[ViewType3: 15.0, 15.0, 30.0, 30.0]
[ViewType2: 10.0, 10.0, 50.0, 50.0]
[ViewType3: 15.0, 15.0, 30.0, 30.0]
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
[ViewType1: 0.0, 0.0, 414.0, 896.0]
[ViewType2: 10.0, 10.0, 50.0, 50.0]
[ViewType3: 15.0, 15.0, 30.0, 30.0]
[ViewType2: 10.0, 10.0, 50.0, 50.0]
[ViewType3: 15.0, 15.0, 30.0, 30.0]
[ViewType2: 10.0, 10.0, 50.0, 50.0]
[ViewType3: 15.0, 15.0, 30.0, 30.0]
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Result
Loading