I have a Form on my View containing couple of Pickers.
Picker stops working when @Environment(\.presentationMode) var presentationMode
is added to a View.
struct NewOperationView: View {
@Environment(\.presentationMode) var presentationMode
@State var docDate: Date
@State var doctorID: Int64
@State var doctors: [listStruct] = []
@State var refOperationID: Int64
@State var refOperations: [listStruct] = []
@State var productsList: [productListStruct] = []
let df: DateFormatter = DateFormatter()
let barcodeService = BarcodeService()
var body: some View {
VStack {
Form {
HStack {
Text("Date")
Spacer()
Text(df.string(from: docDate))
}
Picker("Doctor", selection: $doctorID) {
ForEach(doctors) { doctor in
Text(doctor.title).tag(doctor.id)
}
}
Picker("Operation", selection: $refOperationID) {
ForEach(refOperations) { refOperation in
Text(refOperation.title).tag(refOperation.id)
}
}
Section("Prothesis") {
List {
ForEach(productsList) { product in
ProductRow(product: product)
}.onDelete(perform: delete)
}
}
}
}
}
}
Before importing the @Environment
all works well, Picker's value is displayed, and selectable. But After importing pickers turns empty, and selecting the value in picker does not change the value of the picker
Before importing
After importing