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

Replaces WorkflowLauncher and thenProceed(with:) with a new WorkflowView API, as discussed in #61 #179

Merged
merged 115 commits into from
Mar 21, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
115 commits
Select commit Hold shift + click to select a range
896cf26
[workflow-builder] - A very basic version of the API works! - TT MF
Tyler-Keith-Thompson Feb 21, 2022
bf44f41
[workflow-builder] - We managed to dedup the code! - TT MF
Tyler-Keith-Thompson Feb 21, 2022
bab2071
[workflow-builder] - Next set of tests completed and workflows up to …
Tyler-Keith-Thompson Feb 21, 2022
742a4d7
[workflow-builder] - 10 item workflows now supported, past that the o…
Tyler-Keith-Thompson Feb 21, 2022
ffec112
[workflow-builder] - Better formatting around these huge generics - TT
Tyler-Keith-Thompson Feb 21, 2022
c9d52f5
[workflow-builder] - Some additional tests and some things to make Sw…
Tyler-Keith-Thompson Feb 21, 2022
1aa38c9
[workflow-builder] - Adding support for startingArgs on WorkflowView …
MattFreiburgAsynchrony Feb 21, 2022
86b1ed7
[workflow-builder] - Adding Anyworkflow.PassedArgs support for Workfl…
MattFreiburgAsynchrony Feb 21, 2022
8e5a11b
[workflow-builder] - Additional overload for Anyworkflow.PassedArgs -…
MattFreiburgAsynchrony Feb 21, 2022
f6dcff0
[workflow-builder] - Testing that multiple different arguments throug…
MattFreiburgAsynchrony Feb 21, 2022
929491d
[workflow-builder] - Fixing some linting errors - mf tt nk
MattFreiburgAsynchrony Feb 21, 2022
9e41a8b
[workflow-builder] - Adding onAbandon support, isLaunched Binding to …
MattFreiburgAsynchrony Feb 21, 2022
f66a216
[workflow-builder] - Supporting multiple onAbandons to WorkflowView -…
MattFreiburgAsynchrony Feb 21, 2022
4caf9a4
[workflow-builder] - Ensuring applyModifiers works on WorkflowItem in…
MattFreiburgAsynchrony Feb 21, 2022
b8cc780
[workflow-builder] - Ensuring Workflow relaunches when abandoned in W…
MattFreiburgAsynchrony Feb 21, 2022
a190d1d
[workflow-builder] - Ensuring Workflow can hav a passthroughRepresent…
MattFreiburgAsynchrony Feb 21, 2022
a45630f
[workflow-builder] - Ensuring workflow can convert any args to correc…
MattFreiburgAsynchrony Feb 21, 2022
3f9b0e3
[workflow-builder] - Ensuring Workflow can hav a passthroughRepresent…
MattFreiburgAsynchrony Feb 21, 2022
6da6686
[workflow-builder] - Ensure workflow correctly handles state using Wo…
MattFreiburgAsynchrony Feb 21, 2022
432cced
[workflow-builder] - Ensure workflow can have a delayed launch in Wor…
MattFreiburgAsynchrony Feb 21, 2022
9ac8d76
[workflow-builder] - Doing weird backflips to make github actions to …
MattFreiburgAsynchrony Feb 21, 2022
4ca0478
Revert "[workflow-builder] - Doing weird backflips to make github act…
MattFreiburgAsynchrony Feb 21, 2022
c86d135
[workflow-builder] - Made WorkflowView inspectable in SwiftUIExample,…
Tyler-Keith-Thompson Feb 21, 2022
2fae4dd
[workflow-builder] - Adding Arity tests - mf tt nk
MattFreiburgAsynchrony Feb 21, 2022
32d70ab
[workflow-builder] - Adding documentation for WorkflowView - mf tt nk
MattFreiburgAsynchrony Feb 21, 2022
182ce1d
[skip ci] workflow-builder - EmbedInNavigationView - mf tt nk
MattFreiburgAsynchrony Feb 21, 2022
3ae49cf
[workflow-builder] - Added embedInNavigationView to WorkflowView - TT MF
Tyler-Keith-Thompson Feb 21, 2022
0cb07c6
[workflow-builder] - DEAD CODE REMOVAL, - TT MF
Tyler-Keith-Thompson Feb 21, 2022
baf3f4f
[workflow-builder] - Added docs to WorkflowBuilder - TT MF
Tyler-Keith-Thompson Feb 21, 2022
16de7f5
[workflow-builder] - Moved WorkflowBuilder and WorkflowView under cor…
Tyler-Keith-Thompson Feb 21, 2022
5208a36
Merge remote-tracking branch 'origin/main' into workflow-builder
Tyler-Keith-Thompson Feb 23, 2022
cd8c841
[skip ci] workflow-builder-if-statement - It kinda works because it c…
Tyler-Keith-Thompson Feb 23, 2022
52f0776
[workflow-builder] - Merged in main, refactored existing tests to use…
Tyler-Keith-Thompson Feb 23, 2022
0a33668
[workflow-builder-if-statement] - Merged in async await changes, got …
Tyler-Keith-Thompson Feb 23, 2022
4679869
[workflow-builder-if-statement] - All workflow view tests work again …
Tyler-Keith-Thompson Feb 23, 2022
4d8f771
[skip ci] workflow-builder-if-statement - it compiles! it just does n…
Tyler-Keith-Thompson Feb 23, 2022
052832b
[workflow-builder-example-app] - Updates TestView to use WorkflowView…
Feb 23, 2022
e760884
[skip ci] workflow-builder-example-app - Added a test for WorkflowVie…
Feb 23, 2022
4422382
[skip ci] workflow-builder-example-app - I actually do want this to c…
Feb 23, 2022
7eff4fb
[workflow-builder-example-app] - Fixes fastlane lintfix path. - nk tt mf
Feb 23, 2022
105ac1f
[workflow-builder-example-app] - Moving all the WorkflowLauncher and …
Feb 23, 2022
2c5116d
[skip ci] workflow-builder-example-app - WorkflowBuilder applyModifie…
MattFreiburgAsynchrony Feb 24, 2022
6f2b66d
[skip ci] workflow-builder-example-app - Refactoring WorkflowBuilder …
MattFreiburgAsynchrony Feb 24, 2022
f60ac13
[workflow-builder-example-app] - Fixed inspectable tests. - mf nk
Feb 25, 2022
3daad81
[workflow-builder-example-app] - Creating new barebones example proje…
MattFreiburgAsynchrony Feb 28, 2022
4c03195
[workflow-builder] - Adding documentation alternative files for Workf…
MattFreiburgAsynchrony Mar 2, 2022
daa0fde
[skip ci] workflow-builder-example-app - I broke everything...but Wor…
Tyler-Keith-Thompson Mar 8, 2022
f672fe1
[workflow-builder-example-app] - Deleted slimmed down example - TT NK MF
Tyler-Keith-Thompson Mar 8, 2022
6dda321
[skip ci] workflow-builder-example-app - Goodbye thenProceed - TT
Tyler-Keith-Thompson Mar 8, 2022
a1bff15
[workflow-builder-example-app] - SwiftUIExampleApp tests pass! - TT
Tyler-Keith-Thompson Mar 8, 2022
3812a14
[skip ci] workflow-builder-example-app - Consumer tests compile! - TT
Tyler-Keith-Thompson Mar 8, 2022
5779409
[skip ci] workflow-builder-example-app - More tests are compiling - TT
Tyler-Keith-Thompson Mar 8, 2022
4417ae6
[skip ci] workflow-builder-example-app - Generic constraint tests com…
Tyler-Keith-Thompson Mar 8, 2022
db93a83
[skip ci] workflow-builder-example-app - Generic constraint tests now…
Tyler-Keith-Thompson Mar 8, 2022
f92e5d2
[skip ci] workflow-builder-example-app - All tests compile, not all p…
Tyler-Keith-Thompson Mar 8, 2022
488ea12
[workflow-builder-example-app] - Consumer tests passing - TT
Tyler-Keith-Thompson Mar 8, 2022
8f9ce40
[workflow-builder-example-app] - WorkflowBuilder tests pass - TT
Tyler-Keith-Thompson Mar 8, 2022
cda05b7
[workflow-builder-example-app] - More tests pass, still some legitima…
Tyler-Keith-Thompson Mar 9, 2022
df5b223
[workflow-builder-example-app] - Nav stacks and modals playing nicer …
Tyler-Keith-Thompson Mar 10, 2022
d1b588d
[workflow-builder-example-app] - All nav tests pass again, we were no…
Tyler-Keith-Thompson Mar 10, 2022
128d161
[workflow-builder-example-app] - WorkflowGroup now works for multiple…
Tyler-Keith-Thompson Mar 10, 2022
94f7922
[workflow-builder-example-app] - Added a 12 item workflow test - TT NK
Tyler-Keith-Thompson Mar 10, 2022
28713c9
[workflow-builder-example-app] - Workflow is now 100 items long - TT
Tyler-Keith-Thompson Mar 10, 2022
ff1cd54
[workflow-builder-example-app] - Had an extra 52 for some reason - TT NK
Tyler-Keith-Thompson Mar 10, 2022
1fea3bb
[workflow-builder-example-app] - Removed a few views so ViewInspector…
Tyler-Keith-Thompson Mar 10, 2022
0e66ada
[workflow-builder-example-app] - Use triangulation to try and get thi…
Tyler-Keith-Thompson Mar 10, 2022
39a2956
[workflow-builder-example-app] - Generic constraint tests all pass! - TT
Tyler-Keith-Thompson Mar 11, 2022
5684bf0
[workflow-builder-example-app] - modals work across workflowgroup bou…
Tyler-Keith-Thompson Mar 11, 2022
cb51756
[workflow-builder-example-app] - proceeding with the same view repeat…
Tyler-Keith-Thompson Mar 11, 2022
21bd712
[skip ci] workflow-builder-example-app - Fixed a minor formatting err…
Tyler-Keith-Thompson Mar 11, 2022
8302e9b
[workflow-builder-example-app] - Triangulated the modal tests using a…
Tyler-Keith-Thompson Mar 14, 2022
4009530
[workflow-builder-example-app] - Tests are a lot more sane bonus poin…
Tyler-Keith-Thompson Mar 14, 2022
493f9b9
[workflow-builder-example-app] - All SwiftUI tests pass! - TT MF NK
Tyler-Keith-Thompson Mar 15, 2022
508b47f
[workflow-builder-example-app] - Made SwiftUIExampleApp tests compile…
Tyler-Keith-Thompson Mar 15, 2022
9091a7d
[workflow-builder-example-app] - Everything works again, I am not hap…
Tyler-Keith-Thompson Mar 15, 2022
9f87a52
Merge branch 'workflow-builder-example-app' into workflow-builder
Tyler-Keith-Thompson Mar 17, 2022
08e569a
[workflow-builder] - Consolidated into a single protocol - TT
Tyler-Keith-Thompson Mar 17, 2022
6ff480f
[workflow-builder] - Removed slimmed down example - TT
Tyler-Keith-Thompson Mar 17, 2022
bf90457
[wb-if-statement] - Added tests and prod code for building optional w…
Tyler-Keith-Thompson Mar 18, 2022
69d0dee
[workflow-builder] - Content was not actually needed as an assocaited…
Tyler-Keith-Thompson Mar 18, 2022
ec80a49
[workflow-builder] - ViewInspector crashes when injecting the environ…
Tyler-Keith-Thompson Mar 18, 2022
5900f3e
[workflow-builder] - Added another test for BuildEither, unfortunatle…
Tyler-Keith-Thompson Mar 18, 2022
eee22e5
[workflow-builder] - A refactor to clean up use of optionals fixed th…
Tyler-Keith-Thompson Mar 18, 2022
0d31877
[workflow-builder] - Added tests to NavLinks to ensure WorkflowGroup,…
Tyler-Keith-Thompson Mar 18, 2022
2599e8e
[workflow-builder] - Added tests to modals to ensure WorkflowGroup, O…
Tyler-Keith-Thompson Mar 18, 2022
2c15c72
[workflow-builder] - Renamed F to FlowRepresentableType - TT
Tyler-Keith-Thompson Mar 18, 2022
6425c39
[workflow-builder] - Minor tweaks to docs and sample app - TT
Tyler-Keith-Thompson Mar 18, 2022
fa6b3f2
[workflow-builder] - Lowered access on WorkflowLauncher to the minima…
Tyler-Keith-Thompson Mar 18, 2022
67fc339
[workflow-builder] - Minor refactor of EitherWorkflowItem - TT
Tyler-Keith-Thompson Mar 18, 2022
47adccf
[workflow-builder] - WorkflowItem dead code cleanup - TT
Tyler-Keith-Thompson Mar 18, 2022
993e26f
[workflow-builder] - Docs update - TT
Tyler-Keith-Thompson Mar 18, 2022
9204f7c
[workflow-builder] - Further docs updates, removing references to Wor…
Tyler-Keith-Thompson Mar 18, 2022
60d03c0
[workflow-builder] - Missed a launcher reference - TT
Tyler-Keith-Thompson Mar 18, 2022
1afc9cc
Merge branch 'main' into workflow-builder
Tyler-Keith-Thompson Mar 18, 2022
6c5b49d
[workflow-builder] - Removed some dead code from WorkflowLauncher - TT
Tyler-Keith-Thompson Mar 18, 2022
4178a34
[workflow-builder] - Replaced HTML with Markdown to keep consistency …
Tyler-Keith-Thompson Mar 18, 2022
10c1746
Revert "[workflow-builder] - Replaced HTML with Markdown to keep cons…
Tyler-Keith-Thompson Mar 18, 2022
7135c79
[workflow-builder] - Revved the major version - TT
Tyler-Keith-Thompson Mar 18, 2022
2060c4a
[workflow-builder] - Updated README code - TT
Tyler-Keith-Thompson Mar 18, 2022
864e7c5
[workflow-builder] - Added a couple of sanity check tests for buildOp…
Tyler-Keith-Thompson Mar 18, 2022
504798e
Merge branch 'main' into workflow-builder
Tyler-Keith-Thompson Mar 18, 2022
40c40a0
[workflow-builder] - Removed ambiguity around canDisplay - TT
Tyler-Keith-Thompson Mar 18, 2022
7f043dd
Merge branch 'workflow-builder' of github.com:wwt/SwiftCurrent into w…
Tyler-Keith-Thompson Mar 18, 2022
45b68da
Merge branch 'main' into workflow-builder
Tyler-Keith-Thompson Mar 18, 2022
d4427f4
[workflow-builder] - Fixed some comments as per PR suggestion - TT
Tyler-Keith-Thompson Mar 18, 2022
1299cd7
[workflow-builder] - Upgrade path has been updated to talk about v4 t…
Tyler-Keith-Thompson Mar 18, 2022
48379c4
[workflow-builder] - Adds deprecations for thenProceed and WorkflowLa…
nickkaczmarek Mar 18, 2022
ca4ece5
Update .github/abstract/Creating Workflows in SwiftUI.md
Tyler-Keith-Thompson Mar 18, 2022
c078f37
Update .github/abstract/Creating Workflows.md
Tyler-Keith-Thompson Mar 18, 2022
7118850
[workflow-builder] - Fixed some docs on WorkflowItem - TT
Tyler-Keith-Thompson Mar 18, 2022
1ff53bc
Merge branch 'workflow-builder' of github.com:wwt/SwiftCurrent into w…
Tyler-Keith-Thompson Mar 18, 2022
c8d04ad
[workflow-builder] - WorkflowBuilder needed a bit more context for it…
Tyler-Keith-Thompson Mar 18, 2022
5604437
[workflow-builder] - Added UIKit interop into the SwiftUI example app…
nickkaczmarek Mar 18, 2022
8f91a0b
Update .github/guides/Getting Started with SwiftUI.md
Mar 18, 2022
94f06fe
[workflow-builder] - Fix linter error - TT
Tyler-Keith-Thompson Mar 18, 2022
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
6 changes: 2 additions & 4 deletions .github/.jazzy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,9 @@ custom_categories:
- Working with Modals
- name: Creating Workflows in SwiftUI
children:
- WorkflowLauncher
- WorkflowView
- WorkflowItem
- View
- App
- Scene
- WorkflowBuilder
- name: How to use SwiftCurrent with UIKit
children:
- Using Programmatic Views
Expand Down
20 changes: 20 additions & 0 deletions .github/UPGRADE_PATH.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,26 @@ Use this document to help you understand how to update between major versions of

