Skip to content
This repository was archived by the owner on Jun 17, 2018. It is now read-only.

Commit 088e4a2

Browse files
committed
Convert to Swift 3.0
1 parent b144838 commit 088e4a2

File tree

14 files changed

+143
-137
lines changed

14 files changed

+143
-137
lines changed

Example/PagingMenuControllerDemo.xcodeproj/project.pbxproj

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -422,9 +422,11 @@
422422
};
423423
EC7BA3F61B524BB4007FB8A5 = {
424424
CreatedOnToolsVersion = 6.4;
425+
LastSwiftMigration = 0800;
425426
};
426427
EC7BA40A1B524BB4007FB8A5 = {
427428
CreatedOnToolsVersion = 6.4;
429+
LastSwiftMigration = 0800;
428430
TestTargetID = EC7BA3F61B524BB4007FB8A5;
429431
};
430432
EC96215C1C5B4F1700DA6EE6 = {
@@ -902,6 +904,7 @@
902904
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
903905
PRODUCT_BUNDLE_IDENTIFIER = "com.yusuke.$(PRODUCT_NAME:rfc1034identifier)";
904906
PRODUCT_NAME = "$(TARGET_NAME)";
907+
SWIFT_VERSION = 3.0;
905908
TARGETED_DEVICE_FAMILY = "1,2";
906909
};
907910
name = Debug;
@@ -916,6 +919,7 @@
916919
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
917920
PRODUCT_BUNDLE_IDENTIFIER = "com.yusuke.$(PRODUCT_NAME:rfc1034identifier)";
918921
PRODUCT_NAME = "$(TARGET_NAME)";
922+
SWIFT_VERSION = 3.0;
919923
TARGETED_DEVICE_FAMILY = "1,2";
920924
};
921925
name = Release;
@@ -937,6 +941,7 @@
937941
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
938942
PRODUCT_BUNDLE_IDENTIFIER = "com.yusuke.$(PRODUCT_NAME:rfc1034identifier)";
939943
PRODUCT_NAME = "$(TARGET_NAME)";
944+
SWIFT_VERSION = 3.0;
940945
TEST_HOST = "$(BUILT_PRODUCTS_DIR)/PagingMenuControllerDemo2.app/PagingMenuControllerDemo2";
941946
};
942947
name = Debug;
@@ -954,6 +959,7 @@
954959
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
955960
PRODUCT_BUNDLE_IDENTIFIER = "com.yusuke.$(PRODUCT_NAME:rfc1034identifier)";
956961
PRODUCT_NAME = "$(TARGET_NAME)";
962+
SWIFT_VERSION = 3.0;
957963
TEST_HOST = "$(BUILT_PRODUCTS_DIR)/PagingMenuControllerDemo2.app/PagingMenuControllerDemo2";
958964
};
959965
name = Release;

Example/PagingMenuControllerDemo2/AppDelegate.swift

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,10 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
1313

1414
var window: UIWindow?
1515

16-
func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
16+
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: Any]?) -> Bool {
1717
// Override point for customization after application launch.
1818

19-
window = UIWindow(frame: UIScreen.mainScreen().bounds)
19+
window = UIWindow(frame: UIScreen.main.bounds)
2020
let viewController = RootViewControoler()
2121
let navigationController = UINavigationController(rootViewController: viewController)
2222
window?.rootViewController = navigationController
@@ -25,25 +25,25 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
2525
return true
2626
}
2727

