Skip to content

Commit

Permalink
Add supports for tvOS targets
Browse files Browse the repository at this point in the history
  • Loading branch information
ktiays committed Oct 4, 2023
1 parent f6417a2 commit f11704f
Show file tree
Hide file tree
Showing 10 changed files with 26 additions and 20 deletions.
2 changes: 1 addition & 1 deletion Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import PackageDescription

let package = Package(
name: "CyanKit",
platforms: [.iOS(.v14), .macOS(.v11)],
platforms: [.iOS(.v14), .macOS(.v11), .tvOS(.v14)],
products: [
.library(
name: "CyanKit",
Expand Down
2 changes: 1 addition & 1 deletion Sources/CyanExtensions/PlatformFont+Extension.swift
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
// Copyright (c) 2022 ktiays. All rights reserved.
//

#if os(iOS)
#if canImport(UIKit)
import UIKit
public typealias PlatformFont = UIFont
#else
Expand Down
4 changes: 3 additions & 1 deletion Sources/CyanSwiftUI/AnimatedClickable.swift
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ private struct _AnimatedClickableView<V>: View where V: View {
: configuration.identityModifier)
#if os(iOS)
.overlay(gestureView())
#else
#elseif os(macOS)
.highPriorityGesture(dragGesture())
#endif
}
Expand Down Expand Up @@ -200,6 +200,7 @@ private struct _AnimatedClickableView<V>: View where V: View {
}
#endif

#if os(macOS)
private func dragGesture() -> some Gesture {
DragGesture(minimumDistance: 0)
.onChanged { value in
Expand All @@ -222,6 +223,7 @@ private struct _AnimatedClickableView<V>: View where V: View {
}
}
}
#endif

private func sizeReader() -> some View {
GeometryReader { proxy in
Expand Down
10 changes: 5 additions & 5 deletions Sources/CyanSwiftUI/Extensions/Color.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ import CyanExtensions
public extension Color {

init(platformColor: PlatformColor) {
#if os(iOS)
if #available(iOS 15.0, *) {
#if canImport(UIKit)
if #available(iOS 15.0, tvOS 15.0, *) {
self.init(uiColor: platformColor)
} else {
self.init(platformColor)
Expand Down Expand Up @@ -63,11 +63,11 @@ public extension Color {
static let systemTeal: Color = .init(platformColor: .systemTeal)

/// A context-dependent cyan color that automatically adapts to the current trait environment.
@available(iOS 15.0, macOS 12.0, *)
@available(iOS 15.0, macOS 12.0, tvOS 15.0, *)
static let systemCyan: Color = .init(platformColor: .systemCyan)

/// A context-dependent mint color that automatically adapts to the current trait environment.
@available(iOS 15.0, macOS 12.0, *)
@available(iOS 15.0, macOS 12.0, tvOS 15.0, *)
static let systemMint: Color = .init(platformColor: .systemMint)


Expand All @@ -76,7 +76,7 @@ public extension Color {
/// A context-dependent gray color that automatically adapts to the current trait environment.
static let systemGray: Color = .init(platformColor: .systemGray)

#if canImport(UIKit)
#if canImport(UIKit) && !os(tvOS)

/// A second-level shade of gray that adapts to the environment.
///
Expand Down
2 changes: 1 addition & 1 deletion Sources/CyanUI/Banner/BannerManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
// Copyright (c) 2022 ktiays. All rights reserved.
//

#if canImport(UIKit)
#if os(iOS) || targetEnvironment(macCatalyst)

import SwiftUI
import UIKit
Expand Down
2 changes: 1 addition & 1 deletion Sources/CyanUI/Banner/PillContainerView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
// Copyright (c) 2022 ktiays. All rights reserved.
//

#if canImport(UIKit)
#if os(iOS) || targetEnvironment(macCatalyst)

import UIKit
import SwiftUI
Expand Down
2 changes: 1 addition & 1 deletion Sources/CyanUI/Banner/PillContainerViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
// Copyright (c) 2022 ktiays. All rights reserved.
//

#if canImport(UIKit)
#if os(iOS) || targetEnvironment(macCatalyst)

import UIKit
import SwiftUI
Expand Down
12 changes: 6 additions & 6 deletions Sources/CyanUI/Duotone.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import SwiftUI
import CyanExtensions

@available(iOS 15.0, macOS 12.0, *)
@available(iOS 15.0, macOS 12.0, tvOS 15.0, *)
public protocol DuotoneIconStyle {

typealias Configuration = DuotoneIconConfiguration
Expand All @@ -17,14 +17,14 @@ public protocol DuotoneIconStyle {

}

@available(iOS 15.0, macOS 12.0, *)
@available(iOS 15.0, macOS 12.0, tvOS 15.0, *)
public struct DuotoneIconConfiguration {
public let context: GraphicsContext
public let bounds: CGRect
public let isHighlighted: Bool
}

@available(iOS 15.0, macOS 12.0, *)
@available(iOS 15.0, macOS 12.0, tvOS 15.0, *)
public struct IconColorConfiguration {
public let primaryColor: Color
public let highlightPrimaryColor: Color
Expand All @@ -46,7 +46,7 @@ public struct IconColorConfiguration {
}
}

@available(iOS 15.0, macOS 12.0, *)
@available(iOS 15.0, macOS 12.0, tvOS 15.0, *)
public struct IconColorConfigurationKey: EnvironmentKey {
public static var defaultValue: IconColorConfiguration? {
let primaryColor: Color = .init(lightColor: .label, darkColor: .white)
Expand All @@ -56,15 +56,15 @@ public struct IconColorConfigurationKey: EnvironmentKey {
}
}

@available(iOS 15.0, macOS 12.0, *)
@available(iOS 15.0, macOS 12.0, tvOS 15.0, *)
public extension EnvironmentValues {
var iconColorConfiguration: IconColorConfiguration? {
get { self[IconColorConfigurationKey.self] }
set { self[IconColorConfigurationKey.self] = newValue }
}
}

@available(iOS 15.0, macOS 12.0, *)
@available(iOS 15.0, macOS 12.0, tvOS 15.0, *)
public struct DuotoneIcon<S>: View where S: DuotoneIconStyle {

@Environment(\.iconColorConfiguration) var iconColorConfiguration
Expand Down
4 changes: 4 additions & 0 deletions Sources/CyanUI/SegmentedControl.swift
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
// Copyright (c) 2021 ktiays. All rights reserved.
//

#if os(iOS) || targetEnvironment(macCatalyst)

import SwiftUI
import CyanExtensions

Expand Down Expand Up @@ -179,3 +181,5 @@ struct SegmentedControl_Previews: PreviewProvider {
PreviewView()
}
}

#endif
6 changes: 3 additions & 3 deletions Tests/CyanConcurrencyTests/ExtensionsTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@
import XCTest
@testable import CyanConcurrency

@available(macOS 13.0, iOS 16.0, *)
@available(macOS 13.0, iOS 16.0, tvOS 16.0, *)
fileprivate func fakeAsyncTransformer(_ input: Int) async -> String {
try? await Task.sleep(for: .milliseconds(10))
return "\(input)"
}

@available(macOS 13.0, iOS 16.0, *)
@available(macOS 13.0, iOS 16.0, tvOS 16.0, *)
fileprivate func fakeAsyncTransformerThrows(_ input: Int) async throws -> String {
if input % 2 == 0 {
struct _DummyError: Error { }
Expand All @@ -21,7 +21,7 @@ fileprivate func fakeAsyncTransformerThrows(_ input: Int) async throws -> String
return await fakeAsyncTransformer(input)
}

@available(macOS 13.0, iOS 16.0, *)
@available(macOS 13.0, iOS 16.0, tvOS 16.0, *)
final class ConcurrencyAlgorithmsTests: XCTestCase {

func testArrayMap() async {
Expand Down

0 comments on commit f11704f

Please sign in to comment.