Accessing the isEditing property of environment value editMode leads to a compiler error.
In the code below I'm getting 'Generic parameter 'S' could not be inferred' applied to the Button
If I remove && !mode?.isEditing it compiles OK. I've tried juggling things around, but it always finds some problem. It looks like a bug to me either in @Environment or ViewBuilder. Any suggestions?
Here's the full struct:
struct ProjectView: View {
@Environment(\.editMode) var mode
@State private var canAddProject = false
@State private var showAlert = false
var projects: FetchedResults
var alert: Alert {
Alert(title: Text("Write Now"), message: Text("Please enter a project name"), dismissButton: .default(Text("Dismiss")))
}
var body: some View {
NavigationView {
List {
if !canAddProject && !mode?.isEditing {
Button("Add New Project") {}
.onTapGesture {
self.canAddProject.toggle()
}
}
if canAddProject {
AddProject(canAddProject: $canAddProject, showAlert: $showAlert)
}
ProjectList(projects: projects)
}
.listStyle(GroupedListStyle())
.navigationBarTitle(Text("Write Now"))
.navigationBarItems(trailing: EditButton())
}
.navigationViewStyle(StackNavigationViewStyle())
.alert(isPresented: $showAlert, content: { self.alert })
}
}