mirror of
https://github.com/maxgoedjen/secretive.git
synced 2024-12-23 12:47:08 +00:00
edf01cc6d4
* Switch test to Big Sur * Switch to new logger api * Fix versions * .
54 lines
1.6 KiB
Swift
54 lines
1.6 KiB
Swift
import SwiftUI
|
|
import SecretKit
|
|
|
|
struct CreateSecretView<StoreType: SecretStoreModifiable>: View {
|
|
|
|
@ObservedObject var store: StoreType
|
|
@Binding var showing: Bool
|
|
|
|
@State private var name = ""
|
|
@State private var requiresAuthentication = true
|
|
|
|
var body: some View {
|
|
VStack {
|
|
HStack {
|
|
Image(nsImage: NSApp.applicationIconImage)
|
|
.resizable()
|
|
.frame(width: 64, height: 64)
|
|
.padding()
|
|
VStack {
|
|
HStack {
|
|
Text("Create a New Secret").bold()
|
|
Spacer()
|
|
}
|
|
HStack {
|
|
Text("Name:")
|
|
TextField("Shhhhh", text: $name).focusable()
|
|
}
|
|
HStack {
|
|
Toggle(isOn: $requiresAuthentication) {
|
|
Text("Requires Authentication (Biometrics or Password)")
|
|
}
|
|
Spacer()
|
|
}
|
|
}
|
|
}
|
|
HStack {
|
|
Spacer()
|
|
Button("Cancel") {
|
|
showing = false
|
|
}
|
|
.keyboardShortcut(.cancelAction)
|
|
Button("Create", action: save)
|
|
.disabled(name.isEmpty)
|
|
.keyboardShortcut(.defaultAction)
|
|
}
|
|
}.padding()
|
|
}
|
|
|
|
func save() {
|
|
try! store.create(name: name, requiresAuthentication: requiresAuthentication)
|
|
showing = false
|
|
}
|
|
}
|