28-
func applicationWillResignActive(application: UIApplication) {
28+
func applicationWillResignActive(_ application: UIApplication) {
2929
// Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
3030
// Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game.
3131
}
3232

33-
func applicationDidEnterBackground(application: UIApplication) {
33+
func applicationDidEnterBackground(_ application: UIApplication) {
3434
// Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.
3535
// If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
3636
}
3737

38-
func applicationWillEnterForeground(application: UIApplication) {
38+
func applicationWillEnterForeground(_ application: UIApplication) {
3939
// Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background.
4040
}
4141

42-
func applicationDidBecomeActive(application: UIApplication) {
42+
func applicationDidBecomeActive(_ application: UIApplication) {
4343
// Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
4444
}
4545

46-
func applicationWillTerminate(application: UIApplication) {
46+
func applicationWillTerminate(_ application: UIApplication) {
4747
// Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
4848
}
4949

Example/PagingMenuControllerDemo2/RootViewControoler.swift

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,17 +10,17 @@ import UIKit
1010
import PagingMenuController
1111

1212
private struct PagingMenuOptions: PagingMenuControllerCustomizable {
13-
private var componentType: ComponentType {
13+
fileprivate var componentType: ComponentType {
1414
return .All(menuOptions: MenuOptions(), pagingControllers: pagingControllers)
1515
}
1616

17-
private var pagingControllers: [UIViewController] {
17+
fileprivate var pagingControllers: [UIViewController] {
1818
let viewController1 = ViewController1()
1919
let viewController2 = ViewController2()
2020
return [viewController1, viewController2]
2121
}
2222

23-
private struct MenuOptions: MenuViewCustomizable {
23+
fileprivate struct MenuOptions: MenuViewCustomizable {
2424
var displayMode: MenuDisplayMode {
2525
return .SegmentedControl
2626
}
@@ -29,12 +29,12 @@ private struct PagingMenuOptions: PagingMenuControllerCustomizable {
2929
}
3030
}
3131

32-
private struct MenuItem1: MenuItemViewCustomizable {
32+
fileprivate struct MenuItem1: MenuItemViewCustomizable {
3333
var displayMode: MenuItemDisplayMode {
3434
return .Text(title: MenuItemText(text: "First Menu"))
3535
}
3636
}
37-
private struct MenuItem2: MenuItemViewCustomizable {
37+
fileprivate struct MenuItem2: MenuItemViewCustomizable {
3838
var displayMode: MenuItemDisplayMode {
3939
return .Text(title: MenuItemText(text: "Second Menu"))
4040
}
@@ -45,7 +45,7 @@ class RootViewControoler: UIViewController {
4545
override func viewDidLoad() {
4646
super.viewDidLoad()
4747
// Do any additional setup after loading the view, typically from a nib.
48-
view.backgroundColor = UIColor.whiteColor()
48+
view.backgroundColor = UIColor.white
4949

5050
let options = PagingMenuOptions()
5151
let pagingMenuController = PagingMenuController(options: options)
@@ -56,4 +56,4 @@ class RootViewControoler: UIViewController {
5656
view.addSubview(pagingMenuController.view)
5757
pagingMenuController.didMoveToParentViewController(self)
5858
}
59-
}
59+
}

Example/PagingMenuControllerDemo2/ViewController1.swift

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,13 @@ class ViewController1: UIViewController {
1313
override func viewDidLoad() {
1414
super.viewDidLoad()
1515

16-
view.backgroundColor = UIColor.lightGrayColor()
16+
view.backgroundColor = UIColor.lightGray
1717

18-
let textLabel = UILabel(frame: CGRectMake(0, 0, 200, 30))
18+
let textLabel = UILabel(frame: CGRect(x: 0, y: 0, width: 200, height: 30))
1919
textLabel.center = view.center
20-
textLabel.textAlignment = .Center
21-
textLabel.font = UIFont.systemFontOfSize(24)
20+
textLabel.textAlignment = .center
21+
textLabel.font = UIFont.systemFont(ofSize: 24)
2222
textLabel.text = "View Controller 1"
2323
view.addSubview(textLabel)
2424
}
25-
}
25+
}

Example/PagingMenuControllerDemo2/ViewController2.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,12 @@ class ViewController2: UIViewController {
1313
override func viewDidLoad() {
1414
super.viewDidLoad()
1515

16-
view.backgroundColor = UIColor.lightGrayColor()
16+
view.backgroundColor = UIColor.lightGray
1717

18-
let textLabel = UILabel(frame: CGRectMake(0, 0, 200, 30))
18+
let textLabel = UILabel(frame: CGRect(x: 0, y: 0, width: 200, height: 30))
1919
textLabel.center = view.center
20-
textLabel.textAlignment = .Center
21-
textLabel.font = UIFont.systemFontOfSize(24)
20+
textLabel.textAlignment = .center
21+
textLabel.font = UIFont.systemFont(ofSize: 24)
2222
textLabel.text = "View Controller 2"
2323
view.addSubview(textLabel)
2424
}

Example/PagingMenuControllerDemo2Tests/PagingMenuControllerDemo2Tests.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ class PagingMenuControllerDemo2Tests: XCTestCase {
2828

2929
func testPerformanceExample() {
3030
// This is an example of a performance test case.
31-
self.measureBlock() {
31+
self.measure() {
3232
// Put the code you want to measure the time of here.
3333
}
3434
}

Pod/Classes/MenuItemView.swift

Lines changed: 32 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -8,25 +8,25 @@
88

99
import UIKit
1010

11-
public class MenuItemView: UIView {
12-
lazy public var titleLabel: UILabel = self.initLabel()
13-
lazy public var descriptionLabel: UILabel = self.initLabel()
14-
lazy public var menuImageView: UIImageView = {
11+
open class MenuItemView: UIView {
12+
lazy open var titleLabel: UILabel = self.initLabel()
13+
lazy open var descriptionLabel: UILabel = self.initLabel()
14+
lazy open var menuImageView: UIImageView = {
1515
$0.isUserInteractionEnabled = true
1616
$0.translatesAutoresizingMaskIntoConstraints = false
1717
return $0
1818
}(UIImageView(frame: .zero))
19-
public private(set) var customView: UIView? {
19+
open fileprivate(set) var customView: UIView? {
2020
didSet {
2121
guard let customView = customView else { return }
2222

2323
addSubview(customView)
2424
}
2525
}
26-
public internal(set) var selected: Bool = false {
26+
open internal(set) var selected: Bool = false {
2727
didSet {
2828
if case .roundRect = menuOptions.focusMode {
29-
backgroundColor = UIColor.clear()
29+
backgroundColor = UIColor.clear
3030
} else {
3131
backgroundColor = selected ? menuOptions.selectedBackgroundColor : menuOptions.backgroundColor
3232
}
@@ -51,18 +51,18 @@ public class MenuItemView: UIView {
5151
}
5252
}
5353
}
54-
lazy public private(set) var dividerImageView: UIImageView? = { [unowned self] in
54+
lazy open fileprivate(set) var dividerImageView: UIImageView? = { [unowned self] in
5555
guard let image = self.menuOptions.dividerImage else { return nil }
5656
let imageView = UIImageView(image: image)
5757
imageView.translatesAutoresizingMaskIntoConstraints = false
5858
return imageView
5959
}()
6060

61-
private var menuOptions: MenuViewCustomizable!
62-
private var menuItemOptions: MenuItemViewCustomizable!
63-
private var widthConstraint: NSLayoutConstraint!
64-
private var descriptionWidthConstraint: NSLayoutConstraint!
65-
private var horizontalMargin: CGFloat {
61+
fileprivate var menuOptions: MenuViewCustomizable!
62+
fileprivate var menuItemOptions: MenuItemViewCustomizable!
63+
fileprivate var widthConstraint: NSLayoutConstraint!
64+
fileprivate var descriptionWidthConstraint: NSLayoutConstraint!
65+
fileprivate var horizontalMargin: CGFloat {
6666
switch menuOptions.displayMode {
6767
case .segmentedControl: return 0.0
6868
default: return menuItemOptions.horizontalMargin
@@ -101,15 +101,15 @@ public class MenuItemView: UIView {
101101
}
102102
}
103103

104-
private func commonInit(_ setupContentView: () -> Void) {
104+
fileprivate func commonInit(_ setupContentView: () -> Void) {
105105
setupView()
106106
setupContentView()
107107

108108
setupDivider()
109109
layoutDivider()
110110
}
111111

112-
private func initLabel() -> UILabel {
112+
fileprivate func initLabel() -> UILabel {
113113
let label = UILabel(frame: .zero)
114114
label.numberOfLines = 1
115115
label.textAlignment = .center
@@ -142,51 +142,51 @@ public class MenuItemView: UIView {
142142

143143
// MARK: - Constructor
144144

145-
private func setupView() {
145+
fileprivate func setupView() {
146146
if case .roundRect = menuOptions.focusMode {
147-
backgroundColor = UIColor.clear()
147+
backgroundColor = UIColor.clear
148148
} else {
149149
backgroundColor = menuOptions.backgroundColor
150150
}
151151
translatesAutoresizingMaskIntoConstraints = false
152152
}
153153

154-
private func setupTitleLabel(_ text: MenuItemText) {
154+
fileprivate func setupTitleLabel(_ text: MenuItemText) {
155155
setupLabel(titleLabel, text: text)
156156
}
157157

158-
private func setupMultilineLabel(_ text: MenuItemText, description: MenuItemText) {
158+
fileprivate func setupMultilineLabel(_ text: MenuItemText, description: MenuItemText) {
159159
setupLabel(titleLabel, text: text)
160160
setupLabel(descriptionLabel, text: description)
161161
}
162162

163-
private func setupLabel(_ label: UILabel, text: MenuItemText) {
163+
fileprivate func setupLabel(_ label: UILabel, text: MenuItemText) {
164164
label.text = text.text
165165
updateLabel(label, text: text)
166166
addSubview(label)
167167
}
168168

169-
private func updateLabel(_ label: UILabel, text: MenuItemText) {
169+
fileprivate func updateLabel(_ label: UILabel, text: MenuItemText) {
170170
label.textColor = selected ? text.selectedColor : text.color
171171
label.font = selected ? text.selectedFont : text.font
172172
}
173173

174-
private func setupImageView(_ image: UIImage) {
174+
fileprivate func setupImageView(_ image: UIImage) {
175175
menuImageView.image = image
176176
addSubview(menuImageView)
177177
}
178178

179-
private func setupCustomView(_ view: UIView) {
179+
fileprivate func setupCustomView(_ view: UIView) {
180180
customView = view
181181
}
182182

183-
private func setupDivider() {
183+
fileprivate func setupDivider() {
184184
guard let dividerImageView = dividerImageView else { return }
185185

186186
addSubview(dividerImageView)
187187
}
188188

189-
private func layoutMultiLineLabel() {
189+
fileprivate func layoutMultiLineLabel() {
190190
let titleLabelSize = calculateLabelSize(titleLabel, maxWidth: maxWindowSize)
191191
let descriptionLabelSize = calculateLabelSize(descriptionLabel, maxWidth: maxWindowSize)
192192
let verticalMargin = max(menuOptions.height - (titleLabelSize.height + descriptionLabelSize.height), 0) / 2
@@ -202,7 +202,7 @@ public class MenuItemView: UIView {
202202
NSLayoutConstraint.activate(horizontalConstraints + verticalConstraints + descriptionHorizontalConstraints + [widthConstraint, descriptionWidthConstraint])
203203
}
204204

205-
private func layoutLabel() {
205+
fileprivate func layoutLabel() {
206206
let viewsDictionary = ["label": titleLabel]
207207
let labelSize = calculateLabelSize(titleLabel, maxWidth: maxWindowSize)
208208

@@ -214,13 +214,13 @@ public class MenuItemView: UIView {
214214

215215
}
216216

217-
private func layoutImageView() {
217+
fileprivate func layoutImageView() {
218218
guard let image = menuImageView.image else { return }
219219

220220
let width: CGFloat
221221
switch menuOptions.displayMode {
222222
case .segmentedControl:
223-
width = UIApplication.shared().keyWindow!.bounds.size.width / CGFloat(menuOptions.itemsOptions.count)
223+
width = UIApplication.shared.keyWindow!.bounds.size.width / CGFloat(menuOptions.itemsOptions.count)
224224
default:
225225
width = image.size.width + horizontalMargin * 2
226226
}
@@ -236,7 +236,7 @@ public class MenuItemView: UIView {
236236
])
237237
}
238238

239-
private func layoutCustomView() {
239+
fileprivate func layoutCustomView() {
240240
guard let customView = customView else { return }
241241

242242
widthConstraint = NSLayoutConstraint(item: self, attribute: .width, relatedBy: .equal, toItem: nil, attribute: .width, multiplier: 1.0, constant: customView.frame.width)
@@ -250,7 +250,7 @@ public class MenuItemView: UIView {
250250
])
251251
}
252252

253-
private func layoutDivider() {
253+
fileprivate func layoutDivider() {
254254
guard let dividerImageView = dividerImageView else { return }
255255

256256
let centerYConstraint = NSLayoutConstraint(item: dividerImageView, attribute: .centerY, relatedBy: .equal, toItem: self, attribute: .centerY, multiplier: 1.0, constant: 1.0)
@@ -307,7 +307,7 @@ extension MenuItemView: LabelSizeCalculatable {
307307
return CGSize(width: itemWidth + horizontalMargin * 2, height: itemHeight)
308308
}
309309

310-
private var maxWindowSize: CGFloat {
311-
return UIApplication.shared().keyWindow?.bounds.width ?? UIScreen.main().bounds.width
310+
fileprivate var maxWindowSize: CGFloat {
311+
return UIApplication.shared.keyWindow?.bounds.width ?? UIScreen.main.bounds.width
312312
}
313313
}

0 commit comments

Comments
 (0)