mirror of
https://github.com/maxgoedjen/secretive.git
synced 2024-11-22 21:47:08 +00:00
44 lines
1.1 KiB
Swift
44 lines
1.1 KiB
Swift
import SwiftUI
|
|
import SecretKit
|
|
|
|
struct CreateSecureEnclaveSecretView: View {
|
|
|
|
@ObservedObject var store: SecureEnclave.Store
|
|
|
|
@State var name = ""
|
|
@State var requiresAuthentication = true
|
|
|
|
var dismissalBlock: () -> ()
|
|
|
|
var body: some View {
|
|
Form {
|
|
Section(header: Text("Secret Name")) {
|
|
TextField("Name", text: $name)
|
|
}
|
|
Section {
|
|
Toggle(isOn: $requiresAuthentication) {
|
|
Text("Requires Authentication (Biometrics or Password)")
|
|
}
|
|
}
|
|
Section {
|
|
HStack {
|
|
Spacer()
|
|
Button(action: dismissalBlock) {
|
|
Text("Cancel")
|
|
}
|
|
Button(action: save) {
|
|
Text("Create")
|
|
}.disabled(name.isEmpty)
|
|
}
|
|
}
|
|
}
|
|
.padding()
|
|
.onExitCommand(perform: dismissalBlock)
|
|
}
|
|
|
|
func save() {
|
|
try! store.create(name: name, requiresAuthentication: requiresAuthentication)
|
|
dismissalBlock()
|
|
}
|
|
}
|