Also fixes real bugs found while making Phase 4 build clean on both platforms: - FileBookmarkService used .withSecurityScope unconditionally, but that bookmark option is macOS-only -- iOS grants scoped access automatically once the user picks a file. Now conditional per platform. - EntryEditViewModel's groupId was non-optional with no default, but EntryDetailView's edit-sheet call site (Task 14) has no group reference to pass -- only the "add new entry" path actually needs it, so groupId is now optional and validated at save time instead. - Missing `import Combine` in EntryDetailView (Timer.publish/autoconnect) and UnlockViewModel/VaultViewModel/EntryEditViewModel (@Published). - GroupBrowserView's `group: Group` property collided with SwiftUI's own Group view type -- qualified as MyPassCore.Group. - EntryEditView's .keyboardType(.URL) and .navigationBarTitleDisplayMode are iOS-only APIs, guarded with #if os(iOS) for the macOS build. Verified clean (aside from the known, expected ContentView.swift/Item breakage) on both iOS Simulator and macOS destinations. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01WYqycDFsynHH9VnnK7LNSf
73 lines
2.5 KiB
Swift
73 lines
2.5 KiB
Swift
//
|
|
// EntryEditView.swift
|
|
// MyPass
|
|
//
|
|
|
|
import SwiftUI
|
|
import MyPassCore
|
|
|
|
struct EntryEditView: View {
|
|
@ObservedObject var vm: EntryEditViewModel
|
|
@Environment(\.dismiss) private var dismiss
|
|
|
|
var body: some View {
|
|
NavigationStack {
|
|
Form {
|
|
Section("Credentials") {
|
|
TextField("Title", text: $vm.title)
|
|
TextField("Username", text: $vm.username)
|
|
.textContentType(.username)
|
|
.autocorrectionDisabled()
|
|
SecureField("Password", text: $vm.password)
|
|
.textContentType(.password)
|
|
TextField("URL", text: $vm.url)
|
|
.textContentType(.URL)
|
|
#if os(iOS)
|
|
.keyboardType(.URL)
|
|
#endif
|
|
.autocorrectionDisabled()
|
|
}
|
|
|
|
Section("Notes") {
|
|
TextEditor(text: $vm.notes)
|
|
.frame(minHeight: 80)
|
|
}
|
|
|
|
Section {
|
|
ForEach($vm.customFields) { $field in
|
|
HStack {
|
|
TextField("Key", text: $field.key)
|
|
Divider()
|
|
TextField("Value", text: Binding(
|
|
get: { field.value.reveal() },
|
|
set: { field.value = ProtectedString($0, isProtected: field.value.isProtected) }
|
|
))
|
|
}
|
|
}
|
|
.onDelete(perform: vm.removeCustomField)
|
|
Button("Add Field", action: vm.addCustomField)
|
|
} header: {
|
|
Text("Custom Fields")
|
|
}
|
|
|
|
if let msg = vm.errorMessage {
|
|
Section { Text(msg).foregroundStyle(.red) }
|
|
}
|
|
}
|
|
.navigationTitle(vm.isEditing ? "Edit Entry" : "New Entry")
|
|
#if os(iOS)
|
|
.navigationBarTitleDisplayMode(.inline)
|
|
#endif
|
|
.toolbar {
|
|
ToolbarItem(placement: .cancellationAction) {
|
|
Button("Cancel") { dismiss() }
|
|
}
|
|
ToolbarItem(placement: .confirmationAction) {
|
|
Button("Save") { vm.save { dismiss() } }
|
|
.disabled(vm.title.isEmpty || vm.isSaving)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|