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 target for tvOS and get it to compile #392

Merged
merged 1 commit into from
Oct 1, 2015
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
283 changes: 283 additions & 0 deletions Charts/Charts.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

80 changes: 80 additions & 0 deletions Charts/Charts.xcodeproj/xcshareddata/xcschemes/ChartsTV.xcscheme
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0710"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
buildImplicitDependencies = "YES">
<BuildActionEntries>
<BuildActionEntry
buildForTesting = "YES"
buildForRunning = "YES"
buildForProfiling = "YES"
buildForArchiving = "YES"
buildForAnalyzing = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "A52C5C361BAC5CA400594CDD"
BuildableName = "ChartsTV.framework"
BlueprintName = "ChartsTV"
ReferencedContainer = "container:Charts.xcodeproj">
</BuildableReference>
</BuildActionEntry>
</BuildActionEntries>
</BuildAction>
<TestAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES">
<Testables>
</Testables>
<AdditionalOptions>
</AdditionalOptions>
</TestAction>
<LaunchAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
launchStyle = "0"
useCustomWorkingDirectory = "NO"
ignoresPersistentStateOnLaunch = "NO"
debugDocumentVersioning = "YES"
debugServiceExtension = "internal"
allowLocationSimulation = "YES">
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "A52C5C361BAC5CA400594CDD"
BuildableName = "ChartsTV.framework"
BlueprintName = "ChartsTV"
ReferencedContainer = "container:Charts.xcodeproj">
</BuildableReference>
</MacroExpansion>
<AdditionalOptions>
</AdditionalOptions>
</LaunchAction>
<ProfileAction
buildConfiguration = "Release"
shouldUseLaunchSchemeArgsEnv = "YES"
savedToolIdentifier = ""
useCustomWorkingDirectory = "NO"
debugDocumentVersioning = "YES">
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "A52C5C361BAC5CA400594CDD"
BuildableName = "ChartsTV.framework"
BlueprintName = "ChartsTV"
ReferencedContainer = "container:Charts.xcodeproj">
</BuildableReference>
</MacroExpansion>
</ProfileAction>
<AnalyzeAction
buildConfiguration = "Debug">
</AnalyzeAction>
<ArchiveAction
buildConfiguration = "Release"
revealArchiveInOrganizer = "YES">
</ArchiveAction>
</Scheme>
19 changes: 19 additions & 0 deletions Charts/ChartsTV/ChartsTV.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
//
// ChartsTV.h
// ChartsTV
//
// Created by Tracy Keeling on 9/18/15.
// Copyright © 2015 dcg. All rights reserved.
//

#import <UIKit/UIKit.h>

//! Project version number for ChartsTV.
FOUNDATION_EXPORT double ChartsTVVersionNumber;

//! Project version string for ChartsTV.
FOUNDATION_EXPORT const unsigned char ChartsTVVersionString[];

// In this header, you should import all the public headers of your framework using statements like #import <ChartsTV/PublicHeader.h>


26 changes: 26 additions & 0 deletions Charts/ChartsTV/Info.plist
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>en</string>
<key>CFBundleExecutable</key>
<string>$(EXECUTABLE_NAME)</string>
<key>CFBundleIdentifier</key>
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>$(PRODUCT_NAME)</string>
<key>CFBundlePackageType</key>
<string>FMWK</string>
<key>CFBundleShortVersionString</key>
<string>1.0</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>$(CURRENT_PROJECT_VERSION)</string>
<key>NSPrincipalClass</key>
<string></string>
</dict>
</plist>
48 changes: 35 additions & 13 deletions Charts/Classes/Charts/BarLineChartViewBase.swift
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,9 @@ public class BarLineChartViewBase: ChartViewBase, UIGestureRecognizerDelegate

internal var _tapGestureRecognizer: UITapGestureRecognizer!
internal var _doubleTapGestureRecognizer: UITapGestureRecognizer!
#if !os(tvOS)
internal var _pinchGestureRecognizer: UIPinchGestureRecognizer!
#endif
internal var _panGestureRecognizer: UIPanGestureRecognizer!

/// flag that indicates if a custom viewport offset has been set
Expand Down Expand Up @@ -106,20 +108,23 @@ public class BarLineChartViewBase: ChartViewBase, UIGestureRecognizerDelegate
_tapGestureRecognizer = UITapGestureRecognizer(target: self, action: Selector("tapGestureRecognized:"))
_doubleTapGestureRecognizer = UITapGestureRecognizer(target: self, action: Selector("doubleTapGestureRecognized:"))
_doubleTapGestureRecognizer.numberOfTapsRequired = 2
_pinchGestureRecognizer = UIPinchGestureRecognizer(target: self, action: Selector("pinchGestureRecognized:"))
_panGestureRecognizer = UIPanGestureRecognizer(target: self, action: Selector("panGestureRecognized:"))

