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

Swift 4.2 and Xcode 10 #5

Merged
merged 3 commits into from Oct 16, 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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 0 additions & 1 deletion .swift-version

This file was deleted.

4 changes: 2 additions & 2 deletions .travis.yml
Expand Up @@ -2,10 +2,10 @@ language: objective-c
matrix:
include:
- os: osx
osx_image: xcode9.2
osx_image: xcode10
env: DEVICE="Apple TV 4K"
- os: osx
osx_image: xcode9.2
osx_image: xcode10
env: DEVICE="Apple TV"
script:
- swiftlint
Expand Down
6 changes: 2 additions & 4 deletions Example/Example.xcodeproj/project.pbxproj
Expand Up @@ -12,7 +12,6 @@
FF2D4C542106071A002A8032 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = FF2D4C522106071A002A8032 /* Main.storyboard */; };
FF2D4C562106071C002A8032 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = FF2D4C552106071C002A8032 /* Assets.xcassets */; };
FF2D4C6321060775002A8032 /* TvOSSlider.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = FF2D4C6221060775002A8032 /* TvOSSlider.framework */; };
FF2D4C642106078D002A8032 /* TvOSSlider.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = FF2D4C6221060775002A8032 /* TvOSSlider.framework */; };
FF2D4C652106078D002A8032 /* TvOSSlider.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = FF2D4C6221060775002A8032 /* TvOSSlider.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
/* End PBXBuildFile section */

