- Notifications
You must be signed in to change notification settings - Fork18
A library for managing complex workflows in Swift
License
wwt/SwiftCurrent
Folders and files
| Name | Name | Last commit message | Last commit date | |
|---|---|---|---|---|
Repository files navigation
SwiftCurrent is a library that lets you easily manage journeys through your Swift application and comes with built-in support for UIKit and SwiftUI app-routing.
In SwiftCurrent, workflows are a sequence of operations. Those operations usually display views in an application. The workflow describes the sequence of views and manages which view should come next. Your views are responsible for performing necessary tasks before proceeding forward in the workflow, like processing user input.
Architectural patterns and libraries that attempt to create a separation between views and workflows already exist. However, SwiftCurrent is different. We took a new design approach that focuses on:
- A Developer-Friendly API. The library was built with developers in mind. It started with a group of developers talking about the code experience they desired. Then the library team took on whatever complexities were necessary to bring them that experience.
- Compile-Time Safety. At compile-time, we tell you everything we can so you know things will work.
- Minimal Boilerplate. We have hidden this as much as possible. We hate it as much as you do and are constantly working on cutting the cruft.
This library:
- Isolates Your Views. Design your views so that they are unaware of the view that will come next.
- Easily Reorders Views. Changing view order is as easy as ⌘+⌥+[ (moving the line up or down).
- Composes Workflows Together. Create branching flows easily by joining workflows together.
- Creates Conditional Flows. Make your flows robust and handle ever-changing designs. Need a screen to only to show up sometimes? Need a flow for person A and another for person B? We've got you covered.
Why show a quick start when we have an example app? Because it's so easy to get started, we can drop in two code snippets, and you're ready to go! This quick start uses Swift Package Manager and SwiftUI, but for other approaches,see our installation instructions.
.package(url:"https://github.com/wwt/SwiftCurrent.git",.upToNextMajor(from:"5.1.0")),....product(name:"SwiftCurrent",package:"SwiftCurrent"),.product(name:"SwiftCurrent_SwiftUI",package:"SwiftCurrent")
Then make your first FlowRepresentable view:
import SwiftCurrentimport SwiftUIstructOptionalView:View,FlowRepresentable{ weakvar_workflowPointer:AnyFlowRepresentable?letinput:Stringinit(with args:String){ input= args}varbody:someView{Text("Only shows up if no input")}func shouldLoad()->Bool{ input.isEmpty}}structExampleView:View,PassthroughFlowRepresentable{ weakvar_workflowPointer:AnyFlowRepresentable?varbody:someView{Text("This is ExampleView!")}}
Then from yourContentView or whatever view (or app) you'd like to contain the workflow, add the following view to the body:
import SwiftCurrent_SwiftUI// ...varbody:someView{ // ... other view code (if any)WorkflowView(launchingWith:"Skip optional screen"){WorkflowItem(OptionalView.self)WorkflowItem(ExampleView.self)}}
And just like that, you've got a workflow! You can now add more items to it or reorder the items that are there. To understand more of how this works,check out our developer docs.
SwiftCurrent now supports server driven workflows! Check out our schema for details on defining workflows with JSON, YAML, or any other key/value-based data format. Then, simply have yourFlowRepresentable types that you wish to decode conform toWorkflowDecodable and decode the workflow. For more information,see our docs.
We haveexample apps for both SwiftUI and UIKit that show SwiftCurrent in action. They've already been tested, so you can see what it's like to test SwiftCurrent code. To run it locally, start by cloning the repo, openSwiftCurrent.xcworkspace and then run theSwiftUIExample scheme or theUIKitExample scheme.
For specific documentation check out:
- Why SwiftCurrent?
- Installation
- Getting Started With SwiftUI
- Getting Started With Storyboards
- Getting Started With Programmatic UIKit Views
- Server Driven Workflows
- Developer Documentation
- Upgrade Path
- Contributing to SwiftCurrent
If you like what you've seen, considergiving us a star! If you don't, let us knowhow we can improve.
SwiftCurrent would not be nearly as amazing without all of the great work done by the authors of our test dependencies:
About
A library for managing complex workflows in Swift
Topics
Resources
License
Code of conduct
Contributing
Security policy
Uh oh!
There was an error while loading.Please reload this page.
Stars
Watchers
Forks
Packages0
Uh oh!
There was an error while loading.Please reload this page.
Contributors11
Uh oh!
There was an error while loading.Please reload this page.
