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

Adds Passthrough representable #79

Merged
merged 13 commits into from Jul 26, 2021
Merged
Show file tree
Hide file tree
Changes from 9 commits
Commits
Show all changes
13 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
11 changes: 2 additions & 9 deletions ExampleApps/SwiftUIExample/Views/MFAView.swift
Expand Up @@ -9,21 +9,14 @@
import SwiftUI
import SwiftCurrent

struct MFAView: View, FlowRepresentable {
typealias WorkflowOutput = AnyWorkflow.PassedArgs

struct MFAView: View, PassthroughFlowRepresentable {
@State var pushSent = false
@State var enteredCode = ""
@State var errorMessage: ErrorMessage?

let inspection = Inspection<Self>() // ViewInspector
weak var _workflowPointer: AnyFlowRepresentable?

private let heldWorkflowData: AnyWorkflow.PassedArgs
init(with data: AnyWorkflow.PassedArgs) {
heldWorkflowData = data
}

var body: some View {
VStack(spacing: 30) {
if !pushSent {
Expand All @@ -42,7 +35,7 @@ struct MFAView: View, FlowRepresentable {
TextField("Enter Code:", text: $enteredCode)
Button("Submit") {
if enteredCode == "1234" {
proceedInWorkflow(heldWorkflowData)
proceedInWorkflow()
} else {
errorMessage = ErrorMessage(message: "Invalid code entered, abandoning workflow.")
}
Expand Down
1,679 changes: 1,679 additions & 0 deletions ExampleApps/UIKitExample/SwiftCurrent_UIKitTests/GenericConstraintTests.swift

Large diffs are not rendered by default.

Expand Up @@ -29,7 +29,7 @@ class ModalStyleTests: XCTestCase {

UIApplication.topViewController()?
.launchInto(Workflow(TestViewController.self,
presentationType: .modal(.fullScreen)))
launchStyle: .modal(.fullScreen)))

XCTAssertUIViewControllerDisplayed(ofType: TestViewController.self)
XCTAssertEqual(UIApplication.topViewController()?.modalPresentationStyle, .fullScreen)
Expand All @@ -41,7 +41,7 @@ class ModalStyleTests: XCTestCase {

UIApplication.topViewController()?
.launchInto(Workflow(TestViewController.self,
presentationType: .modal(.pageSheet)))
launchStyle: .modal(.pageSheet)))

XCTAssertUIViewControllerDisplayed(ofType: TestViewController.self)
XCTAssertEqual(UIApplication.topViewController()?.modalPresentationStyle, .pageSheet)
Expand All @@ -52,7 +52,7 @@ class ModalStyleTests: XCTestCase {

UIApplication.topViewController()?
.launchInto(Workflow(TestViewController.self,
presentationType: .modal(.formSheet)))
launchStyle: .modal(.formSheet)))

XCTAssertUIViewControllerDisplayed(ofType: TestViewController.self)
XCTAssertEqual(UIApplication.topViewController()?.modalPresentationStyle, .formSheet)
Expand All @@ -63,7 +63,7 @@ class ModalStyleTests: XCTestCase {

UIApplication.topViewController()?
.launchInto(Workflow(TestViewController.self,
presentationType: .modal(.currentContext)))
launchStyle: .modal(.currentContext)))

XCTAssertUIViewControllerDisplayed(ofType: TestViewController.self)
XCTAssertEqual(UIApplication.topViewController()?.modalPresentationStyle, .currentContext)
Expand All @@ -77,7 +77,7 @@ class ModalStyleTests: XCTestCase {
print("!!!! \(Date().timeIntervalSince1970) - testShowModalAsCustom - about to launchInto from: \(String(describing: UIApplication.topViewController()))")
UIApplication.topViewController()?
.launchInto(Workflow(TestViewController.self,
presentationType: .modal(.custom)))
launchStyle: .modal(.custom)))
print("!!!! \(Date().timeIntervalSince1970) - testShowModalAsCustom - Completed launchInto")

XCTAssertUIViewControllerDisplayed(ofType: TestViewController.self)
Expand All @@ -90,7 +90,7 @@ class ModalStyleTests: XCTestCase {

UIApplication.topViewController()?
.launchInto(Workflow(TestViewController.self,
presentationType: .modal(.overFullScreen)))
launchStyle: .modal(.overFullScreen)))

XCTAssertUIViewControllerDisplayed(ofType: TestViewController.self)
XCTAssertEqual(UIApplication.topViewController()?.modalPresentationStyle, .overFullScreen)
Expand All @@ -101,7 +101,7 @@ class ModalStyleTests: XCTestCase {

UIApplication.topViewController()?
.launchInto(Workflow(TestViewController.self,
presentationType: .modal(.overCurrentContext)))
launchStyle: .modal(.overCurrentContext)))

