diff --git a/Example/ContainerControllerSwift.xcodeproj/project.pbxproj b/Example/ContainerControllerSwift.xcodeproj/project.pbxproj index d6fada8..f00ccd6 100644 --- a/Example/ContainerControllerSwift.xcodeproj/project.pbxproj +++ b/Example/ContainerControllerSwift.xcodeproj/project.pbxproj @@ -1309,8 +1309,11 @@ MODULE_NAME = ExampleApp; PRODUCT_BUNDLE_IDENTIFIER = mrustaa.ContainerController; PRODUCT_NAME = ContainerController; + SUPPORTED_PLATFORMS = "iphoneos iphonesimulator xros xrsimulator"; + SUPPORTS_MACCATALYST = NO; SWIFT_SWIFT3_OBJC_INFERENCE = Default; SWIFT_VERSION = 5.0; + TARGETED_DEVICE_FAMILY = "1,2,7"; }; name = Debug; }; @@ -1325,8 +1328,11 @@ MODULE_NAME = ExampleApp; PRODUCT_BUNDLE_IDENTIFIER = mrustaa.ContainerController; PRODUCT_NAME = ContainerController; + SUPPORTED_PLATFORMS = "iphoneos iphonesimulator xros xrsimulator"; + SUPPORTS_MACCATALYST = NO; SWIFT_SWIFT3_OBJC_INFERENCE = Default; SWIFT_VERSION = 5.0; + TARGETED_DEVICE_FAMILY = "1,2,7"; }; name = Release; }; diff --git a/Example/ContainerControllerSwift/Framework/Utils/UIView+Positioning.swift b/Example/ContainerControllerSwift/Framework/Utils/UIView+Positioning.swift index 3d5f091..bb7add0 100755 --- a/Example/ContainerControllerSwift/Framework/Utils/UIView+Positioning.swift +++ b/Example/ContainerControllerSwift/Framework/Utils/UIView+Positioning.swift @@ -187,7 +187,11 @@ public extension UIView { // MARK: - Private Methods fileprivate func _pixelIntegral(_ pointValue: CGFloat) -> CGFloat { + #if os(iOS) let scale = UIScreen.main.scale return (round(pointValue * scale) / scale) + #else + return pointValue + #endif } } diff --git a/Example/ContainerControllerSwift/Maps/MapManager/MapViewManager.swift b/Example/ContainerControllerSwift/Maps/MapManager/MapViewManager.swift index ffda32b..fffa9db 100644 --- a/Example/ContainerControllerSwift/Maps/MapManager/MapViewManager.swift +++ b/Example/ContainerControllerSwift/Maps/MapManager/MapViewManager.swift @@ -50,7 +50,9 @@ class MapViewManager: NSObject { self.locationManager = CLLocationManager() self.locationManager?.delegate = self self.locationManager?.desiredAccuracy = kCLLocationAccuracyBest + #if os(iOS) self.locationManager?.requestAlwaysAuthorization() + #endif self.locationManager?.startUpdatingLocation() } } diff --git a/Example/ContainerControllerSwift/Maps/MapsViewController.swift b/Example/ContainerControllerSwift/Maps/MapsViewController.swift index 70b38fb..6c05358 100644 --- a/Example/ContainerControllerSwift/Maps/MapsViewController.swift +++ b/Example/ContainerControllerSwift/Maps/MapsViewController.swift @@ -44,7 +44,9 @@ class MapsViewController: StoryboardController, MapsContainerControllerDelegate, override func viewDidLoad() { super.viewDidLoad() + #if os(iOS) NotificationCenter.default.addObserver(self, selector: #selector(rotated), name: UIDevice.orientationDidChangeNotification, object: nil) + #endif updateMapManager() @@ -61,7 +63,9 @@ class MapsViewController: StoryboardController, MapsContainerControllerDelegate, navigationController?.navigationBar.isTranslucent = false + #if os(iOS) setNeedsStatusBarAppearanceUpdate() + #endif navBar(hide: true) if !showOnce { @@ -105,12 +109,14 @@ class MapsViewController: StoryboardController, MapsContainerControllerDelegate, // MARK: - Rotation Callback + #if os(iOS) @objc func rotated() { if !UIDevice.current.orientation.isRotateAllowed { return } updateMapViewTopPadding() } + #endif func updateMapViewTopPadding() { @@ -328,7 +334,9 @@ class MapsViewController: StoryboardController, MapsContainerControllerDelegate, let style: UIBlurEffect.Style = darkStyle ? .systemUltraThinMaterialDark : .regular statusBlur.effect = UIBlurEffect(style: style) + #if os(iOS) setNeedsStatusBarAppearanceUpdate() + #endif } // MARK: - Show Maps-Container diff --git a/Example/ContainerControllerSwift/Maps/UI/View/Maps/HeaderSearchBarView/HeaderSearchBarView.swift b/Example/ContainerControllerSwift/Maps/UI/View/Maps/HeaderSearchBarView/HeaderSearchBarView.swift index 691292d..40e9a7d 100644 --- a/Example/ContainerControllerSwift/Maps/UI/View/Maps/HeaderSearchBarView/HeaderSearchBarView.swift +++ b/Example/ContainerControllerSwift/Maps/UI/View/Maps/HeaderSearchBarView/HeaderSearchBarView.swift @@ -27,10 +27,12 @@ class HeaderSearchBarView: XibView { searchBar.placeholder = _L("LNG_MAPS_SEARCH_PLACE_ADDRESS") let textFieldInsideSearchBar = searchBar.value(forKey: "searchField") as? UITextField - let imageV = textFieldInsideSearchBar?.leftView as! UIImageView - imageV.image = imageV.image?.withRenderingMode(UIImage.RenderingMode.alwaysTemplate) -// imageV.image = imageV.image?.imageWithRenderingMode(UIImageRenderingMode.AlwaysTemplate) - imageV.tintColor = Colors.rgb(128, 128, 128) + if let imageV = textFieldInsideSearchBar?.leftView as? UIImageView + { + imageV.image = imageV.image?.withRenderingMode(UIImage.RenderingMode.alwaysTemplate) +// imageV.image = imageV.image?.imageWithRenderingMode(UIImageRenderingMode.AlwaysTemplate) + imageV.tintColor = Colors.rgb(128, 128, 128) + } } func set(darkStyle: Bool) { diff --git a/Example/Pods/Pods.xcodeproj/project.pbxproj b/Example/Pods/Pods.xcodeproj/project.pbxproj index 8ab8f7a..2081b68 100644 --- a/Example/Pods/Pods.xcodeproj/project.pbxproj +++ b/Example/Pods/Pods.xcodeproj/project.pbxproj @@ -608,10 +608,12 @@ PRODUCT_NAME = ContainerControllerSwift; SDKROOT = iphoneos; SKIP_INSTALL = YES; + SUPPORTED_PLATFORMS = "iphoneos iphonesimulator xros xrsimulator"; + SUPPORTS_MACCATALYST = YES; SWIFT_ACTIVE_COMPILATION_CONDITIONS = "$(inherited) "; SWIFT_OPTIMIZATION_LEVEL = "-Onone"; SWIFT_VERSION = 5.2.4; - TARGETED_DEVICE_FAMILY = "1,2"; + TARGETED_DEVICE_FAMILY = "1,2,7"; VERSIONING_SYSTEM = "apple-generic"; VERSION_INFO_PREFIX = ""; }; @@ -676,9 +678,11 @@ PRODUCT_NAME = ContainerControllerSwift; SDKROOT = iphoneos; SKIP_INSTALL = YES; + SUPPORTED_PLATFORMS = "iphoneos iphonesimulator xros xrsimulator"; + SUPPORTS_MACCATALYST = YES; SWIFT_ACTIVE_COMPILATION_CONDITIONS = "$(inherited) "; SWIFT_VERSION = 5.2.4; - TARGETED_DEVICE_FAMILY = "1,2"; + TARGETED_DEVICE_FAMILY = "1,2,7"; VALIDATE_PRODUCT = YES; VERSIONING_SYSTEM = "apple-generic"; VERSION_INFO_PREFIX = ""; @@ -713,7 +717,9 @@ PRODUCT_NAME = "$(TARGET_NAME:c99extidentifier)"; SDKROOT = iphoneos; SKIP_INSTALL = YES; - TARGETED_DEVICE_FAMILY = "1,2"; + SUPPORTED_PLATFORMS = "iphoneos iphonesimulator xros xrsimulator"; + SUPPORTS_MACCATALYST = YES; + TARGETED_DEVICE_FAMILY = "1,2,7"; VALIDATE_PRODUCT = YES; VERSIONING_SYSTEM = "apple-generic"; VERSION_INFO_PREFIX = ""; @@ -812,7 +818,9 @@ PRODUCT_NAME = "$(TARGET_NAME:c99extidentifier)"; SDKROOT = iphoneos; SKIP_INSTALL = YES; - TARGETED_DEVICE_FAMILY = "1,2"; + SUPPORTED_PLATFORMS = "iphoneos iphonesimulator xros xrsimulator"; + SUPPORTS_MACCATALYST = YES; + TARGETED_DEVICE_FAMILY = "1,2,7"; VERSIONING_SYSTEM = "apple-generic"; VERSION_INFO_PREFIX = ""; }; diff --git a/Sources/ContainerController/ContainerController.swift b/Sources/ContainerController/ContainerController.swift index 3b5a13f..83ad544 100644 --- a/Sources/ContainerController/ContainerController.swift +++ b/Sources/ContainerController/ContainerController.swift @@ -178,7 +178,9 @@ open class ContainerController: NSObject { self.controller = controller set(layout: layout) + #if os(iOS) NotificationCenter.default.addObserver(self, selector: #selector(rotated), name: UIDevice.orientationDidChangeNotification, object: nil) + #endif createShadowButton() createContainerView() @@ -209,6 +211,7 @@ open class ContainerController: NSObject { // MARK: - Rotated + #if os(iOS) @objc func rotated() { if !UIDevice.current.orientation.isRotateAllowed { return } @@ -225,6 +228,7 @@ open class ContainerController: NSObject { move(type: moveType, from: .rotation) } + #endif // MARK: - Update Layout diff --git a/Sources/ContainerController/ContainerDevice.swift b/Sources/ContainerController/ContainerDevice.swift index 7738823..a73a4b3 100644 --- a/Sources/ContainerController/ContainerDevice.swift +++ b/Sources/ContainerController/ContainerDevice.swift @@ -22,8 +22,20 @@ open class ContainerDevice { // MARK: - Size - class public var width: CGFloat { UIScreen.main.bounds.size.width } - class public var height: CGFloat { UIScreen.main.bounds.size.height } + class public var width: CGFloat { + #if os(iOS) + UIScreen.main.bounds.size.width + #else + UIApplication.shared.connectedScenes.compactMap { ($0 as? UIWindowScene)?.keyWindow }.last?.bounds.size.width ?? 0 + #endif + } + class public var height: CGFloat { + #if os(iOS) + UIScreen.main.bounds.size.height + #else + UIApplication.shared.connectedScenes.compactMap { ($0 as? UIWindowScene)?.keyWindow }.last?.bounds.size.height ?? 0 + #endif + } class public var frame: CGRect { CGRect(x: 0, y: 0, width: width, height: height) } @@ -36,7 +48,13 @@ open class ContainerDevice { static public let isIpad = UIDevice.current.userInterfaceIdiom == .pad static public let isIphone = UIDevice.current.userInterfaceIdiom == .phone - static public let isRetina = UIScreen.main.scale >= 2.0 + static public let isRetina = { + #if os(iOS) + UIScreen.main.scale >= 2.0 + #else + true + #endif + } class public var isIphone4: Bool { (isIphone && screenMax < 568.0) } class public var isIphone5: Bool { (isIphone && screenMax == 568.0) } // SE @@ -74,6 +92,7 @@ open class ContainerDevice { var portrait: Bool = false + #if os(iOS) let size: CGSize = UIScreen.main.bounds.size if size.width / size.height > 1 { portrait = false @@ -88,6 +107,7 @@ open class ContainerDevice { portrait = true default: break } + #endif return portrait }