Skip to content

Commit

Permalink
Fix macOS 13.2 Display Issue (#66)
Browse files Browse the repository at this point in the history
* Attempt 1

* Fix

* style: variable names represent their values

* #available

* Fix `if #available`

Co-authored-by: TheMoonThatRises <[email protected]>
  • Loading branch information
IsaacMarovitz and TheMoonThatRises authored Jan 19, 2023
1 parent f420f3f commit 1e17f6d
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions PlayTools/PlayScreen.swift
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,11 @@ extension CGSize {
}

func toAspectRatio() -> CGSize {
return CGSize(width: mainScreenHeight, height: mainScreenWidth)
if #available(macCatalyst 16.3, *) {
return CGSize(width: mainScreenWidth, height: mainScreenHeight)
} else {
return CGSize(width: mainScreenHeight, height: mainScreenWidth)
}
}
}

Expand All @@ -34,11 +38,11 @@ extension CGRect {
}

func toAspectRatio() -> CGRect {
return CGRect(x: minX, y: minY, width: mainScreenHeight, height: mainScreenWidth)
return CGRect(x: minX, y: minY, width: mainScreenWidth, height: mainScreenHeight)
}

func toAspectRatioReversed() -> CGRect {
return CGRect(x: minX, y: minY, width: mainScreenWidth, height: mainScreenHeight)
return CGRect(x: minX, y: minY, width: mainScreenHeight, height: mainScreenWidth)
}
}

Expand All @@ -65,11 +69,11 @@ public class PlayScreen: NSObject {
@objc public static let shared = PlayScreen()

@objc public static func frame(_ rect: CGRect) -> CGRect {
return rect.toAspectRatio()
return rect.toAspectRatioReversed()
}

@objc public static func bounds(_ rect: CGRect) -> CGRect {
return rect.toAspectRatioReversed()
return rect.toAspectRatio()
}

@objc public static func width(_ size: Int) -> Int {
Expand Down

0 comments on commit 1e17f6d

Please sign in to comment.