refactor(android): centralize clipboard handling
This commit is contained in:
@@ -11,6 +11,10 @@ import CoreGraphics
|
||||
import UIKit
|
||||
#endif
|
||||
|
||||
#if canImport(AppKit)
|
||||
import AppKit
|
||||
#endif
|
||||
|
||||
#if !canImport(UIKit)
|
||||
struct UIDevice {
|
||||
static let topNotch = 0.0
|
||||
@@ -32,6 +36,31 @@ func printError(title: String, msg: String) {
|
||||
}
|
||||
#endif
|
||||
|
||||
func appReadClipboardText() -> String? {
|
||||
#if canImport(UIKit)
|
||||
return UIPasteboard.general.string
|
||||
#elseif canImport(AppKit)
|
||||
return NSPasteboard.general.string(forType: .string)
|
||||
#elseif os(Android)
|
||||
return UIPasteboard.general.string
|
||||
#else
|
||||
return nil
|
||||
#endif
|
||||
}
|
||||
|
||||
func appWriteClipboardText(_ value: String) {
|
||||
#if canImport(UIKit)
|
||||
UIPasteboard.general.string = value
|
||||
#elseif canImport(AppKit)
|
||||
NSPasteboard.general.clearContents()
|
||||
NSPasteboard.general.setString(value, forType: .string)
|
||||
#elseif os(Android)
|
||||
UIPasteboard.general.string = value
|
||||
#else
|
||||
_ = value
|
||||
#endif
|
||||
}
|
||||
|
||||
extension View {
|
||||
@ViewBuilder
|
||||
func appInlineNavigationTitle() -> some View {
|
||||
|
||||
Reference in New Issue
Block a user