appreciate your response @BabyJ , unfortunately I cannot do that since here is how I setup my app:
struct LaunchApp: App {
@State private var appModel = AppModel()
var body: some Scene {
WindowGroup {
appModel.viewProvider.layoutUI()
}
}
}
and in my AppModel, the view provider is a property that can be changed based on what module user is currently on.
If I make the ViewProvider generic as you suggested, then I have to specify those requirements in my app model layer which is not possible afaik.
@Observable @MainActor
final class AppModel {
var viewProvider: ViewProvider
init() {
let defaultProvider = SplashScreenProvider()
self.viewProvider = ViewProvider(provider: defaultProvider, completion: {})
setupFlowCoordinator()
}
func setupFlowCoordinator() {
flowCoordinator = FlowCoordinator(registry: appCoordinator.registry, configuration: config) { provider in
self.viewProvider = provider
}
}
during the app session, the setupFlowCoordinator method will be updating the view provider depending on what we want to show to the user, it could be onboarding/ new feature flows etc.
Topic:
UI Frameworks
SubTopic:
SwiftUI
Tags: