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

Removed unnecessary #if statements and unified style to align with Xc… #3884

Merged
merged 2 commits into from
Mar 7, 2019
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
4 changes: 0 additions & 4 deletions Source/Charts/Animation/Animator.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,6 @@
import Foundation
import CoreGraphics

#if !os(OSX)
import UIKit
#endif

@objc(ChartAnimatorDelegate)
public protocol AnimatorDelegate
{
Expand Down
40 changes: 18 additions & 22 deletions Source/Charts/Charts/BarLineChartViewBase.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,6 @@
import Foundation
import CoreGraphics

#if !os(OSX)
import UIKit
#endif

/// Base-class of LineChart, BarChart, ScatterChart and CandleStickChart.
open class BarLineChartViewBase: ChartViewBase, BarLineScatterCandleBubbleChartDataProvider, NSUIGestureRecognizerDelegate
{
Expand Down Expand Up @@ -134,10 +130,10 @@ open class BarLineChartViewBase: ChartViewBase, BarLineScatterCandleBubbleChartD
_panGestureRecognizer.isEnabled = _dragXEnabled || _dragYEnabled

#if !os(tvOS)
_pinchGestureRecognizer = NSUIPinchGestureRecognizer(target: self, action: #selector(BarLineChartViewBase.pinchGestureRecognized(_:)))
_pinchGestureRecognizer.delegate = self
self.addGestureRecognizer(_pinchGestureRecognizer)
_pinchGestureRecognizer.isEnabled = _pinchZoomEnabled || _scaleXEnabled || _scaleYEnabled
_pinchGestureRecognizer = NSUIPinchGestureRecognizer(target: self, action: #selector(BarLineChartViewBase.pinchGestureRecognized(_:)))
_pinchGestureRecognizer.delegate = self
self.addGestureRecognizer(_pinchGestureRecognizer)
_pinchGestureRecognizer.isEnabled = _pinchZoomEnabled || _scaleXEnabled || _scaleYEnabled
#endif
}

Expand Down Expand Up @@ -892,13 +888,13 @@ open class BarLineChartViewBase: ChartViewBase, BarLineScatterCandleBubbleChartD
else
{
#if !os(tvOS)
if gestureRecognizer == _pinchGestureRecognizer
if gestureRecognizer == _pinchGestureRecognizer
{
if _data === nil || (!_pinchZoomEnabled && !_scaleXEnabled && !_scaleYEnabled)
{
if _data === nil || (!_pinchZoomEnabled && !_scaleXEnabled && !_scaleYEnabled)
{
return false
}
return false
}
}
#endif
}

Expand Down Expand Up @@ -927,11 +923,11 @@ open class BarLineChartViewBase: ChartViewBase, BarLineScatterCandleBubbleChartD
open func gestureRecognizer(_ gestureRecognizer: NSUIGestureRecognizer, shouldRecognizeSimultaneouslyWith otherGestureRecognizer: NSUIGestureRecognizer) -> Bool
{
#if !os(tvOS)
if ((gestureRecognizer is NSUIPinchGestureRecognizer && otherGestureRecognizer is NSUIPanGestureRecognizer) ||
(gestureRecognizer is NSUIPanGestureRecognizer && otherGestureRecognizer is NSUIPinchGestureRecognizer))
{
return true
}
if ((gestureRecognizer is NSUIPinchGestureRecognizer && otherGestureRecognizer is NSUIPanGestureRecognizer) ||
(gestureRecognizer is NSUIPanGestureRecognizer && otherGestureRecognizer is NSUIPinchGestureRecognizer))
{
return true
}
#endif

if gestureRecognizer is NSUIPanGestureRecognizer,
Expand Down Expand Up @@ -1594,7 +1590,7 @@ open class BarLineChartViewBase: ChartViewBase, BarLineScatterCandleBubbleChartD
_scaleXEnabled = enabled
_scaleYEnabled = enabled
#if !os(tvOS)
_pinchGestureRecognizer.isEnabled = _pinchZoomEnabled || _scaleXEnabled || _scaleYEnabled
_pinchGestureRecognizer.isEnabled = _pinchZoomEnabled || _scaleXEnabled || _scaleYEnabled
#endif
}
}
Expand All @@ -1611,7 +1607,7 @@ open class BarLineChartViewBase: ChartViewBase, BarLineScatterCandleBubbleChartD
{
_scaleXEnabled = newValue
#if !os(tvOS)
_pinchGestureRecognizer.isEnabled = _pinchZoomEnabled || _scaleXEnabled || _scaleYEnabled
_pinchGestureRecognizer.isEnabled = _pinchZoomEnabled || _scaleXEnabled || _scaleYEnabled
#endif
}
}
Expand All @@ -1629,7 +1625,7 @@ open class BarLineChartViewBase: ChartViewBase, BarLineScatterCandleBubbleChartD
{
_scaleYEnabled = newValue
#if !os(tvOS)
_pinchGestureRecognizer.isEnabled = _pinchZoomEnabled || _scaleXEnabled || _scaleYEnabled
_pinchGestureRecognizer.isEnabled = _pinchZoomEnabled || _scaleXEnabled || _scaleYEnabled
#endif
}
}
Expand Down Expand Up @@ -1775,7 +1771,7 @@ open class BarLineChartViewBase: ChartViewBase, BarLineScatterCandleBubbleChartD
{
_pinchZoomEnabled = newValue
#if !os(tvOS)
_pinchGestureRecognizer.isEnabled = _pinchZoomEnabled || _scaleXEnabled || _scaleYEnabled
_pinchGestureRecognizer.isEnabled = _pinchZoomEnabled || _scaleXEnabled || _scaleYEnabled
#endif
}
}
Expand Down
6 changes: 1 addition & 5 deletions Source/Charts/Charts/ChartViewBase.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,6 @@
import Foundation
import CoreGraphics

