[WIP] SwiftUIScreen with action sink #225
Closed
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR demonstrates rewriting some Workflow-backed screens from UIKit to SwiftUI, significantly simplifying their implementations:
LoginScreenfrom the TicTacToe exampleTodoEditScreenfrom Tutorial 5It does so by:
Renderings'Screenconformances withSwiftUIScreenconformances.Renderings themselves to hold a single,Equatableaction sink rather than multiple callback functions, allowing theRenderingitself to deriveEquatable.Commits
The PR is designed to be read commit-by-commit:
c7d51b6: Introduce WorkflowSwiftUI types
Pastes in some types from previous Workflow SwiftUI experiments, nearly unchanged, that are discussed in the Binding SwiftUI Views to Workflow Renderings design doc. Most importantly:
SwiftUIScreen, the protocol that aScreenmay conform to if it wishes to provide a SwiftUIViewin lieu of aViewControllerDescriptionObservableValue, which exposesRenderings from theWorkflowto the SwiftUIView2fbfc5e: Make
LoginScreenaSwiftUIScreenReplaces
LoginScreen'sScreenconformance with aSwiftUIScreenconformance. This already simplifies the implementation significantly, but the next few commits simplify it further.0340049: Replace callbacks with action sink
Replaces the callback functions in
LoginScreenwith a singleScreenActionSink, allowingLoginScreento deriveEquatable. The also simplifiesLoginWorkflowand its tests a bit.f039b47, 7a9164a: Syntactic sugar
Introduces extensions on
ObservableValuethat make data bindings in theViewmore concise.53fc65b: Make
TodoEditScreenaSwiftUIScreenRewrite another screen to SwiftUI, taking advantage again of all types and extensions described above.
Further reading
#228 adds additional syntactic sugar for exposing two-way bindings to properties on the
State.