For some reason, passing again the view model instance from the parent view works:
struct SettingsView: View {
@EnvironmentObject var mainModel: MainViewModel
@EnvironmentObject var authModel: AuthViewModel
@EnvironmentObject var purchaseModel: PurchaseViewModel
[some stuff]
var body: some View {
GeometryReader { geo in
[some stuff]
}
.sheet(isPresented: self.$isProfileEditPresented) {
ProfileEditView(isPresented: self.$isProfileEditPresented)
.environmentObject(authModel)
}
}
}
I don't see why this is necessary, since ProfileEditView is a child View to SettingsView, and therefore should already have access to the environment object, but passing it again solved the problem.
Topic:
UI Frameworks
SubTopic:
SwiftUI
Tags: