Skip to content

Commit 06f6bca

Browse files
Merge pull request #213 from quickbirdstudios/more-platforms
Draft: tvOS Support
2 parents 44841fb + 2058e6b commit 06f6bca

File tree

6 files changed

+34
-10
lines changed

6 files changed

+34
-10
lines changed

Package.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import PackageDescription
55

66
let package = Package(
77
name: "XCoordinator",
8-
platforms: [.iOS(.v9)],
8+
platforms: [.iOS(.v9), .tvOS(.v9)],
99
products: [
1010
// Products define the executables and libraries produced by a package, and make them visible to other packages.
1111
.library(

Sources/XCoordinator/InterruptibleTransitionAnimation.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import UIKit
1212
/// [UIViewPropertyAnimator](https://developer.apple.com/documentation/uikit/UIViewPropertyAnimator)
1313
/// APIs introduced in iOS 10.
1414
///
15-
@available(iOS 10.0, *)
15+
@available(iOS 10.0, tvOS 10.0, *)
1616
open class InterruptibleTransitionAnimation: InteractiveTransitionAnimation {
1717

1818
// MARK: Stored properties

Sources/XCoordinator/NavigationAnimationDelegate.swift

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,9 @@ extension NavigationAnimationDelegate: UINavigationControllerDelegate {
132132
///
133133
open func navigationController(_ navigationController: UINavigationController,
134134
didShow viewController: UIViewController, animated: Bool) {
135+
#if !os(tvOS)
135136
setupPopGestureRecognizer(for: navigationController)
137+
#endif
136138
presentable?.childTransitionCompleted()
137139
delegate?.navigationController?(navigationController, didShow: viewController, animated: animated)
138140
}
@@ -153,6 +155,8 @@ extension NavigationAnimationDelegate: UINavigationControllerDelegate {
153155
}
154156
}
155157

158+
#if !os(tvOS)
159+
156160
// MARK: - UIGestureRecognizerDelegate
157161

158162
extension NavigationAnimationDelegate: UIGestureRecognizerDelegate {
@@ -271,6 +275,8 @@ extension NavigationAnimationDelegate: UIGestureRecognizerDelegate {
271275

272276
}
273277

278+
#endif
279+
274280
extension UINavigationController {
275281
internal var animationDelegate: NavigationAnimationDelegate? {
276282
delegate as? NavigationAnimationDelegate

Sources/XCoordinator/Router.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ extension Router {
8383
contextTrigger(route, with: options) { _ in completion?() }
8484
}
8585
}
86+
8687
}
8788

8889
extension Router {
@@ -112,6 +113,7 @@ extension Router {
112113
public func router<R: Route>(for route: R) -> StrongRouter<R>? {
113114
strongRouter as? StrongRouter<R>
114115
}
116+
115117
}
116118

117119
#if swift(>=5.5.2)

Sources/XCoordinator/TabBarAnimationDelegate.swift

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,8 @@ extension TabBarAnimationDelegate: UITabBarControllerDelegate {
102102
delegate?.tabBarController?(tabBarController, shouldSelect: viewController) ?? true
103103
}
104104

105+
#if !os(tvOS)
106+
105107
///
106108
/// See [UITabBarControllerDelegate](https://developer.apple.com/documentation/uikit/UITabBarControllerDelegate)
107109
/// for further reference.
@@ -146,6 +148,9 @@ extension TabBarAnimationDelegate: UITabBarControllerDelegate {
146148
willEndCustomizing viewControllers: [UIViewController], changed: Bool) {
147149
delegate?.tabBarController?(tabBarController, willEndCustomizing: viewControllers, changed: changed)
148150
}
151+
152+
#endif
153+
149154
}
150155

151156
extension UITabBarController {

Sources/XCoordinatorCombine/Router+Combine.swift

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,24 +16,35 @@ public struct PublisherExtension<Base> {
1616
}
1717

1818
extension Router {
19+
1920
public var publishers: PublisherExtension<Self> {
2021
.init(base: self)
2122
}
22-
}
2323

24-
@available(iOS 13.0, *)
25-
extension PublisherExtension where Base: Router {
26-
27-
public func trigger(_ route: Base.RouteType,
28-
with options: TransitionOptions = .init(animated: true)
29-
) -> Future<Void, Never> {
24+
@available(iOS 13.0, tvOS 13.0, *)
25+
public func triggerPublisher(
26+
_ route: RouteType,
27+
with options: TransitionOptions = .init(animated: true)
28+
) -> Future<Void, Never> {
3029
Future { completion in
31-
self.base.trigger(route, with: options) {
30+
self.trigger(route, with: options) {
3231
completion(.success(()))
3332
}
3433
}
3534
}
3635

3736
}
3837

38+
@available(iOS 13.0, tvOS 13.0, *)
39+
extension PublisherExtension where Base: Router {
40+
41+
public func trigger(
42+
_ route: Base.RouteType,
43+
with options: TransitionOptions = .init(animated: true)
44+
) -> Future<Void, Never> {
45+
base.triggerPublisher(route, with: options)
46+
}
47+
48+
}
49+
3950
#endif

0 commit comments

Comments
 (0)