Skip to content

Commit

Permalink
Merge pull request #12 from antonmartinsson/2.4.1
Browse files Browse the repository at this point in the history
Add support for visionOS
  • Loading branch information
antonmartinsson authored Jun 8, 2024
2 parents 5ba704d + e144169 commit 8e4a4c9
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 19 deletions.
4 changes: 2 additions & 2 deletions Package.swift
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
// swift-tools-version:5.3
// swift-tools-version:5.9
// The swift-tools-version declares the minimum version of Swift required to build this package.

import PackageDescription

let package = Package(
name: "GaugeKit",
platforms: [
.macOS(.v11), .iOS(.v13), .watchOS(.v6)
.macOS(.v11), .iOS(.v13), .watchOS(.v6), .visionOS(.v1)
],
products: [
// Products define the executables and libraries a package produces, and make them visible to other packages.
Expand Down
22 changes: 5 additions & 17 deletions Sources/GaugeKit/CrossPlatform.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,27 +8,13 @@
import SwiftUI

class CrossPlatform {
static func mainScreenSize() -> CGSize {
#if os(macOS)
if let screenSize = NSScreen.main?.frame.size {
return screenSize
}
else {
// Use a generic FHD size so any calculations will still work
return CGSize(width: 1920, height: 1080)
}
#elseif os(iOS)
return UIScreen.main.bounds.size
#elseif os(watchOS)
return WKInterfaceDevice.current().screenBounds.size
#endif
}

static func systemBackgroundColor() -> Color {
#if os(macOS)
Color(NSColor.windowBackgroundColor)
#elseif os(iOS)
Color(UIColor.systemBackground)
#elseif os(visionOS)
Color.primary
#elseif os(watchOS)
Color.black
#endif
Expand All @@ -38,7 +24,9 @@ class CrossPlatform {
#if os(macOS)
Color(NSColor.labelColor)
#elseif os(iOS)
Color(UIColor.label)
Color(.label)
#elseif os(visionOS)
Color(.label)
#elseif os(watchOS)
Color.black
#endif
Expand Down

0 comments on commit 8e4a4c9

Please sign in to comment.