Skip to content

Commit

Permalink
Merge pull request #15 from klolev/main
Browse files Browse the repository at this point in the history
Added missing tvOS version checks
  • Loading branch information
sampettersson authored Jan 20, 2025
2 parents d48d965 + aa1de69 commit 8ddb72d
Show file tree
Hide file tree
Showing 9 changed files with 20 additions and 18 deletions.
4 changes: 3 additions & 1 deletion Placement.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@ Pod::Spec.new do |spec|
spec.homepage = "https://github.com/sampettersson/Placement"
spec.license = "MIT"
spec.author = { "Sam Pettersson" => "sam@sampettersson.com" }
spec.platform = :ios, "14.0"
spec.ios.deployment_target = "14.0"
spec.tvos.deployment_target = "14.0"
spec.visionos.deployment_target = "1.0"

spec.source = { :git => "https://github.com/sampettersson/Placement.git", :tag => "#{spec.version}" }

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ public struct PlacementLayoutProperties {
self.stackOrientation = nil
}

@available(iOS 16.0, macCatalyst 16, *)
@available(iOS 16.0, macCatalyst 16, tvOS 16.0, *)
var native: PlacementLayoutProperties {
var properties = PlacementLayoutProperties()
properties.stackOrientation = stackOrientation
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ struct LayoutPriorityValueKey: PlacementLayoutValueKey {
}
}

