Download this file
| 1 | import SwiftUI |
| 2 | |
| 3 | // The one sanctioned platform seam in LChatCore (the NetNewsWire RSImage |
| 4 | // trick, anticipated in docs/native-chat.md): a decoded image is NSImage on |
| 5 | // the Mac and UIImage everywhere else, so image-handling code stays shared |
| 6 | // without the core growing real AppKit/UIKit dependencies. |
| 7 | #if canImport(AppKit) && !targetEnvironment(macCatalyst) |
| 8 | import AppKit |
| 9 | public typealias PlatformImage = NSImage |
| 10 | public typealias PlatformFont = NSFont |
| 11 | #else |
| 12 | import UIKit |
| 13 | public typealias PlatformImage = UIImage |
| 14 | public typealias PlatformFont = UIFont |
| 15 | #endif |
| 16 | |
| 17 | public extension Image { |
| 18 | init(platform image: PlatformImage) { |
| 19 | #if canImport(AppKit) && !targetEnvironment(macCatalyst) |
| 20 | self.init(nsImage: image) |
| 21 | #else |
| 22 | self.init(uiImage: image) |
| 23 | #endif |
| 24 | } |
| 25 | } |
| 26 | |