Skip to content

Commit

Permalink
Finish conversion to Swift 4.2
Browse files Browse the repository at this point in the history
  • Loading branch information
ivnsch committed Sep 25, 2018
1 parent 3d5b7da commit d1f4c58
Show file tree
Hide file tree
Showing 45 changed files with 135 additions and 137 deletions.
2 changes: 1 addition & 1 deletion Examples/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UISplitViewControllerDele
var window: UIWindow?


func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {

if UIDevice.current.userInterfaceIdiom == .pad {

Expand Down
4 changes: 2 additions & 2 deletions Examples/DetailViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -114,10 +114,10 @@ class DetailViewController: UIViewController, UISplitViewControllerDelegate {

fileprivate func showExampleController(_ controller: UIViewController) {
if let currentExampleController = currentExampleController {
currentExampleController.removeFromParentViewController()
currentExampleController.removeFromParent()
currentExampleController.view.removeFromSuperview()
}
addChildViewController(controller)
addChild(controller)
view.addSubview(controller.view)
currentExampleController = controller
}
Expand Down
4 changes: 2 additions & 2 deletions Examples/Examples/AreasExample.swift
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ class AreasExample: UIViewController, ChartDelegate {
bubbleView.addSubview(infoView)
weakSelf.popups.append(bubbleView)

UIView.animate(withDuration: 0.2, delay: 0, options: UIViewAnimationOptions(), animations: {
UIView.animate(withDuration: 0.2, delay: 0, options: UIView.AnimationOptions(), animations: {
view.selected = true
selectedView = view

Expand All @@ -105,7 +105,7 @@ class AreasExample: UIViewController, ChartDelegate {
}
}

UIView.animate(withDuration: 0.7, delay: 0, usingSpringWithDamping: 0.6, initialSpringVelocity: 0, options: UIViewAnimationOptions(), animations: {
UIView.animate(withDuration: 0.7, delay: 0, usingSpringWithDamping: 0.6, initialSpringVelocity: 0, options: UIView.AnimationOptions(), animations: {
let w: CGFloat = v.frame.size.width
let h: CGFloat = v.frame.size.height
let frame = CGRect(x: screenLoc.x - (w/2), y: screenLoc.y - (h/2), width: w, height: h)
Expand Down
10 changes: 5 additions & 5 deletions Examples/Examples/BarsExample.swift
Original file line number Diff line number Diff line change
Expand Up @@ -111,9 +111,9 @@ class BarsExample: UIViewController {
self.controller = controller

horizontal = UIButton()
horizontal.setTitle("Horizontal", for: UIControlState())
horizontal.setTitle("Horizontal", for: UIControl.State())
vertical = UIButton()
vertical.setTitle("Vertical", for: UIControlState())
vertical.setTitle("Vertical", for: UIControl.State())

buttonDirs = [horizontal : true, vertical : false]

Expand All @@ -124,7 +124,7 @@ class BarsExample: UIViewController {

for button in [horizontal, vertical] {
button.titleLabel?.font = ExamplesDefaults.fontWithSize(14)
button.setTitleColor(UIColor.blue, for: UIControlState())
button.setTitleColor(UIColor.blue, for: UIControl.State())
button.addTarget(self, action: #selector(DirSelector.buttonTapped(_:)), for: .touchUpInside)
}
}
Expand Down Expand Up @@ -155,9 +155,9 @@ class BarsExample: UIViewController {
"\(str)-(\(buttonsSpace))-[\(tuple.0)]"
}

let vConstraits = namedViews.flatMap {NSLayoutConstraint.constraints(withVisualFormat: "V:|[\($0.0)]", options: NSLayoutFormatOptions(), metrics: nil, views: viewsDict)}
let vConstraits = namedViews.flatMap {NSLayoutConstraint.constraints(withVisualFormat: "V:|[\($0.0)]", options: NSLayoutConstraint.FormatOptions(), metrics: nil, views: viewsDict)}

addConstraints(NSLayoutConstraint.constraints(withVisualFormat: hConstraintStr, options: NSLayoutFormatOptions(), metrics: nil, views: viewsDict)
addConstraints(NSLayoutConstraint.constraints(withVisualFormat: hConstraintStr, options: NSLayoutConstraint.FormatOptions(), metrics: nil, views: viewsDict)
+ vConstraits)
}

Expand Down
8 changes: 3 additions & 5 deletions Examples/Examples/CandleStickInteractiveExample.swift
Original file line number Diff line number Diff line change
Expand Up @@ -78,9 +78,7 @@ class CandleStickInteractiveExample: UIViewController {
let calendar = Calendar.current
let monthDays = calendar.range(of: .day, in: .month, for: date)!

let arr = CountableRange<Int>(monthDays)

return arr.map {day in
return monthDays.map {day in
let date = dateWithComponents(day, month, year)
let axisValue = ChartAxisValueDate(date: date, formatter: displayFormatter, labelSettings: labelSettings)
axisValue.hidden = !(day % 5 == 0)
Expand Down Expand Up @@ -252,9 +250,9 @@ private class InfoView: UIView {
"\(str)-(\(labelsSpace))-[\(tuple.0)]"
}

let vConstraits = namedViews.flatMap {NSLayoutConstraint.constraints(withVisualFormat: "V:|-(18)-[\($0.0)(\(circleDiameter))]", options: NSLayoutFormatOptions(), metrics: nil, views: viewsDict)}
let vConstraits = namedViews.flatMap {NSLayoutConstraint.constraints(withVisualFormat: "V:|-(18)-[\($0.0)(\(circleDiameter))]", options: NSLayoutConstraint.FormatOptions(), metrics: nil, views: viewsDict)}

addConstraints(NSLayoutConstraint.constraints(withVisualFormat: hConstraintStr, options: NSLayoutFormatOptions(), metrics: nil, views: viewsDict)
addConstraints(NSLayoutConstraint.constraints(withVisualFormat: hConstraintStr, options: NSLayoutConstraint.FormatOptions(), metrics: nil, views: viewsDict)
+ vConstraits)

}
Expand Down
10 changes: 5 additions & 5 deletions Examples/Examples/GroupedAndStackedBarsExample.swift
Original file line number Diff line number Diff line change
Expand Up @@ -170,9 +170,9 @@ class GroupedAndStackedBarsExample: UIViewController {
self.controller = controller

horizontal = UIButton()
horizontal.setTitle("Horizontal", for: UIControlState())
horizontal.setTitle("Horizontal", for: UIControl.State())
vertical = UIButton()
vertical.setTitle("Vertical", for: UIControlState())
vertical.setTitle("Vertical", for: UIControl.State())

buttonDirs = [horizontal: true, vertical: false]

Expand All @@ -183,7 +183,7 @@ class GroupedAndStackedBarsExample: UIViewController {

for button in [horizontal, vertical] {
button.titleLabel?.font = ExamplesDefaults.fontWithSize(14)
button.setTitleColor(UIColor.blue, for: UIControlState())
button.setTitleColor(UIColor.blue, for: UIControl.State())
button.addTarget(self, action: #selector(DirSelector.buttonTapped(_:)), for: .touchUpInside)
}
}
Expand Down Expand Up @@ -214,9 +214,9 @@ class GroupedAndStackedBarsExample: UIViewController {
"\(str)-(\(buttonsSpace))-[\(tuple.0)]"
}

let vConstraits = namedViews.flatMap {NSLayoutConstraint.constraints(withVisualFormat: "V:|[\($0.0)]", options: NSLayoutFormatOptions(), metrics: nil, views: viewsDict)}
let vConstraits = namedViews.flatMap {NSLayoutConstraint.constraints(withVisualFormat: "V:|[\($0.0)]", options: NSLayoutConstraint.FormatOptions(), metrics: nil, views: viewsDict)}

addConstraints(NSLayoutConstraint.constraints(withVisualFormat: hConstraintStr, options: NSLayoutFormatOptions(), metrics: nil, views: viewsDict)
addConstraints(NSLayoutConstraint.constraints(withVisualFormat: hConstraintStr, options: NSLayoutConstraint.FormatOptions(), metrics: nil, views: viewsDict)
+ vConstraits)
}

Expand Down
10 changes: 5 additions & 5 deletions Examples/Examples/GroupedBarsExample.swift
Original file line number Diff line number Diff line change
Expand Up @@ -151,9 +151,9 @@ class GroupedBarsExample: UIViewController {
self.controller = controller

horizontal = UIButton()
horizontal.setTitle("Horizontal", for: UIControlState())
horizontal.setTitle("Horizontal", for: UIControl.State())
vertical = UIButton()
vertical.setTitle("Vertical", for: UIControlState())
vertical.setTitle("Vertical", for: UIControl.State())

buttonDirs = [horizontal : true, vertical : false]

Expand All @@ -164,7 +164,7 @@ class GroupedBarsExample: UIViewController {

for button in [horizontal, vertical] {
button.titleLabel?.font = ExamplesDefaults.fontWithSize(14)
button.setTitleColor(UIColor.blue, for: UIControlState())
button.setTitleColor(UIColor.blue, for: UIControl.State())
button.addTarget(self, action: #selector(DirSelector.buttonTapped(_:)), for: .touchUpInside)
}
}
Expand Down Expand Up @@ -195,9 +195,9 @@ class GroupedBarsExample: UIViewController {
"\(str)-(\(buttonsSpace))-[\(tuple.0)]"
}

let vConstraits = namedViews.flatMap {NSLayoutConstraint.constraints(withVisualFormat: "V:|[\($0.0)]", options: NSLayoutFormatOptions(), metrics: nil, views: viewsDict)}
let vConstraits = namedViews.flatMap {NSLayoutConstraint.constraints(withVisualFormat: "V:|[\($0.0)]", options: NSLayoutConstraint.FormatOptions(), metrics: nil, views: viewsDict)}

addConstraints(NSLayoutConstraint.constraints(withVisualFormat: hConstraintStr, options: NSLayoutFormatOptions(), metrics: nil, views: viewsDict)
addConstraints(NSLayoutConstraint.constraints(withVisualFormat: hConstraintStr, options: NSLayoutConstraint.FormatOptions(), metrics: nil, views: viewsDict)
+ vConstraits)
}

Expand Down
6 changes: 3 additions & 3 deletions Examples/Examples/NotificationsExample.swift
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ class NotificationsExample: UIViewController {
label.transform = CGAffineTransform(scaleX: 0, y: 0)

chartPointView.movedToSuperViewHandler = {
UIView.animate(withDuration: 0.5, delay: 0, usingSpringWithDamping: 0.6, initialSpringVelocity: 0, options: UIViewAnimationOptions(), animations: {
UIView.animate(withDuration: 0.5, delay: 0, usingSpringWithDamping: 0.6, initialSpringVelocity: 0, options: UIView.AnimationOptions(), animations: {
label.transform = CGAffineTransform(scaleX: 1, y: 1)
}, completion: nil)
}
Expand All @@ -58,8 +58,8 @@ class NotificationsExample: UIViewController {
let ok = "Ok"

if #available(iOS 8.0, *) {
let alert = UIAlertController(title: title, message: message, preferredStyle: UIAlertControllerStyle.alert)
alert.addAction(UIAlertAction(title: ok, style: UIAlertActionStyle.default, handler: nil))
let alert = UIAlertController(title: title, message: message, preferredStyle: UIAlertController.Style.alert)
alert.addAction(UIAlertAction(title: ok, style: UIAlertAction.Style.default, handler: nil))
self!.present(alert, animated: true, completion: nil)

} else {
Expand Down
2 changes: 1 addition & 1 deletion Examples/Examples/RangedAxisExample.swift
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class RangedAxisExample: UIViewController {

view.backgroundColor = UIColor.black

NotificationCenter.default.addObserver(self, selector: #selector(rotated), name: NSNotification.Name.UIDeviceOrientationDidChange, object: nil)
NotificationCenter.default.addObserver(self, selector: #selector(rotated), name: UIDevice.orientationDidChangeNotification, object: nil)
}

private func initChart() {
Expand Down
10 changes: 5 additions & 5 deletions Examples/Examples/StackedBarsExample.swift
Original file line number Diff line number Diff line change
Expand Up @@ -131,9 +131,9 @@ class StackedBarsExample: UIViewController {
self.controller = controller

self.horizontal = UIButton()
self.horizontal.setTitle("Horizontal", for: UIControlState())
self.horizontal.setTitle("Horizontal", for: UIControl.State())
self.vertical = UIButton()
self.vertical.setTitle("Vertical", for: UIControlState())
self.vertical.setTitle("Vertical", for: UIControl.State())

self.buttonDirs = [horizontal: true, vertical: false]

Expand All @@ -144,7 +144,7 @@ class StackedBarsExample: UIViewController {

for button in [horizontal, vertical] {
button.titleLabel?.font = ExamplesDefaults.fontWithSize(14)
button.setTitleColor(UIColor.blue, for: UIControlState())
button.setTitleColor(UIColor.blue, for: UIControl.State())
button.addTarget(self, action: #selector(DirSelector.buttonTapped(_:)), for: .touchUpInside)
}
}
Expand Down Expand Up @@ -175,9 +175,9 @@ class StackedBarsExample: UIViewController {
"\(str)-(\(buttonsSpace))-[\(tuple.0)]"
}

let vConstraits = namedViews.flatMap {NSLayoutConstraint.constraints(withVisualFormat: "V:|[\($0.0)]", options: NSLayoutFormatOptions(), metrics: nil, views: viewsDict)}
let vConstraits = namedViews.flatMap {NSLayoutConstraint.constraints(withVisualFormat: "V:|[\($0.0)]", options: NSLayoutConstraint.FormatOptions(), metrics: nil, views: viewsDict)}

addConstraints(NSLayoutConstraint.constraints(withVisualFormat: hConstraintStr, options: NSLayoutFormatOptions(), metrics: nil, views: viewsDict)
addConstraints(NSLayoutConstraint.constraints(withVisualFormat: hConstraintStr, options: NSLayoutConstraint.FormatOptions(), metrics: nil, views: viewsDict)
+ vConstraits)
}

Expand Down
2 changes: 1 addition & 1 deletion Examples/MasterViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ class MasterViewController: UITableViewController {

navigationController?.navigationBar.titleTextAttributes = [.font : ExamplesDefaults.fontWithSize(22)]
UIBarButtonItem.appearance().setTitleTextAttributes([.font : ExamplesDefaults.fontWithSize(22)],
for: UIControlState())
for: UIControl.State())

if let split = splitViewController {

Expand Down
6 changes: 3 additions & 3 deletions SwiftCharts.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -980,7 +980,7 @@
06342AC01B8AAD7F001C9F5D = {
CreatedOnToolsVersion = 6.4;
DevelopmentTeam = 37QAPDY2PR;
LastSwiftMigration = 0800;
LastSwiftMigration = 1000;
};
06405DA51B8AA74700A689FF = {
CreatedOnToolsVersion = 6.4;
Expand Down Expand Up @@ -1386,7 +1386,7 @@
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = "com.schuetz.$(PRODUCT_NAME:rfc1034identifier)";
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 4.0;
SWIFT_VERSION = 4.2;
};
name = Debug;
};
Expand All @@ -1402,7 +1402,7 @@
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = "com.schuetz.$(PRODUCT_NAME:rfc1034identifier)";
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 4.0;
SWIFT_VERSION = 4.2;
};
name = Release;
};
Expand Down
4 changes: 2 additions & 2 deletions SwiftCharts/Axis/ChartAxis.swift
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ open class ChartAxis: CustomStringConvertible {
open internal(set) var firstVisibleScreen: CGFloat
open internal(set) var lastVisibleScreen: CGFloat

open let paddingFirstScreen: CGFloat
open let paddingLastScreen: CGFloat
public let paddingFirstScreen: CGFloat
public let paddingLastScreen: CGFloat

/// Optional fixed padding value which overwrites paddingFirstScreen/paddingLastScreen when determining if model values are in bounds. This is useful e.g. when setting an initial zoom level, and scaling the padding proportionally such that it appears constant for different zoom levels. In this case it may be necessary to store the un-scaled padding in these variables to keep the bounds constant.
open var fixedPaddingFirstScreen: CGFloat?
Expand Down
4 changes: 2 additions & 2 deletions SwiftCharts/Axis/ChartAxisLabel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ import UIKit
open class ChartAxisLabel {

/// Displayed text. Can be truncated.
open let text: String
public let text: String

open let settings: ChartLabelSettings
public let settings: ChartLabelSettings

open fileprivate(set) var originalText: String

Expand Down
4 changes: 2 additions & 2 deletions SwiftCharts/Axis/ChartAxisLabelGeneratorDate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ import UIKit

open class ChartAxisLabelsGeneratorDate: ChartAxisLabelsGeneratorBase {

open let labelSettings: ChartLabelSettings
public let labelSettings: ChartLabelSettings

open let formatter: DateFormatter
public let formatter: DateFormatter

public init(labelSettings: ChartLabelSettings, formatter: DateFormatter = ChartAxisLabelsGeneratorDate.defaultFormatter) {
self.labelSettings = labelSettings
Expand Down
2 changes: 1 addition & 1 deletion SwiftCharts/Axis/ChartAxisLabelsGeneratorBasic.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import Foundation
/// Generates a single unformatted label for scalar
open class ChartAxisLabelsGeneratorBasic: ChartAxisLabelsGeneratorBase {

open let labelSettings: ChartLabelSettings
public let labelSettings: ChartLabelSettings

public init(labelSettings: ChartLabelSettings) {
self.labelSettings = labelSettings
Expand Down
4 changes: 2 additions & 2 deletions SwiftCharts/Axis/ChartAxisLabelsGeneratorFixed.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import Foundation

open class ChartAxisLabelsGeneratorFixed: ChartAxisLabelsGeneratorBase {

open let dict: [Double: [ChartAxisLabel]]
public let dict: [Double: [ChartAxisLabel]]

public convenience init(axisValues: [ChartAxisValue]) {
var dict = [Double: [ChartAxisLabel]]()
Expand All @@ -34,4 +34,4 @@ open class ChartAxisLabelsGeneratorFixed: ChartAxisLabelsGeneratorBase {
open override func fonts(_ scalar: Double) -> [UIFont] {
return dict[scalar].map {labels in labels.map{$0.settings.font}} ?? []
}
}
}
4 changes: 2 additions & 2 deletions SwiftCharts/Axis/ChartAxisLabelsGeneratorNumber.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ import Foundation
/// Generates a single formatted number for scalar
open class ChartAxisLabelsGeneratorNumber: ChartAxisLabelsGeneratorBase {

open let labelSettings: ChartLabelSettings
public let labelSettings: ChartLabelSettings

open let formatter: NumberFormatter
public let formatter: NumberFormatter

public init(labelSettings: ChartLabelSettings, formatter: NumberFormatter = ChartAxisLabelsGeneratorNumber.defaultFormatter) {
self.labelSettings = labelSettings
Expand Down
6 changes: 3 additions & 3 deletions SwiftCharts/Axis/ChartAxisLabelsGeneratorNumberSuffix.swift
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,11 @@ public enum ChartAxisLabelNumberSuffixUnit {

open class ChartAxisLabelsGeneratorNumberSuffix: ChartAxisLabelsGeneratorBase {

open let labelSettings: ChartLabelSettings
public let labelSettings: ChartLabelSettings

open let startUnit: ChartAxisLabelNumberSuffixUnit
public let startUnit: ChartAxisLabelNumberSuffixUnit

open let formatter: NumberFormatter
public let formatter: NumberFormatter

public init(labelSettings: ChartLabelSettings, startUnit: ChartAxisLabelNumberSuffixUnit = .m, formatter: NumberFormatter = ChartAxisLabelsGeneratorNumberSuffix.defaultFormatter) {
self.labelSettings = labelSettings
Expand Down
2 changes: 1 addition & 1 deletion SwiftCharts/Axis/ChartAxisLayerDefault.swift
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ open class ChartAxisLayerDefault: ChartAxisLayer {

open var currentAxisValues: [Double] = []

open let valuesGenerator: ChartAxisValuesGenerator
public let valuesGenerator: ChartAxisValuesGenerator
open var labelsGenerator: ChartAxisLabelsGenerator

let axisTitleLabels: [ChartAxisLabel]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@ import UIKit

open class ChartAxisValuesGeneratorFixedNonOverlapping: ChartAxisValuesGeneratorFixed {

open let axisValues: [ChartAxisValue]
public let axisValues: [ChartAxisValue]

open let maxLabelSize: CGSize
open let totalLabelSize: CGSize
open let spacing: CGFloat
public let maxLabelSize: CGSize
public let totalLabelSize: CGSize
public let spacing: CGFloat

fileprivate var isX: Bool

Expand Down Expand Up @@ -60,4 +60,4 @@ open class ChartAxisValuesGeneratorFixedNonOverlapping: ChartAxisValuesGenerator

return filteredAxisValues
}
}
}
6 changes: 3 additions & 3 deletions SwiftCharts/AxisValues/ChartAxisValue.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ import UIKit
open class ChartAxisValue: Equatable, Hashable, CustomStringConvertible {

/// The backing value for all other types of axis values
open let scalar: Double
open let labelSettings: ChartLabelSettings
open var hidden = false
public let scalar: Double
public let labelSettings: ChartLabelSettings
public var hidden = false

/// The labels that will be displayed in the chart
open var labels: [ChartAxisLabel] {
Expand Down
Loading

0 comments on commit d1f4c58

Please sign in to comment.