_pinchGestureRecognizer.delegate = self
_panGestureRecognizer.delegate = self

self.addGestureRecognizer(_tapGestureRecognizer)
self.addGestureRecognizer(_doubleTapGestureRecognizer)
self.addGestureRecognizer(_pinchGestureRecognizer)
self.addGestureRecognizer(_panGestureRecognizer)

_doubleTapGestureRecognizer.enabled = _doubleTapToZoomEnabled
_pinchGestureRecognizer.enabled = _pinchZoomEnabled || _scaleXEnabled || _scaleYEnabled
_panGestureRecognizer.enabled = _dragEnabled

#if !os(tvOS)
_pinchGestureRecognizer = UIPinchGestureRecognizer(target: self, action: Selector("pinchGestureRecognized:"))
_pinchGestureRecognizer.delegate = self
self.addGestureRecognizer(_pinchGestureRecognizer)
_pinchGestureRecognizer.enabled = _pinchZoomEnabled || _scaleXEnabled || _scaleYEnabled
#endif
}

public override func drawRect(rect: CGRect)
Expand Down Expand Up @@ -657,6 +662,7 @@ public class BarLineChartViewBase: ChartViewBase, UIGestureRecognizerDelegate
}
}

#if !os(tvOS)
@objc private func pinchGestureRecognized(recognizer: UIPinchGestureRecognizer)
{
if (recognizer.state == UIGestureRecognizerState.Began)
Expand Down Expand Up @@ -742,6 +748,7 @@ public class BarLineChartViewBase: ChartViewBase, UIGestureRecognizerDelegate
}
}
}
#endif

@objc private func panGestureRecognized(recognizer: UIPanGestureRecognizer)
{
Expand Down Expand Up @@ -918,26 +925,33 @@ public class BarLineChartViewBase: ChartViewBase, UIGestureRecognizerDelegate
return false
}
}
else if (gestureRecognizer == _pinchGestureRecognizer)
else
{
if (_dataNotSet || (!_pinchZoomEnabled && !_scaleXEnabled && !_scaleYEnabled))
{
return false
}
#if !os(tvOS)
if (gestureRecognizer == _pinchGestureRecognizer)
{
if (_dataNotSet || (!_pinchZoomEnabled && !_scaleXEnabled && !_scaleYEnabled))
{
return false
}
}
#endif
}

return true
}

public func gestureRecognizer(gestureRecognizer: UIGestureRecognizer, shouldRecognizeSimultaneouslyWithGestureRecognizer otherGestureRecognizer: UIGestureRecognizer) -> Bool
{
#if !os(tvOS)
if ((gestureRecognizer.isKindOfClass(UIPinchGestureRecognizer) &&
otherGestureRecognizer.isKindOfClass(UIPanGestureRecognizer)) ||
(gestureRecognizer.isKindOfClass(UIPanGestureRecognizer) &&
otherGestureRecognizer.isKindOfClass(UIPinchGestureRecognizer)))
{
return true
}
#endif

if (gestureRecognizer.isKindOfClass(UIPanGestureRecognizer) &&
otherGestureRecognizer.isKindOfClass(UIPanGestureRecognizer) && (
Expand Down Expand Up @@ -1257,7 +1271,9 @@ public class BarLineChartViewBase: ChartViewBase, UIGestureRecognizerDelegate
{
_scaleXEnabled = enabled
_scaleYEnabled = enabled
_pinchGestureRecognizer.enabled = _pinchZoomEnabled || _scaleXEnabled || _scaleYEnabled
#if !os(tvOS)
_pinchGestureRecognizer.enabled = _pinchZoomEnabled || _scaleXEnabled || _scaleYEnabled
#endif
}
}

Expand All @@ -1272,7 +1288,9 @@ public class BarLineChartViewBase: ChartViewBase, UIGestureRecognizerDelegate
if (_scaleXEnabled != newValue)
{
_scaleXEnabled = newValue
_pinchGestureRecognizer.enabled = _pinchZoomEnabled || _scaleXEnabled || _scaleYEnabled
#if !os(tvOS)
_pinchGestureRecognizer.enabled = _pinchZoomEnabled || _scaleXEnabled || _scaleYEnabled
#endif
}
}
}
Expand All @@ -1288,7 +1306,9 @@ public class BarLineChartViewBase: ChartViewBase, UIGestureRecognizerDelegate
if (_scaleYEnabled != newValue)
{
_scaleYEnabled = newValue
_pinchGestureRecognizer.enabled = _pinchZoomEnabled || _scaleXEnabled || _scaleYEnabled
#if !os(tvOS)
_pinchGestureRecognizer.enabled = _pinchZoomEnabled || _scaleXEnabled || _scaleYEnabled
#endif
}
}
}
Expand Down Expand Up @@ -1493,7 +1513,9 @@ public class BarLineChartViewBase: ChartViewBase, UIGestureRecognizerDelegate
if (_pinchZoomEnabled != newValue)
{
_pinchZoomEnabled = newValue
_pinchGestureRecognizer.enabled = _pinchZoomEnabled || _scaleXEnabled || _scaleYEnabled
#if !os(tvOS)
_pinchGestureRecognizer.enabled = _pinchZoomEnabled || _scaleXEnabled || _scaleYEnabled
#endif
}
}
}
Expand Down
9 changes: 8 additions & 1 deletion Charts/Classes/Charts/ChartViewBase.swift
Original file line number Diff line number Diff line change
Expand Up @@ -336,7 +336,12 @@ public class ChartViewBase: UIView, ChartAnimatorDelegate

