Skip to content

Commit

Permalink
Compatibility with tvOS
Browse files Browse the repository at this point in the history
  • Loading branch information
richardtop committed Mar 20, 2023
1 parent ced37ab commit 2154298
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 6 deletions.
1 change: 1 addition & 0 deletions Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ let package = Package(
defaultLocalization: "en",
platforms: [
.iOS(.v11),
.tvOS(.v11)
],
products: [
// Products define the executables and libraries produced by a package, and make them visible to other packages.
Expand Down
25 changes: 20 additions & 5 deletions Sources/Extensions/UIColor+SystemColors.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2,55 +2,70 @@ import UIKit

public enum SystemColors {
public static var label: UIColor {
if #available(iOS 13, *) {
if #available(iOS 13, tvOS 13, *) {
return .label
}
return .black
}

public static var secondaryLabel: UIColor {
if #available(iOS 13, *) {
if #available(iOS 13, tvOS 13, *) {
return .secondaryLabel
}
return .lightGray
}

public static var systemBackground: UIColor {
#if os(iOS)
if #available(iOS 13, *) {
return .systemBackground
}
#endif
return .white
}

public static var secondarySystemBackground: UIColor {
#if os(iOS)
if #available(iOS 13, *) {
return .secondarySystemBackground
}
#endif
return UIColor(white: 247/255, alpha: 1)
}

public static var systemRed: UIColor {
if #available(iOS 13, *) {
return .systemRed
}
return .red
}

public static var systemBlue: UIColor {
if #available(iOS 13, *) {
return .systemBlue
}
return .blue
}

public static var systemGray4: UIColor {
#if os(iOS)
if #available(iOS 13, *) {
return .systemGray4
}
#endif
return UIColor(red: 209/255,
green: 209/255,
blue: 213/255, alpha: 1)
blue: 213/255,
alpha: 1)
}

public static var systemSeparator: UIColor {
if #available(iOS 13, *) {
if #available(iOS 13, tvOS 13, *) {
return .opaqueSeparator
}
return UIColor(red: 198/255,
green: 198/255,
blue: 200/255, alpha: 1)
blue: 200/255,
alpha: 1)
}
}
2 changes: 1 addition & 1 deletion Sources/Timeline/Event.swift
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ public final class Event: EventDescriptor {
}

private func dynamicColor(light: UIColor, dark: UIColor) -> UIColor {
if #available(iOS 13.0, *) {
if #available(iOS 13, tvOS 13, *) {
return UIColor { traitCollection in
let interfaceStyle = traitCollection.userInterfaceStyle
switch interfaceStyle {
Expand Down

0 comments on commit 2154298

Please sign in to comment.