#if !os(OSX)
import UIKit
#endif

@objc
public protocol ChartViewDelegate
{
Expand Down Expand Up @@ -171,7 +167,7 @@ open class ChartViewBase: NSUIView, ChartDataProvider, AnimatorDelegate
internal func initialize()
{
#if os(iOS)
self.backgroundColor = NSUIColor.clear
self.backgroundColor = NSUIColor.clear
#endif

_animator = Animator()
Expand Down
4 changes: 0 additions & 4 deletions Source/Charts/Charts/HorizontalBarChartView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,6 @@
import Foundation
import CoreGraphics

#if !os(OSX)
import UIKit
#endif

/// BarChart with horizontal bar orientation. In this implementation, x- and y-axis are switched.
open class HorizontalBarChartView: BarChartView
{
Expand Down
19 changes: 5 additions & 14 deletions Source/Charts/Charts/PieChartView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,6 @@
import Foundation
import CoreGraphics

#if !os(OSX)
import UIKit
#endif

/// View that represents a pie chart. Draws cake like slices.
open class PieChartView: PieRadarChartViewBase
{
Expand Down Expand Up @@ -387,20 +383,15 @@ open class PieChartView: PieRadarChartViewBase
}
else
{
#if os(OSX)
let paragraphStyle = NSParagraphStyle.default.mutableCopy() as! NSMutableParagraphStyle
paragraphStyle.lineBreakMode = NSLineBreakMode.byTruncatingTail
#else
let paragraphStyle = NSParagraphStyle.default.mutableCopy() as! NSMutableParagraphStyle
paragraphStyle.lineBreakMode = NSLineBreakMode.byTruncatingTail
#endif
let paragraphStyle = NSParagraphStyle.default.mutableCopy() as! NSMutableParagraphStyle
paragraphStyle.lineBreakMode = .byTruncatingTail
paragraphStyle.alignment = .center

attrString = NSMutableAttributedString(string: newValue!)
attrString?.setAttributes([
NSAttributedString.Key.foregroundColor: NSUIColor.black,
NSAttributedString.Key.font: NSUIFont.systemFont(ofSize: 12.0),
NSAttributedString.Key.paragraphStyle: paragraphStyle
.foregroundColor: NSUIColor.black,
.font: NSUIFont.systemFont(ofSize: 12.0),
.paragraphStyle: paragraphStyle
], range: NSMakeRange(0, attrString!.length))
}
self.centerAttributedText = attrString
Expand Down
12 changes: 4 additions & 8 deletions Source/Charts/Charts/PieRadarChartViewBase.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,6 @@
import Foundation
import CoreGraphics

#if !os(OSX)
import UIKit
#endif

/// Base class of PieChartView and RadarChartView.
open class PieRadarChartViewBase: ChartViewBase
{
Expand Down Expand Up @@ -63,9 +59,9 @@ open class PieRadarChartViewBase: ChartViewBase
self.addGestureRecognizer(_tapGestureRecognizer)

#if !os(tvOS)
_rotationGestureRecognizer = NSUIRotationGestureRecognizer(target: self, action: #selector(rotationGestureRecognized(_:)))
self.addGestureRecognizer(_rotationGestureRecognizer)
_rotationGestureRecognizer.isEnabled = rotationWithTwoFingers
_rotationGestureRecognizer = NSUIRotationGestureRecognizer(target: self, action: #selector(rotationGestureRecognized(_:)))
self.addGestureRecognizer(_rotationGestureRecognizer)
_rotationGestureRecognizer.isEnabled = rotationWithTwoFingers
#endif
}

Expand Down Expand Up @@ -407,7 +403,7 @@ open class PieRadarChartViewBase: ChartViewBase
{
_rotationWithTwoFingers = newValue
#if !os(tvOS)
_rotationGestureRecognizer.isEnabled = _rotationWithTwoFingers
_rotationGestureRecognizer.isEnabled = _rotationWithTwoFingers
#endif
}
}
Expand Down
12 changes: 4 additions & 8 deletions Source/Charts/Components/Description.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,22 +12,18 @@
import Foundation
import CoreGraphics

#if !os(OSX)
import UIKit
#endif

@objc(ChartDescription)
open class Description: ComponentBase
{
public override init()
{
#if os(tvOS)
// 23 is the smallest recommended font size on the TV
font = NSUIFont.systemFont(ofSize: 23)
// 23 is the smallest recommended font size on the TV
font = .systemFont(ofSize: 23)
#elseif os(OSX)
font = NSUIFont.systemFont(ofSize: NSUIFont.systemFontSize)
font = .systemFont(ofSize: NSUIFont.systemFontSize)
#else
font = NSUIFont.systemFont(ofSize: 8.0)
font = .systemFont(ofSize: 8.0)
#endif

super.init()
Expand Down
4 changes: 0 additions & 4 deletions Source/Charts/Components/Legend.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,6 @@
import Foundation
import CoreGraphics

#if !os(OSX)
import UIKit
#endif

@objc(ChartLegend)
open class Legend: ComponentBase
{
Expand Down
4 changes: 0 additions & 4 deletions Source/Charts/Components/LegendEntry.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,6 @@
import Foundation
import CoreGraphics

#if !os(OSX)
import UIKit
#endif

@objc(ChartLegendEntry)
open class LegendEntry: NSObject
{
Expand Down
4 changes: 0 additions & 4 deletions Source/Charts/Components/MarkerImage.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,6 @@
import Foundation
import CoreGraphics

#if !os(OSX)
import UIKit
#endif

@objc(ChartMarkerImage)
open class MarkerImage: NSObject, IMarker
{
Expand Down
38 changes: 17 additions & 21 deletions Source/Charts/Components/MarkerView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,6 @@
import Foundation
import CoreGraphics

#if !os(OSX)
import UIKit
#endif

@objc(ChartMarkerView)
open class MarkerView: NSUIView, IMarker
{
Expand Down Expand Up @@ -75,24 +71,24 @@ open class MarkerView: NSUIView, IMarker
open class func viewFromXib(in bundle: Bundle = .main) -> MarkerView?
{
#if !os(OSX)
return bundle.loadNibNamed(
String(describing: self),
owner: nil,
options: nil)?[0] as? MarkerView
return bundle.loadNibNamed(
String(describing: self),
owner: nil,
options: nil)?[0] as? MarkerView
#else
var loadedObjects = NSArray()
let loadedObjectsPointer = AutoreleasingUnsafeMutablePointer<NSArray?>(&loadedObjects)
if bundle.loadNibNamed(
NSNib.Name(String(describing: self)),
owner: nil,
topLevelObjects: loadedObjectsPointer)
{
return loadedObjects[0] as? MarkerView
}
return nil

var loadedObjects = NSArray()
let loadedObjectsPointer = AutoreleasingUnsafeMutablePointer<NSArray?>(&loadedObjects)

if bundle.loadNibNamed(
NSNib.Name(String(describing: self)),
owner: nil,
topLevelObjects: loadedObjectsPointer)
{
return loadedObjects[0] as? MarkerView
}

return nil
#endif
}

Expand Down
4 changes: 0 additions & 4 deletions Source/Charts/Components/YAxis.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,6 @@
import Foundation
import CoreGraphics

#if !os(OSX)
import UIKit
#endif


/// Class representing the y-axis labels settings and its entries.
/// Be aware that not all features the YLabels class provides are suitable for the RadarChart.
Expand Down
4 changes: 0 additions & 4 deletions Source/Charts/Data/Interfaces/IPieChartDataSet.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,6 @@
import Foundation
import CoreGraphics

#if !os(OSX)
import UIKit
#endif

@objc
public protocol IPieChartDataSet: IChartDataSet
{
Expand Down
4 changes: 0 additions & 4 deletions Source/Charts/Formatters/DefaultFillFormatter.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,6 @@
import Foundation
import CoreGraphics

#if !os(OSX)
import UIKit
#endif

/// Default formatter that calculates the position of the filled line.
@objc(ChartDefaultFillFormatter)
open class DefaultFillFormatter: NSObject, IFillFormatter
Expand Down
4 changes: 0 additions & 4 deletions Source/Charts/Jobs/AnimatedMoveViewJob.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,6 @@
import Foundation
import CoreGraphics

#if !os(OSX)
import UIKit
#endif

open class AnimatedMoveViewJob: AnimatedViewPortJob
{
internal override func animationUpdate()
Expand Down
4 changes: 0 additions & 4 deletions Source/Charts/Jobs/AnimatedViewPortJob.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,6 @@
import Foundation
import CoreGraphics

#if !os(OSX)
import UIKit
#endif

open class AnimatedViewPortJob: ViewPortJob
{
internal var phase: CGFloat = 1.0
Expand Down
4 changes: 0 additions & 4 deletions Source/Charts/Jobs/MoveViewJob.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,6 @@
import Foundation
import CoreGraphics

#if !os(OSX)
import UIKit
#endif

@objc(MoveChartViewJob)
open class MoveViewJob: ViewPortJob
{
Expand Down
4 changes: 0 additions & 4 deletions Source/Charts/Jobs/ZoomViewJob.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,6 @@
import Foundation
import CoreGraphics

#if !os(OSX)
import UIKit
#endif

@objc(ZoomChartViewJob)
open class ZoomViewJob: ViewPortJob
{
Expand Down
Loading