From 21421df3266c99b83992face9e1523c8f1acb924 Mon Sep 17 00:00:00 2001 From: Enes Karaosman Date: Wed, 5 May 2021 16:27:05 +0300 Subject: [PATCH] [ADD] macOS support added. --- Package.swift | 3 +- .../SwiftUIEKtensions/DeviceOrientation.swift | 2 + .../Style/ColoredToggleStyle.swift | 46 ------------------- .../Views/DeviceOrientationBasedView.swift | 3 ++ .../Representables/ImagePickerView.swift | 2 + .../Views/Representables/MailView.swift | 2 + 6 files changed, 11 insertions(+), 47 deletions(-) delete mode 100644 Sources/SwiftUIEKtensions/Style/ColoredToggleStyle.swift diff --git a/Package.swift b/Package.swift index 668cae9..14d9441 100644 --- a/Package.swift +++ b/Package.swift @@ -6,7 +6,8 @@ import PackageDescription let package = Package( name: "SwiftUIEKtensions", platforms: [ - .iOS(.v13) + .iOS(.v13), + .macOS(.v11) ], products: [ // Products define the executables and libraries produced by a package, and make them visible to other packages. diff --git a/Sources/SwiftUIEKtensions/DeviceOrientation.swift b/Sources/SwiftUIEKtensions/DeviceOrientation.swift index 8736d4c..87cfd67 100644 --- a/Sources/SwiftUIEKtensions/DeviceOrientation.swift +++ b/Sources/SwiftUIEKtensions/DeviceOrientation.swift @@ -5,6 +5,7 @@ // Created by Enes Karaosman on 6.08.2020. // +#if canImport(UIKit) import class UIKit.UIDevice import SwiftUI @@ -48,3 +49,4 @@ final public class DeviceOrientationInfo: ObservableObject { } } +#endif diff --git a/Sources/SwiftUIEKtensions/Style/ColoredToggleStyle.swift b/Sources/SwiftUIEKtensions/Style/ColoredToggleStyle.swift deleted file mode 100644 index 0adc67d..0000000 --- a/Sources/SwiftUIEKtensions/Style/ColoredToggleStyle.swift +++ /dev/null @@ -1,46 +0,0 @@ -// -// ColoredToggleStyle.swift -// -// -// Created by Enes Karaosman on 14.07.2020. -// - -import SwiftUI - -public struct ColoredToggleStyle: ToggleStyle { - -// var label = "" - var onColor = Color(UIColor.green) - var offColor = Color(UIColor.systemGray5) - var thumbColor = Color.white - - public func makeBody(configuration: Self.Configuration) -> some View { - HStack { - configuration.label - Spacer() - Button(action: { configuration.isOn.toggle() } ) - { - RoundedRectangle(cornerRadius: 16, style: .circular) - .fill(configuration.isOn ? onColor : offColor) - .frame(width: 50, height: 29) - .overlay( - Circle() - .fill(thumbColor) - .shadow(radius: 1, x: 0, y: 1) - .padding(1.5) - .offset(x: configuration.isOn ? 10 : -10)) - .animation(Animation.easeInOut(duration: 0.1)) - } - } - .font(.title) - .padding(.horizontal) - } -} - -struct ColoredToggleStyle_Previews: PreviewProvider { - static var previews: some View { - Toggle(isOn: .constant(true), label: { - Text("Label") - }).toggleStyle(ColoredToggleStyle(onColor: .blue, offColor: .orange, thumbColor: .black)) - } -} diff --git a/Sources/SwiftUIEKtensions/Views/DeviceOrientationBasedView.swift b/Sources/SwiftUIEKtensions/Views/DeviceOrientationBasedView.swift index c4e96b0..23a0312 100644 --- a/Sources/SwiftUIEKtensions/Views/DeviceOrientationBasedView.swift +++ b/Sources/SwiftUIEKtensions/Views/DeviceOrientationBasedView.swift @@ -7,6 +7,8 @@ import SwiftUI +#if canImport(UIKit) + /** Recommended Usage, put `DeviceOrientationBasedView` inside let say in a page's body @@ -48,3 +50,4 @@ public struct DeviceOrientationBasedView: View { } } +#endif diff --git a/Sources/SwiftUIEKtensions/Views/Representables/ImagePickerView.swift b/Sources/SwiftUIEKtensions/Views/Representables/ImagePickerView.swift index 2b06227..2700ce1 100644 --- a/Sources/SwiftUIEKtensions/Views/Representables/ImagePickerView.swift +++ b/Sources/SwiftUIEKtensions/Views/Representables/ImagePickerView.swift @@ -35,6 +35,7 @@ import SwiftUI } */ +#if canImport(UIKit) public struct ImagePickerView: UIViewControllerRepresentable { private let sourceType: UIImagePickerController.SourceType @@ -86,3 +87,4 @@ public struct ImagePickerView: UIViewControllerRepresentable { } } +#endif diff --git a/Sources/SwiftUIEKtensions/Views/Representables/MailView.swift b/Sources/SwiftUIEKtensions/Views/Representables/MailView.swift index d32abb2..3acbb94 100644 --- a/Sources/SwiftUIEKtensions/Views/Representables/MailView.swift +++ b/Sources/SwiftUIEKtensions/Views/Representables/MailView.swift @@ -6,6 +6,7 @@ // import SwiftUI +#if canImport(UIKit) import MessageUI /** @@ -100,3 +101,4 @@ public struct MailView: UIViewControllerRepresentable { } } +#endif