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

[WIP] WorkflowSwiftUI without ObservedObject #253

Conversation

square-tomb
Copy link
Contributor

@square-tomb square-tomb commented Oct 30, 2023

Experiment:

  • No SwiftUIScreen protocol. SwiftUI View conforms directly to Screen
  • No ObservableValue. SwiftUI View has multiple, plain, value-typed properties instead of a single @ObservedObject model
  • Each Workflow re-render sets UIHostingController.rootView

This approach previously resulted in animation issues documented in Binding SwiftUI Views to Workflow Renderings and 2020's WorkflowView, but I saw none in the SwiftUITestbed app under Xcode 14 and iOS 16.

This approach might lead to more view body evaluations, but after my performance noodling last month, I think those evaluations are cheap as long as they don't trigger additional work in the Core Animation commit phase.

import WorkflowUI

public extension Screen where Self: View {
func viewControllerDescription(environment: ViewEnvironment) -> ViewControllerDescription {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Clever!

@square-tomb
Copy link
Contributor Author

This approach previously resulted in animation issues documented in Binding SwiftUI Views to Workflow Renderings - Google Docs and 2020's WorkflowView, but I saw none in the SwiftUITestbed app under Xcode 14 and iOS 16.

Update: @mjohnson12 tested under iOS 15 and found the same broken animation for Toggle that we reported in that design doc.

iOS.15.2.mp4

square-tomb added a commit that referenced this pull request Nov 1, 2023
Experiment to see if this affects the iOS 15 issue[1]. It doesn't.

[1]: #253 (comment)
Binding+Buffered.swift Outdated Show resolved Hide resolved
square-tomb added a commit that referenced this pull request Nov 1, 2023
@square-tomb square-tomb force-pushed the tomb/swiftui-no-observableobject branch from 9f3c49d to 1997b06 Compare November 4, 2023 03:45
@square-tomb square-tomb changed the base branch from tomb/swiftui-testbed-workflowswiftuiexperimental to tomb/swiftui-testbed-workflowswiftui November 4, 2023 03:46
…are/workflow-swift into tomb/swiftui-no-observableobject

* 'tomb/swiftui-testbed-workflowswiftui' of github.com:square/workflow-swift:
  add animation(_:value:) modifier
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants