Skip to content

Commit

Permalink
Enable macos support
Browse files Browse the repository at this point in the history
  • Loading branch information
abdullah-original committed Mar 1, 2024
1 parent 5b4a0c2 commit 015a648
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 11 deletions.
2 changes: 1 addition & 1 deletion Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import PackageDescription

let package = Package(
name: "ExtendedDatePicker",
platforms: [.iOS(.v14), .macCatalyst(.v14), .macOS(.v12)],
platforms: [.iOS(.v14), .macCatalyst(.v14), .macOS(.v11)],
products: [
.library(
name: "ExtendedDatePicker",
Expand Down
16 changes: 9 additions & 7 deletions Sources/ExtendedDatePicker.swift
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
#if os(iOS)
#if os(iOS) || os(macOS)
import SwiftUI

public struct ExtendedDatePicker: View {
@State private var isPickerPresented = false

private var canUsePopover: Bool {
if #available(iOS 16.4, *), options.shouldUseWheelStyleDatePicker {
if #available(iOS 16.4, macCatalyst 16.4, macOS 13.3, *), options.shouldUseWheelStyleDatePicker {
return true
}

Expand Down Expand Up @@ -34,13 +34,15 @@ public struct ExtendedDatePicker: View {
}

public var body: some View {
if canUsePopover, #available(iOS 16.4, *) {
if canUsePopover, #available(iOS 16.4, macCatalyst 16.4, macOS 13.3, *) {
header()
.popover(isPresented: $isPickerPresented) {
datePicker()
.datePickerStyle(.wheel)
.pickerStyle(.wheel)
.presentationCompactAdaptation(.popover)
datePicker()
.presentationCompactAdaptation(.popover)
#if os(iOS)
.datePickerStyle(.wheel)
.pickerStyle(.wheel)
#endif
}
} else {
header()
Expand Down
3 changes: 0 additions & 3 deletions Sources/ExtendedDatePickerOptions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,19 @@ import SwiftUI
public struct ExtendedDatePickerOptions {
let backSymbol: Image
let forwardSymbol: Image
let horizontalPadding: CGFloat?
let header: ((Date) -> AnyView)?
let spacing: CGFloat?
let shouldUseWheelStyleDatePicker: Bool

public init(
backSymbol: Image = .init(systemName: "chevron.left"),
forwardSymbol: Image = .init(systemName: "chevron.right"),
horizontalPadding: CGFloat? = nil,
header: ((Date) -> AnyView)? = nil,
spacing: CGFloat? = nil,
shouldUseWheelStyleDatePicker: Bool = true
) {
self.backSymbol = backSymbol
self.forwardSymbol = forwardSymbol
self.horizontalPadding = horizontalPadding
self.header = header
self.spacing = spacing
self.shouldUseWheelStyleDatePicker = shouldUseWheelStyleDatePicker
Expand Down

0 comments on commit 015a648

Please sign in to comment.