Skip to content

Commit

Permalink
Merge pull request #55 from iZettle/tvos-support
Browse files Browse the repository at this point in the history
Add support for tvOS
  • Loading branch information
CarlEkman authored Nov 7, 2018
2 parents b989f36 + b355e21 commit e06aca1
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 17 deletions.
12 changes: 8 additions & 4 deletions Flow.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -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;
};
Expand All @@ -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;
};
Expand All @@ -675,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;
};
Expand All @@ -689,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;
};
Expand Down
32 changes: 20 additions & 12 deletions Flow/UIControls+Extensions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,21 @@ extension UIButton: SignalProvider {
}
}

extension UISegmentedControl: SignalProvider {
public var providedSignal: ReadWriteSignal<Int> {
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<Int> {
return signal(for: .valueChanged, keyPath: \.currentPage)
}
}

#if !os(tvOS)

extension UISwitch: SignalProvider {
public var providedSignal: ReadWriteSignal<Bool> {
return signal(for: .valueChanged, keyPath: \.isOn)
Expand All @@ -74,13 +89,6 @@ extension UISlider: SignalProvider {
}
}

extension UISegmentedControl: SignalProvider {
public var providedSignal: ReadWriteSignal<Int> {
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)
Expand Down Expand Up @@ -114,11 +122,7 @@ extension UIDatePicker: SignalProvider {
}
}

extension UIPageControl: SignalProvider {
public var providedSignal: ReadWriteSignal<Int> {
return signal(for: .valueChanged, keyPath: \.currentPage)
}
}
#endif

extension UIBarItem: Enablable {}

Expand Down Expand Up @@ -195,11 +199,15 @@ public extension UITextField {
}
}

#if !os(tvOS)

/// Returns a signal that will signal on orientation changes.
public var orientationSignal: ReadSignal<UIInterfaceOrientation> {
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<String, Bool>()
Expand Down
2 changes: 1 addition & 1 deletion Flow/UIView+EditingMenu.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
// Copyright © 2015 iZettle. All rights reserved.
//

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

import UIKit

Expand Down
1 change: 1 addition & 0 deletions FlowFramework.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -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}"
Expand Down

0 comments on commit e06aca1

Please sign in to comment.