Skip to content
This repository has been archived by the owner on Oct 6, 2023. It is now read-only.

Commit

Permalink
Added a notes field
Browse files Browse the repository at this point in the history
  • Loading branch information
EthanLipnik committed Aug 24, 2021
1 parent 65b9fce commit 4b55dfe
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
7 changes: 7 additions & 0 deletions Shared/Views/AccountView/AccountView+Content.swift
Expand Up @@ -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
Expand Down
6 changes: 5 additions & 1 deletion Shared/Views/AccountView/AccountView.swift
Expand Up @@ -9,7 +9,7 @@ import SwiftUI

struct AccountView: View {
// MARK: - Environment
@Environment(\.managedObjectContext) private var viewContext
@Environment(\.managedObjectContext) var viewContext

// MARK: - CoreData
@FetchRequest(
Expand All @@ -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
Expand All @@ -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
Expand Down

0 comments on commit 4b55dfe

Please sign in to comment.