diff --git a/Shared/Views/AccountView/AccountView+Content.swift b/Shared/Views/AccountView/AccountView+Content.swift index c219201..41bddde 100644 --- a/Shared/Views/AccountView/AccountView+Content.swift +++ b/Shared/Views/AccountView/AccountView+Content.swift @@ -58,6 +58,13 @@ extension AccountView { } AccountDetailsView(account: account, isEditing: $isEditing) .padding(.vertical) + GroupBox { + TextField("Notes", text: $newNotes, onCommit: { + account.notes = newNotes + + try? viewContext.save() + }).textFieldStyle(.plain) + } #if os(macOS) Spacer() #endif diff --git a/Shared/Views/AccountView/AccountView.swift b/Shared/Views/AccountView/AccountView.swift index 0bf11de..29eb516 100644 --- a/Shared/Views/AccountView/AccountView.swift +++ b/Shared/Views/AccountView/AccountView.swift @@ -9,7 +9,7 @@ import SwiftUI struct AccountView: View { // MARK: - Environment - @Environment(\.managedObjectContext) private var viewContext + @Environment(\.managedObjectContext) var viewContext // MARK: - CoreData @FetchRequest( @@ -20,6 +20,8 @@ struct AccountView: View { // MARK: - Variables let account: Account @State var isEditing: Bool = false + @State var newNotes: String = "" + @State private var isAddingAlternateDomains: Bool = false @State private var newAlternateDomains: String = "" @State private var isSharing: Bool = false @@ -30,6 +32,8 @@ struct AccountView: View { let predicate = NSPredicate(format: "domain contains[c] %@", account.domain!) self._accounts = FetchRequest(sortDescriptors: [], predicate: predicate, animation: .default) + + self._newNotes = .init(initialValue: account.notes ?? "") } // MARK: - View