I have added .environmentObject(AuthViewModel())
to ContentView which is also wrapped inside geometryReader inside struct conforming to App called MyApp.
Exactly like it's reccomended in this answer
https://stackoverflow.com/a/71970454/14743849 .
@main
struct MyApp: App {
@UIApplicationDelegateAdaptor(AppDelegate.self) var delegate
var body: some Scene {
WindowGroup {
GeometryReader { proxy in
ContentView()
.environmentObject(AuthViewModel())
.environment(\.mainWindowSize, proxy.size)
}
}
I started using my environment object and I have noticed that it is affecting my AuthViewModel properties by reseting their values. I think it's also worth to mention that app is not allowed to be used in landscape.
After removing geometryReader everything works fine.