The following code presents the same view PatientView in 2 ways:
var body: some View {
NavigationView {
List {
ForEach(patients, id: \.self) { patient in
NavigationLink(destination:
PatientView(selectedPatient: patient, isDependant: false, mainID: "")) {
PatientRowView(patient: patient)
}
}
.onDelete { indexSet in
for index in indexSet {
self.moc.delete(self.patients[index])
}
}
}
.navigationBarItems(trailing: Button(action: {
self.showingAddScreen.toggle()
}) {
Image(systemName: "plus")
})
.sheet(isPresented: $showingAddScreen) {
PatientView(selectedPatient: nil, isDependant: false, mainID: "").environment(\.managedObjectContext, self.moc)
}
.navigationBarTitle("Patients")
.background(NavigationConfigurator { nc in
nc.navigationBar.barTintColor = .launchpadBackgroundGray
nc.navigationBar.titleTextAttributes = [.foregroundColor : UIColor.black]
})
}
}
When presented as a Sheet the Pickers on the PatientView are disabled:
But when presented through the Navigationlink the pickers work as expected:
Does anyone know why this is happening? Any solutions to make the pickers were properly when presented as a Sheet would be greatly appreciated.
Thank You
Form
picker requires NavigationView
so provide it for sheet workflow explicitly
.sheet(isPresented: $showingAddScreen) {
NavigationView {
PatientView(selectedPatient: nil, isDependant: false,
mainID: "").environment(\.managedObjectContext, self.moc)
}
}