From 8211e3391497de34eff72caf1fd839f0cecc6470 Mon Sep 17 00:00:00 2001 From: Carl Ekman Date: Wed, 31 Oct 2018 22:50:38 +0100 Subject: [PATCH 1/2] Add support for tvOS --- Flow.xcodeproj/project.pbxproj | 6 ++++-- Flow/UIControls+Extensions.swift | 32 ++++++++++++++++++++------------ Flow/UIView+EditingMenu.swift | 2 +- FlowFramework.podspec | 1 + 4 files changed, 26 insertions(+), 15 deletions(-) diff --git a/Flow.xcodeproj/project.pbxproj b/Flow.xcodeproj/project.pbxproj index a9dbf17..91cd2c3 100644 --- a/Flow.xcodeproj/project.pbxproj +++ b/Flow.xcodeproj/project.pbxproj @@ -636,8 +636,9 @@ PROVISIONING_PROFILE_SPECIFIER = ""; SDKROOT = ""; SKIP_INSTALL = YES; - SUPPORTED_PLATFORMS = "iphonesimulator iphoneos macosx"; + SUPPORTED_PLATFORMS = "iphonesimulator iphoneos macosx appletvos appletvsimulator"; SWIFT_VERSION = 4.0; + TARGETED_DEVICE_FAMILY = "1,2,3"; }; name = Debug; }; @@ -661,8 +662,9 @@ PROVISIONING_PROFILE_SPECIFIER = ""; SDKROOT = ""; SKIP_INSTALL = YES; - SUPPORTED_PLATFORMS = "iphonesimulator iphoneos macosx"; + SUPPORTED_PLATFORMS = "iphonesimulator iphoneos macosx appletvos appletvsimulator"; SWIFT_VERSION = 4.0; + TARGETED_DEVICE_FAMILY = "1,2,3"; }; name = Release; }; diff --git a/Flow/UIControls+Extensions.swift b/Flow/UIControls+Extensions.swift index 2170dbb..7e6c126 100644 --- a/Flow/UIControls+Extensions.swift +++ b/Flow/UIControls+Extensions.swift @@ -62,6 +62,21 @@ extension UIButton: SignalProvider { } } +extension UISegmentedControl: SignalProvider { + public var providedSignal: ReadWriteSignal { + return signal(for: .valueChanged, keyPath: \.selectedSegmentIndex) + .distinct() // KVO seems to trigger when tapping as well, even when tapping selected. + } +} + +extension UIPageControl: SignalProvider { + public var providedSignal: ReadWriteSignal { + return signal(for: .valueChanged, keyPath: \.currentPage) + } +} + +#if !os(tvOS) + extension UISwitch: SignalProvider { public var providedSignal: ReadWriteSignal { return signal(for: .valueChanged, keyPath: \.isOn) @@ -74,13 +89,6 @@ extension UISlider: SignalProvider { } } -extension UISegmentedControl: SignalProvider { - public var providedSignal: ReadWriteSignal { - return signal(for: .valueChanged, keyPath: \.selectedSegmentIndex) - .distinct() // KVO seems to trigger when tapping as well, even when tapping selected. - } -} - extension UIRefreshControl: SignalProvider { public var providedSignal: Signal<()> { return signal(for: .valueChanged) @@ -114,11 +122,7 @@ extension UIDatePicker: SignalProvider { } } -extension UIPageControl: SignalProvider { - public var providedSignal: ReadWriteSignal { - return signal(for: .valueChanged, keyPath: \.currentPage) - } -} +#endif extension UIBarItem: Enablable {} @@ -195,11 +199,15 @@ public extension UITextField { } } +#if !os(tvOS) + /// Returns a signal that will signal on orientation changes. public var orientationSignal: ReadSignal { return NotificationCenter.default.signal(forName: .UIApplicationDidChangeStatusBarOrientation).map { _ in UIApplication.shared.statusBarOrientation }.readable(capturing: UIApplication.shared.statusBarOrientation) } +#endif + private extension UITextField { class TextFieldDelegate: NSObject, UITextFieldDelegate { var shouldEndEditing = Delegate() diff --git a/Flow/UIView+EditingMenu.swift b/Flow/UIView+EditingMenu.swift index d7be760..024d811 100644 --- a/Flow/UIView+EditingMenu.swift +++ b/Flow/UIView+EditingMenu.swift @@ -6,7 +6,7 @@ // Copyright © 2015 iZettle. All rights reserved. // -#if canImport(UIKit) +#if canImport(UIKit) && !os(tvOS) import UIKit diff --git a/FlowFramework.podspec b/FlowFramework.podspec index a89780b..0957633 100644 --- a/FlowFramework.podspec +++ b/FlowFramework.podspec @@ -12,6 +12,7 @@ Pod::Spec.new do |s| s.osx.deployment_target = "10.11" s.ios.deployment_target = "9.0" + s.tvos.deployment_target = "9.0" s.source = { :git => "https://github.com/iZettle/Flow.git", :tag => "#{s.version}" } s.source_files = "Flow/*.{swift}" From b355e210bc5d02528ef799dacec430b4c31ac8c7 Mon Sep 17 00:00:00 2001 From: Carl Ekman Date: Thu, 1 Nov 2018 22:52:34 +0100 Subject: [PATCH 2/2] Add tvOS support to test target --- Flow.xcodeproj/project.pbxproj | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Flow.xcodeproj/project.pbxproj b/Flow.xcodeproj/project.pbxproj index 91cd2c3..aa8e540 100644 --- a/Flow.xcodeproj/project.pbxproj +++ b/Flow.xcodeproj/project.pbxproj @@ -677,8 +677,9 @@ PRODUCT_NAME = "$(TARGET_NAME)"; PROVISIONING_PROFILE_SPECIFIER = ""; SDKROOT = ""; - SUPPORTED_PLATFORMS = "macosx iphonesimulator iphoneos"; + SUPPORTED_PLATFORMS = "macosx iphonesimulator iphoneos appletvos appletvsimulator"; SWIFT_VERSION = 4.0; + TARGETED_DEVICE_FAMILY = "1,2,3"; }; name = Debug; }; @@ -691,8 +692,9 @@ PRODUCT_NAME = "$(TARGET_NAME)"; PROVISIONING_PROFILE_SPECIFIER = ""; SDKROOT = ""; - SUPPORTED_PLATFORMS = "macosx iphonesimulator iphoneos"; + SUPPORTED_PLATFORMS = "macosx iphonesimulator iphoneos appletvos appletvsimulator"; SWIFT_VERSION = 4.0; + TARGETED_DEVICE_FAMILY = "1,2,3"; }; name = Release; };