So i try to edit a project in the view created by https://www.hackingwithswift.com/plus/ultimate-portfolio-app/editing-projects
And whenever i do a change in the project, insert a new letter in the textField or tap the color. The EditProjectView automatically dismisses.
I'm definitively not sure what went wrong.
In ProjectsView
i use the header like:
List {
ForEach(projects.wrappedValue) { project in
Section(header: ProjectHeaderView(project: project)) {
...
}
Then the ProjectHeaderView
is defined like:
struct ProjectHeaderView: View {
@ObservedObject var project: Project
var body: some View {
HStack {
VStack(alignment: .leading) {
Text(project.projectTitle)
ProgressView(value: project.completionAmount)
.accentColor(Color(project.projectColor))
}
Spacer()
NavigationLink(destination: EditProjectView(project: project)) {
Image(systemName: "square.and.pencil")
.imageScale(.large)
}
}
.padding(.bottom, 10)
}
}
Finally the EditProjectView
starts with code like:
struct EditProjectView: View {
let project: Project
@State var title: String
@State var detail: String
@State var color: String
@State var isShowingAlert: Bool = false
@Environment(\.presentationMode) var presentationMode
@EnvironmentObject var dataController: DataController
var colorColumns: [GridItem] = [GridItem(.adaptive(minimum: 44))]
init(project: Project) {
self.project = project
self._title = State(wrappedValue: project.projectTitle)
self._detail = State(wrappedValue: project.projectDetail)
self._color = State(wrappedValue: project.projectColor)
}
var body: some View {
Form {
Section(header: Text("Basic settings")) {
TextField("Title", text: $title.onChange(update))
TextField("Description of the project", text: $detail.onChange(update))
}
...
I don't get it, has anyone found an issue like this?