Browse Source

Use PasteButton on iOS 16

main
Shadowfacts 2 months ago
parent
commit
02e229042a
  1. 26
      OTP/Views/EditKeyForm.swift

26
OTP/Views/EditKeyForm.swift

@ -41,15 +41,25 @@ struct EditKeyForm: View {
HStack {
TextField("Secret", text: $editedKey.secret)
Button {
self.editedKey.secret = UIPasteboard.general.string ?? ""
} label: {
Label("Paste", systemImage: "doc.on.clipboard")
.labelStyle(.iconOnly)
.foregroundColor(.accentColor)
if #available(iOS 16.0, *) {
PasteButton(payloadType: String.self) { pasted in
if let s = pasted.first {
self.editedKey.secret = s
}
}
.labelStyle(.iconOnly)
.buttonBorderShape(.capsule)
} else {
Button {
self.editedKey.secret = UIPasteboard.general.string ?? ""
} label: {
Label("Paste", systemImage: "doc.on.clipboard")
.labelStyle(.iconOnly)
.foregroundColor(.accentColor)
}
.buttonStyle(.plain)
.disabled(!UIPasteboard.general.hasStrings)
}
.buttonStyle(.plain)
.disabled(!UIPasteboard.general.hasStrings)
}
HStack {

Loading…
Cancel
Save