Expand Down Expand Up @@ -46,7 +45,6 @@
buildActionMask = 2147483647;
files = (
FF2D4C6321060775002A8032 /* TvOSSlider.framework in Frameworks */,
FF2D4C642106078D002A8032 /* TvOSSlider.framework in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down Expand Up @@ -236,6 +234,7 @@
SDKROOT = appletvos;
SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG;
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
SWIFT_VERSION = 4.2;
TVOS_DEPLOYMENT_TARGET = 12.0;
};
name = Debug;
Expand Down Expand Up @@ -289,6 +288,7 @@
SDKROOT = appletvos;
SWIFT_COMPILATION_MODE = wholemodule;
SWIFT_OPTIMIZATION_LEVEL = "-O";
SWIFT_VERSION = 4.2;
TVOS_DEPLOYMENT_TARGET = 12.0;
VALIDATE_PRODUCT = YES;
};
Expand All @@ -308,7 +308,6 @@
);
PRODUCT_BUNDLE_IDENTIFIER = com.dcodero.Example;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 4.2;
TARGETED_DEVICE_FAMILY = 3;
TVOS_DEPLOYMENT_TARGET = 11.0;
};
Expand All @@ -328,7 +327,6 @@
);
PRODUCT_BUNDLE_IDENTIFIER = com.dcodero.Example;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 4.2;
TARGETED_DEVICE_FAMILY = 3;
TVOS_DEPLOYMENT_TARGET = 11.0;
};
Expand Down
1 change: 1 addition & 0 deletions TvOSSlider.podspec
Expand Up @@ -6,6 +6,7 @@ Pod::Spec.new do |s|
s.summary = 'TvOSSlider is an implementation of UISlider for tvOS.'
s.homepage = 'https://github.com/zattoo/TvOSSlider'
s.source = { :git => 'https://github.com/zattoo/TvOSSlider.git', :tag => s.version }
s.swift_version = '4.2'
s.tvos.deployment_target = '11.0'
s.source_files = 'TvOSSlider/**/*.swift'
end
6 changes: 2 additions & 4 deletions TvOSSlider.xcodeproj/project.pbxproj
Expand Up @@ -282,6 +282,7 @@
SDKROOT = appletvos;
SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG;
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
SWIFT_VERSION = 4.2;
TVOS_DEPLOYMENT_TARGET = 12.0;
VERSIONING_SYSTEM = "apple-generic";
VERSION_INFO_PREFIX = "";
Expand Down Expand Up @@ -338,6 +339,7 @@
SDKROOT = appletvos;
SWIFT_COMPILATION_MODE = wholemodule;
SWIFT_OPTIMIZATION_LEVEL = "-O";
SWIFT_VERSION = 4.2;
TVOS_DEPLOYMENT_TARGET = 12.0;
VALIDATE_PRODUCT = YES;
VERSIONING_SYSTEM = "apple-generic";
Expand Down Expand Up @@ -366,7 +368,6 @@
PRODUCT_NAME = "$(TARGET_NAME:c99extidentifier)";
SKIP_INSTALL = YES;
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
SWIFT_VERSION = 4.2;
TARGETED_DEVICE_FAMILY = 3;
TVOS_DEPLOYMENT_TARGET = 11.0;
};
Expand All @@ -392,7 +393,6 @@
PRODUCT_BUNDLE_IDENTIFIER = com.dcodero.TvOSSlider;
PRODUCT_NAME = "$(TARGET_NAME:c99extidentifier)";
SKIP_INSTALL = YES;
SWIFT_VERSION = 4.2;
TARGETED_DEVICE_FAMILY = 3;
TVOS_DEPLOYMENT_TARGET = 11.0;
};
Expand All @@ -411,7 +411,6 @@
MTL_ENABLE_DEBUG_INFO = YES;
PRODUCT_BUNDLE_IDENTIFIER = com.dcodero.TvOSSliderTests;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 4.0;
TARGETED_DEVICE_FAMILY = 3;
TVOS_DEPLOYMENT_TARGET = 11.4;
};
Expand All @@ -429,7 +428,6 @@
);
PRODUCT_BUNDLE_IDENTIFIER = com.dcodero.TvOSSliderTests;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 4.0;
TARGETED_DEVICE_FAMILY = 3;
TVOS_DEPLOYMENT_TARGET = 11.4;
};
Expand Down
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0940"
LastUpgradeVersion = "1000"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand Down
26 changes: 13 additions & 13 deletions TvOSSlider/TvOSSlider.swift
Expand Up @@ -127,7 +127,7 @@ public final class TvOSSlider: UIControl {
- image: The minimum track image to associate with the specified states.
- state: The control state with which to associate the image.
*/
public func setMinimumTrackImage(_ image: UIImage?, for state: UIControlState) {
public func setMinimumTrackImage(_ image: UIImage?, for state: UIControl.State) {
minimumTrackViewImages[state.rawValue] = image
updateStateDependantViews()
}
Expand All @@ -139,7 +139,7 @@ public final class TvOSSlider: UIControl {
- image: The maximum track image to associate with the specified states.
- state: The control state with which to associate the image.
*/
public func setMaximumTrackImage(_ image: UIImage?, for state: UIControlState) {
public func setMaximumTrackImage(_ image: UIImage?, for state: UIControl.State) {
maximumTrackViewImages[state.rawValue] = image
updateStateDependantViews()
}
Expand All @@ -151,7 +151,7 @@ public final class TvOSSlider: UIControl {
- image: The thumb image to associate with the specified states.
- state: The control state with which to associate the image.
*/
public func setThumbImage(_ image: UIImage?, for state: UIControlState) {
public func setThumbImage(_ image: UIImage?, for state: UIControl.State) {
thumbViewImages[state.rawValue] = image
updateStateDependantViews()
}
Expand Down Expand Up @@ -179,7 +179,7 @@ public final class TvOSSlider: UIControl {

- Returns: The minimum track image associated with the specified state, or nil if no image has been set. This method might also return nil if you specify multiple control states in the state parameter. For a description of track images, see Customizing the Slider’s Appearance.
*/
public func minimumTrackImage(for state: UIControlState) -> UIImage? {
public func minimumTrackImage(for state: UIControl.State) -> UIImage? {
return minimumTrackViewImages[state.rawValue]
}

Expand All @@ -191,7 +191,7 @@ public final class TvOSSlider: UIControl {

- Returns: The maximum track image associated with the specified state, or nil if an appropriate image could not be retrieved. This method might return nil if you specify multiple control states in the state parameter. For a description of track images, see Customizing the Slider’s Appearance.
*/
public func maximumTrackImage(for state: UIControlState) -> UIImage? {
public func maximumTrackImage(for state: UIControl.State) -> UIImage? {
return maximumTrackViewImages[state.rawValue]
}

Expand All @@ -203,7 +203,7 @@ public final class TvOSSlider: UIControl {

- Returns: The thumb image associated with the specified state, or nil if an appropriate image could not be retrieved. This method might return nil if you specify multiple control states in the state parameter. For a description of track and thumb images, see Customizing the Slider’s Appearance.
*/
public func thumbImage(for state: UIControlState) -> UIImage? {
public func thumbImage(for state: UIControl.State) -> UIImage? {
return thumbViewImages[state.rawValue]
}

Expand Down Expand Up @@ -370,20 +370,20 @@ public final class TvOSSlider: UIControl {
addGestureRecognizer(panGestureRecognizer)

leftTapGestureRecognizer = UITapGestureRecognizer(target: self, action: #selector(leftTapWasTriggered))
leftTapGestureRecognizer.allowedPressTypes = [NSNumber(value: UIPressType.leftArrow.rawValue)]
leftTapGestureRecognizer.allowedTouchTypes = [NSNumber(value: UITouchType.indirect.rawValue)]
leftTapGestureRecognizer.allowedPressTypes = [NSNumber(value: UIPress.PressType.leftArrow.rawValue)]
leftTapGestureRecognizer.allowedTouchTypes = [NSNumber(value: UITouch.TouchType.indirect.rawValue)]
addGestureRecognizer(leftTapGestureRecognizer)

rightTapGestureRecognizer = UITapGestureRecognizer(target: self, action: #selector(rightTapWasTriggered))
rightTapGestureRecognizer.allowedPressTypes = [NSNumber(value: UIPressType.rightArrow.rawValue)]
rightTapGestureRecognizer.allowedTouchTypes = [NSNumber(value: UITouchType.indirect.rawValue)]
rightTapGestureRecognizer.allowedPressTypes = [NSNumber(value: UIPress.PressType.rightArrow.rawValue)]
rightTapGestureRecognizer.allowedTouchTypes = [NSNumber(value: UITouch.TouchType.indirect.rawValue)]
addGestureRecognizer(rightTapGestureRecognizer)
}

private func updateStateDependantViews() {
minimumTrackView.image = minimumTrackViewImages[state.rawValue] ?? minimumTrackViewImages[UIControlState.normal.rawValue]
maximumTrackView.image = maximumTrackViewImages[state.rawValue] ?? maximumTrackViewImages[UIControlState.normal.rawValue]
thumbView.image = thumbViewImages[state.rawValue] ?? thumbViewImages[UIControlState.normal.rawValue]
minimumTrackView.image = minimumTrackViewImages[state.rawValue] ?? minimumTrackViewImages[UIControl.State.normal.rawValue]
maximumTrackView.image = maximumTrackViewImages[state.rawValue] ?? maximumTrackViewImages[UIControl.State.normal.rawValue]
thumbView.image = thumbViewImages[state.rawValue] ?? thumbViewImages[UIControl.State.normal.rawValue]

if isFocused {
transform = CGAffineTransform(scaleX: focusScaleFactor, y: focusScaleFactor)
Expand Down