Our directions are written for only 1 major version upgrade at a time, as we have found that to be the best experience.

<details>
<summary><b>V4 -> V5</b></summary>

## SwiftUI - WorkflowView
Our approach to a SwiftUI API drastically changed. This new API is much more idiomatic and natural feeling when using SwiftUI. Additionally, it enables a series of new features. Previously, you used `thenProceed(with:)` and `WorkflowLauncher` to launch a workflow in SwiftUI. You now use `WorkflowGroup` and `WorkflowItem`.

```swift
WorkflowView {
WorkflowItem(FirstView.self) // This view is shown first
WorkflowItem(SecondView.self) // After proceeding, this view is shown
}
```

To transition from the old API, replace your calls to `WorkflowLauncher` with `WorkflowView`. Also note that `startingArgs` has changed to `launchingWith`. So the full signature changes from `WorkflowLauncher(isLaunched: .constant(true), startingArgs: "someArgs")` to `WorkflowView(isLaunched: .constant(true), launchingWith: "someArgs")`.

`WorkflowView`'s initializer defaults `isLaunched` to `.constant(true)` meaning you can exclude that parameter and just use `WorkflowView(launchingWith: "someArgs")`
</details>

---

<details>
<summary><b>V3 -> V4</b></summary>

Expand Down
2 changes: 1 addition & 1 deletion .github/abstract/Controlling Presentation.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ SwiftCurrent allows you to control how your workflow presents its `FlowRepresent
In UIKit, you control presentation with `LaunchStyle.PresentationType`. The default is a contextual presentation mode. If it detects you are in a navigation view, it'll present by pushing onto the navigation stack. If it cannot detect a navigation view, it presents modally. Alternatively, you can explicitly state you'd like it to present modally or in a navigation stack when you define your `Workflow`.

### In SwiftUI
In SwiftUI, you control presentation using `LaunchStyle.SwiftUI.PresentationType`. The default is simple view replacement. This is especially powerful because your workflows in SwiftUI do not need to be an entire screen; they can be just part of a view. Using the default presentation type, you can also get fine-grained control over animations. You can also explicitly state you'd like it to present modally (using a sheet or fullScreenCover) or in a navigation stack when you define your `WorkflowLauncher`.
In SwiftUI, you control presentation using `LaunchStyle.SwiftUI.PresentationType`. The default is simple view replacement. This is especially powerful because your workflows in SwiftUI do not need to be an entire screen; they can be just part of a view. Using the default presentation type, you can also get fine-grained control over animations. You can also explicitly state you'd like it to present modally (using a sheet or fullScreenCover) or in a navigation stack when you define your `WorkflowView`.

### Persistence
You can control what happens to items in your workflow using `FlowPersistence`. Using `FlowPersistence.persistWhenSkipped` means that when `FlowRepresentable.shouldLoad` returns false, the item is still stored on the workflow. If, for example, you're in a navigation stack, this means the item *is* skipped, but you can back up to it.
Expand Down
17 changes: 10 additions & 7 deletions .github/abstract/Creating Workflows in SwiftUI.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,18 @@ struct FirstView: View, FlowRepresentable {
> **Note:** `FlowRepresentable.proceedInWorkflow()` is what you call to have your view move forward to the next item in the `Workflow` it is part of.

### Step 2:
Define your `WorkflowLauncher`. This indicates if the workflow is shown and describes what items are in it.
Define your `WorkflowView`. This indicates if the workflow is shown and describes what items are in it.

#### Example:
```swift
WorkflowLauncher(isLaunched: .constant(true)) { // Could also have been $someStateOrBindingBoolean
thenProceed(with: FirstView.self) { // thenProceed is a function to create a `WorkflowItem`
thenProceed(with: SecondView.self) { // Use closures to define what comes next
thenProceed(with: ThirdView.self) // The final item needs no closures
}
}
/*
Each item in the workflow is defined as a `WorkflowItem`
passing the type of the FlowRepresentable to create
when appropriate as the workflow proceeds
*/
WorkflowView {
WorkflowItem(FirstView.self)
WorkflowItem(SecondView.self)
WorkflowItem(ThirdView.self)
}
```
2 changes: 1 addition & 1 deletion .github/abstract/Creating Workflows.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@ Workflows enforce (either at compile-time or run-time) that the sequence of `Flo

In some cases, like UIKit, the compiler is efficient enough to give you compile-time feedback if a workflow is malformed. This means that run-time errors are rare. They can still occur; for example, if you have Item1 declare a `FlowRepresentable.WorkflowOutput` of `AnyWorkflow.PassedArgs`, then call `FlowRepresentable.proceedInWorkflow(_:)` with `.args("string")`, but Item2 has a `FlowRepresentable.WorkflowInput` of `Int`, there'll be a run-time error because the data passed forward does not meet expectations.

In SwiftUI, the compiler was not efficient enough to give the same compile-time feedback on malformed workflows. When that safety was added, the compiler only allowed for small workflows to be created. To combat this, SwiftUI is heavily run-time influenced. When you create a `WorkflowLauncher`, the launcher performs a run-time check to guarantee the workflow is well-formed. This means that if you wanted to test your workflow was well-formed, all you have to do is instantiate a `WorkflowLauncher`.
In SwiftUI, the compiler was not efficient enough to give the same compile-time feedback on malformed workflows. When that safety was added, the compiler only allowed for small workflows to be created. To combat this, SwiftUI is heavily run-time influenced. When you create a `WorkflowView`, the library performs a run-time check to guarantee the workflow is well-formed. This means that if you wanted to test your workflow was well-formed, all you need to do is instantiate a `WorkflowView`.
8 changes: 4 additions & 4 deletions .github/fastlane/Fastfile
Original file line number Diff line number Diff line change
Expand Up @@ -68,22 +68,22 @@ platform :ios do

lane :cocoapods_liblint do
pod_lib_lint(
podspec: '../SwiftCurrent.podspec',
podspec: '../SwiftCurrent.podspec',
allow_warnings: true,
no_clean: true
)
end

lane :lint do
lane :lint do
swiftlint(
config_file: 'SwiftCurrentLint/.swiftlint.yml',
raise_if_swiftlint_error: true,
strict: true
)
end

lane :lintfix do
sh('swiftlint --fix --config=../../SwiftCurrentLint/.swiftlint.yml')
lane :lintfix do
sh('swiftlint --fix --config=../SwiftCurrentLint/.swiftlint.yml')
end

desc "Release a new version with a patch bump_type"
Expand Down
28 changes: 14 additions & 14 deletions .github/guides/Getting Started with SwiftUI.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

This guide will walk you through getting a `Workflow` up and running in a new iOS project. If you would like to see an existing project, clone the repo and view the `SwiftUIExample` scheme in `SwiftCurrent.xcworkspace`.

The app in this guide is going to be very simple. It consists of a view that will host the `WorkflowLauncher`, a view to enter an email address, and an optional view for when the user enters an email with `@wwt.com` in it. Here is a preview of what the app will look like:
The app in this guide is going to be very simple. It consists of a view that will host the `WorkflowView`, a view to enter an email address, and an optional view for when the user enters an email with `@wwt.com` in it. Here is a preview of what the app will look like:

![Preview image of app](https://user-images.githubusercontent.com/79471462/131556533-f2ad1e6c-9acd-4d62-94ac-9140c9718f95.gif)

Expand Down Expand Up @@ -111,7 +111,7 @@ struct SecondView_Previews: PreviewProvider {

## Launching the `Workflow`

Next we add a `WorkflowLauncher` to the body of our starting app view, in this case `ContentView`.
Next we add a `WorkflowView` to the body of our starting app view, in this case `ContentView`.

```swift
import SwiftUI
Expand All @@ -123,10 +123,11 @@ struct ContentView: View {
if !workflowIsPresented {
Button("Present") { workflowIsPresented = true }
} else {
WorkflowLauncher(isLaunched: $workflowIsPresented, startingArgs: "SwiftCurrent") { // SwiftCurrent
thenProceed(with: FirstView.self) { // SwiftCurrent
thenProceed(with: SecondView.self).applyModifiers { $0.padding().border(Color.gray) } // SwiftCurrent
}.applyModifiers { firstView in firstView.padding().border(Color.gray) } // SwiftCurrent
WorkflowView(isLaunched: $workflowIsPresented, launchingWith: "SwiftCurrent") { // SwiftCurrent
WorkflowItem(FirstView.self) // SwiftCurrent
.applyModifiers { firstView in firstView.padding().border(Color.gray) } // SwiftCurrent
WorkflowItem(SecondView.self) // SwiftCurrent
.applyModifiers { $0.padding().border(Color.gray) } // SwiftCurrent
}.onFinish { passedArgs in // SwiftCurrent
workflowIsPresented = false
guard case .args(let emailAddress as String) = passedArgs else {
Expand All @@ -152,21 +153,21 @@ struct Content_Previews: PreviewProvider {

<details>

In SwiftUI, the <code>Workflow</code> type is handled by the library when you start with a <code>WorkflowLauncher</code>.
In SwiftUI, the <code>Workflow</code> type is handled by the library when you start with a <code>WorkflowView</code>.
</details>

#### **Where is the type safety I heard about?**

<details>

<code>WorkflowLauncher</code> is specialized with your <code>startingArgs</code> type. <code>FlowRepresentable</code> is specialized with the <code>FlowRepresentable.WorkflowInput</code> and <code>FlowRepresentable.WorkflowOutput</code> associated types. These all work together when creating your flow at run-time to ensure the validity of your <code>Workflow</code>. If the output of <code>FirstView</code> does not match the input of <code>SecondView</code>, the library will send an error when creating the <code>Workflow</code>.
<code>WorkflowView</code> is specialized with your <code>launchingWith</code> type. <code>FlowRepresentable</code> is specialized with the <code>FlowRepresentable.WorkflowInput</code> and <code>FlowRepresentable.WorkflowOutput</code> associated types. These all work together when creating your flow at run-time to ensure the validity of your <code>Workflow</code>. If the output of <code>FirstView</code> does not match the input of <code>SecondView</code>, the library will send an error when creating the <code>Workflow</code>.
</details>

#### **What's going on with this `startingArgs` and `passedArgs`?**
#### **What's going on with this `launchingWith` and `passedArgs`?**

<details>

<code>startingArgs</code> are the <code>AnyWorkflow.PassedArgs</code> handed to the first <code>FlowRepresentable</code> in the workflow. These arguments are used to pass data and determine if the view should load.
<code>launchingWith</code> are the <code>AnyWorkflow.PassedArgs</code> handed to the first <code>FlowRepresentable</code> in the workflow. These arguments are used to pass data and determine if the view should load.

<code>passedArgs</code> are the <code>AnyWorkflow.PassedArgs</code> coming from the last view in the workflow. <code>onFinish</code> is only called when the user has gone through all the screens in the <code>Workflow</code> by navigation or skipping. For this workflow, <code>passedArgs</code> is going to be the output of <code>FirstView</code> or <code>SecondView</code>, depending on the email signature typed in <code>FirstView</code>. To extract the value, we unwrap the variable within the case of <code>.args()</code> as we expect this workflow to return some argument.
</details>
Expand Down Expand Up @@ -205,9 +206,8 @@ final class FirstViewController: UIWorkflowItem<Never, Never>, FlowRepresentable
Now in SwiftUI simply reference that controller.

```swift
WorkflowLauncher(isLaunched: $workflowIsPresented) { // SwiftCurrent
thenProceed(with: FirstViewController.self) { // SwiftCurrent
thenProceed(with: SecondView.self) // SwiftCurrent
}
WorkflowView(isLaunched: $workflowIsPresented) { // SwiftCurrent
WorkflowItem(FirstViewController.self) // SwiftCurrent
WorkflowItem(SecondView.self) // SwiftCurrent
}
```
18 changes: 6 additions & 12 deletions .github/guides/Working with Modals.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,9 @@ When constructing a workflow, you can use `WorkflowItem.presentationType(_:)` al

#### Example
```swift
NavigationView {
WorkflowLauncher(isLaunched: .constant(true)) {
thenProceed(with: FirstView.self) {
thenProceed(with: SecondView.self).presentationType(.modal)
}
}
WorkflowView {
WorkflowItem(FirstView.self)
WorkflowItem(SecondView.self).presentationType(.modal)
}
```

Expand All @@ -22,11 +19,8 @@ When you use a presentation type of `LaunchStyle.SwiftUI.PresentationType.modal`
#### Example
The following will use a full-screen cover:
```swift
NavigationView {
WorkflowLauncher(isLaunched: .constant(true)) {
thenProceed(with: FirstView.self) {
thenProceed(with: SecondView.self).presentationType(.modal(.fullScreenCover))
}
}
WorkflowView {
WorkflowItem(FirstView.self)
WorkflowItem(SecondView.self).presentationType(.modal(.fullScreenCover))
}
```
26 changes: 13 additions & 13 deletions .github/guides/Working with NavigationView.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ When constructing a workflow, you can use `WorkflowItem.presentationType(_:)` al
#### Example
```swift
NavigationView {
WorkflowLauncher(isLaunched: .constant(true)) {
thenProceed(with: FirstView.self) {
thenProceed(with: SecondView.self)
}.presentationType(.navigationLink)
WorkflowView {
WorkflowItem(FirstView.self)
.presentationType(.navigationLink)
WorkflowItem(SecondView.self)
}
}
```
Expand All @@ -17,15 +17,15 @@ With that, you've described that `FirstView` should be wrapped in a `NavigationL
> **NOTE:** The `NavigationLink` is in the background of the view to prevent your entire view from being tappable.

### Different NavigationView Styles
SwiftCurrent comes with a convenience function on `WorkflowLauncher` that tries to pick the best `NavigationViewStyle` for a `Workflow`. Normally that's stack-based navigation.
SwiftCurrent comes with a convenience function on `WorkflowView` that tries to pick the best `NavigationViewStyle` for a `Workflow`. Normally that's stack-based navigation.

#### Example
The earlier example could be rewritten as:
```swift
WorkflowLauncher(isLaunched: .constant(true)) {
thenProceed(with: FirstView.self) {
thenProceed(with: SecondView.self)
}.presentationType(.navigationLink)
WorkflowView {
WorkflowItem(FirstView.self)
.presentationType(.navigationLink)
WorkflowItem(SecondView.self)
}.embedInNavigationView()
```

Expand All @@ -36,10 +36,10 @@ If you want to use column-based navigation you can simply manage it yourself:
```swift
NavigationView {
FirstColumn() // Could ALSO be a workflow
WorkflowLauncher(isLaunched: .constant(true)) {
thenProceed(with: FirstView.self) {
thenProceed(with: SecondView.self)
}.presentationType(.navigationLink)
WorkflowView {
WorkflowItem(FirstView.self)
.presentationType(.navigationLink)
WorkflowItem(SecondView.self)
} // don't call embedInNavigationView here
}
```
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
objects = {

/* Begin PBXBuildFile section */
628952DA27E5281700FDDCEF /* SettingsOnboardingViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 628952D927E5281700FDDCEF /* SettingsOnboardingViewController.swift */; };
628952DC27E528CC00FDDCEF /* SettingsViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 628952DB27E528CC00FDDCEF /* SettingsViewController.swift */; };
CA0536F626A0888200BF8FC5 /* ProfileFeatureOnboardingView.swift in Sources */ = {isa = PBXBuildFile; fileRef = CA0536F526A0888200BF8FC5 /* ProfileFeatureOnboardingView.swift */; };
CA238D1426A1153B000A36EC /* ContentViewTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = CA238D1326A1153B000A36EC /* ContentViewTests.swift */; };
CA4A6F2026CDAEE600BE3E74 /* TestEventReceiver.swift in Sources */ = {isa = PBXBuildFile; fileRef = CA4A6F1F26CDAEE600BE3E74 /* TestEventReceiver.swift */; };
Expand Down Expand Up @@ -112,6 +114,8 @@
/* End PBXContainerItemProxy section */

/* Begin PBXFileReference section */
628952D927E5281700FDDCEF /* SettingsOnboardingViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SettingsOnboardingViewController.swift; sourceTree = "<group>"; };
628952DB27E528CC00FDDCEF /* SettingsViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SettingsViewController.swift; sourceTree = "<group>"; };
CA0536F526A0888200BF8FC5 /* ProfileFeatureOnboardingView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ProfileFeatureOnboardingView.swift; sourceTree = "<group>"; };
CA238D1326A1153B000A36EC /* ContentViewTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ContentViewTests.swift; sourceTree = "<group>"; };
CA4A6F1F26CDAEE600BE3E74 /* TestEventReceiver.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TestEventReceiver.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -231,6 +235,15 @@
/* End PBXFrameworksBuildPhase section */

/* Begin PBXGroup section */
628952D827E5280000FDDCEF /* Settings */ = {
isa = PBXGroup;
children = (
628952D927E5281700FDDCEF /* SettingsOnboardingViewController.swift */,
628952DB27E528CC00FDDCEF /* SettingsViewController.swift */,
);
path = Settings;
sourceTree = "<group>";
};
CA0536F926A0917A00BF8FC5 /* Profile */ = {
isa = PBXGroup;
children = (
Expand Down Expand Up @@ -334,6 +347,7 @@
CAC34B6D26A07FE90039A373 /* Views */ = {
isa = PBXGroup;
children = (
628952D827E5280000FDDCEF /* Settings */,
D72B763526FBCF5A00E0405F /* Design */,
D78139CB270DE3AD004A4721 /* Map */,
CA0536F926A0917A00BF8FC5 /* Profile */,
Expand Down Expand Up @@ -663,6 +677,7 @@
CA7B829F26A1FAAC005AA87D /* InspectableAlert.swift in Sources */,
CA0536F626A0888200BF8FC5 /* ProfileFeatureOnboardingView.swift in Sources */,
CAC34B4326A07F830039A373 /* SwiftUIExampleApp.swift in Sources */,
628952DC27E528CC00FDDCEF /* SettingsViewController.swift in Sources */,
D72B765526FC032B00E0405F /* ChangeEmailView.swift in Sources */,
CA6FB0DE26C6AD5200FB3285 /* UIKitInteropProgrammaticViewController.swift in Sources */,
CA7B821026A123F6005AA87D /* InspectableSheet.swift in Sources */,
Expand All @@ -687,6 +702,7 @@
D72B765726FC036A00E0405F /* AccountInformationView.swift in Sources */,
CAC34B7526A07FE90039A373 /* MapFeatureOnboardingView.swift in Sources */,
D72B764926FBCFB200E0405F /* LoginView.swift in Sources */,
628952DA27E5281700FDDCEF /* SettingsOnboardingViewController.swift in Sources */,
D72B764326FBCF7000E0405F /* PasswordField.swift in Sources */,
D7A6CE7E26E039C300599824 /* TestView.swift in Sources */,
D72B764A26FBCFB200E0405F /* SignUp.swift in Sources */,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@ struct SwiftUIExampleApp: App {
if Environment.shouldTest {
TestView()
} else {
WorkflowLauncher(isLaunched: .constant(true)) {
thenProceed(with: SwiftCurrentOnboarding.self) {
thenProceed(with: ContentView.self)
.applyModifiers { $0.transition(.slide) }
}.applyModifiers { $0.transition(.slide) }
WorkflowView {
WorkflowItem(SwiftCurrentOnboarding.self)
.applyModifiers { $0.transition(.slide) }
WorkflowItem(ContentView.self)
.applyModifiers { $0.transition(.slide) }
}
.preferredColorScheme(.dark)
}
Expand Down
Loading