Skip to content

Commit 6a67dfb

Browse files
[master] - 'Modify shouldLoad when IntakeType is Never so it can actually be overriden by FlowRepresentables - TT'
1 parent fcdd81e commit 6a67dfb

36 files changed

+209
-68
lines changed

Workflow/Protocols/FlowRepresentable.swift

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,16 @@ public protocol FlowRepresentable: AnyFlowRepresentable {
4545
/// - Returns: Bool
4646
/// - Note: This method is called *before* your view loads. Do not attempt to do any UI work in this method. This is however a good place to set up data on your view.
4747
mutating func shouldLoad(with args:IntakeType) -> Bool
48+
mutating func shouldLoad() -> Bool
4849
}
4950

50-
extension FlowRepresentable where IntakeType == Never {
51+
public extension FlowRepresentable {
52+
mutating func shouldLoad() -> Bool {
53+
return true
54+
}
55+
}
56+
57+
public extension FlowRepresentable where IntakeType == Never {
5158
mutating func erasedShouldLoad(with args: Any?) -> Bool {
5259
return shouldLoad()
5360
}
@@ -57,7 +64,7 @@ extension FlowRepresentable where IntakeType == Never {
5764
/// shouldLoad: A method indicating whether it makes sense for this view to load in a workflow
5865
/// - Returns: Bool
5966
/// - Note: This particular version of shouldLoad is only available when your `IntakeType` is `Never`, indicating you do not care about data passed to this view
60-
func shouldLoad() -> Bool {
67+
mutating func shouldLoad() -> Bool {
6168
return true
6269
}
6370
}

WorkflowTests/UIKitPresenterTests.swift

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1040,7 +1040,27 @@ class UIKitPresenterTests: XCTestCase {
10401040
XCTAssertEqual((rootController.mostRecentlyPresentedViewController as? UINavigationController)?.viewControllers.count, 1)
10411041
XCTAssert((rootController.mostRecentlyPresentedViewController as? UINavigationController)?.viewControllers.first is ExpectedController)
10421042
}
1043-
}
1043+
1044+
func testFlowRepresentableThatDoesNotTakeInDataAndOverridesShouldLoad() {
1045+
class ExpectedController: UIWorkflowItem<Never>, FlowRepresentable {
1046+
static func instance() -> AnyFlowRepresentable {
1047+
let controller = ExpectedController()
1048+
controller.view.backgroundColor = .green
1049+
return controller
1050+
}
1051+
func shouldLoad() -> Bool {
1052+
return false
1053+
}
1054+
}
1055+
1056+
let rootController = UIViewController()
1057+
loadView(controller: rootController)
1058+
1059+
rootController.launchInto(Workflow([ExpectedController.self]))
1060+
RunLoop.current.singlePass()
1061+
1062+
XCTAssert(UIApplication.topViewController() === rootController)
1063+
}}
10441064

10451065
extension UIKitPresenterTests {
10461066
class TestViewController: UIWorkflowItem<Any?>, FlowRepresentable {

docs/Classes.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
<a title="Classes Reference"></a>
1515
<header>
1616
<div class="content-wrapper">
17-
<p><a href="index.html">DynamicWorkflow Docs</a> (79% documented)</p>
17+
<p><a href="index.html">DynamicWorkflow Docs</a> (77% documented)</p>
1818
</div>
1919
</header>
2020
<div class="content-wrapper">

docs/Classes/LinkedList.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
<a title="LinkedList Class Reference"></a>
1515
<header>
1616
<div class="content-wrapper">
17-
<p><a href="../index.html">DynamicWorkflow Docs</a> (79% documented)</p>
17+
<p><a href="../index.html">DynamicWorkflow Docs</a> (77% documented)</p>
1818
</div>
1919
</header>
2020
<div class="content-wrapper">

docs/Classes/LinkedList/Node.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
<a title="Node Class Reference"></a>
1515
<header>
1616
<div class="content-wrapper">
17-
<p><a href="../../index.html">DynamicWorkflow Docs</a> (79% documented)</p>
17+
<p><a href="../../index.html">DynamicWorkflow Docs</a> (77% documented)</p>
1818
</div>
1919
</header>
2020
<div class="content-wrapper">

docs/Classes/Workflow.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
<a title="Workflow Class Reference"></a>
1515
<header>
1616
<div class="content-wrapper">
17-
<p><a href="../index.html">DynamicWorkflow Docs</a> (79% documented)</p>
17+
<p><a href="../index.html">DynamicWorkflow Docs</a> (77% documented)</p>
1818
</div>
1919
</header>
2020
<div class="content-wrapper">

docs/Enums.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
<a title="Enumerations Reference"></a>
1515
<header>
1616
<div class="content-wrapper">
17-
<p><a href="index.html">DynamicWorkflow Docs</a> (79% documented)</p>
17+
<p><a href="index.html">DynamicWorkflow Docs</a> (77% documented)</p>
1818
</div>
1919
</header>
2020
<div class="content-wrapper">

docs/Enums/PresentationType.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
<a title="PresentationType Enumeration Reference"></a>
1515
<header>
1616
<div class="content-wrapper">
17-
<p><a href="../index.html">DynamicWorkflow Docs</a> (79% documented)</p>
17+
<p><a href="../index.html">DynamicWorkflow Docs</a> (77% documented)</p>
1818
</div>
1919
</header>
2020
<div class="content-wrapper">

docs/Extensions.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
<a title="Extensions Reference"></a>
1515
<header>
1616
<div class="content-wrapper">
17-
<p><a href="index.html">DynamicWorkflow Docs</a> (79% documented)</p>
17+
<p><a href="index.html">DynamicWorkflow Docs</a> (77% documented)</p>
1818
</div>
1919
</header>
2020
<div class="content-wrapper">

docs/Extensions/UIViewController.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
<a title="UIViewController Extension Reference"></a>
1515
<header>
1616
<div class="content-wrapper">
17-
<p><a href="../index.html">DynamicWorkflow Docs</a> (79% documented)</p>
17+
<p><a href="../index.html">DynamicWorkflow Docs</a> (77% documented)</p>
1818
</div>
1919
</header>
2020
<div class="content-wrapper">

0 commit comments

Comments
 (0)