You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: .github/UPGRADE_PATH.md
+20Lines changed: 20 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -3,6 +3,26 @@ Use this document to help you understand how to update between major versions of
3
3
4
4
Our directions are written for only 1 major version upgrade at a time, as we have found that to be the best experience.
5
5
6
+
<details>
7
+
<summary><b>V4 -> V5</b></summary>
8
+
9
+
## SwiftUI - WorkflowView
10
+
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`.
11
+
12
+
```swift
13
+
WorkflowView {
14
+
WorkflowItem(FirstView.self) // This view is shown first
15
+
WorkflowItem(SecondView.self) // After proceeding, this view is shown
16
+
}
17
+
```
18
+
19
+
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")`.
20
+
21
+
`WorkflowView`'s initializer defaults `isLaunched` to `.constant(true)` meaning you can exclude that parameter and just use `WorkflowView(launchingWith: "someArgs")`
Copy file name to clipboardExpand all lines: .github/abstract/Controlling Presentation.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -4,7 +4,7 @@ SwiftCurrent allows you to control how your workflow presents its `FlowRepresent
4
4
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`.
5
5
6
6
### In SwiftUI
7
-
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`.
7
+
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`.
8
8
9
9
### Persistence
10
10
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.
Copy file name to clipboardExpand all lines: .github/abstract/Creating Workflows.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -9,4 +9,4 @@ Workflows enforce (either at compile-time or run-time) that the sequence of `Flo
9
9
10
10
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.
11
11
12
-
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`.
12
+
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`.
Copy file name to clipboardExpand all lines: .github/guides/Getting Started with SwiftUI.md
+14-14Lines changed: 14 additions & 14 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -2,7 +2,7 @@
2
2
3
3
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`.
4
4
5
-
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:
5
+
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:
6
6
7
7

In SwiftUI, the <code>Workflow</code> type is handled by the library when you start with a <code>WorkflowLauncher</code>.
156
+
In SwiftUI, the <code>Workflow</code> type is handled by the library when you start with a <code>WorkflowView</code>.
156
157
</details>
157
158
158
159
#### **Where is the type safety I heard about?**
159
160
160
161
<details>
161
162
162
-
<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>.
163
+
<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>.
163
164
</details>
164
165
165
-
#### **What's going on with this `startingArgs` and `passedArgs`?**
166
+
#### **What's going on with this `launchingWith` and `passedArgs`?**
166
167
167
168
<details>
168
169
169
-
<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.
170
+
<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.
170
171
171
172
<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.
172
173
</details>
@@ -205,9 +206,8 @@ final class FirstViewController: UIWorkflowItem<Never, Never>, FlowRepresentable
Copy file name to clipboardExpand all lines: .github/guides/Working with NavigationView.md
+13-13Lines changed: 13 additions & 13 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -4,10 +4,10 @@ When constructing a workflow, you can use `WorkflowItem.presentationType(_:)` al
4
4
#### Example
5
5
```swift
6
6
NavigationView {
7
-
WorkflowLauncher(isLaunched: .constant(true)) {
8
-
thenProceed(with: FirstView.self) {
9
-
thenProceed(with: SecondView.self)
10
-
}.presentationType(.navigationLink)
7
+
WorkflowView {
8
+
WorkflowItem(FirstView.self)
9
+
.presentationType(.navigationLink)
10
+
WorkflowItem(SecondView.self)
11
11
}
12
12
}
13
13
```
@@ -17,15 +17,15 @@ With that, you've described that `FirstView` should be wrapped in a `NavigationL
17
17
> **NOTE:** The `NavigationLink` is in the background of the view to prevent your entire view from being tappable.
18
18
19
19
### Different NavigationView Styles
20
-
SwiftCurrent comes with a convenience function on `WorkflowLauncher` that tries to pick the best `NavigationViewStyle` for a `Workflow`. Normally that's stack-based navigation.
20
+
SwiftCurrent comes with a convenience function on `WorkflowView` that tries to pick the best `NavigationViewStyle` for a `Workflow`. Normally that's stack-based navigation.
21
21
22
22
#### Example
23
23
The earlier example could be rewritten as:
24
24
```swift
25
-
WorkflowLauncher(isLaunched: .constant(true)) {
26
-
thenProceed(with: FirstView.self) {
27
-
thenProceed(with: SecondView.self)
28
-
}.presentationType(.navigationLink)
25
+
WorkflowView {
26
+
WorkflowItem(FirstView.self)
27
+
.presentationType(.navigationLink)
28
+
WorkflowItem(SecondView.self)
29
29
}.embedInNavigationView()
30
30
```
31
31
@@ -36,10 +36,10 @@ If you want to use column-based navigation you can simply manage it yourself:
0 commit comments