if (font == nil)
{
font = UIFont.systemFontOfSize(UIFont.systemFontSize())
#if os(tvOS)
// 23 is the smallest recommened font size on the TV
font = UIFont.systemFontOfSize(23, weight: UIFontWeightMedium)
#else
font = UIFont.systemFontOfSize(UIFont.systemFontSize())
#endif
}

attrs[NSFontAttributeName] = font
Expand Down Expand Up @@ -798,11 +803,13 @@ public class ChartViewBase: UIView, ChartAnimatorDelegate
return imageData.writeToFile(path, atomically: true)
}

#if !os(tvOS)
/// Saves the current state of the chart to the camera roll
public func saveToCameraRoll()
{
UIImageWriteToSavedPhotosAlbum(getChartImage(transparent: false), nil, nil, nil)
}
#endif

internal typealias VoidClosureType = () -> ()
internal var _sizeChangeEventActions = [VoidClosureType]()
Expand Down
18 changes: 13 additions & 5 deletions Charts/Classes/Charts/PieRadarChartViewBase.swift
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,9 @@ public class PieRadarChartViewBase: ChartViewBase
private var _rotationWithTwoFingers = false

private var _tapGestureRecognizer: UITapGestureRecognizer!
#if !os(tvOS)
private var _rotationGestureRecognizer: UIRotationGestureRecognizer!
#endif

public override init(frame: CGRect)
{
Expand All @@ -52,12 +54,14 @@ public class PieRadarChartViewBase: ChartViewBase
super.initialize()

_tapGestureRecognizer = UITapGestureRecognizer(target: self, action: Selector("tapGestureRecognized:"))
_rotationGestureRecognizer = UIRotationGestureRecognizer(target: self, action: Selector("rotationGestureRecognized:"))

self.addGestureRecognizer(_tapGestureRecognizer)
self.addGestureRecognizer(_rotationGestureRecognizer)

_rotationGestureRecognizer.enabled = rotationWithTwoFingers

#if !os(tvOS)
_rotationGestureRecognizer = UIRotationGestureRecognizer(target: self, action: Selector("rotationGestureRecognized:"))
self.addGestureRecognizer(_rotationGestureRecognizer)
_rotationGestureRecognizer.enabled = rotationWithTwoFingers
#endif
}

internal override func calcMinMax()
Expand Down Expand Up @@ -392,7 +396,9 @@ public class PieRadarChartViewBase: ChartViewBase
set
{
_rotationWithTwoFingers = newValue
_rotationGestureRecognizer.enabled = _rotationWithTwoFingers
#if !os(tvOS)
_rotationGestureRecognizer.enabled = _rotationWithTwoFingers
#endif
}
}

Expand Down Expand Up @@ -786,6 +792,7 @@ public class PieRadarChartViewBase: ChartViewBase
}
}

#if !os(tvOS)
@objc private func rotationGestureRecognized(recognizer: UIRotationGestureRecognizer)
{
if (recognizer.state == UIGestureRecognizerState.Began)
Expand Down Expand Up @@ -824,4 +831,5 @@ public class PieRadarChartViewBase: ChartViewBase
}
}
}
#endif
}