Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for tvOS #55

Merged
merged 2 commits into from
Nov 7, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just moved this code around to make the preprocessor checks cleaner.

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