txtodo

[DORMANT] a minimalist todo list app inspired by jeff huang
git clone git://git.figbert.com/txtodo.git
Log | Files | Refs | README

commit 84fe1390469711faec98314e59ece3e0caa96fce
parent d0c766b0f6a08695c5c791ccc592ec3985369e74
Author: FIGBERT <figbert@figbert.com>
Date:   Fri, 11 Dec 2020 17:44:39 -0800

Fix glitch preventing note editing

Diffstat:
MShared/NoteView.swift | 12+++---------
MiOS/NoteSheet.swift | 2+-
MmacOS/TaskView.swift | 2+-
3 files changed, 5 insertions(+), 11 deletions(-)

diff --git a/Shared/NoteView.swift b/Shared/NoteView.swift @@ -11,15 +11,9 @@ struct NoteView: View { @Environment(\.managedObjectContext) var managedObjectContext @ObservedObject var task: Task @State var note: String - @State private var config = NoteViewConfig() + @State var config: NoteViewConfig var body: some View { - let noteIntermediary = Binding<String>( - get: { self.note }, - set: { value in - self.config.editingCache = value - } - ) return HStack { Image(systemName: "minus") .padding(.trailing) @@ -29,7 +23,7 @@ struct NoteView: View { self.config.editing = true } } else { - TextField("edit note", text: noteIntermediary, onCommit: { + TextField("edit note", text: $config.editingCache, onCommit: { if let index = self.task.notes.firstIndex(of: self.note) { self.managedObjectContext.performAndWait { self.task.notes[index] = self.config.editingCache @@ -74,5 +68,5 @@ struct NoteViewConfig { var editing: Bool = false var showingDelete: Bool = false var offset: CGFloat = 0 - var editingCache = "" + var editingCache: String } diff --git a/iOS/NoteSheet.swift b/iOS/NoteSheet.swift @@ -17,7 +17,7 @@ struct NoteSheet: View { Text(task.name) .underline() ForEach(task.notes, id: \.self) { note in - NoteView(task: task, note: note) + NoteView(task: task, note: note, config: NoteViewConfig(editingCache: note)) .environment(\.managedObjectContext, self.managedObjectContext) } AddNoteView(task: task) diff --git a/macOS/TaskView.swift b/macOS/TaskView.swift @@ -130,7 +130,7 @@ struct TaskView: View { if config.showingNotes { VStack(spacing: 10) { ForEach(task.notes, id: \.self) { note in - NoteView(task: task, note: note) + NoteView(task: task, note: note, config: NoteViewConfig(editingCache: note)) .environment(\.managedObjectContext, self.managedObjectContext) } AddNoteView(task: task)