[WIP] SwiftUIScreen with action sink
This PR demonstrates rewriting some Workflow-backed screens from UIKit to SwiftUI, significantly simplifying their implementations:
LoginScreenfrom the TicTacToe exampleTodoEditScreenfrom Tutorial 5
It does so by:
- Following the approach described in the Binding SwiftUI Views to Workflow Renderings design doc, replacing the
Renderings'Screenconformances withSwiftUIScreenconformances. - Altering the
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:
c7d51b623518a1bd219d302ff0f8ebb70ff4dc79: 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 SwiftUIView
2fbfc5e2e91ab316a17d178a315c156f0ca4a12d: Make LoginScreen a SwiftUIScreen
Replaces LoginScreen's Screen conformance with a SwiftUIScreen conformance. This already simplifies the implementation significantly, but the next few commits simplify it further.
0340049e1e80261193db11dfe2fe27782470c8f3: Replace callbacks with action sink
Replaces the callback functions in LoginScreen with a single ScreenActionSink, allowing LoginScreen to derive Equatable. The also simplifies LoginWorkflow and its tests a bit.
f039b474084fbf76c85c98f2cc9ede36e9a18b1e, 7a9164a4f3a5e37e443b1fb3b1a6c223b4dd83d6: Syntactic sugar
Introduces extensions on ObservableValue that make data bindings in the View more concise.
53fc65b53fc9d77a73bc532ac7dfb9ae6e41cd9a: Make TodoEditScreen a SwiftUIScreen
Rewrite 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.