refactor(android): centralize clipboard handling
This commit is contained in:
@@ -181,31 +181,20 @@ struct OtpView: View {
|
||||
}
|
||||
|
||||
private func pasteOtpFromClipboard() {
|
||||
#if canImport(UIKit)
|
||||
let raw = UIPasteboard.general.string ?? ""
|
||||
let raw = appReadClipboardText() ?? ""
|
||||
let digits = raw.filter(\.isNumber)
|
||||
let trimmed = String(digits.prefix(8))
|
||||
if trimmed.isEmpty == false {
|
||||
otp = trimmed
|
||||
}
|
||||
#elseif canImport(AppKit)
|
||||
let raw = NSPasteboard.general.string(forType: .string) ?? ""
|
||||
let digits = raw.filter(\.isNumber)
|
||||
let trimmed = String(digits.prefix(8))
|
||||
if trimmed.isEmpty == false {
|
||||
otp = trimmed
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
private func autoFillOtpFromClipboardIfAvailable() {
|
||||
#if canImport(UIKit)
|
||||
guard otp.isEmpty else { return }
|
||||
let raw = UIPasteboard.general.string ?? ""
|
||||
let raw = appReadClipboardText() ?? ""
|
||||
let digits = raw.filter(\.isNumber)
|
||||
guard digits.count >= 8 else { return }
|
||||
otp = String(digits.prefix(8))
|
||||
#endif
|
||||
}
|
||||
|
||||
private var otpDeliveryMessage: String {
|
||||
|
||||
@@ -692,12 +692,7 @@ struct PaymentPixView: View {
|
||||
}
|
||||
|
||||
private func copyToClipboard(_ value: String) {
|
||||
#if canImport(UIKit)
|
||||
UIPasteboard.general.string = value
|
||||
#elseif canImport(AppKit)
|
||||
NSPasteboard.general.clearContents()
|
||||
NSPasteboard.general.setString(value, forType: .string)
|
||||
#endif
|
||||
appWriteClipboardText(value)
|
||||
}
|
||||
|
||||
private var parsedExpirationDate: Date? {
|
||||
|
||||
Reference in New Issue
Block a user