@available(iOS 16, OSX 13, *)
@available(iOS 16, OSX 13, tvOS 16.0, *)
struct LayoutValueKeyMapper<K: PlacementLayoutValueKey> {
struct Key: LayoutValueKey {
static var defaultValue: K.Value {
Expand All @@ -34,7 +34,7 @@ struct LayoutKeyValueModifier<K>: ViewModifier where K : PlacementLayoutValueKey
var value: K.Value

func body(content: Content) -> some View {
if #available(iOS 16.0, macCatalyst 16, *) {
if #available(iOS 16.0, macCatalyst 16, tvOS 16.0, *) {
content.layoutValue(key: LayoutValueKeyMapper<K>.Key.self, value: value)
} else {
content
Expand Down
2 changes: 1 addition & 1 deletion Sources/Placement/LayoutProtocol/PlacementLayout.swift
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ extension PlacementLayout {
@ViewBuilder public func callAsFunction<V: View>(
@ViewBuilder _ content: @escaping () -> V
) -> some View {
if #available(iOS 16, macCatalyst 16, *) {
if #available(iOS 16, macCatalyst 16, tvOS 16.0, *) {
if prefersLayoutProtocol {
PlacementLayoutNative(layoutBP: self).callAsFunction {
content()
Expand Down
6 changes: 3 additions & 3 deletions Sources/Placement/LayoutProtocol/PlacementLayoutNative.swift
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
import Foundation
import SwiftUI

@available(iOS 16.0, macCatalyst 16, *)
@available(iOS 16.0, macCatalyst 16, tvOS 16.0, *)
extension ProposedViewSize {
var placement: PlacementProposedViewSize {
PlacementProposedViewSize(width: width, height: height)
}
}

@available(iOS 16.0, macCatalyst 16, *)
@available(iOS 16.0, macCatalyst 16, tvOS 16.0, *)
extension PlacementProposedViewSize {
var proposedViewSize: ProposedViewSize {
ProposedViewSize(width: width, height: height)
}
}

@available(iOS 16.0, macCatalyst 16, *)
@available(iOS 16.0, macCatalyst 16, tvOS 16.0, *)
struct PlacementLayoutNative<L: PlacementLayout>: Layout {
var layoutBP: L

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public struct PlacementThatFits<Content: View>: View {
}

public var body: some View {
if #available(iOS 16.0, macCatalyst 16, *), prefersViewThatFits {
if #available(iOS 16.0, macCatalyst 16, tvOS 16.0, *), prefersViewThatFits {
ViewThatFits(in: axes) {
content()
}
Expand Down
14 changes: 7 additions & 7 deletions Sources/Placement/Spacing/PlacementViewSpacing.swift
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import Foundation
import SwiftUI

@available(iOS 16.0, macCatalyst 16, *)
@available(iOS 16.0, macCatalyst 16, tvOS 16.0, *)
extension ViewSpacing {
var placement: PlacementViewSpacing {
PlacementViewSpacing(underlyingViewSpacing: self)
Expand All @@ -12,7 +12,7 @@ extension ViewSpacing {
public struct PlacementViewSpacing {
private var _underlyingViewSpacing: Any? = nil

@available(iOS 16.0, macCatalyst 16, *)
@available(iOS 16.0, macCatalyst 16, tvOS 16.0, *)
var underlyingViewSpacing: ViewSpacing {
get {
_underlyingViewSpacing as! ViewSpacing
Expand All @@ -24,12 +24,12 @@ public struct PlacementViewSpacing {

/// Initializes an instance with default spacing values.
public init() {
if #available(iOS 16.0, macCatalyst 16, *) {
if #available(iOS 16.0, macCatalyst 16, tvOS 16.0, *) {
_underlyingViewSpacing = ViewSpacing()
}
}

@available(iOS 16.0, macCatalyst 16, *)
@available(iOS 16.0, macCatalyst 16, tvOS 16.0, *)
init(underlyingViewSpacing: ViewSpacing) {
_underlyingViewSpacing = underlyingViewSpacing.placement
}
Expand All @@ -39,7 +39,7 @@ public struct PlacementViewSpacing {

/// Gets the preferred spacing distance along the specified axis to the view that returns a specified spacing preference.
public func distance(to next: PlacementViewSpacing, along axis: Axis) -> CGFloat {
if #available(iOS 16.0, macCatalyst 16, *) {
if #available(iOS 16.0, macCatalyst 16, tvOS 16.0, *) {
return underlyingViewSpacing.distance(
to: next.underlyingViewSpacing,
along: axis
Expand All @@ -51,14 +51,14 @@ public struct PlacementViewSpacing {

/// Merges the spacing preferences of another spacing instance with this instance for a specified set of edges.
public mutating func formUnion(_ other: PlacementViewSpacing, edges: Edge.Set = .all) {
if #available(iOS 16.0, macCatalyst 16, *) {
if #available(iOS 16.0, macCatalyst 16, tvOS 16.0, *) {
underlyingViewSpacing.formUnion(other.underlyingViewSpacing, edges: edges)
}
}

/// Gets a new value that merges the spacing preferences of another spacing instance with this instance for a specified set of edges.
public func union(_ other: PlacementViewSpacing, edges: Edge.Set = .all) -> PlacementViewSpacing {
if #available(iOS 16.0, macCatalyst 16, *) {
if #available(iOS 16.0, macCatalyst 16, tvOS 16.0, *) {
return underlyingViewSpacing.union(other.underlyingViewSpacing, edges: edges).placement
} else {
return PlacementViewSpacing()
Expand Down
2 changes: 1 addition & 1 deletion Sources/Placement/Subview/PlacementLayoutSubview.swift
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ struct LayoutSubviewPolyfill: PlacementLayoutSubview {
var child: _VariadicView_Children.Element
}

@available(iOS 16.0, macCatalyst 16, *)
@available(iOS 16.0, macCatalyst 16, tvOS 16.0, *)
extension LayoutSubview: PlacementLayoutSubview {
public func dimensions(in proposal: PlacementProposedViewSize) -> PlacementViewDimensions {
let dimension = dimensions(in: proposal.proposedViewSize)
Expand Down
2 changes: 1 addition & 1 deletion Sources/Placement/Subview/PlacementLayoutSubviews.swift
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public struct PlacementLayoutSubviews: BidirectionalCollection, Collection, Comp
}

public static func == (lhs: PlacementLayoutSubviews, rhs: PlacementLayoutSubviews) -> Bool {
if #available(iOS 16.0, macCatalyst 16, *) {
if #available(iOS 16.0, macCatalyst 16, tvOS 16.0, *) {
let castedLhs = lhs.subviews as? [LayoutSubview]
let castedRhs = rhs.subviews as? [LayoutSubview]
return castedLhs == castedRhs
Expand Down

0 comments on commit 8ddb72d

Please sign in to comment.