Hello for SwiftUI

This commit is contained in:
Artur Gurgul 2025-08-02 13:00:06 +02:00
parent 14aa6a777b
commit 4e4a92c2a3
5 changed files with 75 additions and 33 deletions

View file

@ -1,4 +1,5 @@
import UIKit
import SwiftUI
import React
import React_RCTAppDelegate
import ReactAppDependencyProvider
@ -8,7 +9,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
var window: UIWindow?
var reactNativeDelegate: ReactNativeDelegate?
var reactNativeFactory: RCTReactNativeFactory?
private let sharedState = SharedState()
func application(
_ application: UIApplication,
@ -19,7 +20,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
delegate.dependencyProvider = RCTAppDependencyProvider()
reactNativeDelegate = delegate
reactNativeFactory = factory
sharedState.reactNativeFactory = factory
window = UIWindow(frame: UIScreen.main.bounds)
@ -34,10 +35,11 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
}
func startNativeApp() {
guard let window, let reactNativeFactory else {
guard let window, sharedState.reactNativeFactory != nil else {
return
}
window.rootViewController = UIReactNativeHostingViewController(reactNativeFactory)
window.rootViewController = UIHostingController(rootView: RootView(sharedState))
window.makeKeyAndVisible()
}
}