Skip to content

Commit

Permalink
Add Label Function to KeyType Enum
Browse files Browse the repository at this point in the history
  • Loading branch information
joelklabo committed Aug 19, 2023
1 parent 6c3faba commit a178e83
Showing 1 changed file with 7 additions and 10 deletions.
17 changes: 7 additions & 10 deletions demo/NostrSDKDemo/Views/KeyInputSectionView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,12 @@ import NostrSDK
enum KeyType {
case `public`
case `private`
var label: String {
switch self {
case .public: return "Public Key"
case .private: return "Private Key"
}
}
}

struct KeyInputSectionView: View {
Expand All @@ -22,7 +28,7 @@ struct KeyInputSectionView: View {

var body: some View {
HStack {
TextField(label(for: type),
TextField(type.label,
text: $key)
.font(.system(size: 16, weight: .regular, design: .monospaced))
.autocapitalization(.none)
Expand All @@ -46,15 +52,6 @@ struct KeyInputSectionView: View {
}
}

private func label(for type: KeyType) -> String {
switch type {
case .public:
return "Public Key"
case .private:
return "Private Key"
}
}

private func checkValidity(key: String, type: KeyType) -> Bool {
switch type {
case .public:
Expand Down

0 comments on commit a178e83

Please sign in to comment.