mirror of
https://github.com/SideStore/SideStore.git
synced 2026-02-16 18:23:53 +01:00
Fix HMR crashing the app
This commit is contained in:
@@ -11,6 +11,7 @@ import SwiftUI
|
|||||||
import Roxas
|
import Roxas
|
||||||
import EmotionalDamage
|
import EmotionalDamage
|
||||||
import minimuxer
|
import minimuxer
|
||||||
|
import Inject
|
||||||
|
|
||||||
import AltStoreCore
|
import AltStoreCore
|
||||||
import UniformTypeIdentifiers
|
import UniformTypeIdentifiers
|
||||||
@@ -44,7 +45,9 @@ final class LaunchViewController: RSTLaunchViewController, UIDocumentPickerDeleg
|
|||||||
// self.destinationViewController = self.storyboard!.instantiateViewController(withIdentifier: "tabBarController") as! TabBarController
|
// self.destinationViewController = self.storyboard!.instantiateViewController(withIdentifier: "tabBarController") as! TabBarController
|
||||||
let rootView = RootView()
|
let rootView = RootView()
|
||||||
.environment(\.managedObjectContext, DatabaseManager.shared.viewContext)
|
.environment(\.managedObjectContext, DatabaseManager.shared.viewContext)
|
||||||
self.destinationViewController = UIHostingController(rootView: rootView)
|
// NOTE: Injection/HMR can be done directly from the SwiftUI side of things, however, it crashes the app when editing a view inside another view (such as the dev mode menu)
|
||||||
|
// A major downside to doing it from UIKit is that if we do it this way, the whole UI will reload when you make a change. If we do it from SwiftUI, it won't reload the entire UI.
|
||||||
|
self.destinationViewController = Inject.ViewControllerHost(UIHostingController(rootView: rootView))
|
||||||
}
|
}
|
||||||
super.viewDidLoad()
|
super.viewDidLoad()
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,11 +8,8 @@
|
|||||||
|
|
||||||
import SwiftUI
|
import SwiftUI
|
||||||
import SFSafeSymbols
|
import SFSafeSymbols
|
||||||
import Inject
|
|
||||||
|
|
||||||
struct RootView: View {
|
struct RootView: View {
|
||||||
@ObservedObject private var iO = Inject.observer
|
|
||||||
|
|
||||||
@State var selectedTab: Tab = .defaultTab
|
@State var selectedTab: Tab = .defaultTab
|
||||||
|
|
||||||
var body: some View {
|
var body: some View {
|
||||||
@@ -29,7 +26,6 @@ struct RootView: View {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
.overlay(self.notificationsOverlay)
|
.overlay(self.notificationsOverlay)
|
||||||
.enableInjection()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ViewBuilder
|
@ViewBuilder
|
||||||
|
|||||||
Reference in New Issue
Block a user