|
@@ -1,8 +1,73 @@
|
|
|
import Foundation
|
|
|
|
|
|
+public class VisionOSScreen: NSObject {
|
|
|
+
|
|
|
+ public static let main = VisionOSScreen()
|
|
|
+
|
|
|
+}
|
|
|
+
|
|
|
/** This file provides a thin abstraction layer atop of UIKit (iOS, tvOS) and Cocoa (OS X). The two APIs are very much
|
|
|
alike, and for the chart library's usage of the APIs it is often sufficient to typealias one to the other. The NSUI*
|
|
|
types are aliased to either their UI* implementation (on iOS) or their NS* implementation (on OS X). */
|
|
|
+#if os(visionOS)
|
|
|
+import UIKit
|
|
|
+
|
|
|
+public typealias ParagraphStyle = NSParagraphStyle
|
|
|
+public typealias MutableParagraphStyle = NSMutableParagraphStyle
|
|
|
+public typealias TextAlignment = NSTextAlignment
|
|
|
+public typealias NSUIFont = UIFont
|
|
|
+public typealias NSUIImage = UIImage
|
|
|
+public typealias NSUIScrollView = UIScrollView
|
|
|
+public typealias NSUIScreen = VisionOSScreen
|
|
|
+public typealias NSUIDisplayLink = CADisplayLink
|
|
|
+
|
|
|
+extension NSUIColor
|
|
|
+{
|
|
|
+ var nsuirgba: (red: CGFloat, green: CGFloat, blue: CGFloat, alpha: CGFloat)? {
|
|
|
+ var red: CGFloat = 0
|
|
|
+ var green: CGFloat = 0
|
|
|
+ var blue: CGFloat = 0
|
|
|
+ var alpha: CGFloat = 0
|
|
|
+
|
|
|
+ guard getRed(&red, green: &green, blue: &blue, alpha: &alpha) else {
|
|
|
+ return nil
|
|
|
+ }
|
|
|
+
|
|
|
+ return (red: red, green: green, blue: blue, alpha: alpha)
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+open class NSUIView: UIView
|
|
|
+{
|
|
|
+ @objc var nsuiLayer: CALayer?
|
|
|
+ {
|
|
|
+ return self.layer
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+extension UIScrollView
|
|
|
+{
|
|
|
+ @objc var nsuiIsScrollEnabled: Bool
|
|
|
+ {
|
|
|
+ get { return isScrollEnabled }
|
|
|
+ set { isScrollEnabled = newValue }
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+extension VisionOSScreen
|
|
|
+{
|
|
|
+ @objc final var nsuiScale: CGFloat
|
|
|
+ {
|
|
|
+ return 1
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+func NSUIMainScreen() -> NSUIScreen?
|
|
|
+{
|
|
|
+ return NSUIScreen.main
|
|
|
+}
|
|
|
+#endif
|
|
|
+
|
|
|
#if os(iOS) || os(tvOS)
|
|
|
import UIKit
|
|
|
|