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

Commit 4b55dfe

Browse files
committed
Added a notes field
1 parent 65b9fce commit 4b55dfe

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

Shared/Views/AccountView/AccountView+Content.swift

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,13 @@ extension AccountView {
5858
}
5959
AccountDetailsView(account: account, isEditing: $isEditing)
6060
.padding(.vertical)
61+
GroupBox {
62+
TextField("Notes", text: $newNotes, onCommit: {
63+
account.notes = newNotes
64+
65+
try? viewContext.save()
66+
}).textFieldStyle(.plain)
67+
}
6168
#if os(macOS)
6269
Spacer()
6370
#endif

Shared/Views/AccountView/AccountView.swift

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import SwiftUI
99

1010
struct AccountView: View {
1111
// MARK: - Environment
12-
@Environment(\.managedObjectContext) private var viewContext
12+
@Environment(\.managedObjectContext) var viewContext
1313

1414
// MARK: - CoreData
1515
@FetchRequest(
@@ -20,6 +20,8 @@ struct AccountView: View {
2020
// MARK: - Variables
2121
let account: Account
2222
@State var isEditing: Bool = false
23+
@State var newNotes: String = ""
24+
2325
@State private var isAddingAlternateDomains: Bool = false
2426
@State private var newAlternateDomains: String = ""
2527
@State private var isSharing: Bool = false
@@ -30,6 +32,8 @@ struct AccountView: View {
3032

3133
let predicate = NSPredicate(format: "domain contains[c] %@", account.domain!)
3234
self._accounts = FetchRequest(sortDescriptors: [], predicate: predicate, animation: .default)
35+
36+
self._newNotes = .init(initialValue: account.notes ?? "")
3337
}
3438

3539
// MARK: - View

0 commit comments

Comments
 (0)