secretive/Secretive/CreateSecureEnclaveSecretVi...

44 lines
1.1 KiB
Swift
Raw Normal View History

2020-03-04 07:14:38 +00:00
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)
}
2020-03-06 07:48:24 +00:00
Section {
2020-03-04 07:14:38 +00:00
Toggle(isOn: $requiresAuthentication) {
Text("Requires Authentication (Biometrics or Password)")
}
}
Section {
HStack {
Spacer()
Button(action: dismissalBlock) {
Text("Cancel")
}
Button(action: save) {
2020-03-07 03:01:45 +00:00
Text("Create")
2020-03-04 07:14:38 +00:00
}.disabled(name.isEmpty)
}
}
}
.padding()
.onExitCommand(perform: dismissalBlock)
}
func save() {
try! store.create(name: name, requiresAuthentication: requiresAuthentication)
dismissalBlock()
}
}