XCTAssertUIViewControllerDisplayed(ofType: TestViewController.self)
XCTAssertEqual(UIApplication.topViewController()?.modalPresentationStyle, .overCurrentContext)
Expand All @@ -112,7 +112,7 @@ class ModalStyleTests: XCTestCase {

UIApplication.topViewController()?
.launchInto(Workflow(TestViewController.self,
presentationType: .modal(.popover)))
launchStyle: .modal(.popover)))

XCTAssertUIViewControllerDisplayed(ofType: TestViewController.self)
XCTAssertEqual(UIApplication.topViewController()?.modalPresentationStyle, .popover)
Expand All @@ -124,7 +124,7 @@ class ModalStyleTests: XCTestCase {

UIApplication.topViewController()?
.launchInto(Workflow(TestViewController.self,
presentationType: .modal(.automatic)))
launchStyle: .modal(.automatic)))

XCTAssertUIViewControllerDisplayed(ofType: TestViewController.self)
XCTAssertEqual(UIApplication.topViewController()?.modalPresentationStyle, UIViewController().modalPresentationStyle)
Expand Down Expand Up @@ -235,7 +235,7 @@ class ModalStyleTests: XCTestCase {
RootViewController.standard.loadForTesting()

UIApplication.topViewController()?
.launchInto(Workflow(TestViewController.self, presentationType: .navigationStack),
.launchInto(Workflow(TestViewController.self, launchStyle: .navigationStack),
withLaunchStyle: .modal(.fullScreen))

XCTAssertUIViewControllerDisplayed(ofType: TestViewController.self)
Expand All @@ -247,7 +247,7 @@ class ModalStyleTests: XCTestCase {
vc.loadForTesting()

UIApplication.topViewController()?
.launchInto(Workflow(TestViewController.self, presentationType: .navigationStack),
.launchInto(Workflow(TestViewController.self, launchStyle: .navigationStack),
withLaunchStyle: .modal(.pageSheet))

XCTAssertUIViewControllerDisplayed(ofType: TestViewController.self)
Expand All @@ -258,7 +258,7 @@ class ModalStyleTests: XCTestCase {
RootViewController.standard.loadForTesting()

UIApplication.topViewController()?
.launchInto(Workflow(TestViewController.self, presentationType: .navigationStack),
.launchInto(Workflow(TestViewController.self, launchStyle: .navigationStack),
withLaunchStyle: .modal(.formSheet))

XCTAssertUIViewControllerDisplayed(ofType: TestViewController.self)
Expand All @@ -269,7 +269,7 @@ class ModalStyleTests: XCTestCase {
RootViewController.standard.loadForTesting()

UIApplication.topViewController()?
.launchInto(Workflow(TestViewController.self, presentationType: .navigationStack),
.launchInto(Workflow(TestViewController.self, launchStyle: .navigationStack),
withLaunchStyle: .modal(.currentContext))

XCTAssertUIViewControllerDisplayed(ofType: TestViewController.self)
Expand All @@ -280,7 +280,7 @@ class ModalStyleTests: XCTestCase {
RootViewController.standard.loadForTesting()

UIApplication.topViewController()?
.launchInto(Workflow(TestViewController.self, presentationType: .navigationStack),
.launchInto(Workflow(TestViewController.self, launchStyle: .navigationStack),
withLaunchStyle: .modal(.custom))

XCTAssertUIViewControllerDisplayed(ofType: TestViewController.self)
Expand All @@ -291,7 +291,7 @@ class ModalStyleTests: XCTestCase {
RootViewController.standard.loadForTesting()

UIApplication.topViewController()?
.launchInto(Workflow(TestViewController.self, presentationType: .navigationStack),
.launchInto(Workflow(TestViewController.self, launchStyle: .navigationStack),
withLaunchStyle: .modal(.overFullScreen))

XCTAssertUIViewControllerDisplayed(ofType: TestViewController.self)
Expand All @@ -302,7 +302,7 @@ class ModalStyleTests: XCTestCase {
RootViewController.standard.loadForTesting()

UIApplication.topViewController()?
.launchInto(Workflow(TestViewController.self, presentationType: .navigationStack),
.launchInto(Workflow(TestViewController.self, launchStyle: .navigationStack),
withLaunchStyle: .modal(.overCurrentContext))

XCTAssertUIViewControllerDisplayed(ofType: TestViewController.self)
Expand All @@ -313,7 +313,7 @@ class ModalStyleTests: XCTestCase {
RootViewController.standard.loadForTesting()

UIApplication.topViewController()?
.launchInto(Workflow(TestViewController.self, presentationType: .navigationStack),
.launchInto(Workflow(TestViewController.self, launchStyle: .navigationStack),
withLaunchStyle: .modal(.popover))

XCTAssertUIViewControllerDisplayed(ofType: TestViewController.self)
Expand All @@ -325,7 +325,7 @@ class ModalStyleTests: XCTestCase {
RootViewController.standard.loadForTesting()

UIApplication.topViewController()?
.launchInto(Workflow(TestViewController.self, presentationType: .navigationStack),
.launchInto(Workflow(TestViewController.self, launchStyle: .navigationStack),
withLaunchStyle: .modal(.automatic))

XCTAssertUIViewControllerDisplayed(ofType: TestViewController.self)
Expand Down
Expand Up @@ -203,9 +203,9 @@ class UIKitConsumerAbandonTests: XCTestCase {
root.loadForTesting()

root.launchInto(Workflow(FR1.self)
.thenPresent(FR2.self, presentationType: .modal)
.thenPresent(FR3.self)
.thenPresent(FR4.self), withLaunchStyle: .navigationStack)
.thenProceed(with: FR2.self, launchStyle: .modal)
.thenProceed(with: FR3.self)
.thenProceed(with: FR4.self), withLaunchStyle: .navigationStack)

XCTAssertUIViewControllerDisplayed(ofType: FR1.self)
XCTAssertNotNil(UIApplication.topViewController()?.navigationController)
Expand All @@ -230,9 +230,9 @@ class UIKitConsumerAbandonTests: XCTestCase {
root.loadForTesting()

root.launchInto(Workflow(FR1.self)
.thenPresent(FR2.self)
.thenPresent(FR3.self)
.thenPresent(FR4.self), withLaunchStyle: .modal)
.thenProceed(with: FR2.self)
.thenProceed(with: FR3.self)
.thenProceed(with: FR4.self), withLaunchStyle: .modal)

XCTAssertUIViewControllerDisplayed(ofType: FR1.self)
(UIApplication.topViewController() as? FR1)?.proceedInWorkflow(nil)
Expand All @@ -252,9 +252,9 @@ class UIKitConsumerAbandonTests: XCTestCase {
class FR4: TestViewController { }

let wf = Workflow(FR1.self)
.thenPresent(FR2.self)
.thenPresent(FR3.self)
.thenPresent(FR4.self)
.thenProceed(with: FR2.self)
.thenProceed(with: FR3.self)
.thenProceed(with: FR4.self)

let root = UIViewController()
root.loadForTesting()
Expand Down Expand Up @@ -282,9 +282,9 @@ class UIKitConsumerAbandonTests: XCTestCase {
class FR4: TestViewController { }

let wf = Workflow(FR1.self)
.thenPresent(FR2.self)
.thenPresent(FR3.self)
.thenPresent(FR4.self)
.thenProceed(with: FR2.self)
.thenProceed(with: FR3.self)
.thenProceed(with: FR4.self)

let root = UIViewController()
root.loadForTesting()
Expand Down Expand Up @@ -314,9 +314,9 @@ class UIKitConsumerAbandonTests: XCTestCase {
class FR4: TestViewController { }

let wf = Workflow(FR1.self)
.thenPresent(FR2.self, presentationType: .modal)
.thenPresent(FR3.self, presentationType: .modal)
.thenPresent(FR4.self, presentationType: .modal)
.thenProceed(with: FR2.self, launchStyle: .modal)
.thenProceed(with: FR3.self, launchStyle: .modal)
.thenProceed(with: FR4.self, launchStyle: .modal)

let root = UIViewController()
root.loadForTesting()
Expand Down Expand Up @@ -349,9 +349,9 @@ class UIKitConsumerAbandonTests: XCTestCase {
root.loadForTesting()
root.launchInto(
Workflow(FR1.self)
.thenPresent(FR2.self, presentationType: .modal)
.thenPresent(FR3.self)
.thenPresent(FR4.self),
.thenProceed(with: FR2.self, launchStyle: .modal)
.thenProceed(with: FR3.self)
.thenProceed(with: FR4.self),
withLaunchStyle: .navigationStack)
XCTAssertUIViewControllerDisplayed(ofType: FR1.self)
XCTAssertNotNil(UIApplication.topViewController()?.navigationController)
Expand All @@ -375,9 +375,9 @@ class UIKitConsumerAbandonTests: XCTestCase {
let root = UIViewController()
root.loadForTesting()
root.launchInto(Workflow(FR1.self)
.thenPresent(FR2.self, presentationType: .modal)
.thenPresent(FR3.self, presentationType: .navigationStack)
.thenPresent(FR4.self, presentationType: .modal),
.thenProceed(with: FR2.self, launchStyle: .modal)
.thenProceed(with: FR3.self, launchStyle: .navigationStack)
.thenProceed(with: FR4.self, launchStyle: .modal),
withLaunchStyle: .navigationStack)

XCTAssertUIViewControllerDisplayed(ofType: FR1.self)
Expand All @@ -403,9 +403,9 @@ class UIKitConsumerAbandonTests: XCTestCase {
root.loadForTesting()
root.launchInto(
Workflow(FR1.self)
.thenPresent(FR2.self, presentationType: .modal)
.thenPresent(FR3.self, presentationType: .navigationStack)
.thenPresent(FR4.self, presentationType: .modal),
.thenProceed(with: FR2.self, launchStyle: .modal)
.thenProceed(with: FR3.self, launchStyle: .navigationStack)
.thenProceed(with: FR4.self, launchStyle: .modal),
withLaunchStyle: .navigationStack)

XCTAssertUIViewControllerDisplayed(ofType: FR1.self)
Expand All @@ -432,9 +432,9 @@ class UIKitConsumerAbandonTests: XCTestCase {
nav.loadForTesting()

root.launchInto(Workflow(FR1.self)
.thenPresent(FR2.self, presentationType: .modal)
.thenPresent(FR3.self, presentationType: .navigationStack)
.thenPresent(FR4.self, presentationType: .modal),
.thenProceed(with: FR2.self, launchStyle: .modal)
.thenProceed(with: FR3.self, launchStyle: .navigationStack)
.thenProceed(with: FR4.self, launchStyle: .modal),
withLaunchStyle: .navigationStack)

XCTAssertUIViewControllerDisplayed(ofType: FR1.self)
Expand Down
Expand Up @@ -108,7 +108,7 @@ class UIKitConsumerLaunchTests: XCTestCase {
let nav = UINavigationController()
nav.loadForTesting()

nav.launchInto(Workflow(FR1.self, presentationType: .navigationStack), withLaunchStyle: .navigationStack)
nav.launchInto(Workflow(FR1.self, launchStyle: .navigationStack), withLaunchStyle: .navigationStack)
XCTAssertUIViewControllerDisplayed(ofType: FR1.self)
XCTAssertNil(nav.mostRecentlyPresentedViewController)
XCTAssertNotNil(UIApplication.topViewController()?.navigationController)
Expand Down Expand Up @@ -167,7 +167,7 @@ class UIKitConsumerLaunchTests: XCTestCase {
controller.loadForTesting()

rootController.launchInto(Workflow(ExpectedModal.self)
.thenPresent(ExpectedModalPreferNav.self, presentationType: .navigationStack),
.thenProceed(with: ExpectedModalPreferNav.self, launchStyle: .navigationStack),
withLaunchStyle: .modal)
RunLoop.current.singlePass()

Expand Down Expand Up @@ -206,8 +206,8 @@ class UIKitConsumerLaunchTests: XCTestCase {

rootController.launchInto(
Workflow(ExpectedModal.self)
.thenPresent(ExpectedModalPreferNav.self,
presentationType: .navigationStack),
.thenProceed(with: ExpectedModalPreferNav.self,
launchStyle: .navigationStack),
withLaunchStyle: .modal)
RunLoop.current.singlePass()

Expand All @@ -233,7 +233,7 @@ class UIKitConsumerLaunchTests: XCTestCase {
firstView.loadForTesting()
firstView.present(controller, animated: false)

let workflow = Workflow(ExpectedModal.self, presentationType: .navigationStack)
let workflow = Workflow(ExpectedModal.self, launchStyle: .navigationStack)

rootController.launchInto(workflow, withLaunchStyle: .modal)
RunLoop.current.singlePass()
Expand All @@ -260,7 +260,7 @@ class UIKitConsumerLaunchTests: XCTestCase {
firstView.loadForTesting()
firstView.present(controller, animated: false)

let workflow = Workflow(ExpectedNav.self, presentationType: .navigationStack)
let workflow = Workflow(ExpectedNav.self, launchStyle: .navigationStack)
rootController.launchInto(workflow, withLaunchStyle: .modal)
RunLoop.current.singlePass()

Expand All @@ -284,7 +284,7 @@ class UIKitConsumerLaunchTests: XCTestCase {
controller.loadForTesting()

let workflow = Workflow(TestViewController.self)
.thenPresent(ExpectedModal.self, presentationType: .modal)
.thenProceed(with: ExpectedModal.self, launchStyle: .modal)

rootController.launchInto(workflow)

Expand Down Expand Up @@ -362,7 +362,7 @@ class UIKitConsumerLaunchTests: XCTestCase {
controller.loadForTesting()

rootController.launchInto(Workflow(ExpectedNav.self)
.thenPresent(ExpectedModal.self, presentationType: .modal))
.thenProceed(with: ExpectedModal.self, launchStyle: .modal))

XCTAssertUIViewControllerDisplayed(ofType: ExpectedNav.self)
XCTAssertEqual(controller.viewControllers.count, 2)
Expand Down