2020-03-04 07:14:38 +00:00
|
|
|
import SwiftUI
|
|
|
|
import SecretKit
|
|
|
|
|
|
|
|
struct SecretDetailView<SecretType: Secret>: View {
|
2020-09-22 06:12:50 +00:00
|
|
|
|
2020-03-04 07:14:38 +00:00
|
|
|
@State var secret: SecretType
|
|
|
|
|
2020-09-22 06:12:50 +00:00
|
|
|
private let keyWriter = OpenSSHKeyWriter()
|
|
|
|
|
2020-03-04 07:14:38 +00:00
|
|
|
var body: some View {
|
|
|
|
Form {
|
|
|
|
Section {
|
2020-09-22 06:12:50 +00:00
|
|
|
CopyableView(title: "Fingerprint", image: Image(systemName: "touchid"), text: keyWriter.openSSHFingerprint(secret: secret))
|
|
|
|
Spacer()
|
|
|
|
.frame(height: 20)
|
|
|
|
CopyableView(title: "Public Key", image: Image(systemName: "key"), text: keyWriter.openSSHString(secret: secret))
|
2020-03-06 06:53:04 +00:00
|
|
|
Spacer()
|
2020-03-04 07:14:38 +00:00
|
|
|
}
|
2020-09-22 06:12:50 +00:00
|
|
|
}
|
|
|
|
.padding()
|
|
|
|
.frame(minHeight: 200, maxHeight: .infinity)
|
2020-03-04 07:14:38 +00:00
|
|
|
}
|
2020-09-22 06:12:50 +00:00
|
|
|
|
2020-03-04 07:14:38 +00:00
|
|
|
var keyString: String {
|
|
|
|
keyWriter.openSSHString(secret: secret)
|
|
|
|
}
|
2020-09-22 06:12:50 +00:00
|
|
|
|
2020-03-04 07:14:38 +00:00
|
|
|
func copy() {
|
|
|
|
NSPasteboard.general.declareTypes([.string], owner: nil)
|
|
|
|
NSPasteboard.general.setString(keyString, forType: .string)
|
|
|
|
}
|
2020-09-22 06:12:50 +00:00
|
|
|
|
2020-03-04 07:14:38 +00:00
|
|
|
}
|
2020-03-12 04:58:32 +00:00
|
|
|
|
2020-03-12 06:07:22 +00:00
|
|
|
#if DEBUG
|
|
|
|
|
2020-03-12 04:58:32 +00:00
|
|
|
struct SecretDetailView_Previews: PreviewProvider {
|
|
|
|
static var previews: some View {
|
|
|
|
SecretDetailView(secret: Preview.Store(numberOfRandomSecrets: 1).secrets[0])
|
|
|
|
}
|
|
|
|
}
|
2020-03-12 06:07:22 +00:00
|
|
|
|
|
|
|
#endif
|