Closed n8chur closed 7 months ago
Would ViewEnvironmentUI
be a better home? We'll need to pull that in anyway in order to bridge from VC land to SwiftUI, right?
Would
ViewEnvironmentUI
be a better home? We'll need to pull that in anyway in order to bridge from VC land to SwiftUI, right?
I don't think so, but I might be missing something.
ViewEnvironmentUI
is the framework that handles node-based propagation and integrates specifically with UIKit
. I believe there is going to be a WorkflowSwiftUI
module that would handle SwiftUI bridging of the ViewEnvironment
—I don't think any bridging to/from SwiftUI would live in ViewEnvironmentUI
, but we could talk about what the right place for that would be.
I do think it'd be nice avoid importing all of the UIKit-specific code in MarketSwiftUI
(at least in its current form where it does not rely on UIKit
).
Would
ViewEnvironmentUI
be a better home? We'll need to pull that in anyway in order to bridge from VC land to SwiftUI, right?I don't think so, but I might be missing something.
ViewEnvironmentUI
is the framework that handles node-based propagation and integrates specifically withUIKit
. I believe there is going to be aWorkflowSwiftUI
module that would handle SwiftUI bridging of theViewEnvironment
—I don't think any bridging to/from SwiftUI would live inViewEnvironmentUI
, but we could talk about what the right place for that would be. I do think it'd be nice avoid importing all of the UIKit-specific code inMarketSwiftUI
(at least in its current form where it does not rely onUIKit
).
I talked to Westin out of band about this. The integration PR doesn't implement bridging so it's a little abstract to talk about. Realistically, there will be a need for bridging the ViewEnvironment
from view controllers to SwiftUI without Workflow, and that has got to be in, or depend on, ViewEnvironmentUI
. Will there ever be a pure SwiftUI + Workflow world that doesn't involve Screens or UIKit, and uses ViewEnvironment
? I doubt it.
I like the idea of keeping the ViewEnvironment
module as a simple dictionary type without adding any UI concerns, and letting ViewEnvironmentUI
handle those (meaning both UIKit and SwiftUI fall under the "UI" moniker). But I don't feel strongly enough to block this for now.
Why?
Moving this environment value key to
ViewEnvironment
means that modules that aren't dependent on WorkflowUI (like MarketSwiftUI) are able to accessViewEnvironment
keys on the SwiftUIEnvironmentValues
. Market will use this key to access theMarketContext
on theViewEnvironment
which is bridged by either our Market SwiftUI Hosting Controller or the standard WorkflowUI SwiftUI Screen depending on context rather than having to manually bridge theMarketContext
in addition to theViewEnvironment
, and have the potential for theMarketContext
s in both environments to get out of sync.The integration in Market can be found here: https://github.com/squareup/market/pull/7763
Checklist
UI-5335