From ea3c425f70d4ed670efa0a7926f3bce482e8b68c Mon Sep 17 00:00:00 2001 From: Yutaro Muta Date: Tue, 20 Sep 2016 18:37:59 +0900 Subject: [PATCH 01/26] Add UIDeviceExtension and use --- PyConJP2016.xcodeproj/project.pbxproj | 44 ++++++++++--------- ...ntion.swift => AppDelegateExtension.swift} | 2 +- ...ayExtention.swift => ArrayExtension.swift} | 2 +- ...xtention.swift => NSLocaleExtension.swift} | 2 +- ...gExtention.swift => StringExtension.swift} | 2 +- PyConJP2016/Extension/UIDeviceExtension.swift | 24 ++++++++++ ...wExtention.swift => UIViewExtension.swift} | 2 +- .../URLScheme/TwitterURLSchemeType.swift | 4 -- .../More/MoreListViewController.swift | 6 ++- 9 files changed, 57 insertions(+), 31 deletions(-) rename PyConJP2016/Extension/{AppDelegateExtention.swift => AppDelegateExtension.swift} (95%) rename PyConJP2016/Extension/{ArrayExtention.swift => ArrayExtension.swift} (94%) rename PyConJP2016/Extension/{NSLocaleExtention.swift => NSLocaleExtension.swift} (94%) rename PyConJP2016/Extension/{StringExtention.swift => StringExtension.swift} (97%) create mode 100644 PyConJP2016/Extension/UIDeviceExtension.swift rename PyConJP2016/Extension/{UIViewExtention.swift => UIViewExtension.swift} (97%) diff --git a/PyConJP2016.xcodeproj/project.pbxproj b/PyConJP2016.xcodeproj/project.pbxproj index ab7aa67..68a216e 100644 --- a/PyConJP2016.xcodeproj/project.pbxproj +++ b/PyConJP2016.xcodeproj/project.pbxproj @@ -21,11 +21,11 @@ 7F2B717F1D654D44006A60BC /* BookmarkListViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7F2B717E1D654D44006A60BC /* BookmarkListViewController.swift */; }; 7F52375D1D65917500C5A048 /* RealmTalksType.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7F52375C1D65917500C5A048 /* RealmTalksType.swift */; }; 7F63E3E51D75556A00110E9F /* Map.strings in Resources */ = {isa = PBXBuildFile; fileRef = 7F63E3E71D75556A00110E9F /* Map.strings */; }; - 7F6879031D41BE28003D5742 /* ArrayExtention.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7F6879021D41BE28003D5742 /* ArrayExtention.swift */; }; - 7F6879051D420626003D5742 /* StringExtention.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7F6879041D420626003D5742 /* StringExtention.swift */; }; - 7F7EBFE01D751EED00F1EE30 /* NSLocaleExtention.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7F7EBFDF1D751EED00F1EE30 /* NSLocaleExtention.swift */; }; + 7F6879031D41BE28003D5742 /* ArrayExtension.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7F6879021D41BE28003D5742 /* ArrayExtension.swift */; }; + 7F6879051D420626003D5742 /* StringExtension.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7F6879041D420626003D5742 /* StringExtension.swift */; }; + 7F7EBFE01D751EED00F1EE30 /* NSLocaleExtension.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7F7EBFDF1D751EED00F1EE30 /* NSLocaleExtension.swift */; }; 7F7EBFE21D75308400F1EE30 /* PCJConfig.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7F7EBFE11D75308400F1EE30 /* PCJConfig.swift */; }; - 7F8443CE1D50320400A0BCBA /* UIViewExtention.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7F8443CD1D50320400A0BCBA /* UIViewExtention.swift */; }; + 7F8443CE1D50320400A0BCBA /* UIViewExtension.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7F8443CD1D50320400A0BCBA /* UIViewExtension.swift */; }; 7FB4D3031D542DD2005F314E /* FloorMapListViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7FB4D3021D542DD2005F314E /* FloorMapListViewController.swift */; }; 7FB4D3051D5433CA005F314E /* DetailImageViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7FB4D3041D5433CA005F314E /* DetailImageViewController.swift */; }; 7FB4D3071D5434E2005F314E /* FloorMapZoomableImageViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7FB4D3061D5434E2005F314E /* FloorMapZoomableImageViewController.swift */; }; @@ -77,6 +77,7 @@ DBA253721D73434400FE9DC5 /* Bookmark.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = DBA253741D73434400FE9DC5 /* Bookmark.storyboard */; }; DBA253791D7344E000FE9DC5 /* Conference.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = DBA2537B1D7344E000FE9DC5 /* Conference.storyboard */; }; DBB2538B1CCB700400AA17C8 /* UIColorExtension.swift in Sources */ = {isa = PBXBuildFile; fileRef = DBB2538A1CCB700400AA17C8 /* UIColorExtension.swift */; }; + DBB33BF81D91108E00EC5235 /* UIDeviceExtension.swift in Sources */ = {isa = PBXBuildFile; fileRef = DBB33BF71D91108E00EC5235 /* UIDeviceExtension.swift */; }; DBC72D151D6F0B0C008DF718 /* Alamofire.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = DBC72D121D6F0B0C008DF718 /* Alamofire.framework */; }; DBC72D161D6F0B0C008DF718 /* Alamofire.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = DBC72D121D6F0B0C008DF718 /* Alamofire.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; DBC72D171D6F0B0C008DF718 /* Realm.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = DBC72D131D6F0B0C008DF718 /* Realm.framework */; }; @@ -91,7 +92,7 @@ DBE6120C1D6DFFBF0043F2DF /* ConferenceModelController.swift in Sources */ = {isa = PBXBuildFile; fileRef = DBE612071D6DFFBF0043F2DF /* ConferenceModelController.swift */; }; DBE6120D1D6DFFBF0043F2DF /* ConferencePageViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = DBE612081D6DFFBF0043F2DF /* ConferencePageViewController.swift */; }; DBEBDB481C8C89FC002B25B3 /* MoreListViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = DBEBDB471C8C89FC002B25B3 /* MoreListViewController.swift */; }; - DBF32BB51CD48C4C004E7F3B /* AppDelegateExtention.swift in Sources */ = {isa = PBXBuildFile; fileRef = DBF32BB41CD48C4C004E7F3B /* AppDelegateExtention.swift */; }; + DBF32BB51CD48C4C004E7F3B /* AppDelegateExtension.swift in Sources */ = {isa = PBXBuildFile; fileRef = DBF32BB41CD48C4C004E7F3B /* AppDelegateExtension.swift */; }; DBF6D89F1D870E1300F9DAE5 /* GestureType.swift in Sources */ = {isa = PBXBuildFile; fileRef = DBF6D89E1D870E1300F9DAE5 /* GestureType.swift */; }; DBF78FCD1D8CF52B00EA66E4 /* TwitterURLSchemeType.swift in Sources */ = {isa = PBXBuildFile; fileRef = DBF78FCC1D8CF52B00EA66E4 /* TwitterURLSchemeType.swift */; }; DBF78FCF1D8CF56600EA66E4 /* MailURLSchemeType.swift in Sources */ = {isa = PBXBuildFile; fileRef = DBF78FCE1D8CF56600EA66E4 /* MailURLSchemeType.swift */; }; @@ -151,11 +152,11 @@ 7F63E3E61D75556A00110E9F /* Base */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = Base; path = Base.lproj/Map.strings; sourceTree = ""; }; 7F63E3E81D75557500110E9F /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/Map.strings; sourceTree = ""; }; 7F63E3E91D75557600110E9F /* ja */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = ja; path = ja.lproj/Map.strings; sourceTree = ""; }; - 7F6879021D41BE28003D5742 /* ArrayExtention.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ArrayExtention.swift; sourceTree = ""; }; - 7F6879041D420626003D5742 /* StringExtention.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = StringExtention.swift; sourceTree = ""; }; - 7F7EBFDF1D751EED00F1EE30 /* NSLocaleExtention.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = NSLocaleExtention.swift; sourceTree = ""; }; + 7F6879021D41BE28003D5742 /* ArrayExtension.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ArrayExtension.swift; sourceTree = ""; }; + 7F6879041D420626003D5742 /* StringExtension.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = StringExtension.swift; sourceTree = ""; }; + 7F7EBFDF1D751EED00F1EE30 /* NSLocaleExtension.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = NSLocaleExtension.swift; sourceTree = ""; }; 7F7EBFE11D75308400F1EE30 /* PCJConfig.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PCJConfig.swift; sourceTree = ""; }; - 7F8443CD1D50320400A0BCBA /* UIViewExtention.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = UIViewExtention.swift; sourceTree = ""; }; + 7F8443CD1D50320400A0BCBA /* UIViewExtension.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = UIViewExtension.swift; sourceTree = ""; }; 7FB4D3021D542DD2005F314E /* FloorMapListViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = FloorMapListViewController.swift; sourceTree = ""; }; 7FB4D3041D5433CA005F314E /* DetailImageViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DetailImageViewController.swift; sourceTree = ""; }; 7FB4D3061D5434E2005F314E /* FloorMapZoomableImageViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = FloorMapZoomableImageViewController.swift; sourceTree = ""; }; @@ -230,6 +231,7 @@ DBA2537D1D7344E200FE9DC5 /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/Conference.strings; sourceTree = ""; }; DBA2537F1D7344E300FE9DC5 /* ja */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = ja; path = ja.lproj/Conference.strings; sourceTree = ""; }; DBB2538A1CCB700400AA17C8 /* UIColorExtension.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = UIColorExtension.swift; sourceTree = ""; }; + DBB33BF71D91108E00EC5235 /* UIDeviceExtension.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = UIDeviceExtension.swift; sourceTree = ""; }; DBC72D121D6F0B0C008DF718 /* Alamofire.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Alamofire.framework; path = Carthage/Build/iOS/Alamofire.framework; sourceTree = ""; }; DBC72D131D6F0B0C008DF718 /* Realm.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Realm.framework; path = Carthage/Build/iOS/Realm.framework; sourceTree = ""; }; DBC72D141D6F0B0C008DF718 /* RealmSwift.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = RealmSwift.framework; path = Carthage/Build/iOS/RealmSwift.framework; sourceTree = ""; }; @@ -241,7 +243,7 @@ DBE612071D6DFFBF0043F2DF /* ConferenceModelController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ConferenceModelController.swift; sourceTree = ""; }; DBE612081D6DFFBF0043F2DF /* ConferencePageViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ConferencePageViewController.swift; sourceTree = ""; }; DBEBDB471C8C89FC002B25B3 /* MoreListViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MoreListViewController.swift; sourceTree = ""; }; - DBF32BB41CD48C4C004E7F3B /* AppDelegateExtention.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AppDelegateExtention.swift; sourceTree = ""; }; + DBF32BB41CD48C4C004E7F3B /* AppDelegateExtension.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AppDelegateExtension.swift; sourceTree = ""; }; DBF6D89E1D870E1300F9DAE5 /* GestureType.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = GestureType.swift; sourceTree = ""; }; DBF78FCC1D8CF52B00EA66E4 /* TwitterURLSchemeType.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TwitterURLSchemeType.swift; sourceTree = ""; }; DBF78FCE1D8CF56600EA66E4 /* MailURLSchemeType.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MailURLSchemeType.swift; sourceTree = ""; }; @@ -630,13 +632,14 @@ DBF32BB31CD48C4C004E7F3B /* Extension */ = { isa = PBXGroup; children = ( - DBF32BB41CD48C4C004E7F3B /* AppDelegateExtention.swift */, + DBF32BB41CD48C4C004E7F3B /* AppDelegateExtension.swift */, DBB2538A1CCB700400AA17C8 /* UIColorExtension.swift */, DBFAEC541D3CF7AD00BCC880 /* NSDateExtension.swift */, - 7F6879021D41BE28003D5742 /* ArrayExtention.swift */, - 7F6879041D420626003D5742 /* StringExtention.swift */, - 7F8443CD1D50320400A0BCBA /* UIViewExtention.swift */, - 7F7EBFDF1D751EED00F1EE30 /* NSLocaleExtention.swift */, + 7F6879021D41BE28003D5742 /* ArrayExtension.swift */, + 7F6879041D420626003D5742 /* StringExtension.swift */, + 7F8443CD1D50320400A0BCBA /* UIViewExtension.swift */, + 7F7EBFDF1D751EED00F1EE30 /* NSLocaleExtension.swift */, + DBB33BF71D91108E00EC5235 /* UIDeviceExtension.swift */, ); path = Extension; sourceTree = ""; @@ -854,7 +857,7 @@ DBE6120D1D6DFFBF0043F2DF /* ConferencePageViewController.swift in Sources */, DBF78FCD1D8CF52B00EA66E4 /* TwitterURLSchemeType.swift in Sources */, DB0206891D4FB8430067C94B /* ReceiveLocalNotificationManager.swift in Sources */, - 7F6879031D41BE28003D5742 /* ArrayExtention.swift in Sources */, + 7F6879031D41BE28003D5742 /* ArrayExtension.swift in Sources */, DBE6120A1D6DFFBF0043F2DF /* ConferenceDateViewController.swift in Sources */, DBE6120B1D6DFFBF0043F2DF /* ConferenceListViewController.swift in Sources */, DBF6D89F1D870E1300F9DAE5 /* GestureType.swift in Sources */, @@ -884,13 +887,14 @@ 7FBC34CF1D40F956002919B1 /* AppDelegate.swift in Sources */, DBF78FCF1D8CF56600EA66E4 /* MailURLSchemeType.swift in Sources */, 7F1CBEA11D52CAFA007C058D /* TalkDetail.swift in Sources */, - 7F8443CE1D50320400A0BCBA /* UIViewExtention.swift in Sources */, + 7F8443CE1D50320400A0BCBA /* UIViewExtension.swift in Sources */, DB90E0A51D84022500F2172F /* StaffListDataSource.swift in Sources */, 7F1CBEA21D52CAFA007C058D /* Timeline.swift in Sources */, 7FFB733E1C915B6E006FB375 /* MapViewController.swift in Sources */, 7F1CBE9C1D52CAFA007C058D /* Language.swift in Sources */, DB3A77AE1D5631A400C25D8D /* TalkObject.swift in Sources */, - DBF32BB51CD48C4C004E7F3B /* AppDelegateExtention.swift in Sources */, + DBF32BB51CD48C4C004E7F3B /* AppDelegateExtension.swift in Sources */, + DBB33BF81D91108E00EC5235 /* UIDeviceExtension.swift in Sources */, DB43FCFF1D806AA400BB45EC /* SpeakersCollectionViewDataSource.swift in Sources */, 7F7EBFE21D75308400F1EE30 /* PCJConfig.swift in Sources */, DB90E0AE1D8410A700F2172F /* StaffTableViewCell.swift in Sources */, @@ -904,7 +908,7 @@ 7FB4D3031D542DD2005F314E /* FloorMapListViewController.swift in Sources */, DB1347E01CCB27D900CA0539 /* ErrorAlertType.swift in Sources */, 7FFF87EE1D5AF2070093E316 /* Result.swift in Sources */, - 7F6879051D420626003D5742 /* StringExtention.swift in Sources */, + 7F6879051D420626003D5742 /* StringExtension.swift in Sources */, DB90E0A71D8402EF00F2172F /* Staff.swift in Sources */, DBE6120C1D6DFFBF0043F2DF /* ConferenceModelController.swift in Sources */, DBFE92311D6613C300327F74 /* TimelineDataSource.swift in Sources */, @@ -912,7 +916,7 @@ 7FB4D3091D544333005F314E /* AcknowledgmentsListViewController.swift in Sources */, DBFAEC551D3CF7AD00BCC880 /* NSDateExtension.swift in Sources */, DBFE922E1D66136B00327F74 /* BookmarkListDataSource.swift in Sources */, - 7F7EBFE01D751EED00F1EE30 /* NSLocaleExtention.swift in Sources */, + 7F7EBFE01D751EED00F1EE30 /* NSLocaleExtension.swift in Sources */, 7F1CBEA01D52CAFA007C058D /* Speaker.swift in Sources */, 7F1CBE9D1D52CAFA007C058D /* Category.swift in Sources */, ); diff --git a/PyConJP2016/Extension/AppDelegateExtention.swift b/PyConJP2016/Extension/AppDelegateExtension.swift similarity index 95% rename from PyConJP2016/Extension/AppDelegateExtention.swift rename to PyConJP2016/Extension/AppDelegateExtension.swift index a10997e..0392867 100644 --- a/PyConJP2016/Extension/AppDelegateExtention.swift +++ b/PyConJP2016/Extension/AppDelegateExtension.swift @@ -1,5 +1,5 @@ // -// AppDelegateExtention.swift +// AppDelegateExtension.swift // PyConJP2016 // // Created by Yutaro Muta on 2016/03/15. diff --git a/PyConJP2016/Extension/ArrayExtention.swift b/PyConJP2016/Extension/ArrayExtension.swift similarity index 94% rename from PyConJP2016/Extension/ArrayExtention.swift rename to PyConJP2016/Extension/ArrayExtension.swift index 0be89c7..898a5ff 100644 --- a/PyConJP2016/Extension/ArrayExtention.swift +++ b/PyConJP2016/Extension/ArrayExtension.swift @@ -1,5 +1,5 @@ // -// ArrayExtention.swift +// ArrayExtension.swift // PyConJP2016 // // Created by Yutaro Muta on 2016/07/22. diff --git a/PyConJP2016/Extension/NSLocaleExtention.swift b/PyConJP2016/Extension/NSLocaleExtension.swift similarity index 94% rename from PyConJP2016/Extension/NSLocaleExtention.swift rename to PyConJP2016/Extension/NSLocaleExtension.swift index 30637be..60e7199 100644 --- a/PyConJP2016/Extension/NSLocaleExtention.swift +++ b/PyConJP2016/Extension/NSLocaleExtension.swift @@ -1,5 +1,5 @@ // -// NSLocaleExtention.swift +// NSLocaleExtension.swift // PyConJP2016 // // Created by Yutaro Muta on 8/16/2016. diff --git a/PyConJP2016/Extension/StringExtention.swift b/PyConJP2016/Extension/StringExtension.swift similarity index 97% rename from PyConJP2016/Extension/StringExtention.swift rename to PyConJP2016/Extension/StringExtension.swift index 5fa20e5..11bb367 100644 --- a/PyConJP2016/Extension/StringExtention.swift +++ b/PyConJP2016/Extension/StringExtension.swift @@ -1,5 +1,5 @@ // -// StringExtention.swift +// StringExtension.swift // PyConJP2016 // // Created by Yutaro Muta on 2016/07/22. diff --git a/PyConJP2016/Extension/UIDeviceExtension.swift b/PyConJP2016/Extension/UIDeviceExtension.swift new file mode 100644 index 0000000..0010595 --- /dev/null +++ b/PyConJP2016/Extension/UIDeviceExtension.swift @@ -0,0 +1,24 @@ +// +// UIDeviceExtension.swift +// PyConJP2016 +// +// Created by Yutaro Muta on 9/20/16. +// Copyright © 2016 PyCon JP. All rights reserved. +// + +import UIKit + +extension UIDevice { + + var modelType: String { + var systemInfo = utsname() + uname(&systemInfo) + let machineMirror = Mirror(reflecting: systemInfo.machine) + + return machineMirror.children.reduce("") { identifier, element in + guard let value = element.value as? Int8 where value != 0 else { return identifier } + return identifier + String(UnicodeScalar(UInt8(value))) + } + } + +} diff --git a/PyConJP2016/Extension/UIViewExtention.swift b/PyConJP2016/Extension/UIViewExtension.swift similarity index 97% rename from PyConJP2016/Extension/UIViewExtention.swift rename to PyConJP2016/Extension/UIViewExtension.swift index fbc1c19..4d6c53a 100644 --- a/PyConJP2016/Extension/UIViewExtention.swift +++ b/PyConJP2016/Extension/UIViewExtension.swift @@ -1,5 +1,5 @@ // -// UIViewExtention.swift +// UIViewExtension.swift // PyConJP2016 // // Created by Yutaro Muta on 2016/08/02. diff --git a/PyConJP2016/Protocol/URLScheme/TwitterURLSchemeType.swift b/PyConJP2016/Protocol/URLScheme/TwitterURLSchemeType.swift index fe1cb2a..90b6a77 100644 --- a/PyConJP2016/Protocol/URLScheme/TwitterURLSchemeType.swift +++ b/PyConJP2016/Protocol/URLScheme/TwitterURLSchemeType.swift @@ -22,10 +22,6 @@ extension TwitterURLSchemeType { return NSURL(string: "twitter://")! } -} - -extension TwitterURLSchemeType { - private func openTwitterAppWithAlert(targetName: String, url: NSURL, from viewController: UIViewController) { let alertController = UIAlertController(title: NSLocalizedString("TwitterAlertTitle", tableName: "URLScheme", comment: ""), message: String(format: NSLocalizedString("TwitterAlertMessage", tableName: "URLScheme", comment: ""), arguments: [targetName]), diff --git a/PyConJP2016/ViewController/More/MoreListViewController.swift b/PyConJP2016/ViewController/More/MoreListViewController.swift index 19de557..208a1bb 100644 --- a/PyConJP2016/ViewController/More/MoreListViewController.swift +++ b/PyConJP2016/ViewController/More/MoreListViewController.swift @@ -68,7 +68,7 @@ class MoreListViewController: UITableViewController { return [.Repository, .Library, .License, .Feedback] } } - + } private enum RowType: MailURLSchemeType { @@ -111,7 +111,9 @@ class MoreListViewController: UITableViewController { var urlSheme: NSURL? { switch self { - case .Feedback: return mailURLScheme(PCJConfig.mailAddress, subject: "Feedback for PyCon JP 2016 App", body: "iOS version:\nDevice Model:\nReply-to:\n\nFeedback:") + case .Feedback: return mailURLScheme(PCJConfig.mailAddress, + subject: "Feedback for PyCon JP 2016 App", + body: String(format: "iOS version: %@\nDevice Model: %@\nReply-to:\n\nFeedback:", arguments: [UIDevice.currentDevice().systemVersion, UIDevice.currentDevice().modelType])) default: return nil } } From 8d9f11546646b64c72420538b6c6ebc93bb7bafe Mon Sep 17 00:00:00 2001 From: Yutaro Muta Date: Tue, 4 Oct 2016 13:57:39 +0900 Subject: [PATCH 02/26] Update libraries for carthage --- Cartfile | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Cartfile b/Cartfile index d8d7105..d627dfc 100644 --- a/Cartfile +++ b/Cartfile @@ -1,4 +1,4 @@ # PyCon JP use Library -github "Alamofire/Alamofire" ~> 3.5 -github "Alamofire/AlamofireImage" ~> 2.5 -github "realm/realm-cocoa" ~> 1.0 +github "Alamofire/Alamofire" ~> 4.0 +github "Alamofire/AlamofireImage" ~> 3.0 +github "realm/realm-cocoa" ~> 2.0 From 913e2199338ab0f4741a71df1c3fa1f2653504f1 Mon Sep 17 00:00:00 2001 From: Yutaro Muta Date: Thu, 6 Oct 2016 14:21:00 +0900 Subject: [PATCH 03/26] Convert to Swift3.0 --- PyConJP2016.xcodeproj/project.pbxproj | 21 +++- .../xcschemes/PyConJP2016.xcscheme | 2 +- PyConJP2016/Application/AppDelegate.swift | 30 ++--- PyConJP2016/Application/PCJConfig.swift | 8 +- .../DataSource/More/StaffListDataSource.swift | 36 +++--- .../SpeakersCollectionViewDataSource.swift | 8 +- .../Bookmark/BookmarkListDataSource.swift | 16 +-- .../Conference/ConferenceListDataSource.swift | 14 +-- .../Timeline/TimelineDataSource.swift | 12 +- .../Extension/AppDelegateExtension.swift | 6 +- PyConJP2016/Extension/NSDateExtension.swift | 30 ++--- PyConJP2016/Extension/NSLocaleExtension.swift | 8 +- PyConJP2016/Extension/StringExtension.swift | 24 ++-- PyConJP2016/Extension/UIColorExtension.swift | 10 +- PyConJP2016/Extension/UIDeviceExtension.swift | 2 +- PyConJP2016/Extension/UIViewExtension.swift | 2 +- .../LocalNotificationManager.swift | 24 ++-- .../ReceiveLocalNotificationManager.swift | 16 +-- PyConJP2016/Model/Class/TalkObject.swift | 12 +- PyConJP2016/Model/Enum/Result.swift | 20 ++-- PyConJP2016/Model/Struct/Talk.swift | 4 +- .../Protocol/Alamofire/AlamofireType.swift | 37 +++--- .../Protocol/Alamofire/StaffListAPIType.swift | 13 +-- .../Alamofire/TalkDetailAPIType.swift | 28 ++--- .../Protocol/Alamofire/TalksAPIType.swift | 38 +++--- PyConJP2016/Protocol/ErrorAlertType.swift | 12 +- PyConJP2016/Protocol/GestureType.swift | 28 ++--- .../Protocol/Realm/RealmTalksType.swift | 10 +- .../URLScheme/MailURLSchemeType.swift | 18 +-- .../URLScheme/TwitterURLSchemeType.swift | 48 ++++---- PyConJP2016/View/CustomImageView.swift | 46 ++++---- .../SpeakerCollectionViewCell.swift | 6 +- .../UITableViewCell/StaffTableViewCell.swift | 18 +-- .../UITableViewCell/TalkTableViewCell.swift | 4 +- .../Base/BaseTabBarController.swift | 18 +-- .../Base/TalkDetailViewController.swift | 50 ++++---- .../Base/ZoomableImageViewController.swift | 42 +++---- .../Bookmark/BookmarkListViewController.swift | 30 ++--- .../ConferenceBaseViewController.swift | 26 ++--- .../ConferenceDateViewController.swift | 30 ++--- .../ConferenceListViewController.swift | 46 ++++---- .../ConferenceModelController.swift | 14 +-- .../ConferencePageViewController.swift | 20 ++-- .../Conference/ConferenceViewController.swift | 2 +- .../Events/EventsListViewController.swift | 88 +++++++------- .../AcknowledgmentsListViewController.swift | 34 +++--- .../More/FloorMapListViewController.swift | 36 +++--- .../FloorMapZoomableImageViewController.swift | 36 +++--- .../More/MapListViewController.swift | 24 ++-- .../More/MapViewController.swift | 24 ++-- .../More/MoreListViewController.swift | 108 +++++++++--------- .../More/StaffListViewController.swift | 36 +++--- .../WebView/PCJWKWebViewController.swift | 28 ++--- PyConJP2016Tests/PyConJP2016Tests.swift | 2 +- 54 files changed, 653 insertions(+), 652 deletions(-) diff --git a/PyConJP2016.xcodeproj/project.pbxproj b/PyConJP2016.xcodeproj/project.pbxproj index 68a216e..e13dd2e 100644 --- a/PyConJP2016.xcodeproj/project.pbxproj +++ b/PyConJP2016.xcodeproj/project.pbxproj @@ -737,20 +737,24 @@ isa = PBXProject; attributes = { LastSwiftUpdateCheck = 0720; - LastUpgradeCheck = 0720; + LastUpgradeCheck = 0800; ORGANIZATIONNAME = "Yutaro Muta"; TargetAttributes = { DBA1C0A81C7228E2004F0C8D = { CreatedOnToolsVersion = 7.2; + LastSwiftMigration = 0800; + ProvisioningStyle = Automatic; }; DBA1C0BC1C7228E2004F0C8D = { CreatedOnToolsVersion = 7.2; DevelopmentTeam = 3T8B5JQDB8; + LastSwiftMigration = 0800; TestTargetID = DBA1C0A81C7228E2004F0C8D; }; DBA1C0C71C7228E2004F0C8D = { CreatedOnToolsVersion = 7.2; DevelopmentTeam = 3T8B5JQDB8; + LastSwiftMigration = 0800; TestTargetID = DBA1C0A81C7228E2004F0C8D; }; }; @@ -1061,6 +1065,7 @@ isa = XCBuildConfiguration; buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES; CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; CLANG_CXX_LIBRARY = "libc++"; CLANG_ENABLE_MODULES = YES; @@ -1070,8 +1075,10 @@ CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; CLANG_WARN_EMPTY_BODY = YES; CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; CLANG_WARN_INT_CONVERSION = YES; CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_SUSPICIOUS_MOVE = YES; CLANG_WARN_UNREACHABLE_CODE = YES; CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; @@ -1106,6 +1113,7 @@ isa = XCBuildConfiguration; buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES; CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; CLANG_CXX_LIBRARY = "libc++"; CLANG_ENABLE_MODULES = YES; @@ -1115,8 +1123,10 @@ CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; CLANG_WARN_EMPTY_BODY = YES; CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; CLANG_WARN_INT_CONVERSION = YES; CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_SUSPICIOUS_MOVE = YES; CLANG_WARN_UNREACHABLE_CODE = YES; CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; @@ -1135,6 +1145,7 @@ IPHONEOS_DEPLOYMENT_TARGET = 9.2; MTL_ENABLE_DEBUG_INFO = NO; SDKROOT = iphoneos; + SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; TARGETED_DEVICE_FAMILY = "1,2"; VALIDATE_PRODUCT = YES; }; @@ -1146,6 +1157,7 @@ ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; CODE_SIGN_IDENTITY = "iPhone Developer"; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; + DEVELOPMENT_TEAM = ""; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", "$(PROJECT_DIR)/Carthage/Build/iOS", @@ -1156,6 +1168,7 @@ PRODUCT_BUNDLE_IDENTIFIER = PyConJP2016; PRODUCT_NAME = "$(TARGET_NAME)"; PROVISIONING_PROFILE = ""; + SWIFT_VERSION = 3.0; TARGETED_DEVICE_FAMILY = 1; }; name = Debug; @@ -1166,6 +1179,7 @@ ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; CODE_SIGN_IDENTITY = "iPhone Developer"; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; + DEVELOPMENT_TEAM = ""; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", "$(PROJECT_DIR)/Carthage/Build/iOS", @@ -1176,6 +1190,7 @@ PRODUCT_BUNDLE_IDENTIFIER = PyConJP2016; PRODUCT_NAME = "$(TARGET_NAME)"; PROVISIONING_PROFILE = ""; + SWIFT_VERSION = 3.0; TARGETED_DEVICE_FAMILY = 1; }; name = Release; @@ -1188,6 +1203,7 @@ LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = yutaro.PyConJP2016Tests; PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_VERSION = 3.0; TEST_HOST = "$(BUILT_PRODUCTS_DIR)/PyConJP2016.app/PyConJP2016"; }; name = Debug; @@ -1200,6 +1216,7 @@ LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = yutaro.PyConJP2016Tests; PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_VERSION = 3.0; TEST_HOST = "$(BUILT_PRODUCTS_DIR)/PyConJP2016.app/PyConJP2016"; }; name = Release; @@ -1211,6 +1228,7 @@ LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = yutaro.PyConJP2016UITests; PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_VERSION = 3.0; TEST_TARGET_NAME = PyConJP2016; USES_XCTRUNNER = YES; }; @@ -1223,6 +1241,7 @@ LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = yutaro.PyConJP2016UITests; PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_VERSION = 3.0; TEST_TARGET_NAME = PyConJP2016; USES_XCTRUNNER = YES; }; diff --git a/PyConJP2016.xcodeproj/xcshareddata/xcschemes/PyConJP2016.xcscheme b/PyConJP2016.xcodeproj/xcshareddata/xcschemes/PyConJP2016.xcscheme index d5e530e..ac4f215 100644 --- a/PyConJP2016.xcodeproj/xcshareddata/xcschemes/PyConJP2016.xcscheme +++ b/PyConJP2016.xcodeproj/xcshareddata/xcschemes/PyConJP2016.xcscheme @@ -1,6 +1,6 @@ Bool { + func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool { // let settings = UIUserNotificationSettings(forTypes: [UIUserNotificationType.Alert, UIUserNotificationType.Badge, UIUserNotificationType.Sound], categories: nil) // UIApplication.sharedApplication().registerUserNotificationSettings(settings) // @@ -32,46 +32,46 @@ class AppDelegate: UIResponder, UIApplicationDelegate, TalksAPIType, ErrorAlertT getTalks { result in switch result { - case .Success: - NSNotificationCenter.defaultCenter().postNotificationName(PCJNotificationConfig.CompleteFetchDataNotification, object: nil) - case .Failure(let error): + case .success: + NotificationCenter.default.post(name: Notification.Name(rawValue: PCJNotificationConfig.CompleteFetchDataNotification), object: nil) + case .failure(let error): self.showErrorAlartWith(error) } } UINavigationBar.appearance().barTintColor = .pyconJP2016RedColor() - UINavigationBar.appearance().tintColor = .whiteColor() - UINavigationBar.appearance().titleTextAttributes = [NSForegroundColorAttributeName: UIColor.whiteColor()] + UINavigationBar.appearance().tintColor = .white + UINavigationBar.appearance().titleTextAttributes = [NSForegroundColorAttributeName: UIColor.white] UITabBar.appearance().tintColor = UIColor.pyconJP2016BlueColor() - UITabBarItem.appearance().setTitleTextAttributes([NSFontAttributeName: UIFont.boldSystemFontOfSize(10), NSForegroundColorAttributeName: UIColor.pyconJP2016BlueColor()], forState: .Selected) + UITabBarItem.appearance().setTitleTextAttributes([NSFontAttributeName: UIFont.boldSystemFont(ofSize: 10), NSForegroundColorAttributeName: UIColor.pyconJP2016BlueColor()], for: .selected) return true } - func applicationWillResignActive(application: UIApplication) { + func applicationWillResignActive(_ application: UIApplication) { } - func applicationDidEnterBackground(application: UIApplication) { + func applicationDidEnterBackground(_ application: UIApplication) { } - func applicationWillEnterForeground(application: UIApplication) { + func applicationWillEnterForeground(_ application: UIApplication) { } - func applicationDidBecomeActive(application: UIApplication) { - UIApplication.sharedApplication().applicationIconBadgeNumber = 0 + func applicationDidBecomeActive(_ application: UIApplication) { + UIApplication.shared.applicationIconBadgeNumber = 0 } - func applicationWillTerminate(application: UIApplication) { + func applicationWillTerminate(_ application: UIApplication) { } - func application(application: UIApplication, didReceiveLocalNotification notification: UILocalNotification) { + func application(_ application: UIApplication, didReceive notification: UILocalNotification) { if let userInfo = notification.userInfo { let receiveLocalNotificationManager = ReceiveLocalNotificationManager() receiveLocalNotificationManager.application(application, didReceiveLocalNotification: userInfo) } - UIApplication.sharedApplication().cancelLocalNotification(notification) + UIApplication.shared.cancelLocalNotification(notification) } } diff --git a/PyConJP2016/Application/PCJConfig.swift b/PyConJP2016/Application/PCJConfig.swift index 364b2be..444f23c 100644 --- a/PyConJP2016/Application/PCJConfig.swift +++ b/PyConJP2016/Application/PCJConfig.swift @@ -11,15 +11,15 @@ import UIKit enum PCJConfig { - static let hostURL = NSProcessInfo.processInfo().environment["APIBaseURL"] ?? "https://pycon.jp" + static let hostURL = ProcessInfo.processInfo.environment["APIBaseURL"] ?? "https://pycon.jp" - static let baseURL = PCJConfig.hostURL + "/2016/" + NSLocale.currentLanguageLocaleIdentifier + "/" + static let baseURL = PCJConfig.hostURL + "/2016/" + Locale.currentLanguageLocaleIdentifier + "/" static let apiURL = PCJConfig.baseURL + "api/" - static let authUser = NSProcessInfo.processInfo().environment["APIAuthUser"] ?? "" + static let authUser = ProcessInfo.processInfo.environment["APIAuthUser"] ?? "" - static let authPassword = NSProcessInfo.processInfo().environment["APIAuthPassword"] ?? "" + static let authPassword = ProcessInfo.processInfo.environment["APIAuthPassword"] ?? "" static let mailAddress = "symposion@pycon.jp" diff --git a/PyConJP2016/DataSource/More/StaffListDataSource.swift b/PyConJP2016/DataSource/More/StaffListDataSource.swift index 959f1dc..63180b4 100644 --- a/PyConJP2016/DataSource/More/StaffListDataSource.swift +++ b/PyConJP2016/DataSource/More/StaffListDataSource.swift @@ -14,52 +14,52 @@ class StaffListDataSource: NSObject, UITableViewDataSource, StaffListAPIType { var teams: [Team] = [] - let facebookAction: ((url: String) -> (() -> Void)) - let twitterAction: ((url: String) -> (() -> Void)) + let facebookAction: ((_ url: String) -> (() -> Void)) + let twitterAction: ((_ url: String) -> (() -> Void)) - init(facebookAction: ((url: String) -> (() -> Void)), twitterAction: ((url: String) -> (() -> Void))) { + init(facebookAction: @escaping ((_ url: String) -> (() -> Void)), twitterAction: @escaping ((_ url: String) -> (() -> Void))) { self.facebookAction = facebookAction self.twitterAction = twitterAction } - func refreshData(completionHandler: (Result -> Void)) -> Void { + func refreshData(_ completionHandler: @escaping ((Result) -> Void)) -> Void { getStaffs { [weak self](result) in guard let weakSelf = self else { return } switch result { - case .Success(let staffs): + case .success(let staffs): weakSelf.teams.removeAll() let teamNames = staffs.map({ $0.team }).unique() - for tuple in teamNames.enumerate() { - weakSelf.teams.append(Team(name: teamNames[tuple.index], staffs: staffs.filter({ $0.team == teamNames[tuple.index] }))) + for tuple in teamNames.enumerated() { + weakSelf.teams.append(Team(name: teamNames[tuple.offset], staffs: staffs.filter({ $0.team == teamNames[tuple.offset] }))) } - completionHandler(.Success()) - case .Failure(let error): - completionHandler(.Failure(error)) + completionHandler(.success()) + case .failure(let error): + completionHandler(.failure(error)) } } } // MARK: - Table View Controller Data Source - func numberOfSectionsInTableView(tableView: UITableView) -> Int { + func numberOfSections(in tableView: UITableView) -> Int { return teams.count } - func tableView(tableView: UITableView, titleForHeaderInSection section: Int) -> String? { + func tableView(_ tableView: UITableView, titleForHeaderInSection section: Int) -> String? { return teams[section].name } - func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int { + func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { return teams[section].staffs.count } - func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell { - guard let cell = tableView.dequeueReusableCellWithIdentifier(reuseIdentifier, forIndexPath: indexPath) as? StaffTableViewCell else { + func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { + guard let cell = tableView.dequeueReusableCell(withIdentifier: reuseIdentifier, for: indexPath) as? StaffTableViewCell else { fatalError("Could not create StaffTableViewCell") } - cell.fill(teams[indexPath.section].staffs[indexPath.row], - onFacebookButton: facebookAction(url: teams[indexPath.section].staffs[indexPath.row].facebook), - onTwitterButton: twitterAction(url: teams[indexPath.section].staffs[indexPath.row].twitter)) + cell.fill(teams[(indexPath as NSIndexPath).section].staffs[(indexPath as NSIndexPath).row], + onFacebookButton: facebookAction(teams[(indexPath as NSIndexPath).section].staffs[(indexPath as NSIndexPath).row].facebook), + onTwitterButton: twitterAction(teams[(indexPath as NSIndexPath).section].staffs[(indexPath as NSIndexPath).row].twitter)) return cell } } diff --git a/PyConJP2016/DataSource/TalkDetail/SpeakersCollectionViewDataSource.swift b/PyConJP2016/DataSource/TalkDetail/SpeakersCollectionViewDataSource.swift index 6b91a11..3097998 100644 --- a/PyConJP2016/DataSource/TalkDetail/SpeakersCollectionViewDataSource.swift +++ b/PyConJP2016/DataSource/TalkDetail/SpeakersCollectionViewDataSource.swift @@ -14,13 +14,13 @@ class SpeakersCollectionViewDataSource: NSObject, UICollectionViewDataSource { var speakers: [Speaker] = [] - func collectionView(collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int { + func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int { return speakers.count } - func collectionView(collectionView: UICollectionView, cellForItemAtIndexPath indexPath: NSIndexPath) -> UICollectionViewCell { - let cell = collectionView.dequeueReusableCellWithReuseIdentifier(reuseIdentifier, forIndexPath: indexPath) as! SpeakerCollectionViewCell - cell.fill(speakers[indexPath.row]) + func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell { + let cell = collectionView.dequeueReusableCell(withReuseIdentifier: reuseIdentifier, for: indexPath) as! SpeakerCollectionViewCell + cell.fill(speakers[(indexPath as NSIndexPath).row]) return cell } } diff --git a/PyConJP2016/DataSource/Timeline/Bookmark/BookmarkListDataSource.swift b/PyConJP2016/DataSource/Timeline/Bookmark/BookmarkListDataSource.swift index 8428a5f..aa8f959 100644 --- a/PyConJP2016/DataSource/Timeline/Bookmark/BookmarkListDataSource.swift +++ b/PyConJP2016/DataSource/Timeline/Bookmark/BookmarkListDataSource.swift @@ -11,22 +11,22 @@ import RealmSwift class BookmarkListDataSource: TimelineDataSource, RealmTalksType { - let filterPredicate = NSPredicate(format: "favorited == %@", true) + let filterPredicate = NSPredicate(format: "favorited == %@", true as CVarArg) let sortProperties = [SortDescriptor(property: "date", ascending: true), SortDescriptor(property: "place", ascending: true)] - func refreshData(completionHandler: (Result -> Void)) -> Void { + func refreshData(_ completionHandler: @escaping ((Result) -> Void)) -> Void { loadTalkObjects { [weak self](result) in guard let weakSelf = self else { return } switch result { - case .Success(let talks): + case .success(let talks): weakSelf.timelines.removeAll() let keys = talks.map { $0.day }.unique() - for tuple in keys.enumerate() { - weakSelf.timelines.append(Timeline(key: keys[tuple.index], talks: talks.filter { $0.day == keys[tuple.index]})) + for tuple in keys.enumerated() { + weakSelf.timelines.append(Timeline(key: keys[tuple.offset], talks: talks.filter { $0.day == keys[tuple.offset]})) } - completionHandler(.Success()) - case .Failure(let error): - completionHandler(.Failure(error)) + completionHandler(.success()) + case .failure(let error): + completionHandler(.failure(error)) } } } diff --git a/PyConJP2016/DataSource/Timeline/Conference/ConferenceListDataSource.swift b/PyConJP2016/DataSource/Timeline/Conference/ConferenceListDataSource.swift index fa014d2..4af4ec1 100644 --- a/PyConJP2016/DataSource/Timeline/Conference/ConferenceListDataSource.swift +++ b/PyConJP2016/DataSource/Timeline/Conference/ConferenceListDataSource.swift @@ -19,19 +19,19 @@ class ConferenceListDataSource: TimelineDataSource, RealmTalksType { super.init() } - func refreshData(completionHandler: (Result -> Void)) -> Void { + func refreshData(_ completionHandler: @escaping ((Result) -> Void)) -> Void { loadTalkObjects { [weak self](result) in guard let weakSelf = self else { return } switch result { - case .Success(let talks): + case .success(let talks): weakSelf.timelines.removeAll() let keys = talks.map { $0.startTime }.unique() - for tuple in keys.enumerate() { - weakSelf.timelines.append(Timeline(time: keys[tuple.index], talks: talks.filter { $0.startTime == keys[tuple.index]})) + for tuple in keys.enumerated() { + weakSelf.timelines.append(Timeline(time: keys[tuple.offset], talks: talks.filter { $0.startTime == keys[tuple.offset]})) } - completionHandler(.Success()) - case .Failure(let error): - completionHandler(.Failure(error)) + completionHandler(.success()) + case .failure(let error): + completionHandler(.failure(error)) } } } diff --git a/PyConJP2016/DataSource/Timeline/TimelineDataSource.swift b/PyConJP2016/DataSource/Timeline/TimelineDataSource.swift index 096d028..ef29a39 100644 --- a/PyConJP2016/DataSource/Timeline/TimelineDataSource.swift +++ b/PyConJP2016/DataSource/Timeline/TimelineDataSource.swift @@ -16,23 +16,23 @@ class TimelineDataSource: NSObject, UITableViewDataSource { // MARK: - Table View Controller Data Source - func numberOfSectionsInTableView(tableView: UITableView) -> Int { + func numberOfSections(in tableView: UITableView) -> Int { return timelines.count } - func tableView(tableView: UITableView, titleForHeaderInSection section: Int) -> String? { + func tableView(_ tableView: UITableView, titleForHeaderInSection section: Int) -> String? { return timelines[section].key } - func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int { + func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { return timelines[section].talks.count } - func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell { - guard let cell = tableView.dequeueReusableCellWithIdentifier(reuseIdentifier, forIndexPath: indexPath) as? TalkTableViewCell else { + func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { + guard let cell = tableView.dequeueReusableCell(withIdentifier: reuseIdentifier, for: indexPath) as? TalkTableViewCell else { fatalError("Could not create TalkTableViewCell") } - cell.fill(timelines[indexPath.section].talks[indexPath.row]) + cell.fill(timelines[(indexPath as NSIndexPath).section].talks[(indexPath as NSIndexPath).row]) return cell } } diff --git a/PyConJP2016/Extension/AppDelegateExtension.swift b/PyConJP2016/Extension/AppDelegateExtension.swift index 0392867..bf733fa 100644 --- a/PyConJP2016/Extension/AppDelegateExtension.swift +++ b/PyConJP2016/Extension/AppDelegateExtension.swift @@ -10,11 +10,11 @@ import UIKit extension AppDelegate { - func showAlert(alertController: UIAlertController) { - self.window?.rootViewController?.presentingViewController?.presentViewController(alertController, animated: true, completion: nil) + func showAlert(_ alertController: UIAlertController) { + self.window?.rootViewController?.presentingViewController?.present(alertController, animated: true, completion: nil) } - func openTalkDetailViewController(id: Int) { + func openTalkDetailViewController(_ id: Int) { let talkDetailViewController = TalkDetailViewController.build(id) self.window?.rootViewController?.presentedViewController?.navigationController?.pushViewController(talkDetailViewController, animated: true) } diff --git a/PyConJP2016/Extension/NSDateExtension.swift b/PyConJP2016/Extension/NSDateExtension.swift index 5156882..706447f 100644 --- a/PyConJP2016/Extension/NSDateExtension.swift +++ b/PyConJP2016/Extension/NSDateExtension.swift @@ -8,28 +8,22 @@ import UIKit -extension NSDate { +extension Date { - static func dateFromString(string: String) -> NSDate? { - - struct Static { - static var onceToken: dispatch_once_t = 0 - static var instance: NSDateFormatter! = nil - } - - dispatch_once(&Static.onceToken) { - let formatter = NSDateFormatter() - formatter.dateFormat = "yyyy-MM-dd HH:mm:ss" - Static.instance = formatter - } - - return Static.instance.dateFromString(string) + static private let dateFormatterInstance: DateFormatter = { + let dateFormatter = DateFormatter() + dateFormatter.dateFormat = "yyyy-MM-dd HH:mm:ss" + return dateFormatter + }() + + static func dateFromString(_ string: String) -> Date? { + return dateFormatterInstance.date(from: string) } func convertToTime() -> String { - let calender = NSCalendar(calendarIdentifier: NSCalendarIdentifierGregorian)! - let components = calender.components([.Year, .Month, .Day, .Weekday, .Hour, .Minute], fromDate: self) - return String(format: "%02d", components.hour) + ":" + String(format: "%02d", components.minute) + let calender = Calendar(identifier: Calendar.Identifier.gregorian) + let components = (calender as NSCalendar).components([.year, .month, .day, .weekday, .hour, .minute], from: self) + return String(format: "%02d", components.hour!) + ":" + String(format: "%02d", components.minute!) } } diff --git a/PyConJP2016/Extension/NSLocaleExtension.swift b/PyConJP2016/Extension/NSLocaleExtension.swift index 60e7199..291a3a5 100644 --- a/PyConJP2016/Extension/NSLocaleExtension.swift +++ b/PyConJP2016/Extension/NSLocaleExtension.swift @@ -8,14 +8,14 @@ import UIKit -extension NSLocale { +extension Locale { static var currentLanguageLocaleIdentifier: String { - return NSBundle.mainBundle().preferredLocalizations.first! + return Bundle.main.preferredLocalizations.first! } - static var currentLanguageLocale: NSLocale { - return NSLocale(localeIdentifier: NSLocale.currentLanguageLocaleIdentifier) + static var currentLanguageLocale: Locale { + return Locale(identifier: Locale.currentLanguageLocaleIdentifier) } } diff --git a/PyConJP2016/Extension/StringExtension.swift b/PyConJP2016/Extension/StringExtension.swift index 11bb367..9b48ede 100644 --- a/PyConJP2016/Extension/StringExtension.swift +++ b/PyConJP2016/Extension/StringExtension.swift @@ -10,25 +10,19 @@ import UIKit extension String { - func convertToDate() -> NSDate? { - - struct Static { - static var onceToken: dispatch_once_t = 0 - static var instance: NSDateFormatter! = nil - } - - dispatch_once(&Static.onceToken) { - let formatter = NSDateFormatter() - formatter.dateFormat = "yyyy-MM-dd HH:mm:ss" - Static.instance = formatter - } - - return Static.instance.dateFromString(self) + static private let dateFormatterInstance: DateFormatter = { + let dateFormatter = DateFormatter() + dateFormatter.dateFormat = "yyyy-MM-dd HH:mm:ss" + return dateFormatter + }() + + func convertToDate() -> Date? { + return String.dateFormatterInstance.date(from: self) } func timeStringByTrimingSecond() -> String { let dateString = "2000-01-01 " + self - guard let date = NSDate.dateFromString(dateString) else { return self } + guard let date = Date.dateFromString(dateString) else { return self } return date.convertToTime() } diff --git a/PyConJP2016/Extension/UIColorExtension.swift b/PyConJP2016/Extension/UIColorExtension.swift index b9a65d4..9d09743 100644 --- a/PyConJP2016/Extension/UIColorExtension.swift +++ b/PyConJP2016/Extension/UIColorExtension.swift @@ -10,18 +10,18 @@ import UIKit extension UIColor { - static func hexStr(hexStr: NSString, alpha: CGFloat) -> UIColor { - let hex = hexStr.stringByReplacingOccurrencesOfString("#", withString: "") - let scanner = NSScanner(string: hex) + static func hexStr(_ hexStr: NSString, alpha: CGFloat) -> UIColor { + let hex = hexStr.replacingOccurrences(of: "#", with: "") + let scanner = Scanner(string: hex) var color: UInt32 = 0 - if scanner.scanHexInt(&color) { + if scanner.scanHexInt32(&color) { let r = CGFloat((color & 0xFF0000) >> 16) / 255.0 let g = CGFloat((color & 0x00FF00) >> 8) / 255.0 let b = CGFloat(color & 0x0000FF) / 255.0 return UIColor(red:r, green:g, blue:b, alpha:alpha) } else { print("invalid hex string") - return UIColor.whiteColor() + return UIColor.white } } diff --git a/PyConJP2016/Extension/UIDeviceExtension.swift b/PyConJP2016/Extension/UIDeviceExtension.swift index 0010595..7fad644 100644 --- a/PyConJP2016/Extension/UIDeviceExtension.swift +++ b/PyConJP2016/Extension/UIDeviceExtension.swift @@ -16,7 +16,7 @@ extension UIDevice { let machineMirror = Mirror(reflecting: systemInfo.machine) return machineMirror.children.reduce("") { identifier, element in - guard let value = element.value as? Int8 where value != 0 else { return identifier } + guard let value = element.value as? Int8, value != 0 else { return identifier } return identifier + String(UnicodeScalar(UInt8(value))) } } diff --git a/PyConJP2016/Extension/UIViewExtension.swift b/PyConJP2016/Extension/UIViewExtension.swift index 4d6c53a..03d9fd6 100644 --- a/PyConJP2016/Extension/UIViewExtension.swift +++ b/PyConJP2016/Extension/UIViewExtension.swift @@ -15,7 +15,7 @@ extension UIViewController { return presentedViewController.topMostViewController() } else { for view in self.view.subviews { - if let subViewController = view.nextResponder() { + if let subViewController = view.next { if subViewController is UIViewController { let viewController = subViewController as! UIViewController return viewController.topMostViewController() diff --git a/PyConJP2016/Manager/Notification/LocalNotificationManager.swift b/PyConJP2016/Manager/Notification/LocalNotificationManager.swift index 041b3b8..3af09b6 100644 --- a/PyConJP2016/Manager/Notification/LocalNotificationManager.swift +++ b/PyConJP2016/Manager/Notification/LocalNotificationManager.swift @@ -10,12 +10,12 @@ import UIKit class LocalNotificationManager: NSObject { - func makeNotification(talkDetail: TalkDetail) -> Bool { + func makeNotification(_ talkDetail: TalkDetail) -> Bool { guard let date = talkDetail.talkObject.date else { return false } - let calendar = NSCalendar(identifier: NSCalendarIdentifierGregorian) - let fireDate = calendar?.dateByAddingUnit(.Minute, value: -10, toDate: date, options: NSCalendarOptions()) + let calendar = Calendar(identifier: Calendar.Identifier.gregorian) + let fireDate = (calendar as NSCalendar?)?.date(byAdding: .minute, value: -10, to: date as Date, options: NSCalendar.Options()) if fireDate!.timeIntervalSinceNow > 0 { self.schedule(talkDetail) @@ -25,30 +25,30 @@ class LocalNotificationManager: NSObject { } } - private func schedule(talkDetail: TalkDetail) { + fileprivate func schedule(_ talkDetail: TalkDetail) { guard let date = talkDetail.talkObject.date else { return } - let calendar = NSCalendar(identifier: NSCalendarIdentifierGregorian) - let fireDate = calendar?.dateByAddingUnit(.Minute, value: -10, toDate: date, options: NSCalendarOptions()) - let userInfo = ["type": "Talk", "id": talkDetail.talkObject.id] as [NSObject : AnyObject] + let calendar = Calendar(identifier: Calendar.Identifier.gregorian) + let fireDate = (calendar as NSCalendar?)?.date(byAdding: .minute, value: -10, to: date as Date, options: NSCalendar.Options()) + let userInfo = ["type": "Talk", "id": talkDetail.talkObject.id] as [AnyHashable: Any] let notificaiton = UILocalNotification() notificaiton.fireDate = fireDate - notificaiton.timeZone = NSTimeZone.systemTimeZone() + notificaiton.timeZone = TimeZone.current notificaiton.alertBody = "10分後に \" \(talkDetail.talkObject.title) \" が開始します。 \(talkDetail.talkObject.place)" notificaiton.userInfo = userInfo - UIApplication.sharedApplication().scheduleLocalNotification(notificaiton) + UIApplication.shared.scheduleLocalNotification(notificaiton) } - func cancelSchedule(talkDetail: TalkDetail) { - if let localNotifications = UIApplication.sharedApplication().scheduledLocalNotifications { + func cancelSchedule(_ talkDetail: TalkDetail) { + if let localNotifications = UIApplication.shared.scheduledLocalNotifications { localNotifications.forEach({ (notification) -> () in if let userInfo = notification.userInfo { if userInfo["id"] as! Int == talkDetail.talkObject.id { - UIApplication.sharedApplication().cancelLocalNotification(notification) + UIApplication.shared.cancelLocalNotification(notification) } } }) diff --git a/PyConJP2016/Manager/Notification/ReceiveLocalNotificationManager.swift b/PyConJP2016/Manager/Notification/ReceiveLocalNotificationManager.swift index 123d546..cb48535 100644 --- a/PyConJP2016/Manager/Notification/ReceiveLocalNotificationManager.swift +++ b/PyConJP2016/Manager/Notification/ReceiveLocalNotificationManager.swift @@ -10,19 +10,19 @@ import UIKit class ReceiveLocalNotificationManager: NSObject { - func application(application: UIApplication, didReceiveLocalNotification userInfo: [NSObject : AnyObject]) { - guard let type = userInfo["type"] as? String, id = userInfo["id"] as? Int, appDelegate = UIApplication.sharedApplication().delegate as? AppDelegate else { return } + func application(_ application: UIApplication, didReceiveLocalNotification userInfo: [AnyHashable: Any]) { + guard let type = userInfo["type"] as? String, let id = userInfo["id"] as? Int, let appDelegate = UIApplication.shared.delegate as? AppDelegate else { return } switch type { - case "Talk" where application.applicationState == .Active: - let alertController = UIAlertController(title: "", message: "", preferredStyle: .Alert) - alertController.addAction(UIAlertAction(title: "閉じる", style: .Default, handler: nil)) - alertController.addAction(UIAlertAction(title: "詳細へ", style: .Default, handler: {(action) -> Void in + case "Talk" where application.applicationState == .active: + let alertController = UIAlertController(title: "", message: "", preferredStyle: .alert) + alertController.addAction(UIAlertAction(title: "閉じる", style: .default, handler: nil)) + alertController.addAction(UIAlertAction(title: "詳細へ", style: .default, handler: {(action) -> Void in appDelegate.openTalkDetailViewController(id) })) - if let appDelegate = UIApplication.sharedApplication().delegate as? AppDelegate { + if let appDelegate = UIApplication.shared.delegate as? AppDelegate { appDelegate.showAlert(alertController) } - case "Talk" where application.applicationState == .Inactive: + case "Talk" where application.applicationState == .inactive: appDelegate.openTalkDetailViewController(id) case "Information": break diff --git a/PyConJP2016/Model/Class/TalkObject.swift b/PyConJP2016/Model/Class/TalkObject.swift index f97de28..395b94f 100644 --- a/PyConJP2016/Model/Class/TalkObject.swift +++ b/PyConJP2016/Model/Class/TalkObject.swift @@ -14,7 +14,7 @@ class TalkObject: RealmSwift.Object { dynamic var title = "" dynamic var descriptionText = "" dynamic var speakers = "" - dynamic var date: NSDate? + dynamic var date: Date? dynamic var day = "" dynamic var startTime = "" dynamic var endTime = "" @@ -29,10 +29,10 @@ class TalkObject: RealmSwift.Object { id = dictionary["id"] as? Int ?? 0 title = dictionary["title"] as? String ?? "" descriptionText = dictionary["description"] as? String ?? "" - speakers = (dictionary["speakers"] as? [String] ?? []).enumerate().reduce("") { - $0 + $1.element + ((dictionary["speakers"] as? [String] ?? []).count - 1 == $1.index ? "" : ", ") + speakers = (dictionary["speakers"] as? [String] ?? []).enumerated().reduce("") { + $0 + $1.element + ((dictionary["speakers"] as? [String] ?? []).count - 1 == $1.offset ? "" : ", ") } - date = NSDate.dateFromString((dictionary["day"] as? String ?? "") + " " + (dictionary["start"] as? String ?? "")) + date = Date.dateFromString((dictionary["day"] as? String ?? "") + " " + (dictionary["start"] as? String ?? "")) day = dictionary["day"] as? String ?? "" startTime = dictionary["start"] as? String ?? "" endTime = dictionary["end"] as? String ?? "" @@ -43,7 +43,7 @@ class TalkObject: RealmSwift.Object { do { let realm = try Realm() - if let localTalkObject = (realm.objects(TalkObject).filter("id == %@", id).map { $0 }).first { + if let localTalkObject = (realm.objects(TalkObject.self).filter("id == %@", id).map { $0 }).first { favorited = localTalkObject.favorited } } catch { @@ -60,7 +60,7 @@ class TalkObject: RealmSwift.Object { } var placeNumber: String { - return self.place.componentsSeparatedByCharactersInSet(NSCharacterSet.decimalDigitCharacterSet().invertedSet).last ?? "" + return self.place.components(separatedBy: CharacterSet.decimalDigits.inverted).last ?? "" } var room: TalkRoom? { diff --git a/PyConJP2016/Model/Enum/Result.swift b/PyConJP2016/Model/Enum/Result.swift index 7a3a076..a9c7021 100644 --- a/PyConJP2016/Model/Enum/Result.swift +++ b/PyConJP2016/Model/Enum/Result.swift @@ -8,14 +8,14 @@ import Foundation -enum Result { - case Success(T) - case Failure(Error) +enum Result { + case success(Value) + case failure(Error) var isSuccess: Bool { switch self { - case .Success: return true - case .Failure: return false + case .success: return true + case .failure: return false } } @@ -23,17 +23,17 @@ enum Result { return !isSuccess } - var value: T? { + var value: Value? { switch self { - case .Success(let value): return value - case .Failure: return nil + case .success(let value): return value + case .failure: return nil } } var error: Error? { switch self { - case .Success: return nil - case .Failure(let error): return error + case .success: return nil + case .failure(let error): return error } } diff --git a/PyConJP2016/Model/Struct/Talk.swift b/PyConJP2016/Model/Struct/Talk.swift index 8047846..73b2407 100644 --- a/PyConJP2016/Model/Struct/Talk.swift +++ b/PyConJP2016/Model/Struct/Talk.swift @@ -14,7 +14,7 @@ struct Talk { let title: String let description: String let speakers: [String]? - let date: NSDate? + let date: Date? let day: String let startTime: String let endTime: String @@ -32,7 +32,7 @@ extension Talk { self.title = title self.description = description self.speakers = speakers - self.date = NSDate.dateFromString(day + " " + startTime) + self.date = Date.dateFromString(day + " " + startTime) self.day = day self.startTime = startTime self.endTime = endTime diff --git a/PyConJP2016/Protocol/Alamofire/AlamofireType.swift b/PyConJP2016/Protocol/Alamofire/AlamofireType.swift index ced39ea..687365c 100644 --- a/PyConJP2016/Protocol/Alamofire/AlamofireType.swift +++ b/PyConJP2016/Protocol/Alamofire/AlamofireType.swift @@ -10,22 +10,17 @@ import UIKit import Alamofire protocol AlamofireType { - var alamofireManager: Alamofire.Manager { get } var baseURL: String { get } var path: String { get } var authUser: String { get } var authPassword: String { get } - func get(parameter: Dictionary?, successClosure success: (Dictionary) -> Void, failClosure fail: (NSError) -> Void) -> Void - func get(parameter: Dictionary?, completionHandler: (Result, NSError> -> Void)) -> Void + func get(_ parameter: Dictionary?, successClosure success: @escaping (Dictionary) -> Void, failClosure fail: @escaping (Error) -> Void) -> Void + func get(_ parameter: Dictionary?, completionHandler: @escaping ((Result>) -> Void)) -> Void } extension AlamofireType { - var alamofireManager: Alamofire.Manager { - return Alamofire.Manager.sharedInstance - } - var baseURL: String { return PCJConfig.apiURL } @@ -42,36 +37,36 @@ extension AlamofireType { extension AlamofireType { - func get(parameter: Dictionary? = nil, successClosure success: (Dictionary) -> Void, failClosure fail: (NSError) -> Void) -> Void { + func get(_ parameter: Dictionary? = nil, successClosure success: @escaping (Dictionary) -> Void, failClosure fail: @escaping (Error) -> Void) -> Void { let url = baseURL + path - let responseClosure = { (response: Response) in + let responseClosure = { (response: DataResponse) in switch response.result { - case .Success: - if let responseDicsionary = response.result.value as? Dictionary { + case .success(let value): + if let responseDicsionary = value as? Dictionary { success(responseDicsionary) } - case .Failure(let error): + case .failure(let error): fail(error) } } - alamofireManager.request(.GET, url, parameters: parameter).authenticate(user: authUser, password: authPassword).responseJSON(completionHandler: responseClosure) + Alamofire.request(url, method: .get, parameters: parameter).authenticate(user: authUser, password: authPassword).responseJSON(completionHandler: responseClosure) } - func get(parameter: Dictionary? = nil, completionHandler: (Result, NSError> -> Void)) -> Void { + func get(_ parameter: Dictionary? = nil, completionHandler: @escaping ((Result>) -> Void)) -> Void { let url = baseURL + path - let responseClosure = { (response: Response) in + let responseClosure = { (response: DataResponse) in switch response.result { - case .Success: - if let responseDicsionary = response.result.value as? Dictionary { - completionHandler(.Success(responseDicsionary)) + case .success(let value): + if let responseDicsionary = value as? Dictionary { + completionHandler(.success(responseDicsionary)) } - case .Failure(let error): - completionHandler(.Failure(error)) + case .failure(let error): + completionHandler(.failure(error)) } } - alamofireManager.request(.GET, url, parameters: parameter).authenticate(user: authUser, password: authPassword).responseJSON(completionHandler: responseClosure) + Alamofire.request(url, method: .get, parameters: parameter).authenticate(user: authUser, password: authPassword).responseJSON(completionHandler: responseClosure) } } diff --git a/PyConJP2016/Protocol/Alamofire/StaffListAPIType.swift b/PyConJP2016/Protocol/Alamofire/StaffListAPIType.swift index ab5e5c1..85aaf09 100644 --- a/PyConJP2016/Protocol/Alamofire/StaffListAPIType.swift +++ b/PyConJP2016/Protocol/Alamofire/StaffListAPIType.swift @@ -9,8 +9,7 @@ import UIKit protocol StaffListAPIType: AlamofireType { - - func getStaffs(completionHandler: (Result, NSError> -> Void)) -> Void + func getStaffs(_ completionHandler: @escaping ((Result>) -> Void)) -> Void } extension StaffListAPIType { @@ -27,14 +26,14 @@ extension StaffListAPIType { extension StaffListAPIType { - func getStaffs(completionHandler: (Result, NSError> -> Void)) -> Void { + func getStaffs(_ completionHandler: @escaping ((Result>) -> Void)) -> Void { get() { result in switch result { - case .Success(let value): + case .success(let value): let staffList = value["staffList"] as? Array> ?? [] - completionHandler(.Success(staffList.map({ Staff(dictionary: $0) }))) - case .Failure(let error): - completionHandler(.Failure(error)) + completionHandler(.success(staffList.map({ Staff(dictionary: $0) }))) + case .failure(let error): + completionHandler(.failure(error)) } } diff --git a/PyConJP2016/Protocol/Alamofire/TalkDetailAPIType.swift b/PyConJP2016/Protocol/Alamofire/TalkDetailAPIType.swift index 74df184..0accb63 100644 --- a/PyConJP2016/Protocol/Alamofire/TalkDetailAPIType.swift +++ b/PyConJP2016/Protocol/Alamofire/TalkDetailAPIType.swift @@ -12,9 +12,9 @@ import RealmSwift protocol TalkDetailAPIType: AlamofireType { var id: Int? { get set } - func getTalkDetail(successClosure success: (TalkDetail) -> Void, failClosure fail: (NSError) -> Void) -> Void - func getTalkDetail(completionHandler: (Result -> Void)) -> Void - func getTalkDetailFromLocalDummyJson(completionHandler: (Result -> Void)) -> Void + func getTalkDetail(successClosure success: @escaping (TalkDetail) -> Void, failClosure fail: @escaping (Error) -> Void) -> Void + func getTalkDetail(_ completionHandler: @escaping ((Result) -> Void)) -> Void + func getTalkDetailFromLocalDummyJson(_ completionHandler: ((Result) -> Void)) -> Void } extension TalkDetailAPIType { @@ -28,7 +28,7 @@ extension TalkDetailAPIType { extension TalkDetailAPIType { - func getTalkDetail(successClosure success: (TalkDetail) -> Void, failClosure fail: (NSError) -> Void) -> Void { + func getTalkDetail(successClosure success: @escaping (TalkDetail) -> Void, failClosure fail: @escaping (Error) -> Void) -> Void { get(successClosure: { dictionary in let talkDetail = TalkDetail(dictionary: dictionary) success(talkDetail) @@ -37,26 +37,26 @@ extension TalkDetailAPIType { }) } - func getTalkDetail(completionHandler: (Result -> Void)) -> Void { + func getTalkDetail(_ completionHandler: @escaping ((Result) -> Void)) -> Void { get() { result in switch result { - case .Success(let value): + case .success(let value): let talkDetail = TalkDetail(dictionary: value) - completionHandler(.Success(talkDetail)) - case .Failure(let error): - completionHandler(.Failure(error)) + completionHandler(.success(talkDetail)) + case .failure(let error): + completionHandler(.failure(error)) } } } - func getTalkDetailFromLocalDummyJson(completionHandler: (Result -> Void)) -> Void { - let path = NSBundle.mainBundle().pathForResource("DummyTalkDetail", ofType: "json") - let fileHandle = NSFileHandle(forReadingAtPath: path!) + func getTalkDetailFromLocalDummyJson(_ completionHandler: ((Result) -> Void)) -> Void { + let path = Bundle.main.path(forResource: "DummyTalkDetail", ofType: "json") + let fileHandle = FileHandle(forReadingAtPath: path!) let data = fileHandle?.readDataToEndOfFile() - let dictionary = try! NSJSONSerialization.JSONObjectWithData(data!, options: .AllowFragments) as! Dictionary + let dictionary = try! JSONSerialization.jsonObject(with: data!, options: .allowFragments) as! Dictionary let talkDetail = TalkDetail(dictionary: dictionary) - completionHandler(.Success(talkDetail)) + completionHandler(.success(talkDetail)) } diff --git a/PyConJP2016/Protocol/Alamofire/TalksAPIType.swift b/PyConJP2016/Protocol/Alamofire/TalksAPIType.swift index 7a6e758..55d379a 100644 --- a/PyConJP2016/Protocol/Alamofire/TalksAPIType.swift +++ b/PyConJP2016/Protocol/Alamofire/TalksAPIType.swift @@ -10,9 +10,9 @@ import UIKit import RealmSwift protocol TalksAPIType: AlamofireType { - func getTalks(successClosure success: () -> Void, failClosure fail: (NSError) -> Void) -> Void - func getTalks(completionHandler: (Result -> Void)) -> Void - func getTalksFromLocalDummyJson(completionHandler: (Result -> Void)) -> Void + func getTalks(successClosure success: @escaping () -> Void, failClosure fail: @escaping (Error) -> Void) -> Void + func getTalks(_ completionHandler: @escaping ((Result) -> Void)) -> Void + func getTalksFromLocalDummyJson(_ completionHandler: ((Result) -> Void)) -> Void } extension TalksAPIType { @@ -25,7 +25,7 @@ extension TalksAPIType { extension TalksAPIType { - func getTalks(successClosure success: () -> Void, failClosure fail: (NSError) -> Void) -> Void { + func getTalks(successClosure success: @escaping () -> Void, failClosure fail: @escaping (Error) -> Void) -> Void { get(successClosure: { dictionary in let presentations = dictionary["presentations"] as? Array> ?? [Dictionary]() @@ -33,14 +33,14 @@ extension TalksAPIType { let apiTalks = presentations.map({ TalkObject(dictionary: $0) }) let realm = try Realm() - let rejectedLocalTalks = realm.objects(TalkObject).filter("NOT(id IN %@)", apiTalks.map({ $0.id })) + let rejectedLocalTalks = realm.objects(TalkObject.self).filter("NOT(id IN %@)", apiTalks.map({ $0.id })) try realm.write({ realm.delete(rejectedLocalTalks) realm.add(apiTalks, update: true) }) success() - } catch let error as NSError { + } catch let error { fail(error) } @@ -49,37 +49,37 @@ extension TalksAPIType { }) } - func getTalks(completionHandler: (Result -> Void)) -> Void { + func getTalks(_ completionHandler: @escaping ((Result) -> Void)) -> Void { get() { result in switch result { - case .Success(let value): + case .success(let value): let presentations = value["presentations"] as? Array> ?? [Dictionary]() do { let apiTalks = presentations.map({ TalkObject(dictionary: $0) }) let realm = try Realm() - let rejectedLocalTalks = realm.objects(TalkObject).filter("NOT(id IN %@)", apiTalks.map({ $0.id })) + let rejectedLocalTalks = realm.objects(TalkObject.self).filter("NOT(id IN %@)", apiTalks.map({ $0.id })) try realm.write({ realm.delete(rejectedLocalTalks) realm.add(apiTalks, update: true) }) - completionHandler(.Success()) + completionHandler(.success()) } catch let error as NSError { - completionHandler(.Failure(error)) + completionHandler(.failure(error)) } - case .Failure(let error): - completionHandler(.Failure(error)) + case .failure(let error): + completionHandler(.failure(error)) } } } - func getTalksFromLocalDummyJson(completionHandler: (Result -> Void)) -> Void { - let path = NSBundle.mainBundle().pathForResource("DummyTalks", ofType: "json") - let fileHandle = NSFileHandle(forReadingAtPath: path!) + func getTalksFromLocalDummyJson(_ completionHandler: ((Result) -> Void)) -> Void { + let path = Bundle.main.path(forResource: "DummyTalks", ofType: "json") + let fileHandle = FileHandle(forReadingAtPath: path!) let data = fileHandle?.readDataToEndOfFile() - let dictionary = try! NSJSONSerialization.JSONObjectWithData(data!, options: .AllowFragments) as! Dictionary + let dictionary = try! JSONSerialization.jsonObject(with: data!, options: .allowFragments) as! Dictionary let presentations = dictionary["presentations"] as? Array> ?? [Dictionary]() do { @@ -91,9 +91,9 @@ extension TalksAPIType { }) }) - completionHandler(.Success()) + completionHandler(.success()) } catch let error as NSError { - completionHandler(.Failure(error)) + completionHandler(.failure(error)) } } diff --git a/PyConJP2016/Protocol/ErrorAlertType.swift b/PyConJP2016/Protocol/ErrorAlertType.swift index 783ec12..047ea6e 100644 --- a/PyConJP2016/Protocol/ErrorAlertType.swift +++ b/PyConJP2016/Protocol/ErrorAlertType.swift @@ -9,16 +9,16 @@ import UIKit protocol ErrorAlertType { - func showErrorAlartWith(error: NSError, parent viewController: UIViewController?) -> Void + func showErrorAlartWith(_ error: Error, parent viewController: UIViewController?) -> Void } extension ErrorAlertType { - func showErrorAlartWith(error: NSError, parent viewController: UIViewController? = nil) -> Void { + func showErrorAlartWith(_ error: Error, parent viewController: UIViewController? = nil) -> Void { - let rootViewController = viewController != nil ? viewController! : UIApplication.sharedApplication().keyWindow!.rootViewController! + let rootViewController = viewController != nil ? viewController! : UIApplication.shared.keyWindow!.rootViewController! - let alert = UIAlertController(title: error.localizedFailureReason, message: error.localizedRecoverySuggestion, preferredStyle: .Alert) - alert.addAction(UIAlertAction(title: "OK", style: .Default, handler: nil)) - rootViewController.presentViewController(alert, animated: true, completion: nil) + let alert = UIAlertController(title: "", message: error.localizedDescription, preferredStyle: .alert) + alert.addAction(UIAlertAction(title: "OK", style: .default, handler: nil)) + rootViewController.present(alert, animated: true, completion: nil) } } diff --git a/PyConJP2016/Protocol/GestureType.swift b/PyConJP2016/Protocol/GestureType.swift index 7760c8a..4a45a80 100644 --- a/PyConJP2016/Protocol/GestureType.swift +++ b/PyConJP2016/Protocol/GestureType.swift @@ -9,20 +9,20 @@ import UIKit protocol GestureType { - func handleGesture(gesture: UIGestureRecognizer) - func singleTap(gesture: UITapGestureRecognizer) - func doubleTap(gesture: UITapGestureRecognizer) - func pinch(gesture: UIPinchGestureRecognizer) - func pan(gesture: UIPanGestureRecognizer) - func longPress(gesture: UILongPressGestureRecognizer) + func handleGesture(_ gesture: UIGestureRecognizer) + func singleTap(_ gesture: UITapGestureRecognizer) + func doubleTap(_ gesture: UITapGestureRecognizer) + func pinch(_ gesture: UIPinchGestureRecognizer) + func pan(_ gesture: UIPanGestureRecognizer) + func longPress(_ gesture: UILongPressGestureRecognizer) } extension GestureType { - func handleGesture(gesture: UIGestureRecognizer) { - if let singleTapGesture = gesture as? UITapGestureRecognizer where singleTapGesture.numberOfTapsRequired == 1 { + func handleGesture(_ gesture: UIGestureRecognizer) { + if let singleTapGesture = gesture as? UITapGestureRecognizer, singleTapGesture.numberOfTapsRequired == 1 { singleTap(singleTapGesture) - } else if let doubleTapGesture = gesture as? UITapGestureRecognizer where doubleTapGesture.numberOfTapsRequired == 2 { + } else if let doubleTapGesture = gesture as? UITapGestureRecognizer, doubleTapGesture.numberOfTapsRequired == 2 { doubleTap(doubleTapGesture) } else if let pinchGesture = gesture as? UIPinchGestureRecognizer { pinch(pinchGesture) @@ -33,14 +33,14 @@ extension GestureType { } } - func singleTap(gesture: UITapGestureRecognizer) {} + func singleTap(_ gesture: UITapGestureRecognizer) {} - func doubleTap(gesture: UITapGestureRecognizer) {} + func doubleTap(_ gesture: UITapGestureRecognizer) {} - func pinch(gesture: UIPinchGestureRecognizer) {} + func pinch(_ gesture: UIPinchGestureRecognizer) {} - func pan(gesture: UIPanGestureRecognizer) {} + func pan(_ gesture: UIPanGestureRecognizer) {} - func longPress(gesture: UILongPressGestureRecognizer) {} + func longPress(_ gesture: UILongPressGestureRecognizer) {} } diff --git a/PyConJP2016/Protocol/Realm/RealmTalksType.swift b/PyConJP2016/Protocol/Realm/RealmTalksType.swift index 3e378ee..c18eea6 100644 --- a/PyConJP2016/Protocol/Realm/RealmTalksType.swift +++ b/PyConJP2016/Protocol/Realm/RealmTalksType.swift @@ -13,18 +13,18 @@ protocol RealmTalksType { var filterPredicate: NSPredicate { get } var sortProperties: Array { get } - func loadTalkObjects(completionHandler: (Result, NSError> -> Void)) -> Void + func loadTalkObjects(_ completionHandler: ((Result>) -> Void)) -> Void } extension RealmTalksType { - func loadTalkObjects(completionHandler: (Result, NSError> -> Void)) -> Void { + func loadTalkObjects(_ completionHandler: ((Result>) -> Void)) -> Void { do { let realm = try Realm() - let talks = realm.objects(TalkObject).filter(filterPredicate).sorted(sortProperties).map { $0 } - completionHandler(.Success(talks)) + let talks = Array(realm.objects(TalkObject.self).filter(filterPredicate).sorted(by: sortProperties)) + completionHandler(.success(talks)) } catch let error as NSError { - completionHandler(.Failure(error)) + completionHandler(.failure(error)) } } diff --git a/PyConJP2016/Protocol/URLScheme/MailURLSchemeType.swift b/PyConJP2016/Protocol/URLScheme/MailURLSchemeType.swift index 7b2d577..4d29d3e 100644 --- a/PyConJP2016/Protocol/URLScheme/MailURLSchemeType.swift +++ b/PyConJP2016/Protocol/URLScheme/MailURLSchemeType.swift @@ -10,29 +10,29 @@ import UIKit protocol MailURLSchemeType { - func mailURLScheme(to: String, subject: String, body: String) -> NSURL? - func openMail(to: String, subject: String, body: String) + func mailURLScheme(_ to: String, subject: String, body: String) -> URL? + func openMail(_ to: String, subject: String, body: String) } extension MailURLSchemeType { - private var urlScheme: NSURL { - return NSURL(string: "mailto://")! + fileprivate var urlScheme: URL { + return URL(string: "mailto://")! } } extension MailURLSchemeType { - func mailURLScheme(to: String, subject: String, body: String) -> NSURL? { - if !UIApplication.sharedApplication().canOpenURL(urlScheme) { return nil } - return NSURL(string: String(format: "mailto:%@?subject=%@&body=%@", arguments: [to, subject.stringByAddingPercentEncodingWithAllowedCharacters(NSCharacterSet.alphanumericCharacterSet())!, body.stringByAddingPercentEncodingWithAllowedCharacters(NSCharacterSet.alphanumericCharacterSet())!])) + func mailURLScheme(_ to: String, subject: String, body: String) -> URL? { + if !UIApplication.shared.canOpenURL(urlScheme) { return nil } + return URL(string: String(format: "mailto:%@?subject=%@&body=%@", arguments: [to, subject.addingPercentEncoding(withAllowedCharacters: CharacterSet.alphanumerics)!, body.addingPercentEncoding(withAllowedCharacters: CharacterSet.alphanumerics)!])) } - func openMail(to: String, subject: String, body: String) { + func openMail(_ to: String, subject: String, body: String) { guard let url = mailURLScheme(to, subject: subject, body: body) else { return } - UIApplication.sharedApplication().openURL(url) + UIApplication.shared.openURL(url) } } diff --git a/PyConJP2016/Protocol/URLScheme/TwitterURLSchemeType.swift b/PyConJP2016/Protocol/URLScheme/TwitterURLSchemeType.swift index 90b6a77..cc7ad81 100644 --- a/PyConJP2016/Protocol/URLScheme/TwitterURLSchemeType.swift +++ b/PyConJP2016/Protocol/URLScheme/TwitterURLSchemeType.swift @@ -11,59 +11,59 @@ import SafariServices protocol TwitterURLSchemeType { - func openTwitterUser(userName: String, from viewController: UIViewController, alertBefore: Bool) -> Void - func openTwitterHashTag(hashTag: String, from viewController: UIViewController, alertBefore: Bool) -> Void + func openTwitterUser(_ userName: String, from viewController: UIViewController, alertBefore: Bool) -> Void + func openTwitterHashTag(_ hashTag: String, from viewController: UIViewController, alertBefore: Bool) -> Void } extension TwitterURLSchemeType { - private var urlScheme: NSURL { - return NSURL(string: "twitter://")! + fileprivate var urlScheme: URL { + return URL(string: "twitter://")! } - private func openTwitterAppWithAlert(targetName: String, url: NSURL, from viewController: UIViewController) { + fileprivate func openTwitterAppWithAlert(_ targetName: String, url: URL, from viewController: UIViewController) { let alertController = UIAlertController(title: NSLocalizedString("TwitterAlertTitle", tableName: "URLScheme", comment: ""), message: String(format: NSLocalizedString("TwitterAlertMessage", tableName: "URLScheme", comment: ""), arguments: [targetName]), - preferredStyle: .Alert) - alertController.addAction(UIAlertAction(title: NSLocalizedString("Open", comment: ""), style: .Default, handler: { action in - UIApplication.sharedApplication().openURL(url) + preferredStyle: .alert) + alertController.addAction(UIAlertAction(title: NSLocalizedString("Open", comment: ""), style: .default, handler: { action in + UIApplication.shared.openURL(url) })) - alertController.addAction(UIAlertAction(title: NSLocalizedString("Cancel", comment: ""), style: .Cancel, handler: nil)) - viewController.presentViewController(alertController, animated: true, completion: nil) + alertController.addAction(UIAlertAction(title: NSLocalizedString("Cancel", comment: ""), style: .cancel, handler: nil)) + viewController.present(alertController, animated: true, completion: nil) } } extension TwitterURLSchemeType { - func openTwitterUser(userName: String, from viewController: UIViewController, alertBefore: Bool = false) -> Void { - if UIApplication.sharedApplication().canOpenURL(urlScheme) { - guard let url = NSURL(string: "twitter://user?screen_name=" + userName) else { return } + func openTwitterUser(_ userName: String, from viewController: UIViewController, alertBefore: Bool = false) -> Void { + if UIApplication.shared.canOpenURL(urlScheme) { + guard let url = URL(string: "twitter://user?screen_name=" + userName) else { return } if alertBefore { openTwitterAppWithAlert("@\(userName)", url: url, from: viewController) } else { - UIApplication.sharedApplication().openURL(url) + UIApplication.shared.openURL(url) } } else { - guard let url = NSURL(string: "https://mobile.twitter.com/" + userName) else { return } - let safariViewController = SFSafariViewController(URL: url) - viewController.presentViewController(safariViewController, animated: true, completion: nil) + guard let url = URL(string: "https://mobile.twitter.com/" + userName) else { return } + let safariViewController = SFSafariViewController(url: url) + viewController.present(safariViewController, animated: true, completion: nil) } } - func openTwitterHashTag(hashTag: String, from viewController: UIViewController, alertBefore: Bool = false) -> Void { - if UIApplication.sharedApplication().canOpenURL(urlScheme) { - guard let url = NSURL(string: "twitter://search?query=%23" + hashTag) else { return } + func openTwitterHashTag(_ hashTag: String, from viewController: UIViewController, alertBefore: Bool = false) -> Void { + if UIApplication.shared.canOpenURL(urlScheme) { + guard let url = URL(string: "twitter://search?query=%23" + hashTag) else { return } if alertBefore { openTwitterAppWithAlert("#\(hashTag)", url: url, from: viewController) } else { - UIApplication.sharedApplication().openURL(url) + UIApplication.shared.openURL(url) } } else { - guard let url = NSURL(string: "https://mobile.twitter.com/search?q=%23" + hashTag + "&s=typd") else { return } - let safariViewController = SFSafariViewController(URL: url) - viewController.presentViewController(safariViewController, animated: true, completion: nil) + guard let url = URL(string: "https://mobile.twitter.com/search?q=%23" + hashTag + "&s=typd") else { return } + let safariViewController = SFSafariViewController(url: url) + viewController.present(safariViewController, animated: true, completion: nil) } } diff --git a/PyConJP2016/View/CustomImageView.swift b/PyConJP2016/View/CustomImageView.swift index 59d4cb1..456b038 100644 --- a/PyConJP2016/View/CustomImageView.swift +++ b/PyConJP2016/View/CustomImageView.swift @@ -13,13 +13,13 @@ class CustomImageView: UIImageView { //* Gesture Enabled Whether or not */ var gestureEnabled = true - private var beforePoint = CGPoint(x: 0.0, y: 0.0) - private var currentScale: CGFloat = 1.0 + fileprivate var beforePoint = CGPoint(x: 0.0, y: 0.0) + fileprivate var currentScale: CGFloat = 1.0 required init?(coder aDecoder: NSCoder) { super.init(coder: aDecoder) - self.userInteractionEnabled = true + self.isUserInteractionEnabled = true // let doubleTapGesture = UITapGestureRecognizer(target: self, action: #selector(CustomImageView.handleGesture(_:))) // doubleTapGesture.numberOfTapsRequired = 2 @@ -35,7 +35,7 @@ class CustomImageView: UIImageView { // self.addGestureRecognizer(panGesture) } - func handleGesture(gesture: UIGestureRecognizer) { + func handleGesture(_ gesture: UIGestureRecognizer) { if let doubleTapGesture = gesture as? UITapGestureRecognizer { doubleTap(doubleTapGesture) } else if let pinchGesture = gesture as? UIPinchGestureRecognizer { @@ -45,17 +45,17 @@ class CustomImageView: UIImageView { } } - func doubleTap(gesture: UITapGestureRecognizer) { + func doubleTap(_ gesture: UITapGestureRecognizer) { if gestureEnabled { beforePoint = CGPoint(x: 0.0, y: 0.0) currentScale = 1.0 - UIView.animateWithDuration(0.2, animations: { [weak self]() in - self?.transform = CGAffineTransformIdentity + UIView.animate(withDuration: 0.2, animations: { [weak self]() in + self?.transform = CGAffineTransform.identity }) } } - private func pinch(gesture: UIPinchGestureRecognizer) { + fileprivate func pinch(_ gesture: UIPinchGestureRecognizer) { if gestureEnabled { var scale = gesture.scale if currentScale > 1.0 { @@ -63,16 +63,16 @@ class CustomImageView: UIImageView { } switch gesture.state { - case .Changed: - let scaleTransform = CGAffineTransformMakeScale(scale, scale) - let transitionTransform = CGAffineTransformMakeTranslation(beforePoint.x, beforePoint.y) - transform = CGAffineTransformConcat(scaleTransform, transitionTransform) - case .Ended, .Cancelled: + case .changed: + let scaleTransform = CGAffineTransform(scaleX: scale, y: scale) + let transitionTransform = CGAffineTransform(translationX: beforePoint.x, y: beforePoint.y) + transform = scaleTransform.concatenating(transitionTransform) + case .ended, .cancelled: if scale <= 1.0 { beforePoint = CGPoint(x: 0.0, y: 0.0) currentScale = 1.0 - UIView.animateWithDuration(0.1, animations: { [weak self]() in - self?.transform = CGAffineTransformIdentity + UIView.animate(withDuration: 0.1, animations: { [weak self]() in + self?.transform = CGAffineTransform.identity }) } else { currentScale = scale @@ -83,22 +83,22 @@ class CustomImageView: UIImageView { } } - private func pan(gesture: UIPanGestureRecognizer) { + fileprivate func pan(_ gesture: UIPanGestureRecognizer) { if currentScale == 1.0 { return } - if let gestureView = gesture.view where gestureEnabled { + if let gestureView = gesture.view, gestureEnabled { - var translation = gesture.translationInView(gestureView) + var translation = gesture.translation(in: gestureView) if abs(beforePoint.x) > 0.0 || abs(beforePoint.y) > 0.0 { translation = CGPoint(x: beforePoint.x + translation.x, y: beforePoint.y + translation.y) } switch gesture.state { - case .Changed: - let scaleTransform = CGAffineTransformMakeScale(currentScale, currentScale) - let translationTransform = CGAffineTransformMakeTranslation(translation.x, translation.y) - transform = CGAffineTransformConcat(scaleTransform, translationTransform) - case .Ended, .Cancelled: + case .changed: + let scaleTransform = CGAffineTransform(scaleX: currentScale, y: currentScale) + let translationTransform = CGAffineTransform(translationX: translation.x, y: translation.y) + transform = scaleTransform.concatenating(translationTransform) + case .ended, .cancelled: beforePoint = translation default: break diff --git a/PyConJP2016/View/UICollectionViewCell/SpeakerCollectionViewCell.swift b/PyConJP2016/View/UICollectionViewCell/SpeakerCollectionViewCell.swift index 148a5b2..f425f02 100644 --- a/PyConJP2016/View/UICollectionViewCell/SpeakerCollectionViewCell.swift +++ b/PyConJP2016/View/UICollectionViewCell/SpeakerCollectionViewCell.swift @@ -21,9 +21,9 @@ class SpeakerCollectionViewCell: UICollectionViewCell { twitterLabel.text = nil } - func fill(speaker: Speaker) { - if let imageURL = speaker.imageURL, url = NSURL(string: PCJConfig.hostURL + imageURL) { - iconImageView.af_setImageWithURL(url) + func fill(_ speaker: Speaker) { + if let imageURL = speaker.imageURL, let url = URL(string: PCJConfig.hostURL + imageURL) { + iconImageView.af_setImage(withURL: url) } nameLabel.text = speaker.name twitterLabel.text = (speaker.twitterName != nil ? "@\(speaker.twitterName!)" : nil) diff --git a/PyConJP2016/View/UITableViewCell/StaffTableViewCell.swift b/PyConJP2016/View/UITableViewCell/StaffTableViewCell.swift index afd44cf..d1a10cc 100644 --- a/PyConJP2016/View/UITableViewCell/StaffTableViewCell.swift +++ b/PyConJP2016/View/UITableViewCell/StaffTableViewCell.swift @@ -17,10 +17,10 @@ class StaffTableViewCell: UITableViewCell { static let estimatedRowHeight: CGFloat = 100 - private var facebookAction: (() -> Void)? - private var twitterAction: (() -> Void)? + fileprivate var facebookAction: (() -> Void)? + fileprivate var twitterAction: (() -> Void)? - func fill(staff: Staff, onFacebookButton: (() -> Void), onTwitterButton: (() -> Void)) { + func fill(_ staff: Staff, onFacebookButton: @escaping (() -> Void), onTwitterButton: @escaping (() -> Void)) { nameLabel.text = staff.name roleLabel.text = staff.role toggleFacebookButton(!staff.facebook.isEmpty) @@ -36,22 +36,22 @@ class StaffTableViewCell: UITableViewCell { toggleTwitterButton(false) } - private func toggleFacebookButton(enabled: Bool) { - facebookButton.enabled = enabled + fileprivate func toggleFacebookButton(_ enabled: Bool) { + facebookButton.isEnabled = enabled facebookButton.backgroundColor = enabled ? UIColor.facebookColor() : UIColor.pyconJP2016GlayColor() } - private func toggleTwitterButton(enabled: Bool) { - twitterButton.enabled = enabled + fileprivate func toggleTwitterButton(_ enabled: Bool) { + twitterButton.isEnabled = enabled twitterButton.backgroundColor = enabled ? UIColor.twitterColor() : UIColor.pyconJP2016GlayColor() } - @IBAction func onFacebookButton(sender: UIButton) { + @IBAction func onFacebookButton(_ sender: UIButton) { guard let facebookAction = facebookAction else { return } facebookAction() } - @IBAction func onTwitterButton(sender: UIButton) { + @IBAction func onTwitterButton(_ sender: UIButton) { guard let twitterAction = twitterAction else { return } twitterAction() } diff --git a/PyConJP2016/View/UITableViewCell/TalkTableViewCell.swift b/PyConJP2016/View/UITableViewCell/TalkTableViewCell.swift index 0d3cc95..f39e035 100644 --- a/PyConJP2016/View/UITableViewCell/TalkTableViewCell.swift +++ b/PyConJP2016/View/UITableViewCell/TalkTableViewCell.swift @@ -18,7 +18,7 @@ class TalkTableViewCell: UITableViewCell { static let estimatedRowHeight: CGFloat = 134 - func fill(talkObject: TalkObject) { + func fill(_ talkObject: TalkObject) { titleLabel.text = talkObject.title timeLabel.text = talkObject.periodTime placeLabel.text = talkObject.place @@ -33,7 +33,7 @@ class TalkTableViewCell: UITableViewCell { timeLabel.text = nil placeLabel.text = nil speakerLabel.text = nil - placeView.backgroundColor = UIColor.darkGrayColor() + placeView.backgroundColor = UIColor.darkGray } } diff --git a/PyConJP2016/ViewController/Base/BaseTabBarController.swift b/PyConJP2016/ViewController/Base/BaseTabBarController.swift index ea15fd1..4f86cd4 100644 --- a/PyConJP2016/ViewController/Base/BaseTabBarController.swift +++ b/PyConJP2016/ViewController/Base/BaseTabBarController.swift @@ -10,24 +10,24 @@ import UIKit class BaseTabBarController: UITabBarController { - private var eventsTabNavigationController: UINavigationController? - private var conferenceTabNavigationController: UINavigationController? - private var moreTabNavigationController: UINavigationController? + fileprivate var eventsTabNavigationController: UINavigationController? + fileprivate var conferenceTabNavigationController: UINavigationController? + fileprivate var moreTabNavigationController: UINavigationController? override func viewDidLoad() { super.viewDidLoad() //EventsceTab - let eventsStoryboard = UIStoryboard(name: "Events", bundle: NSBundle.mainBundle()) - eventsTabNavigationController = eventsStoryboard.instantiateViewControllerWithIdentifier("EventsNavigationController") as? UINavigationController + let eventsStoryboard = UIStoryboard(name: "Events", bundle: Bundle.main) + eventsTabNavigationController = eventsStoryboard.instantiateViewController(withIdentifier: "EventsNavigationController") as? UINavigationController //ConferenceTab - let conferenceStoryboard = UIStoryboard(name: "Conference", bundle: NSBundle.mainBundle()) - conferenceTabNavigationController = conferenceStoryboard.instantiateViewControllerWithIdentifier("ConferenceNavigationController") as? UINavigationController + let conferenceStoryboard = UIStoryboard(name: "Conference", bundle: Bundle.main) + conferenceTabNavigationController = conferenceStoryboard.instantiateViewController(withIdentifier: "ConferenceNavigationController") as? UINavigationController //MoreTab - let moreStoryboard = UIStoryboard(name: "More", bundle: NSBundle.mainBundle()) - moreTabNavigationController = moreStoryboard.instantiateViewControllerWithIdentifier("MoreNavigationController") as? UINavigationController + let moreStoryboard = UIStoryboard(name: "More", bundle: Bundle.main) + moreTabNavigationController = moreStoryboard.instantiateViewController(withIdentifier: "MoreNavigationController") as? UINavigationController let viewControllers = [eventsTabNavigationController!, conferenceTabNavigationController!, moreTabNavigationController!] as [UIViewController] self.setViewControllers(viewControllers, animated: false) diff --git a/PyConJP2016/ViewController/Base/TalkDetailViewController.swift b/PyConJP2016/ViewController/Base/TalkDetailViewController.swift index 4ca624d..1209e6b 100644 --- a/PyConJP2016/ViewController/Base/TalkDetailViewController.swift +++ b/PyConJP2016/ViewController/Base/TalkDetailViewController.swift @@ -14,7 +14,7 @@ class TalkDetailViewController: UIViewController, TalkDetailAPIType, TwitterURLS @IBOutlet weak var baseScrollView: UIScrollView! { didSet { - refreshControl.addTarget(self, action: #selector(TalkDetailViewController.refresh(_:)), forControlEvents: .ValueChanged) + refreshControl.addTarget(self, action: #selector(TalkDetailViewController.refresh(_:)), for: .valueChanged) baseScrollView.addSubview(refreshControl) } } @@ -32,7 +32,7 @@ class TalkDetailViewController: UIViewController, TalkDetailAPIType, TwitterURLS @IBOutlet weak var speakersCollectionView: UICollectionView! { didSet { let nib = UINib(nibName: speakersCollectionViewDataSource.reuseIdentifier, bundle:nil) - speakersCollectionView.registerNib(nib, forCellWithReuseIdentifier: speakersCollectionViewDataSource.reuseIdentifier) + speakersCollectionView.register(nib, forCellWithReuseIdentifier: speakersCollectionViewDataSource.reuseIdentifier) speakersCollectionView.dataSource = speakersCollectionViewDataSource } } @@ -47,7 +47,7 @@ class TalkDetailViewController: UIViewController, TalkDetailAPIType, TwitterURLS @IBOutlet weak var abstractTextView: UITextView! var id: Int? - private var talkDetail: TalkDetail? { + fileprivate var talkDetail: TalkDetail? { didSet { if let talkDetail = talkDetail { speakersCollectionViewDataSource.speakers = talkDetail.speakers @@ -57,14 +57,14 @@ class TalkDetailViewController: UIViewController, TalkDetailAPIType, TwitterURLS } } - private let refreshControl = UIRefreshControl() + fileprivate let refreshControl = UIRefreshControl() - private let speakersCollectionViewDataSource = SpeakersCollectionViewDataSource() + fileprivate let speakersCollectionViewDataSource = SpeakersCollectionViewDataSource() - private lazy var speakersCollectionViewHeight: CGFloat = self.speakersCollectionViewHeightConstraint.constant + fileprivate lazy var speakersCollectionViewHeight: CGFloat = self.speakersCollectionViewHeightConstraint.constant - class func build(id: Int) -> TalkDetailViewController { - let talkDetailViewController = UIStoryboard(name: "Main", bundle: NSBundle.mainBundle()).instantiateViewControllerWithIdentifier("TalkDetailViewController") as! TalkDetailViewController + class func build(_ id: Int) -> TalkDetailViewController { + let talkDetailViewController = UIStoryboard(name: "Main", bundle: Bundle.main).instantiateViewController(withIdentifier: "TalkDetailViewController") as! TalkDetailViewController talkDetailViewController.id = id return talkDetailViewController } @@ -77,13 +77,13 @@ class TalkDetailViewController: UIViewController, TalkDetailAPIType, TwitterURLS } - override func viewWillAppear(animated: Bool) { + override func viewWillAppear(_ animated: Bool) { super.viewWillAppear(animated) guard let talkDetail = talkDetail else { return } do { let realm = try Realm() - if let talkObject = realm.objectForPrimaryKey(TalkObject.self, key: id) { + if let talkObject = realm.object(ofType: TalkObject.self, forPrimaryKey: id as AnyObject) { talkDetail.talkObject.favorited = talkObject.favorited toggleBookmarkBarButtonItem(talkDetail.talkObject.favorited) } @@ -93,37 +93,37 @@ class TalkDetailViewController: UIViewController, TalkDetailAPIType, TwitterURLS } - func refresh(refreshControl: UIRefreshControl) { + func refresh(_ refreshControl: UIRefreshControl) { talkDetail = nil getDetail() } - private func getDetail() { + fileprivate func getDetail() { getTalkDetail { [weak self](result) in guard let weakSelf = self else { return } switch result { - case .Success(let talkDetail): + case .success(let talkDetail): weakSelf.talkDetail = talkDetail weakSelf.fillData() weakSelf.refreshControl.endRefreshing() - case .Failure(let error): + case .failure(let error): weakSelf.refreshControl.endRefreshing() weakSelf.showErrorAlartWith(error, parent: weakSelf) } } } - private func fillData() { + fileprivate func fillData() { guard let talkDetail = talkDetail else { return } - dispatch_async(dispatch_get_main_queue()) { + DispatchQueue.main.async { self.titleLabel.text = talkDetail.talkObject.title self.dayLabel.text = talkDetail.talkObject.day self.periodTimeLabel.text = talkDetail.talkObject.periodTime self.placeLabel.text = talkDetail.talkObject.place - self.placeLabel.textColor = talkDetail.talkObject.room?.color ?? UIColor.blackColor() - self.hashTagButton.setTitle((talkDetail.talkObject.room?.hashTag ?? "#pyconjp"), forState: .Normal) + self.placeLabel.textColor = talkDetail.talkObject.room?.color ?? UIColor.black + self.hashTagButton.setTitle((talkDetail.talkObject.room?.hashTag ?? "#pyconjp"), for: UIControlState()) self.speakersCollectionViewHeightConstraint.constant = talkDetail.speakers.isEmpty ? 0 : self.speakersCollectionViewHeight self.speakersCollectionView.reloadData() @@ -140,9 +140,9 @@ class TalkDetailViewController: UIViewController, TalkDetailAPIType, TwitterURLS } - func toggleBookmarkBarButtonItem(isFavorite: Bool) { + func toggleBookmarkBarButtonItem(_ isFavorite: Bool) { let image = isFavorite ? UIImage(named: "BookmarkOn") : UIImage(named: "BookmarkOff") - dispatch_async(dispatch_get_main_queue()) { + DispatchQueue.main.async { self.bookmarkBarButtonItem.image = image } } @@ -151,7 +151,7 @@ class TalkDetailViewController: UIViewController, TalkDetailAPIType, TwitterURLS super.didReceiveMemoryWarning() } - @IBAction func onBookmarkBarButton(sender: UIBarButtonItem) { + @IBAction func onBookmarkBarButton(_ sender: UIBarButtonItem) { guard let talkDetail = talkDetail else { return } do { talkDetail.talkObject.favorited = !talkDetail.talkObject.favorited @@ -165,13 +165,13 @@ class TalkDetailViewController: UIViewController, TalkDetailAPIType, TwitterURLS } } - @IBAction func onHashTagButton(sender: UIButton) { - let hashTag = (talkDetail?.talkObject.room?.hashTag ?? "pyconjp").stringByReplacingOccurrencesOfString("#", withString: "") + @IBAction func onHashTagButton(_ sender: UIButton) { + let hashTag = (talkDetail?.talkObject.room?.hashTag ?? "pyconjp").replacingOccurrences(of: "#", with: "") openTwitterHashTag(hashTag, from: self) } - func collectionView(collectionView: UICollectionView, didSelectItemAtIndexPath indexPath: NSIndexPath) { - guard let userName = speakersCollectionViewDataSource.speakers[indexPath.row].twitterName else { return } + func collectionView(_ collectionView: UICollectionView, didSelectItemAtIndexPath indexPath: IndexPath) { + guard let userName = speakersCollectionViewDataSource.speakers[(indexPath as NSIndexPath).row].twitterName else { return } openTwitterUser(userName, from: self) } } diff --git a/PyConJP2016/ViewController/Base/ZoomableImageViewController.swift b/PyConJP2016/ViewController/Base/ZoomableImageViewController.swift index b01af8d..e71b785 100644 --- a/PyConJP2016/ViewController/Base/ZoomableImageViewController.swift +++ b/PyConJP2016/ViewController/Base/ZoomableImageViewController.swift @@ -15,18 +15,18 @@ class ZoomableImageViewController: UIViewController, UIScrollViewDelegate { @IBOutlet weak var baseScrollView: UIScrollView? @IBOutlet weak var imageView: UIImageView? - private var isCompletedLayoutSubviews = false + fileprivate var isCompletedLayoutSubviews = false class func build() -> ZoomableImageViewController { - return UIStoryboard(name: "Main", bundle: NSBundle.mainBundle()).instantiateViewControllerWithIdentifier("ZoomableImageViewController") as! ZoomableImageViewController + return UIStoryboard(name: "Main", bundle: Bundle.main).instantiateViewController(withIdentifier: "ZoomableImageViewController") as! ZoomableImageViewController } - override func prefersStatusBarHidden() -> Bool { + override var prefersStatusBarHidden: Bool { return isCompletedLayoutSubviews } - override func preferredStatusBarUpdateAnimation() -> UIStatusBarAnimation { - return .Fade + override var preferredStatusBarUpdateAnimation: UIStatusBarAnimation { + return .fade } override func viewDidLoad() { @@ -36,7 +36,7 @@ class ZoomableImageViewController: UIViewController, UIScrollViewDelegate { let singleTapGesture = UITapGestureRecognizer(target: self, action: #selector(ZoomableImageViewController.singleTap(_:))) singleTapGesture.numberOfTapsRequired = 1 - singleTapGesture.requireGestureRecognizerToFail(doubleTapGesture) + singleTapGesture.require(toFail: doubleTapGesture) view.addGestureRecognizer(singleTapGesture) } @@ -47,16 +47,16 @@ class ZoomableImageViewController: UIViewController, UIScrollViewDelegate { toggleToolBarHiddenWithAnimation(false) } - private func toggleToolBarHiddenWithAnimation(toHidden: Bool) { + fileprivate func toggleToolBarHiddenWithAnimation(_ toHidden: Bool) { if toHidden { - UIView.animateWithDuration(0.2, animations: { + UIView.animate(withDuration: 0.2, animations: { self.toolBar.alpha = 0 }, completion: { finished in - self.toolBar.hidden = true + self.toolBar.isHidden = true }) } else { - toolBar.hidden = false - UIView.animateWithDuration(0.2, animations: { + toolBar.isHidden = false + UIView.animate(withDuration: 0.2, animations: { self.toolBar.alpha = 1 }) } @@ -64,26 +64,26 @@ class ZoomableImageViewController: UIViewController, UIScrollViewDelegate { // MARK: - Scroll View Delegate - func viewForZoomingInScrollView(scrollView: UIScrollView) -> UIView? { + func viewForZooming(in scrollView: UIScrollView) -> UIView? { return imageView } - func scrollViewWillBeginZooming(scrollView: UIScrollView, withView view: UIView?) { - toolBar.hidden = true + func scrollViewWillBeginZooming(_ scrollView: UIScrollView, with view: UIView?) { + toolBar.isHidden = true } - func singleTap(gesture: UITapGestureRecognizer) { - toggleToolBarHiddenWithAnimation(!toolBar.hidden) + func singleTap(_ gesture: UITapGestureRecognizer) { + toggleToolBarHiddenWithAnimation(!toolBar.isHidden) } - func doubleTap(gesture: UITapGestureRecognizer) { - UIView.animateWithDuration(0.2) { + func doubleTap(_ gesture: UITapGestureRecognizer) { + UIView.animate(withDuration: 0.2, animations: { self.baseScrollView?.zoomScale = 1 - } + }) } - @IBAction func onCloseButton(sender: UIBarButtonItem) { - self.dismissViewControllerAnimated(true, completion: nil) + @IBAction func onCloseButton(_ sender: UIBarButtonItem) { + self.dismiss(animated: true, completion: nil) } } diff --git a/PyConJP2016/ViewController/Bookmark/BookmarkListViewController.swift b/PyConJP2016/ViewController/Bookmark/BookmarkListViewController.swift index 90d30c0..705ca24 100644 --- a/PyConJP2016/ViewController/Bookmark/BookmarkListViewController.swift +++ b/PyConJP2016/ViewController/Bookmark/BookmarkListViewController.swift @@ -13,41 +13,41 @@ class BookmarkListViewController: UIViewController, UITableViewDelegate, ErrorAl @IBOutlet weak var tableView: UITableView! { didSet { let nib = UINib(nibName: bookmarkListDataSource.reuseIdentifier, bundle:nil) - tableView.registerNib(nib, forCellReuseIdentifier: bookmarkListDataSource.reuseIdentifier) + tableView.register(nib, forCellReuseIdentifier: bookmarkListDataSource.reuseIdentifier) tableView.dataSource = bookmarkListDataSource tableView.rowHeight = UITableViewAutomaticDimension tableView.estimatedRowHeight = TalkTableViewCell.estimatedRowHeight } } - private let bookmarkListDataSource = BookmarkListDataSource() + fileprivate let bookmarkListDataSource = BookmarkListDataSource() deinit { - NSNotificationCenter.defaultCenter().removeObserver(self) + NotificationCenter.default.removeObserver(self) } class func build() -> BookmarkListViewController { - return UIStoryboard(name: "Bookmark", bundle: NSBundle.mainBundle()).instantiateViewControllerWithIdentifier("BookmarkListViewController") as! BookmarkListViewController + return UIStoryboard(name: "Bookmark", bundle: Bundle.main).instantiateViewController(withIdentifier: "BookmarkListViewController") as! BookmarkListViewController } override func viewDidLoad() { super.viewDidLoad() - NSNotificationCenter.defaultCenter().addObserver(self, selector: #selector(BookmarkListViewController.refreshNotification(_:)), name: PCJNotificationConfig.CompleteFetchDataNotification, object: nil) + NotificationCenter.default.addObserver(self, selector: #selector(BookmarkListViewController.refreshNotification(_:)), name: NSNotification.Name(rawValue: PCJNotificationConfig.CompleteFetchDataNotification), object: nil) } - override func viewWillAppear(animated: Bool) { + override func viewWillAppear(_ animated: Bool) { super.viewWillAppear(animated) if let indexPath = tableView.indexPathForSelectedRow { - tableView.deselectRowAtIndexPath(indexPath, animated: true) + tableView.deselectRow(at: indexPath, animated: true) } refresh() } - func refreshNotification(notification: NSNotification) { + func refreshNotification(_ notification: Notification) { refresh() } @@ -55,12 +55,12 @@ class BookmarkListViewController: UIViewController, UITableViewDelegate, ErrorAl bookmarkListDataSource.refreshData { [weak self](result) in guard let weakSelf = self else { return } switch result { - case .Success: - dispatch_async(dispatch_get_main_queue()) { + case .success: + DispatchQueue.main.async { weakSelf.tableView.reloadData() } - case .Failure(let error): - dispatch_async(dispatch_get_main_queue()) { + case .failure(let error): + DispatchQueue.main.async { weakSelf.showErrorAlartWith(error, parent: weakSelf) } } @@ -70,12 +70,12 @@ class BookmarkListViewController: UIViewController, UITableViewDelegate, ErrorAl // MARK: - Table View Controller Delegate - func tableView(tableView: UITableView, heightForHeaderInSection section: Int) -> CGFloat { + func tableView(_ tableView: UITableView, heightForHeaderInSection section: Int) -> CGFloat { return 30 } - func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) { - let talkObject = bookmarkListDataSource.timelines[indexPath.section].talks[indexPath.row] + func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) { + let talkObject = bookmarkListDataSource.timelines[(indexPath as NSIndexPath).section].talks[(indexPath as NSIndexPath).row] let talkDetailViewController = TalkDetailViewController.build(talkObject.id) self.navigationController?.pushViewController(talkDetailViewController, animated: true) } diff --git a/PyConJP2016/ViewController/Conference/ConferenceBaseViewController.swift b/PyConJP2016/ViewController/Conference/ConferenceBaseViewController.swift index cfa2d83..966b551 100644 --- a/PyConJP2016/ViewController/Conference/ConferenceBaseViewController.swift +++ b/PyConJP2016/ViewController/Conference/ConferenceBaseViewController.swift @@ -16,13 +16,13 @@ class ConferenceBaseViewController: UIViewController, UIPageViewControllerDelega var conferenceDateViewProtocol: ConferenceDateViewProtocol? var conferencePageViewProtocol: ConferencePageViewProtocol? - private var offsetToChange: CGFloat = 0.0 { + fileprivate var offsetToChange: CGFloat = 0.0 { didSet { } } - private var displayIndex: Int = 0 { + fileprivate var displayIndex: Int = 0 { didSet { if let conferenceDateViewProtocol = conferenceDateViewProtocol { conferenceDateViewProtocol.changeActive(displayIndex) @@ -33,22 +33,22 @@ class ConferenceBaseViewController: UIViewController, UIPageViewControllerDelega override func viewDidLoad() { super.viewDidLoad() - let conferenceStoryboard = UIStoryboard(name: "Conference", bundle: NSBundle.mainBundle()) - let conferencePageViewController = conferenceStoryboard.instantiateViewControllerWithIdentifier("ConferencePageViewController") + let conferenceStoryboard = UIStoryboard(name: "Conference", bundle: Bundle.main) + let conferencePageViewController = conferenceStoryboard.instantiateViewController(withIdentifier: "ConferencePageViewController") conferencePageViewController.view.frame = pageContainerView.bounds self.addChildViewController(conferencePageViewController) pageContainerView.addSubview(conferencePageViewController.view) - conferencePageViewController.didMoveToParentViewController(self) + conferencePageViewController.didMove(toParentViewController: self) - let conferenceDateViewController = conferenceStoryboard.instantiateViewControllerWithIdentifier("ConferenceDateViewController") + let conferenceDateViewController = conferenceStoryboard.instantiateViewController(withIdentifier: "ConferenceDateViewController") conferenceDateViewController.view.frame = barContainerView.bounds self.addChildViewController(conferenceDateViewController) barContainerView.addSubview(conferenceDateViewController.view) - conferenceDateViewController.didMoveToParentViewController(self) + conferenceDateViewController.didMove(toParentViewController: self) } - override func viewDidAppear(animated: Bool) { + override func viewDidAppear(_ animated: Bool) { // offsetToChange = 0.0 } @@ -56,7 +56,7 @@ class ConferenceBaseViewController: UIViewController, UIPageViewControllerDelega super.didReceiveMemoryWarning() } - func pageViewController(pageViewController: UIPageViewController, didFinishAnimating finished: Bool, previousViewControllers: [UIViewController], transitionCompleted completed: Bool) { + func pageViewController(_ pageViewController: UIPageViewController, didFinishAnimating finished: Bool, previousViewControllers: [UIViewController], transitionCompleted completed: Bool) { let displayViewController = pageViewController.viewControllers?.last as! ConferenceListViewController displayIndex = displayViewController.viewControllerIndex // if 1 - barContainerView.frame.origin.x < 1 { @@ -66,7 +66,7 @@ class ConferenceBaseViewController: UIViewController, UIPageViewControllerDelega // } } - func scrollViewDidScroll(scrollView: UIScrollView) { + func scrollViewDidScroll(_ scrollView: UIScrollView) { if scrollView.contentOffset.x - pageContainerView.frame.size.width != 0 { offsetToChange = scrollView.contentOffset.x - pageContainerView.frame.size.width } @@ -75,10 +75,10 @@ class ConferenceBaseViewController: UIViewController, UIPageViewControllerDelega } protocol ConferencePageViewProtocol { - func fowardPage(index: Int) - func reversePage(index: Int) + func fowardPage(_ index: Int) + func reversePage(_ index: Int) } protocol ConferenceDateViewProtocol { - func changeActive(index: Int) + func changeActive(_ index: Int) } diff --git a/PyConJP2016/ViewController/Conference/ConferenceDateViewController.swift b/PyConJP2016/ViewController/Conference/ConferenceDateViewController.swift index 1a3cea1..d92c6d1 100644 --- a/PyConJP2016/ViewController/Conference/ConferenceDateViewController.swift +++ b/PyConJP2016/ViewController/Conference/ConferenceDateViewController.swift @@ -14,22 +14,22 @@ class ConferenceDateViewController: UIViewController, ConferenceDateViewProtocol @IBOutlet weak var day1Button: UIButton! @IBOutlet weak var day2Button: UIButton! - private var buttonOriginXArray: [CGFloat] = [] + fileprivate var buttonOriginXArray: [CGFloat] = [] - private var conferencePageViewProtocol: ConferencePageViewProtocol? + fileprivate var conferencePageViewProtocol: ConferencePageViewProtocol? override func viewDidLoad() { super.viewDidLoad() } - override func viewDidAppear(animated: Bool) { + override func viewDidAppear(_ animated: Bool) { if buttonOriginXArray.isEmpty { view.subviews.filter({ $0 is UIButton }).forEach({ buttonOriginXArray.append($0.frame.origin.x) }) } } - override func didMoveToParentViewController(parent: UIViewController?) { + override func didMove(toParentViewController parent: UIViewController?) { guard let conferenceBaseViewController = parent as? ConferenceBaseViewController else { return } conferenceBaseViewController.conferenceDateViewProtocol = self conferencePageViewProtocol = conferenceBaseViewController.conferencePageViewProtocol @@ -38,14 +38,14 @@ class ConferenceDateViewController: UIViewController, ConferenceDateViewProtocol // MARK: - Day Button - @IBAction func onDay1Button(sender: UIButton) { + @IBAction func onDay1Button(_ sender: UIButton) { if let conferencePageViewProtocol = conferencePageViewProtocol { conferencePageViewProtocol.reversePage(0) changeActive(0) } } - @IBAction func onDay2Button(sender: UIButton) { + @IBAction func onDay2Button(_ sender: UIButton) { if let conferencePageViewProtocol = conferencePageViewProtocol { conferencePageViewProtocol.fowardPage(1) changeActive(1) @@ -54,21 +54,21 @@ class ConferenceDateViewController: UIViewController, ConferenceDateViewProtocol // MARK: - ConferenceDateViewProtocol - func changeActive(index: Int) { + func changeActive(_ index: Int) { - func changeActiveButton(button: UIButton) { - button.enabled = false - button.backgroundColor = .whiteColor() - button.setTitleColor(.blackColor(), forState: .Normal) + func changeActiveButton(_ button: UIButton) { + button.isEnabled = false + button.backgroundColor = .white + button.setTitleColor(.black, for: UIControlState()) } - func changeUnactiveButton(button: UIButton) { - button.enabled = true + func changeUnactiveButton(_ button: UIButton) { + button.isEnabled = true button.backgroundColor = .pyconJP2016GlayColor() - button.setTitleColor(.whiteColor(), forState: .Normal) + button.setTitleColor(.white, for: UIControlState()) } - UIView.animateWithDuration(0.3, animations: { () -> Void in + UIView.animate(withDuration: 0.3, animations: { () -> Void in self.activeBar.frame.origin.x = self.buttonOriginXArray[index] switch index { case 0: diff --git a/PyConJP2016/ViewController/Conference/ConferenceListViewController.swift b/PyConJP2016/ViewController/Conference/ConferenceListViewController.swift index e9a1e87..d552c99 100644 --- a/PyConJP2016/ViewController/Conference/ConferenceListViewController.swift +++ b/PyConJP2016/ViewController/Conference/ConferenceListViewController.swift @@ -13,9 +13,9 @@ class ConferenceListViewController: UIViewController, UITableViewDelegate, Talks @IBOutlet weak var tableView: UITableView! { didSet { let nib = UINib(nibName: conferenceListDataSource.reuseIdentifier, bundle:nil) - tableView.registerNib(nib, forCellReuseIdentifier: conferenceListDataSource.reuseIdentifier) + tableView.register(nib, forCellReuseIdentifier: conferenceListDataSource.reuseIdentifier) - refreshControl.addTarget(self, action: #selector(ConferenceListViewController.onRefresh(_:)), forControlEvents: .ValueChanged) + refreshControl.addTarget(self, action: #selector(ConferenceListViewController.onRefresh(_:)), for: .valueChanged) tableView.addSubview(refreshControl) tableView.dataSource = conferenceListDataSource @@ -24,19 +24,19 @@ class ConferenceListViewController: UIViewController, UITableViewDelegate, Talks } } - private(set) var viewControllerIndex: Int = 0 - private(set) var pyconJPDate: PyConJPDate? + fileprivate(set) var viewControllerIndex: Int = 0 + fileprivate(set) var pyconJPDate: PyConJPDate? - private lazy var conferenceListDataSource: ConferenceListDataSource = ConferenceListDataSource(day: self.pyconJPDate?.rawValue) + fileprivate lazy var conferenceListDataSource: ConferenceListDataSource = ConferenceListDataSource(day: self.pyconJPDate?.rawValue) - private let refreshControl = UIRefreshControl() + fileprivate let refreshControl = UIRefreshControl() deinit { - NSNotificationCenter.defaultCenter().removeObserver(self) + NotificationCenter.default.removeObserver(self) } - class func build(index: Int, storyboard: UIStoryboard, pyconJPDate: PyConJPDate) -> ConferenceListViewController { - let conferenceListViewController = storyboard.instantiateViewControllerWithIdentifier("ConferenceListViewController") as! ConferenceListViewController + class func build(_ index: Int, storyboard: UIStoryboard, pyconJPDate: PyConJPDate) -> ConferenceListViewController { + let conferenceListViewController = storyboard.instantiateViewController(withIdentifier: "ConferenceListViewController") as! ConferenceListViewController conferenceListViewController.viewControllerIndex = index conferenceListViewController.pyconJPDate = pyconJPDate @@ -46,37 +46,37 @@ class ConferenceListViewController: UIViewController, UITableViewDelegate, Talks override func viewDidLoad() { super.viewDidLoad() - NSNotificationCenter.defaultCenter().addObserver(self, selector: #selector(ConferenceListViewController.refreshNotification(_:)), name: PCJNotificationConfig.CompleteFetchDataNotification, object: nil) + NotificationCenter.default.addObserver(self, selector: #selector(ConferenceListViewController.refreshNotification(_:)), name: NSNotification.Name(rawValue: PCJNotificationConfig.CompleteFetchDataNotification), object: nil) refreshControl.beginRefreshing() refresh() } - override func viewWillAppear(animated: Bool) { + override func viewWillAppear(_ animated: Bool) { super.viewWillAppear(animated) if let indexPath = tableView.indexPathForSelectedRow { - tableView.deselectRowAtIndexPath(indexPath, animated: true) + tableView.deselectRow(at: indexPath, animated: true) } } - func onRefresh(sender: UIRefreshControl) { + func onRefresh(_ sender: UIRefreshControl) { conferenceListDataSource.timelines.removeAll() tableView.reloadData() getTalks { [weak self](result) in guard let weakSelf = self else { return } switch result { - case .Success: + case .success: weakSelf.refresh() - case .Failure(let error): + case .failure(let error): weakSelf.refreshControl.endRefreshing() weakSelf.showErrorAlartWith(error, parent: weakSelf) } } } - func refreshNotification(notification: NSNotification) { + func refreshNotification(_ notification: Notification) { refresh() } @@ -84,15 +84,15 @@ class ConferenceListViewController: UIViewController, UITableViewDelegate, Talks conferenceListDataSource.refreshData { [weak self](result) in guard let weakSelf = self else { return } switch result { - case .Success: - dispatch_async(dispatch_get_main_queue()) { + case .success: + DispatchQueue.main.async { weakSelf.tableView.reloadData() if !weakSelf.conferenceListDataSource.timelines.isEmpty { weakSelf.refreshControl.endRefreshing() } } - case .Failure(let error): - dispatch_async(dispatch_get_main_queue()) { + case .failure(let error): + DispatchQueue.main.async { weakSelf.showErrorAlartWith(error, parent: weakSelf) weakSelf.refreshControl.endRefreshing() } @@ -103,12 +103,12 @@ class ConferenceListViewController: UIViewController, UITableViewDelegate, Talks // MARK: - Table View Controller Delegate - func tableView(tableView: UITableView, heightForHeaderInSection section: Int) -> CGFloat { + func tableView(_ tableView: UITableView, heightForHeaderInSection section: Int) -> CGFloat { return 30 } - func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) { - let talkObject = conferenceListDataSource.timelines[indexPath.section].talks[indexPath.row] + func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) { + let talkObject = conferenceListDataSource.timelines[(indexPath as NSIndexPath).section].talks[(indexPath as NSIndexPath).row] let talkDetailViewController = TalkDetailViewController.build(talkObject.id) self.navigationController?.pushViewController(talkDetailViewController, animated: true) } diff --git a/PyConJP2016/ViewController/Conference/ConferenceModelController.swift b/PyConJP2016/ViewController/Conference/ConferenceModelController.swift index c258661..b309523 100644 --- a/PyConJP2016/ViewController/Conference/ConferenceModelController.swift +++ b/PyConJP2016/ViewController/Conference/ConferenceModelController.swift @@ -10,13 +10,13 @@ import UIKit class ConferenceModelController: NSObject, UIPageViewControllerDataSource { - private let days: Array = PyConJPDate.confarenceDate() + fileprivate let days: Array = PyConJPDate.confarenceDate() override init() { super.init() } - func viewControllerAtIndex(index: Int, storyboard: UIStoryboard) -> ConferenceListViewController? { + func viewControllerAtIndex(_ index: Int, storyboard: UIStoryboard) -> ConferenceListViewController? { if self.days.isEmpty || index >= days.count { return nil @@ -27,14 +27,14 @@ class ConferenceModelController: NSObject, UIPageViewControllerDataSource { } - func indexOfViewController(viewController: UIViewController) -> Int { - guard let viewController = viewController as? ConferenceListViewController, pyconJPDate = viewController.pyconJPDate else { return NSNotFound } - return days.indexOf(pyconJPDate) ?? NSNotFound + func indexOfViewController(_ viewController: UIViewController) -> Int { + guard let viewController = viewController as? ConferenceListViewController, let pyconJPDate = viewController.pyconJPDate else { return NSNotFound } + return days.index(of: pyconJPDate) ?? NSNotFound } // MARK: - Page View Controller Data Source - func pageViewController(pageViewController: UIPageViewController, viewControllerBeforeViewController viewController: UIViewController) -> UIViewController? { + func pageViewController(_ pageViewController: UIPageViewController, viewControllerBefore viewController: UIViewController) -> UIViewController? { var index = self.indexOfViewController(viewController) if (index == 0) || (index == NSNotFound) { return nil @@ -44,7 +44,7 @@ class ConferenceModelController: NSObject, UIPageViewControllerDataSource { return self.viewControllerAtIndex(index, storyboard: viewController.storyboard!) } - func pageViewController(pageViewController: UIPageViewController, viewControllerAfterViewController viewController: UIViewController) -> UIViewController? { + func pageViewController(_ pageViewController: UIPageViewController, viewControllerAfter viewController: UIViewController) -> UIViewController? { var index = self.indexOfViewController(viewController) if index == NSNotFound { return nil diff --git a/PyConJP2016/ViewController/Conference/ConferencePageViewController.swift b/PyConJP2016/ViewController/Conference/ConferencePageViewController.swift index 8c56653..0dfa0f6 100644 --- a/PyConJP2016/ViewController/Conference/ConferencePageViewController.swift +++ b/PyConJP2016/ViewController/Conference/ConferencePageViewController.swift @@ -10,22 +10,22 @@ import UIKit class ConferencePageViewController: UIPageViewController, ConferencePageViewProtocol, ErrorAlertType { - private var conferenceModelViewProtocol: ConferenceModelViewProtocol? + fileprivate var conferenceModelViewProtocol: ConferenceModelViewProtocol? override func viewDidLoad() { super.viewDidLoad() let startingViewController = self.conferenceModelController.viewControllerAtIndex(0, storyboard: self.storyboard!)! let viewControllers = [startingViewController] - self.setViewControllers(viewControllers, direction: .Forward, animated: false, completion: {done in }) + self.setViewControllers(viewControllers, direction: .forward, animated: false, completion: {done in }) self.dataSource = self.conferenceModelController } - private var _conferenceModelController: ConferenceModelController? = nil + fileprivate var _conferenceModelController: ConferenceModelController? = nil - private var conferenceModelController: ConferenceModelController { + fileprivate var conferenceModelController: ConferenceModelController { if _conferenceModelController == nil { _conferenceModelController = ConferenceModelController() } @@ -36,7 +36,7 @@ class ConferencePageViewController: UIPageViewController, ConferencePageViewProt super.didReceiveMemoryWarning() } - override func didMoveToParentViewController(parent: UIViewController?) { + override func didMove(toParentViewController parent: UIViewController?) { let conferenceBaseViewController = parent as! ConferenceBaseViewController self.delegate = conferenceBaseViewController conferenceBaseViewController.conferencePageViewProtocol = self @@ -50,15 +50,15 @@ class ConferencePageViewController: UIPageViewController, ConferencePageViewProt // MARK: - ConferencePageViewProtocol - func fowardPage(index: Int) { - self.movePage(index, direction: .Forward) + func fowardPage(_ index: Int) { + self.movePage(index, direction: .forward) } - func reversePage(index: Int) { - self.movePage(index, direction: .Reverse) + func reversePage(_ index: Int) { + self.movePage(index, direction: .reverse) } - private func movePage(index: Int, direction: UIPageViewControllerNavigationDirection) { + fileprivate func movePage(_ index: Int, direction: UIPageViewControllerNavigationDirection) { let viewController = conferenceModelController.viewControllerAtIndex(index, storyboard: self.storyboard!)! let viewControllers = [viewController] self.setViewControllers(viewControllers, direction: direction, animated: true, completion: {done in}) diff --git a/PyConJP2016/ViewController/Conference/ConferenceViewController.swift b/PyConJP2016/ViewController/Conference/ConferenceViewController.swift index 83cd39c..e38136c 100644 --- a/PyConJP2016/ViewController/Conference/ConferenceViewController.swift +++ b/PyConJP2016/ViewController/Conference/ConferenceViewController.swift @@ -10,7 +10,7 @@ import UIKit class ConferenceViewController: UIViewController { - @IBAction func onBookmark(sender: UIBarButtonItem) { + @IBAction func onBookmark(_ sender: UIBarButtonItem) { let bookmarkListViewController = BookmarkListViewController.build() self.navigationController?.pushViewController(bookmarkListViewController, animated: true) } diff --git a/PyConJP2016/ViewController/Events/EventsListViewController.swift b/PyConJP2016/ViewController/Events/EventsListViewController.swift index fea0920..84ad54d 100644 --- a/PyConJP2016/ViewController/Events/EventsListViewController.swift +++ b/PyConJP2016/ViewController/Events/EventsListViewController.swift @@ -11,73 +11,73 @@ import SafariServices class EventsListViewController: UITableViewController { - override func viewWillAppear(animated: Bool) { + override func viewWillAppear(_ animated: Bool) { super.viewWillAppear(animated) if let indexPath = tableView.indexPathForSelectedRow { - tableView.deselectRowAtIndexPath(indexPath, animated: true) + tableView.deselectRow(at: indexPath, animated: true) } } // MARK: - Table View Controller Delegate - override func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) { - guard let sectionType = SectionType(rawValue: indexPath.section) else { return } - let rowType = sectionType.rows[indexPath.row] - let safariViewController = SFSafariViewController(URL: NSURL(string: rowType.url)!) - self.presentViewController(safariViewController, animated: true, completion: nil) + override func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) { + guard let sectionType = SectionType(rawValue: (indexPath as NSIndexPath).section) else { return } + let rowType = sectionType.rows[(indexPath as NSIndexPath).row] + let safariViewController = SFSafariViewController(url: URL(string: rowType.url)!) + self.present(safariViewController, animated: true, completion: nil) } - private enum SectionType: Int { - case TutorialsDay - case ConferenseDay - case SprintsDay + fileprivate enum SectionType: Int { + case tutorialsDay + case conferenseDay + case sprintsDay var rows: Array { switch self { - case .TutorialsDay: - return [.Tutorial] - case .ConferenseDay: - return [.Keynote, .InvitedLecture, .Posters, .LightningTalks, .YouthCoderWorkshop, .BeginnerSession, .CommitteeMeeting, .CommunityBooth, .JobFair, .ProductFair, .OpenSpace] - case .SprintsDay: - return [.Sprints] + case .tutorialsDay: + return [.tutorial] + case .conferenseDay: + return [.keynote, .invitedLecture, .posters, .lightningTalks, .youthCoderWorkshop, .beginnerSession, .committeeMeeting, .communityBooth, .jobFair, .productFair, .openSpace] + case .sprintsDay: + return [.sprints] } } } - private enum RowType { - case Tutorial + fileprivate enum RowType { + case tutorial - case Keynote - case InvitedLecture - case Posters - case LightningTalks - case YouthCoderWorkshop - case BeginnerSession - case CommitteeMeeting - case CommunityBooth - case JobFair - case ProductFair - case OpenSpace + case keynote + case invitedLecture + case posters + case lightningTalks + case youthCoderWorkshop + case beginnerSession + case committeeMeeting + case communityBooth + case jobFair + case productFair + case openSpace - case Sprints + case sprints var url: String { switch self { - case .Tutorial: return PCJConfig.baseURL + "events/tutorial/" - case .Keynote: return PCJConfig.baseURL + "keynote/" - case .InvitedLecture: return PCJConfig.baseURL + "talks/invited-speaker/" - case .Posters: return PCJConfig.baseURL + "schedule/posters/list/" - case .LightningTalks: return PCJConfig.baseURL + "events/lightning-talks/" - case .YouthCoderWorkshop: return PCJConfig.baseURL + "events/youth-ws/" - case .BeginnerSession: return PCJConfig.baseURL + "events/beginners/" - case .CommitteeMeeting: return PCJConfig.baseURL + "events/committee-meeting/" - case .CommunityBooth: return PCJConfig.baseURL + "events/community-booth/" - case .JobFair: return PCJConfig.baseURL + "events/jobsfair/" - case .ProductFair: return PCJConfig.baseURL + "productfair/" - case .OpenSpace: return PCJConfig.baseURL + "events/open-space/" - case .Sprints: return PCJConfig.baseURL + "events/sprint/" + case .tutorial: return PCJConfig.baseURL + "events/tutorial/" + case .keynote: return PCJConfig.baseURL + "keynote/" + case .invitedLecture: return PCJConfig.baseURL + "talks/invited-speaker/" + case .posters: return PCJConfig.baseURL + "schedule/posters/list/" + case .lightningTalks: return PCJConfig.baseURL + "events/lightning-talks/" + case .youthCoderWorkshop: return PCJConfig.baseURL + "events/youth-ws/" + case .beginnerSession: return PCJConfig.baseURL + "events/beginners/" + case .committeeMeeting: return PCJConfig.baseURL + "events/committee-meeting/" + case .communityBooth: return PCJConfig.baseURL + "events/community-booth/" + case .jobFair: return PCJConfig.baseURL + "events/jobsfair/" + case .productFair: return PCJConfig.baseURL + "productfair/" + case .openSpace: return PCJConfig.baseURL + "events/open-space/" + case .sprints: return PCJConfig.baseURL + "events/sprint/" } } diff --git a/PyConJP2016/ViewController/More/AcknowledgmentsListViewController.swift b/PyConJP2016/ViewController/More/AcknowledgmentsListViewController.swift index 7b2e671..f59c4d7 100644 --- a/PyConJP2016/ViewController/More/AcknowledgmentsListViewController.swift +++ b/PyConJP2016/ViewController/More/AcknowledgmentsListViewController.swift @@ -12,49 +12,49 @@ import SafariServices class AcknowledgmentsListViewController: UITableViewController { class func build() -> AcknowledgmentsListViewController { - return UIStoryboard(name: "More", bundle: NSBundle.mainBundle()).instantiateViewControllerWithIdentifier("AcknowledgmentsListViewController") as! AcknowledgmentsListViewController + return UIStoryboard(name: "More", bundle: Bundle.main).instantiateViewController(withIdentifier: "AcknowledgmentsListViewController") as! AcknowledgmentsListViewController } - override func viewWillAppear(animated: Bool) { + override func viewWillAppear(_ animated: Bool) { super.viewWillAppear(animated) if let indexPath = tableView.indexPathForSelectedRow { - tableView.deselectRowAtIndexPath(indexPath, animated: true) + tableView.deselectRow(at: indexPath, animated: true) } } // MARK: - Table View Controller Delegate - override func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) { - guard let rowType = RowType(rawValue: indexPath.row) else { return } + override func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) { + guard let rowType = RowType(rawValue: (indexPath as NSIndexPath).row) else { return } switch rowType { - case .Alamofire, .AlamofireImage: + case .alamofire, .alamofireImage: guard let identifier = rowType.identifier else { return } - let licenseViewController = UIStoryboard(name: "More", bundle: NSBundle.mainBundle()).instantiateViewControllerWithIdentifier(identifier) + let licenseViewController = UIStoryboard(name: "More", bundle: Bundle.main).instantiateViewController(withIdentifier: identifier) self.navigationController?.pushViewController(licenseViewController, animated: true) - case .RealmSwift: + case .realmSwift: guard let url = rowType.url else { return } - let safariViewController = SFSafariViewController(URL: NSURL(string: url)!) - self.presentViewController(safariViewController, animated: true, completion: nil) + let safariViewController = SFSafariViewController(url: URL(string: url)!) + self.present(safariViewController, animated: true, completion: nil) } } - private enum RowType: Int { - case Alamofire = 0 - case AlamofireImage = 1 - case RealmSwift = 2 + fileprivate enum RowType: Int { + case alamofire = 0 + case alamofireImage = 1 + case realmSwift = 2 var identifier: String? { switch self { - case .Alamofire: return "AlamofireLicenseViewController" - case .AlamofireImage: return "AlamofireImageLicenseViewController" + case .alamofire: return "AlamofireLicenseViewController" + case .alamofireImage: return "AlamofireImageLicenseViewController" default: return nil } } var url: String? { switch self { - case .RealmSwift: return "https://realm.io/products/swift/" + case .realmSwift: return "https://realm.io/products/swift/" default: return nil } } diff --git a/PyConJP2016/ViewController/More/FloorMapListViewController.swift b/PyConJP2016/ViewController/More/FloorMapListViewController.swift index 1dea390..807a7b5 100644 --- a/PyConJP2016/ViewController/More/FloorMapListViewController.swift +++ b/PyConJP2016/ViewController/More/FloorMapListViewController.swift @@ -11,39 +11,39 @@ import UIKit class FloorMapListViewController: UITableViewController { class func build() -> FloorMapListViewController { - return UIStoryboard(name: "More", bundle: NSBundle.mainBundle()).instantiateViewControllerWithIdentifier("FloorMapListViewController") as! FloorMapListViewController + return UIStoryboard(name: "More", bundle: Bundle.main).instantiateViewController(withIdentifier: "FloorMapListViewController") as! FloorMapListViewController } - override func viewWillAppear(animated: Bool) { + override func viewWillAppear(_ animated: Bool) { super.viewWillAppear(animated) if let indexPath = tableView.indexPathForSelectedRow { - tableView.deselectRowAtIndexPath(indexPath, animated: true) + tableView.deselectRow(at: indexPath, animated: true) } } // MARK: - Table View Controller Delegate - override func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) { - guard let sectionType = SectionType(rawValue: indexPath.section) else { return } - let floorMapZoomableImageViewController = UIStoryboard(name: "More", bundle: NSBundle.mainBundle()).instantiateViewControllerWithIdentifier("FloorMapZoomableImageViewController") as! FloorMapZoomableImageViewController - floorMapZoomableImageViewController.assetCatalogType = sectionType.rows[indexPath.row] - self.presentViewController(floorMapZoomableImageViewController, animated: true, completion: nil) + override func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) { + guard let sectionType = SectionType(rawValue: (indexPath as NSIndexPath).section) else { return } + let floorMapZoomableImageViewController = UIStoryboard(name: "More", bundle: Bundle.main).instantiateViewController(withIdentifier: "FloorMapZoomableImageViewController") as! FloorMapZoomableImageViewController + floorMapZoomableImageViewController.assetCatalogType = sectionType.rows[(indexPath as NSIndexPath).row] + self.present(floorMapZoomableImageViewController, animated: true, completion: nil) } - private enum SectionType: Int { - case FirstFloor - case SecondFloor - case ThirdFloor + fileprivate enum SectionType: Int { + case firstFloor + case secondFloor + case thirdFloor var rows: Array { switch self { - case .FirstFloor: - return [.FirstFloorView] - case .SecondFloor: - return [.SecondFloorView, .Room201, .Room202, .Room203, .Room204, .Room205] - case .ThirdFloor: - return [.ThirdFloorView] + case .firstFloor: + return [.firstFloorView] + case .secondFloor: + return [.secondFloorView, .room201, .room202, .room203, .room204, .room205] + case .thirdFloor: + return [.thirdFloorView] } } diff --git a/PyConJP2016/ViewController/More/FloorMapZoomableImageViewController.swift b/PyConJP2016/ViewController/More/FloorMapZoomableImageViewController.swift index a03e7bd..9c1c058 100644 --- a/PyConJP2016/ViewController/More/FloorMapZoomableImageViewController.swift +++ b/PyConJP2016/ViewController/More/FloorMapZoomableImageViewController.swift @@ -12,8 +12,8 @@ class FloorMapZoomableImageViewController: ZoomableImageViewController { var assetCatalogType: AssetCatalogType? - func build(assetCatalogType: AssetCatalogType) -> FloorMapZoomableImageViewController { - let floorMapImageViewController = UIStoryboard(name: "More", bundle: NSBundle.mainBundle()).instantiateViewControllerWithIdentifier("FloorMapZoomableImageViewController") as! FloorMapZoomableImageViewController + func build(_ assetCatalogType: AssetCatalogType) -> FloorMapZoomableImageViewController { + let floorMapImageViewController = UIStoryboard(name: "More", bundle: Bundle.main).instantiateViewController(withIdentifier: "FloorMapZoomableImageViewController") as! FloorMapZoomableImageViewController floorMapImageViewController.assetCatalogType = assetCatalogType return floorMapImageViewController } @@ -32,32 +32,32 @@ class FloorMapZoomableImageViewController: ZoomableImageViewController { } enum AssetCatalogType: String { - case FirstFloorView = "FirstFloorMap" - case SecondFloorView = "SecondFloorMap" - case ThirdFloorView = "ThirdFloorMap" - case Room201 = "Room201Map" - case Room202 = "Room202Map" - case Room203 = "Room203Map" - case Room204 = "Room204Map" - case Room205 = "Room205Map" + case firstFloorView = "FirstFloorMap" + case secondFloorView = "SecondFloorMap" + case thirdFloorView = "ThirdFloorMap" + case room201 = "Room201Map" + case room202 = "Room202Map" + case room203 = "Room203Map" + case room204 = "Room204Map" + case room205 = "Room205Map" var navigationItemTitle: String { switch self { - case .FirstFloorView: + case .firstFloorView: return "1F" - case SecondFloorView: + case .secondFloorView: return "2F" - case ThirdFloorView: + case .thirdFloorView: return "3F" - case Room201: + case .room201: return "Room 201" - case Room202: + case .room202: return "Room 202" - case Room203: + case .room203: return "Room 203" - case Room204: + case .room204: return "Room 204" - case Room205: + case .room205: return "Room 205" } } diff --git a/PyConJP2016/ViewController/More/MapListViewController.swift b/PyConJP2016/ViewController/More/MapListViewController.swift index 9295148..528f220 100644 --- a/PyConJP2016/ViewController/More/MapListViewController.swift +++ b/PyConJP2016/ViewController/More/MapListViewController.swift @@ -11,33 +11,33 @@ import UIKit class MapListViewController: UITableViewController { class func build() -> MapListViewController { - return UIStoryboard(name: "More", bundle: NSBundle.mainBundle()).instantiateViewControllerWithIdentifier("MapListViewController") as! MapListViewController + return UIStoryboard(name: "More", bundle: Bundle.main).instantiateViewController(withIdentifier: "MapListViewController") as! MapListViewController } - override func viewWillAppear(animated: Bool) { + override func viewWillAppear(_ animated: Bool) { super.viewWillAppear(animated) if let indexPath = tableView.indexPathForSelectedRow { - tableView.deselectRowAtIndexPath(indexPath, animated: true) + tableView.deselectRow(at: indexPath, animated: true) } } // MARK: - Table View Controller Delegate - override func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) { - switch TableViewCell(rawValue: indexPath.row) ?? .Access { - case .Access: - let mapViewController = MapViewController.build(MapViewController.Venue.Waseda) + override func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) { + switch TableViewCell(rawValue: (indexPath as NSIndexPath).row) ?? .access { + case .access: + let mapViewController = MapViewController.build(MapViewController.Venue.waseda) self.navigationController?.pushViewController(mapViewController, animated: true) - case .Floor: - let floorListViewController = self.storyboard?.instantiateViewControllerWithIdentifier("FloorMapListViewController") + case .floor: + let floorListViewController = self.storyboard?.instantiateViewController(withIdentifier: "FloorMapListViewController") self.navigationController?.pushViewController(floorListViewController!, animated: true) } } - private enum TableViewCell: Int { - case Access = 0 - case Floor = 1 + fileprivate enum TableViewCell: Int { + case access = 0 + case floor = 1 } } diff --git a/PyConJP2016/ViewController/More/MapViewController.swift b/PyConJP2016/ViewController/More/MapViewController.swift index 46bcc0b..8270057 100644 --- a/PyConJP2016/ViewController/More/MapViewController.swift +++ b/PyConJP2016/ViewController/More/MapViewController.swift @@ -14,10 +14,10 @@ class MapViewController: UIViewController, MKMapViewDelegate { @IBOutlet weak var textView: UITextView! @IBOutlet weak var mapView: MKMapView! - private var venue: Venue? + fileprivate var venue: Venue? - class func build(venue: Venue) -> MapViewController { - let mapViewController = UIStoryboard(name: "More", bundle: NSBundle.mainBundle()).instantiateViewControllerWithIdentifier("MapViewController") as! MapViewController + class func build(_ venue: Venue) -> MapViewController { + let mapViewController = UIStoryboard(name: "More", bundle: Bundle.main).instantiateViewController(withIdentifier: "MapViewController") as! MapViewController mapViewController.venue = venue return mapViewController } @@ -29,7 +29,7 @@ class MapViewController: UIViewController, MKMapViewDelegate { textView.text = venue.address - mapView.setCenterCoordinate(venue.location, animated: true) + mapView.setCenter(venue.location, animated: true) var region: MKCoordinateRegion = mapView.region region.center = venue.location @@ -50,27 +50,27 @@ class MapViewController: UIViewController, MKMapViewDelegate { } enum Venue { - case Waseda - case Microsoft + case waseda + case microsoft var name: String { switch self { - case .Waseda: return NSLocalizedString("NameWaseda", tableName: "Map", comment: "") - case .Microsoft: return NSLocalizedString("NameMicrosoft", tableName: "Map", comment: "") + case .waseda: return NSLocalizedString("NameWaseda", tableName: "Map", comment: "") + case .microsoft: return NSLocalizedString("NameMicrosoft", tableName: "Map", comment: "") } } var location: CLLocationCoordinate2D { switch self { - case .Waseda: return CLLocationCoordinate2D(latitude: 35.706069, longitude: 139.706809) - case .Microsoft: return CLLocationCoordinate2D(latitude: 35.626670, longitude: 139.740375) + case .waseda: return CLLocationCoordinate2D(latitude: 35.706069, longitude: 139.706809) + case .microsoft: return CLLocationCoordinate2D(latitude: 35.626670, longitude: 139.740375) } } var address: String { switch self { - case .Waseda: return NSLocalizedString("AddressWaseda", tableName: "Map", comment: "") - case .Microsoft: return NSLocalizedString("AddressMicrosoft", tableName: "Map", comment: "") + case .waseda: return NSLocalizedString("AddressWaseda", tableName: "Map", comment: "") + case .microsoft: return NSLocalizedString("AddressMicrosoft", tableName: "Map", comment: "") } } diff --git a/PyConJP2016/ViewController/More/MoreListViewController.swift b/PyConJP2016/ViewController/More/MoreListViewController.swift index 208a1bb..ad7f77a 100644 --- a/PyConJP2016/ViewController/More/MoreListViewController.swift +++ b/PyConJP2016/ViewController/More/MoreListViewController.swift @@ -15,105 +15,105 @@ class MoreListViewController: UITableViewController { super.viewDidLoad() } - override func viewWillAppear(animated: Bool) { + override func viewWillAppear(_ animated: Bool) { super.viewWillAppear(animated) if let indexPath = tableView.indexPathForSelectedRow { - tableView.deselectRowAtIndexPath(indexPath, animated: true) + tableView.deselectRow(at: indexPath, animated: true) } } // MARK: - Table View Controller Delegate - override func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) { - guard let sectionType = SectionType(rawValue: indexPath.section) else { return } - let rowType = sectionType.rows[indexPath.row] + override func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) { + guard let sectionType = SectionType(rawValue: (indexPath as NSIndexPath).section) else { return } + let rowType = sectionType.rows[(indexPath as NSIndexPath).row] switch rowType { - case .WhatsPyConJP, .CodeOfConduct, .Summary, .License, .StaffList: - guard let identifier = rowType.identifier, viewController = self.storyboard?.instantiateViewControllerWithIdentifier(identifier) else { return } + case .whatsPyConJP, .codeOfConduct, .summary, .license, .staffList: + guard let identifier = rowType.identifier, let viewController = self.storyboard?.instantiateViewController(withIdentifier: identifier) else { return } self.navigationController?.pushViewController(viewController, animated: true) - case .ParticipantsInformation, .Sponsor, .Questionnaire, .Repository: + case .participantsInformation, .sponsor, .questionnaire, .repository: guard let url = rowType.url else { return } - let safariViewController = SFSafariViewController(URL: url) - self.presentViewController(safariViewController, animated: true, completion: nil) - case .ConferenceMap: + let safariViewController = SFSafariViewController(url: url) + self.present(safariViewController, animated: true, completion: nil) + case .conferenceMap: let mapListViewController = MapListViewController.build() self.navigationController?.pushViewController(mapListViewController, animated: true) - case .SprintMap: - let mapViewController = MapViewController.build(MapViewController.Venue.Microsoft) + case .sprintMap: + let mapViewController = MapViewController.build(MapViewController.Venue.microsoft) self.navigationController?.pushViewController(mapViewController, animated: true) - case .Library: + case .library: let acknowledgmentsListViewController = AcknowledgmentsListViewController.build() self.navigationController?.pushViewController(acknowledgmentsListViewController, animated: true) - case .Feedback: + case .feedback: guard let urlSheme = rowType.urlSheme else { return } - UIApplication.sharedApplication().openURL(urlSheme) - tableView.deselectRowAtIndexPath(indexPath, animated: true) + UIApplication.shared.openURL(urlSheme) + tableView.deselectRow(at: indexPath, animated: true) } } - private enum SectionType: Int { - case About - case Map - case Application + fileprivate enum SectionType: Int { + case about + case map + case application var rows: Array { switch self { - case .About: - return [.ParticipantsInformation, .WhatsPyConJP, .CodeOfConduct, .Summary, .Sponsor, .StaffList, .Questionnaire] - case .Map: - return [.ConferenceMap, .SprintMap] - case .Application: - return [.Repository, .Library, .License, .Feedback] + case .about: + return [.participantsInformation, .whatsPyConJP, .codeOfConduct, .summary, .sponsor, .staffList, .questionnaire] + case .map: + return [.conferenceMap, .sprintMap] + case .application: + return [.repository, .library, .license, .feedback] } } } - private enum RowType: MailURLSchemeType { - case ParticipantsInformation - case WhatsPyConJP - case CodeOfConduct - case Summary - case Sponsor - case StaffList - case Questionnaire + fileprivate enum RowType: MailURLSchemeType { + case participantsInformation + case whatsPyConJP + case codeOfConduct + case summary + case sponsor + case staffList + case questionnaire - case ConferenceMap - case SprintMap + case conferenceMap + case sprintMap - case Repository - case Library - case License - case Feedback + case repository + case library + case license + case feedback var identifier: String? { switch self { - case .WhatsPyConJP: return "WhatsPyConJPViewController" - case .CodeOfConduct: return "CodeOfConductViewController" - case .Summary: return "SummaryViewController" - case .License: return "LicenseViewController" - case .StaffList: return "StaffListViewController" + case .whatsPyConJP: return "WhatsPyConJPViewController" + case .codeOfConduct: return "CodeOfConductViewController" + case .summary: return "SummaryViewController" + case .license: return "LicenseViewController" + case .staffList: return "StaffListViewController" default: return nil } } - var url: NSURL? { + var url: URL? { switch self { - case .ParticipantsInformation: return NSURL(string: PCJConfig.baseURL + "participants/") - case .Sponsor: return NSURL(string: PCJConfig.baseURL + "sponsors/") - case .Questionnaire: return NSURL(string: "https://docs.google.com/forms/d/e/1FAIpQLSefOgaVN8_cwUAcW-NmTaBNoNG8K47vursedtxkE_cbv_E37A/viewform") - case .Repository: return NSURL(string: "https://github.com/pyconjp/pyconjp-ios") + case .participantsInformation: return URL(string: PCJConfig.baseURL + "participants/") + case .sponsor: return URL(string: PCJConfig.baseURL + "sponsors/") + case .questionnaire: return URL(string: "https://docs.google.com/forms/d/e/1FAIpQLSefOgaVN8_cwUAcW-NmTaBNoNG8K47vursedtxkE_cbv_E37A/viewform") + case .repository: return URL(string: "https://github.com/pyconjp/pyconjp-ios") default: return nil } } - var urlSheme: NSURL? { + var urlSheme: URL? { switch self { - case .Feedback: return mailURLScheme(PCJConfig.mailAddress, + case .feedback: return mailURLScheme(PCJConfig.mailAddress, subject: "Feedback for PyCon JP 2016 App", - body: String(format: "iOS version: %@\nDevice Model: %@\nReply-to:\n\nFeedback:", arguments: [UIDevice.currentDevice().systemVersion, UIDevice.currentDevice().modelType])) + body: String(format: "iOS version: %@\nDevice Model: %@\nReply-to:\n\nFeedback:", arguments: [UIDevice.current.systemVersion, UIDevice.current.modelType])) default: return nil } } diff --git a/PyConJP2016/ViewController/More/StaffListViewController.swift b/PyConJP2016/ViewController/More/StaffListViewController.swift index e230a92..9b8c4a4 100644 --- a/PyConJP2016/ViewController/More/StaffListViewController.swift +++ b/PyConJP2016/ViewController/More/StaffListViewController.swift @@ -14,9 +14,9 @@ class StaffListViewController: UIViewController, TwitterURLSchemeType, ErrorAler @IBOutlet weak var tableView: UITableView! { didSet { let nib = UINib(nibName: staffListDataSource.reuseIdentifier, bundle:nil) - tableView.registerNib(nib, forCellReuseIdentifier: staffListDataSource.reuseIdentifier) + tableView.register(nib, forCellReuseIdentifier: staffListDataSource.reuseIdentifier) - refreshControl.addTarget(self, action: #selector(StaffListViewController.onRefresh(_:)), forControlEvents: .ValueChanged) + refreshControl.addTarget(self, action: #selector(StaffListViewController.onRefresh(_:)), for: .valueChanged) tableView.addSubview(refreshControl) tableView.dataSource = staffListDataSource @@ -24,12 +24,12 @@ class StaffListViewController: UIViewController, TwitterURLSchemeType, ErrorAler } } - private lazy var staffListDataSource: StaffListDataSource = StaffListDataSource(facebookAction: { (url) -> (() -> Void) in { self.facebookAction(url) } }, twitterAction: { (url) -> (() -> Void) in { self.twitterAction(url) } }) + fileprivate lazy var staffListDataSource: StaffListDataSource = StaffListDataSource(facebookAction: { (url) -> (() -> Void) in { self.facebookAction(url) } }, twitterAction: { (url) -> (() -> Void) in { self.twitterAction(url) } }) - private let refreshControl = UIRefreshControl() + fileprivate let refreshControl = UIRefreshControl() static func build() -> StaffListViewController { - return UIStoryboard(name: "More", bundle: NSBundle.mainBundle()).instantiateViewControllerWithIdentifier("StaffListViewController") as! StaffListViewController + return UIStoryboard(name: "More", bundle: Bundle.main).instantiateViewController(withIdentifier: "StaffListViewController") as! StaffListViewController } override func viewDidLoad() { @@ -39,29 +39,29 @@ class StaffListViewController: UIViewController, TwitterURLSchemeType, ErrorAler refresh() } - override func viewWillAppear(animated: Bool) { + override func viewWillAppear(_ animated: Bool) { super.viewWillAppear(animated) if let indexPath = tableView.indexPathForSelectedRow { - tableView.deselectRowAtIndexPath(indexPath, animated: true) + tableView.deselectRow(at: indexPath, animated: true) } } - func onRefresh(sender: UIRefreshControl) { + func onRefresh(_ sender: UIRefreshControl) { refresh() } func refresh() { staffListDataSource.refreshData { result in switch result { - case .Success: - dispatch_async(dispatch_get_main_queue()) { + case .success: + DispatchQueue.main.async { self.tableView.reloadData() self.refreshControl.endRefreshing() } - case .Failure(let error): - dispatch_async(dispatch_get_main_queue(), { + case .failure(let error): + DispatchQueue.main.async(execute: { self.showErrorAlartWith(error, parent: self) self.refreshControl.endRefreshing() }) @@ -71,14 +71,14 @@ class StaffListViewController: UIViewController, TwitterURLSchemeType, ErrorAler // MARK: - StaffTableViewCell Button Action - private func facebookAction(urlString: String) { - guard let url = NSURL(string: urlString) else { return } - let safariViewController = SFSafariViewController(URL: url) - self.presentViewController(safariViewController, animated: true, completion: nil) + fileprivate func facebookAction(_ urlString: String) { + guard let url = URL(string: urlString) else { return } + let safariViewController = SFSafariViewController(url: url) + self.present(safariViewController, animated: true, completion: nil) } - private func twitterAction(urlString: String) { - let userName = urlString.stringByReplacingOccurrencesOfString("https://twitter.com/", withString: "") + fileprivate func twitterAction(_ urlString: String) { + let userName = urlString.replacingOccurrences(of: "https://twitter.com/", with: "") openTwitterUser(userName, from: self) } diff --git a/PyConJP2016/ViewController/WebView/PCJWKWebViewController.swift b/PyConJP2016/ViewController/WebView/PCJWKWebViewController.swift index d9b74b1..62ca516 100644 --- a/PyConJP2016/ViewController/WebView/PCJWKWebViewController.swift +++ b/PyConJP2016/ViewController/WebView/PCJWKWebViewController.swift @@ -13,10 +13,10 @@ class PCJWKWebViewController: UIViewController, WKNavigationDelegate, WKUIDelega @IBOutlet weak var webContentView: UIView! - private var url: String = "" + fileprivate var url: String = "" - class func build(url: String) -> PCJWKWebViewController { - let pcjWKWebViewController = UIStoryboard(name: "Main", bundle: NSBundle.mainBundle()).instantiateViewControllerWithIdentifier("PCJWKWebViewController") as! PCJWKWebViewController + class func build(_ url: String) -> PCJWKWebViewController { + let pcjWKWebViewController = UIStoryboard(name: "Main", bundle: Bundle.main).instantiateViewController(withIdentifier: "PCJWKWebViewController") as! PCJWKWebViewController pcjWKWebViewController.url = url return pcjWKWebViewController } @@ -31,12 +31,12 @@ class PCJWKWebViewController: UIViewController, WKNavigationDelegate, WKUIDelega webContentView.addSubview(webView) let noLayoutFormatOptions = NSLayoutFormatOptions(rawValue: 0) - webContentView.addConstraints(NSLayoutConstraint.constraintsWithVisualFormat("V:|[webView]|", options: noLayoutFormatOptions, metrics: nil, views: ["webView": webView])) + webContentView.addConstraints(NSLayoutConstraint.constraints(withVisualFormat: "V:|[webView]|", options: noLayoutFormatOptions, metrics: nil, views: ["webView": webView])) - webContentView.addConstraints(NSLayoutConstraint.constraintsWithVisualFormat("H:|[webView]|", options: noLayoutFormatOptions, metrics: nil, views: ["webView": webView])) + webContentView.addConstraints(NSLayoutConstraint.constraints(withVisualFormat: "H:|[webView]|", options: noLayoutFormatOptions, metrics: nil, views: ["webView": webView])) - let request = NSURLRequest(URL: NSURL(string: url)!) - webView.loadRequest(request) + let request = URLRequest(url: URL(string: url)!) + webView.load(request) } @@ -46,23 +46,23 @@ class PCJWKWebViewController: UIViewController, WKNavigationDelegate, WKUIDelega // Dispose of any resources that can be recreated. } - func webView(webView: WKWebView, didFinishNavigation navigation: WKNavigation!) { + func webView(_ webView: WKWebView, didFinish navigation: WKNavigation!) { } - func webView(webView: WKWebView, createWebViewWithConfiguration configuration: WKWebViewConfiguration, forNavigationAction navigationAction: WKNavigationAction, windowFeatures: WKWindowFeatures) -> WKWebView? { - guard let url = navigationAction.request.URL else { + func webView(_ webView: WKWebView, createWebViewWith configuration: WKWebViewConfiguration, for navigationAction: WKNavigationAction, windowFeatures: WKWindowFeatures) -> WKWebView? { + guard let url = navigationAction.request.url else { return nil } - guard let targetFrame = navigationAction.targetFrame where targetFrame.mainFrame else { - webView.loadRequest(NSURLRequest.init(URL: url)) + guard let targetFrame = navigationAction.targetFrame, targetFrame.isMainFrame else { + webView.load(URLRequest.init(url: url)) return nil } return nil } - @IBAction func onCleseButton(sender: UIBarButtonItem) { - self.dismissViewControllerAnimated(true, completion: nil) + @IBAction func onCleseButton(_ sender: UIBarButtonItem) { + self.dismiss(animated: true, completion: nil) } } diff --git a/PyConJP2016Tests/PyConJP2016Tests.swift b/PyConJP2016Tests/PyConJP2016Tests.swift index 1393cfd..5ecb843 100644 --- a/PyConJP2016Tests/PyConJP2016Tests.swift +++ b/PyConJP2016Tests/PyConJP2016Tests.swift @@ -28,7 +28,7 @@ class PyConJP2016Tests: XCTestCase { func testPerformanceExample() { // This is an example of a performance test case. - self.measureBlock { + self.measure { // Put the code you want to measure the time of here. } } From 1d097a5e66bd7eb9099c9f33d4bc12a12f86926d Mon Sep 17 00:00:00 2001 From: Yutaro Muta Date: Thu, 6 Oct 2016 19:38:10 +0900 Subject: [PATCH 04/26] Fix method arguments --- PyConJP2016/Application/PCJConfig.swift | 1 - .../DataSource/More/StaffListDataSource.swift | 2 +- .../SpeakersCollectionViewDataSource.swift | 2 +- .../Timeline/TimelineDataSource.swift | 2 +- .../Extension/AppDelegateExtension.swift | 4 ++-- PyConJP2016/Extension/NSDateExtension.swift | 2 +- PyConJP2016/Extension/StringExtension.swift | 2 +- .../LocalNotificationManager.swift | 8 +++---- .../ReceiveLocalNotificationManager.swift | 6 ++--- PyConJP2016/Model/Class/TalkObject.swift | 2 +- PyConJP2016/Model/Struct/Talk.swift | 2 +- .../Protocol/Alamofire/AlamofireType.swift | 8 +++---- .../Protocol/Alamofire/StaffListAPIType.swift | 4 ++-- .../Alamofire/TalkDetailAPIType.swift | 8 +++---- .../Protocol/Alamofire/TalksAPIType.swift | 8 +++---- PyConJP2016/View/CustomImageView.swift | 12 +++++----- .../SpeakerCollectionViewCell.swift | 2 +- .../UITableViewCell/StaffTableViewCell.swift | 24 +++++++++---------- .../UITableViewCell/TalkTableViewCell.swift | 18 +++++++------- 19 files changed, 58 insertions(+), 59 deletions(-) diff --git a/PyConJP2016/Application/PCJConfig.swift b/PyConJP2016/Application/PCJConfig.swift index 444f23c..ee76eb7 100644 --- a/PyConJP2016/Application/PCJConfig.swift +++ b/PyConJP2016/Application/PCJConfig.swift @@ -5,7 +5,6 @@ // Created by Yutaro Muta on 8/30/2016. // Copyright © 2016 PyCon JP. All rights reserved. // -// import UIKit diff --git a/PyConJP2016/DataSource/More/StaffListDataSource.swift b/PyConJP2016/DataSource/More/StaffListDataSource.swift index 63180b4..3d68ae0 100644 --- a/PyConJP2016/DataSource/More/StaffListDataSource.swift +++ b/PyConJP2016/DataSource/More/StaffListDataSource.swift @@ -57,7 +57,7 @@ class StaffListDataSource: NSObject, UITableViewDataSource, StaffListAPIType { guard let cell = tableView.dequeueReusableCell(withIdentifier: reuseIdentifier, for: indexPath) as? StaffTableViewCell else { fatalError("Could not create StaffTableViewCell") } - cell.fill(teams[(indexPath as NSIndexPath).section].staffs[(indexPath as NSIndexPath).row], + cell.fill(staff: teams[(indexPath as NSIndexPath).section].staffs[(indexPath as NSIndexPath).row], onFacebookButton: facebookAction(teams[(indexPath as NSIndexPath).section].staffs[(indexPath as NSIndexPath).row].facebook), onTwitterButton: twitterAction(teams[(indexPath as NSIndexPath).section].staffs[(indexPath as NSIndexPath).row].twitter)) return cell diff --git a/PyConJP2016/DataSource/TalkDetail/SpeakersCollectionViewDataSource.swift b/PyConJP2016/DataSource/TalkDetail/SpeakersCollectionViewDataSource.swift index 3097998..54dfd04 100644 --- a/PyConJP2016/DataSource/TalkDetail/SpeakersCollectionViewDataSource.swift +++ b/PyConJP2016/DataSource/TalkDetail/SpeakersCollectionViewDataSource.swift @@ -20,7 +20,7 @@ class SpeakersCollectionViewDataSource: NSObject, UICollectionViewDataSource { func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell { let cell = collectionView.dequeueReusableCell(withReuseIdentifier: reuseIdentifier, for: indexPath) as! SpeakerCollectionViewCell - cell.fill(speakers[(indexPath as NSIndexPath).row]) + cell.fill(speaker: speakers[(indexPath as NSIndexPath).row]) return cell } } diff --git a/PyConJP2016/DataSource/Timeline/TimelineDataSource.swift b/PyConJP2016/DataSource/Timeline/TimelineDataSource.swift index ef29a39..bfe6094 100644 --- a/PyConJP2016/DataSource/Timeline/TimelineDataSource.swift +++ b/PyConJP2016/DataSource/Timeline/TimelineDataSource.swift @@ -32,7 +32,7 @@ class TimelineDataSource: NSObject, UITableViewDataSource { guard let cell = tableView.dequeueReusableCell(withIdentifier: reuseIdentifier, for: indexPath) as? TalkTableViewCell else { fatalError("Could not create TalkTableViewCell") } - cell.fill(timelines[(indexPath as NSIndexPath).section].talks[(indexPath as NSIndexPath).row]) + cell.fill(talkObject: timelines[(indexPath as NSIndexPath).section].talks[(indexPath as NSIndexPath).row]) return cell } } diff --git a/PyConJP2016/Extension/AppDelegateExtension.swift b/PyConJP2016/Extension/AppDelegateExtension.swift index bf733fa..f41da66 100644 --- a/PyConJP2016/Extension/AppDelegateExtension.swift +++ b/PyConJP2016/Extension/AppDelegateExtension.swift @@ -10,11 +10,11 @@ import UIKit extension AppDelegate { - func showAlert(_ alertController: UIAlertController) { + func showAlert(alertController: UIAlertController) { self.window?.rootViewController?.presentingViewController?.present(alertController, animated: true, completion: nil) } - func openTalkDetailViewController(_ id: Int) { + func openTalkDetailViewController(id: Int) { let talkDetailViewController = TalkDetailViewController.build(id) self.window?.rootViewController?.presentedViewController?.navigationController?.pushViewController(talkDetailViewController, animated: true) } diff --git a/PyConJP2016/Extension/NSDateExtension.swift b/PyConJP2016/Extension/NSDateExtension.swift index 706447f..48c2ee2 100644 --- a/PyConJP2016/Extension/NSDateExtension.swift +++ b/PyConJP2016/Extension/NSDateExtension.swift @@ -16,7 +16,7 @@ extension Date { return dateFormatter }() - static func dateFromString(_ string: String) -> Date? { + static func date(from string: String) -> Date? { return dateFormatterInstance.date(from: string) } diff --git a/PyConJP2016/Extension/StringExtension.swift b/PyConJP2016/Extension/StringExtension.swift index 9b48ede..9a1afcb 100644 --- a/PyConJP2016/Extension/StringExtension.swift +++ b/PyConJP2016/Extension/StringExtension.swift @@ -22,7 +22,7 @@ extension String { func timeStringByTrimingSecond() -> String { let dateString = "2000-01-01 " + self - guard let date = Date.dateFromString(dateString) else { return self } + guard let date = Date.date(from: dateString) else { return self } return date.convertToTime() } diff --git a/PyConJP2016/Manager/Notification/LocalNotificationManager.swift b/PyConJP2016/Manager/Notification/LocalNotificationManager.swift index 3af09b6..5b793f5 100644 --- a/PyConJP2016/Manager/Notification/LocalNotificationManager.swift +++ b/PyConJP2016/Manager/Notification/LocalNotificationManager.swift @@ -10,7 +10,7 @@ import UIKit class LocalNotificationManager: NSObject { - func makeNotification(_ talkDetail: TalkDetail) -> Bool { + func makeNotification(talkDetail: TalkDetail) -> Bool { guard let date = talkDetail.talkObject.date else { return false } @@ -18,14 +18,14 @@ class LocalNotificationManager: NSObject { let fireDate = (calendar as NSCalendar?)?.date(byAdding: .minute, value: -10, to: date as Date, options: NSCalendar.Options()) if fireDate!.timeIntervalSinceNow > 0 { - self.schedule(talkDetail) + self.schedule(talkDetail: talkDetail) return true } else { return false } } - fileprivate func schedule(_ talkDetail: TalkDetail) { + fileprivate func schedule(talkDetail: TalkDetail) { guard let date = talkDetail.talkObject.date else { return } @@ -43,7 +43,7 @@ class LocalNotificationManager: NSObject { } - func cancelSchedule(_ talkDetail: TalkDetail) { + func cancelSchedule(talkDetail: TalkDetail) { if let localNotifications = UIApplication.shared.scheduledLocalNotifications { localNotifications.forEach({ (notification) -> () in if let userInfo = notification.userInfo { diff --git a/PyConJP2016/Manager/Notification/ReceiveLocalNotificationManager.swift b/PyConJP2016/Manager/Notification/ReceiveLocalNotificationManager.swift index cb48535..6bb8ef1 100644 --- a/PyConJP2016/Manager/Notification/ReceiveLocalNotificationManager.swift +++ b/PyConJP2016/Manager/Notification/ReceiveLocalNotificationManager.swift @@ -17,13 +17,13 @@ class ReceiveLocalNotificationManager: NSObject { let alertController = UIAlertController(title: "", message: "", preferredStyle: .alert) alertController.addAction(UIAlertAction(title: "閉じる", style: .default, handler: nil)) alertController.addAction(UIAlertAction(title: "詳細へ", style: .default, handler: {(action) -> Void in - appDelegate.openTalkDetailViewController(id) + appDelegate.openTalkDetailViewController(id: id) })) if let appDelegate = UIApplication.shared.delegate as? AppDelegate { - appDelegate.showAlert(alertController) + appDelegate.showAlert(alertController: alertController) } case "Talk" where application.applicationState == .inactive: - appDelegate.openTalkDetailViewController(id) + appDelegate.openTalkDetailViewController(id: id) case "Information": break default: diff --git a/PyConJP2016/Model/Class/TalkObject.swift b/PyConJP2016/Model/Class/TalkObject.swift index 395b94f..c774d7b 100644 --- a/PyConJP2016/Model/Class/TalkObject.swift +++ b/PyConJP2016/Model/Class/TalkObject.swift @@ -32,7 +32,7 @@ class TalkObject: RealmSwift.Object { speakers = (dictionary["speakers"] as? [String] ?? []).enumerated().reduce("") { $0 + $1.element + ((dictionary["speakers"] as? [String] ?? []).count - 1 == $1.offset ? "" : ", ") } - date = Date.dateFromString((dictionary["day"] as? String ?? "") + " " + (dictionary["start"] as? String ?? "")) + date = Date.date(from: (dictionary["day"] as? String ?? "") + " " + (dictionary["start"] as? String ?? "")) day = dictionary["day"] as? String ?? "" startTime = dictionary["start"] as? String ?? "" endTime = dictionary["end"] as? String ?? "" diff --git a/PyConJP2016/Model/Struct/Talk.swift b/PyConJP2016/Model/Struct/Talk.swift index 73b2407..1dc5727 100644 --- a/PyConJP2016/Model/Struct/Talk.swift +++ b/PyConJP2016/Model/Struct/Talk.swift @@ -32,7 +32,7 @@ extension Talk { self.title = title self.description = description self.speakers = speakers - self.date = Date.dateFromString(day + " " + startTime) + self.date = Date.date(from: day + " " + startTime) self.day = day self.startTime = startTime self.endTime = endTime diff --git a/PyConJP2016/Protocol/Alamofire/AlamofireType.swift b/PyConJP2016/Protocol/Alamofire/AlamofireType.swift index 687365c..46c59e2 100644 --- a/PyConJP2016/Protocol/Alamofire/AlamofireType.swift +++ b/PyConJP2016/Protocol/Alamofire/AlamofireType.swift @@ -15,8 +15,8 @@ protocol AlamofireType { var authUser: String { get } var authPassword: String { get } - func get(_ parameter: Dictionary?, successClosure success: @escaping (Dictionary) -> Void, failClosure fail: @escaping (Error) -> Void) -> Void - func get(_ parameter: Dictionary?, completionHandler: @escaping ((Result>) -> Void)) -> Void + func get(parameter: Dictionary?, successClosure success: @escaping (Dictionary) -> Void, failClosure fail: @escaping (Error) -> Void) -> Void + func get(parameter: Dictionary?, completionHandler: @escaping ((Result>) -> Void)) -> Void } extension AlamofireType { @@ -37,7 +37,7 @@ extension AlamofireType { extension AlamofireType { - func get(_ parameter: Dictionary? = nil, successClosure success: @escaping (Dictionary) -> Void, failClosure fail: @escaping (Error) -> Void) -> Void { + func get(parameter: Dictionary? = nil, successClosure success: @escaping (Dictionary) -> Void, failClosure fail: @escaping (Error) -> Void) -> Void { let url = baseURL + path let responseClosure = { (response: DataResponse) in switch response.result { @@ -53,7 +53,7 @@ extension AlamofireType { Alamofire.request(url, method: .get, parameters: parameter).authenticate(user: authUser, password: authPassword).responseJSON(completionHandler: responseClosure) } - func get(_ parameter: Dictionary? = nil, completionHandler: @escaping ((Result>) -> Void)) -> Void { + func get(parameter: Dictionary? = nil, completionHandler: @escaping ((Result>) -> Void)) -> Void { let url = baseURL + path let responseClosure = { (response: DataResponse) in switch response.result { diff --git a/PyConJP2016/Protocol/Alamofire/StaffListAPIType.swift b/PyConJP2016/Protocol/Alamofire/StaffListAPIType.swift index 85aaf09..7b9b28c 100644 --- a/PyConJP2016/Protocol/Alamofire/StaffListAPIType.swift +++ b/PyConJP2016/Protocol/Alamofire/StaffListAPIType.swift @@ -9,7 +9,7 @@ import UIKit protocol StaffListAPIType: AlamofireType { - func getStaffs(_ completionHandler: @escaping ((Result>) -> Void)) -> Void + func getStaffs(completionHandler: @escaping ((Result>) -> Void)) -> Void } extension StaffListAPIType { @@ -26,7 +26,7 @@ extension StaffListAPIType { extension StaffListAPIType { - func getStaffs(_ completionHandler: @escaping ((Result>) -> Void)) -> Void { + func getStaffs(completionHandler: @escaping ((Result>) -> Void)) -> Void { get() { result in switch result { case .success(let value): diff --git a/PyConJP2016/Protocol/Alamofire/TalkDetailAPIType.swift b/PyConJP2016/Protocol/Alamofire/TalkDetailAPIType.swift index 0accb63..a1237b7 100644 --- a/PyConJP2016/Protocol/Alamofire/TalkDetailAPIType.swift +++ b/PyConJP2016/Protocol/Alamofire/TalkDetailAPIType.swift @@ -13,8 +13,8 @@ protocol TalkDetailAPIType: AlamofireType { var id: Int? { get set } func getTalkDetail(successClosure success: @escaping (TalkDetail) -> Void, failClosure fail: @escaping (Error) -> Void) -> Void - func getTalkDetail(_ completionHandler: @escaping ((Result) -> Void)) -> Void - func getTalkDetailFromLocalDummyJson(_ completionHandler: ((Result) -> Void)) -> Void + func getTalkDetail(completionHandler: @escaping ((Result) -> Void)) -> Void + func getTalkDetailFromLocalDummyJson(completionHandler: ((Result) -> Void)) -> Void } extension TalkDetailAPIType { @@ -37,7 +37,7 @@ extension TalkDetailAPIType { }) } - func getTalkDetail(_ completionHandler: @escaping ((Result) -> Void)) -> Void { + func getTalkDetail(completionHandler: @escaping ((Result) -> Void)) -> Void { get() { result in switch result { case .success(let value): @@ -49,7 +49,7 @@ extension TalkDetailAPIType { } } - func getTalkDetailFromLocalDummyJson(_ completionHandler: ((Result) -> Void)) -> Void { + func getTalkDetailFromLocalDummyJson(completionHandler: ((Result) -> Void)) -> Void { let path = Bundle.main.path(forResource: "DummyTalkDetail", ofType: "json") let fileHandle = FileHandle(forReadingAtPath: path!) let data = fileHandle?.readDataToEndOfFile() diff --git a/PyConJP2016/Protocol/Alamofire/TalksAPIType.swift b/PyConJP2016/Protocol/Alamofire/TalksAPIType.swift index 55d379a..a6a80ea 100644 --- a/PyConJP2016/Protocol/Alamofire/TalksAPIType.swift +++ b/PyConJP2016/Protocol/Alamofire/TalksAPIType.swift @@ -11,8 +11,8 @@ import RealmSwift protocol TalksAPIType: AlamofireType { func getTalks(successClosure success: @escaping () -> Void, failClosure fail: @escaping (Error) -> Void) -> Void - func getTalks(_ completionHandler: @escaping ((Result) -> Void)) -> Void - func getTalksFromLocalDummyJson(_ completionHandler: ((Result) -> Void)) -> Void + func getTalks(completionHandler: @escaping ((Result) -> Void)) -> Void + func getTalksFromLocalDummyJson(completionHandler: ((Result) -> Void)) -> Void } extension TalksAPIType { @@ -49,7 +49,7 @@ extension TalksAPIType { }) } - func getTalks(_ completionHandler: @escaping ((Result) -> Void)) -> Void { + func getTalks(completionHandler: @escaping ((Result) -> Void)) -> Void { get() { result in switch result { case .success(let value): @@ -75,7 +75,7 @@ extension TalksAPIType { } } - func getTalksFromLocalDummyJson(_ completionHandler: ((Result) -> Void)) -> Void { + func getTalksFromLocalDummyJson(completionHandler: ((Result) -> Void)) -> Void { let path = Bundle.main.path(forResource: "DummyTalks", ofType: "json") let fileHandle = FileHandle(forReadingAtPath: path!) let data = fileHandle?.readDataToEndOfFile() diff --git a/PyConJP2016/View/CustomImageView.swift b/PyConJP2016/View/CustomImageView.swift index 456b038..377c2bb 100644 --- a/PyConJP2016/View/CustomImageView.swift +++ b/PyConJP2016/View/CustomImageView.swift @@ -37,15 +37,15 @@ class CustomImageView: UIImageView { func handleGesture(_ gesture: UIGestureRecognizer) { if let doubleTapGesture = gesture as? UITapGestureRecognizer { - doubleTap(doubleTapGesture) + doubleTap(gesture: doubleTapGesture) } else if let pinchGesture = gesture as? UIPinchGestureRecognizer { - pinch(pinchGesture) + pinch(gesture: pinchGesture) } else if let panGesture = gesture as? UIPanGestureRecognizer { - pan(panGesture) + pan(gesture: panGesture) } } - func doubleTap(_ gesture: UITapGestureRecognizer) { + func doubleTap(gesture: UITapGestureRecognizer) { if gestureEnabled { beforePoint = CGPoint(x: 0.0, y: 0.0) currentScale = 1.0 @@ -55,7 +55,7 @@ class CustomImageView: UIImageView { } } - fileprivate func pinch(_ gesture: UIPinchGestureRecognizer) { + fileprivate func pinch(gesture: UIPinchGestureRecognizer) { if gestureEnabled { var scale = gesture.scale if currentScale > 1.0 { @@ -83,7 +83,7 @@ class CustomImageView: UIImageView { } } - fileprivate func pan(_ gesture: UIPanGestureRecognizer) { + fileprivate func pan(gesture: UIPanGestureRecognizer) { if currentScale == 1.0 { return } if let gestureView = gesture.view, gestureEnabled { diff --git a/PyConJP2016/View/UICollectionViewCell/SpeakerCollectionViewCell.swift b/PyConJP2016/View/UICollectionViewCell/SpeakerCollectionViewCell.swift index f425f02..5af1975 100644 --- a/PyConJP2016/View/UICollectionViewCell/SpeakerCollectionViewCell.swift +++ b/PyConJP2016/View/UICollectionViewCell/SpeakerCollectionViewCell.swift @@ -21,7 +21,7 @@ class SpeakerCollectionViewCell: UICollectionViewCell { twitterLabel.text = nil } - func fill(_ speaker: Speaker) { + func fill(speaker: Speaker) { if let imageURL = speaker.imageURL, let url = URL(string: PCJConfig.hostURL + imageURL) { iconImageView.af_setImage(withURL: url) } diff --git a/PyConJP2016/View/UITableViewCell/StaffTableViewCell.swift b/PyConJP2016/View/UITableViewCell/StaffTableViewCell.swift index d1a10cc..d0ed157 100644 --- a/PyConJP2016/View/UITableViewCell/StaffTableViewCell.swift +++ b/PyConJP2016/View/UITableViewCell/StaffTableViewCell.swift @@ -20,28 +20,28 @@ class StaffTableViewCell: UITableViewCell { fileprivate var facebookAction: (() -> Void)? fileprivate var twitterAction: (() -> Void)? - func fill(_ staff: Staff, onFacebookButton: @escaping (() -> Void), onTwitterButton: @escaping (() -> Void)) { + override func prepareForReuse() { + nameLabel.text = nil + roleLabel.text = nil + toggleFacebookButton(enabled: false) + toggleTwitterButton(enabled: false) + } + + func fill(staff: Staff, onFacebookButton: @escaping (() -> Void), onTwitterButton: @escaping (() -> Void)) { nameLabel.text = staff.name roleLabel.text = staff.role - toggleFacebookButton(!staff.facebook.isEmpty) - toggleTwitterButton(!staff.twitter.isEmpty) + toggleFacebookButton(enabled: !staff.facebook.isEmpty) + toggleTwitterButton(enabled: !staff.twitter.isEmpty) facebookAction = onFacebookButton twitterAction = onTwitterButton } - override func prepareForReuse() { - nameLabel.text = nil - roleLabel.text = nil - toggleFacebookButton(false) - toggleTwitterButton(false) - } - - fileprivate func toggleFacebookButton(_ enabled: Bool) { + fileprivate func toggleFacebookButton(enabled: Bool) { facebookButton.isEnabled = enabled facebookButton.backgroundColor = enabled ? UIColor.facebookColor() : UIColor.pyconJP2016GlayColor() } - fileprivate func toggleTwitterButton(_ enabled: Bool) { + fileprivate func toggleTwitterButton(enabled: Bool) { twitterButton.isEnabled = enabled twitterButton.backgroundColor = enabled ? UIColor.twitterColor() : UIColor.pyconJP2016GlayColor() } diff --git a/PyConJP2016/View/UITableViewCell/TalkTableViewCell.swift b/PyConJP2016/View/UITableViewCell/TalkTableViewCell.swift index f39e035..65912d3 100644 --- a/PyConJP2016/View/UITableViewCell/TalkTableViewCell.swift +++ b/PyConJP2016/View/UITableViewCell/TalkTableViewCell.swift @@ -18,7 +18,15 @@ class TalkTableViewCell: UITableViewCell { static let estimatedRowHeight: CGFloat = 134 - func fill(_ talkObject: TalkObject) { + override func prepareForReuse() { + titleLabel.text = nil + timeLabel.text = nil + placeLabel.text = nil + speakerLabel.text = nil + placeView.backgroundColor = UIColor.darkGray + } + + func fill(talkObject: TalkObject) { titleLabel.text = talkObject.title timeLabel.text = talkObject.periodTime placeLabel.text = talkObject.place @@ -28,12 +36,4 @@ class TalkTableViewCell: UITableViewCell { } } - override func prepareForReuse() { - titleLabel.text = nil - timeLabel.text = nil - placeLabel.text = nil - speakerLabel.text = nil - placeView.backgroundColor = UIColor.darkGray - } - } From 71146ad12efd5dfd01e3adc0eee66cbb513fd19e Mon Sep 17 00:00:00 2001 From: Yutaro Muta Date: Thu, 6 Oct 2016 20:14:13 +0900 Subject: [PATCH 05/26] Fix method arguments with Swift3 API Guide Line --- .../DataSource/More/StaffListDataSource.swift | 2 +- .../SpeakersCollectionViewDataSource.swift | 2 ++ .../Timeline/Bookmark/BookmarkListDataSource.swift | 2 +- .../Conference/ConferenceListDataSource.swift | 2 +- .../DataSource/Timeline/TimelineDataSource.swift | 2 +- PyConJP2016/Extension/AppDelegateExtension.swift | 2 +- .../ViewController/Base/BaseTabBarController.swift | 6 +++--- .../Base/TalkDetailViewController.swift | 10 +++++----- .../Bookmark/BookmarkListViewController.swift | 2 +- .../Conference/ConferenceBaseViewController.swift | 8 ++++---- .../Conference/ConferenceDateViewController.swift | 10 +++++----- .../Conference/ConferenceListViewController.swift | 2 +- .../Conference/ConferenceModelController.swift | 12 ++++++------ .../Conference/ConferencePageViewController.swift | 14 +++++++------- .../More/FloorMapZoomableImageViewController.swift | 5 ----- .../More/MapListViewController.swift | 2 +- .../ViewController/More/MapViewController.swift | 2 +- .../More/MoreListViewController.swift | 2 +- .../More/StaffListViewController.swift | 6 +++--- .../WebView/PCJWKWebViewController.swift | 2 +- 20 files changed, 46 insertions(+), 49 deletions(-) diff --git a/PyConJP2016/DataSource/More/StaffListDataSource.swift b/PyConJP2016/DataSource/More/StaffListDataSource.swift index 3d68ae0..e2ef97b 100644 --- a/PyConJP2016/DataSource/More/StaffListDataSource.swift +++ b/PyConJP2016/DataSource/More/StaffListDataSource.swift @@ -22,7 +22,7 @@ class StaffListDataSource: NSObject, UITableViewDataSource, StaffListAPIType { self.twitterAction = twitterAction } - func refreshData(_ completionHandler: @escaping ((Result) -> Void)) -> Void { + func refreshData(completionHandler: @escaping ((Result) -> Void)) -> Void { getStaffs { [weak self](result) in guard let weakSelf = self else { return } switch result { diff --git a/PyConJP2016/DataSource/TalkDetail/SpeakersCollectionViewDataSource.swift b/PyConJP2016/DataSource/TalkDetail/SpeakersCollectionViewDataSource.swift index 54dfd04..d756834 100644 --- a/PyConJP2016/DataSource/TalkDetail/SpeakersCollectionViewDataSource.swift +++ b/PyConJP2016/DataSource/TalkDetail/SpeakersCollectionViewDataSource.swift @@ -14,6 +14,8 @@ class SpeakersCollectionViewDataSource: NSObject, UICollectionViewDataSource { var speakers: [Speaker] = [] + // MARK: - Collection View DataSource + func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int { return speakers.count } diff --git a/PyConJP2016/DataSource/Timeline/Bookmark/BookmarkListDataSource.swift b/PyConJP2016/DataSource/Timeline/Bookmark/BookmarkListDataSource.swift index aa8f959..d5ae6de 100644 --- a/PyConJP2016/DataSource/Timeline/Bookmark/BookmarkListDataSource.swift +++ b/PyConJP2016/DataSource/Timeline/Bookmark/BookmarkListDataSource.swift @@ -14,7 +14,7 @@ class BookmarkListDataSource: TimelineDataSource, RealmTalksType { let filterPredicate = NSPredicate(format: "favorited == %@", true as CVarArg) let sortProperties = [SortDescriptor(property: "date", ascending: true), SortDescriptor(property: "place", ascending: true)] - func refreshData(_ completionHandler: @escaping ((Result) -> Void)) -> Void { + func refreshData(completionHandler: @escaping ((Result) -> Void)) -> Void { loadTalkObjects { [weak self](result) in guard let weakSelf = self else { return } switch result { diff --git a/PyConJP2016/DataSource/Timeline/Conference/ConferenceListDataSource.swift b/PyConJP2016/DataSource/Timeline/Conference/ConferenceListDataSource.swift index 4af4ec1..e8b37b9 100644 --- a/PyConJP2016/DataSource/Timeline/Conference/ConferenceListDataSource.swift +++ b/PyConJP2016/DataSource/Timeline/Conference/ConferenceListDataSource.swift @@ -19,7 +19,7 @@ class ConferenceListDataSource: TimelineDataSource, RealmTalksType { super.init() } - func refreshData(_ completionHandler: @escaping ((Result) -> Void)) -> Void { + func refreshData(completionHandler: @escaping ((Result) -> Void)) -> Void { loadTalkObjects { [weak self](result) in guard let weakSelf = self else { return } switch result { diff --git a/PyConJP2016/DataSource/Timeline/TimelineDataSource.swift b/PyConJP2016/DataSource/Timeline/TimelineDataSource.swift index bfe6094..2d707ef 100644 --- a/PyConJP2016/DataSource/Timeline/TimelineDataSource.swift +++ b/PyConJP2016/DataSource/Timeline/TimelineDataSource.swift @@ -14,7 +14,7 @@ class TimelineDataSource: NSObject, UITableViewDataSource { var timelines: [Timeline] = [] - // MARK: - Table View Controller Data Source + // MARK: - Table View Data Source func numberOfSections(in tableView: UITableView) -> Int { return timelines.count diff --git a/PyConJP2016/Extension/AppDelegateExtension.swift b/PyConJP2016/Extension/AppDelegateExtension.swift index f41da66..3630686 100644 --- a/PyConJP2016/Extension/AppDelegateExtension.swift +++ b/PyConJP2016/Extension/AppDelegateExtension.swift @@ -15,7 +15,7 @@ extension AppDelegate { } func openTalkDetailViewController(id: Int) { - let talkDetailViewController = TalkDetailViewController.build(id) + let talkDetailViewController = TalkDetailViewController.build(id: id) self.window?.rootViewController?.presentedViewController?.navigationController?.pushViewController(talkDetailViewController, animated: true) } diff --git a/PyConJP2016/ViewController/Base/BaseTabBarController.swift b/PyConJP2016/ViewController/Base/BaseTabBarController.swift index 4f86cd4..876152f 100644 --- a/PyConJP2016/ViewController/Base/BaseTabBarController.swift +++ b/PyConJP2016/ViewController/Base/BaseTabBarController.swift @@ -17,15 +17,15 @@ class BaseTabBarController: UITabBarController { override func viewDidLoad() { super.viewDidLoad() - //EventsceTab + // EventsceTab let eventsStoryboard = UIStoryboard(name: "Events", bundle: Bundle.main) eventsTabNavigationController = eventsStoryboard.instantiateViewController(withIdentifier: "EventsNavigationController") as? UINavigationController - //ConferenceTab + // ConferenceTab let conferenceStoryboard = UIStoryboard(name: "Conference", bundle: Bundle.main) conferenceTabNavigationController = conferenceStoryboard.instantiateViewController(withIdentifier: "ConferenceNavigationController") as? UINavigationController - //MoreTab + // MoreTab let moreStoryboard = UIStoryboard(name: "More", bundle: Bundle.main) moreTabNavigationController = moreStoryboard.instantiateViewController(withIdentifier: "MoreNavigationController") as? UINavigationController diff --git a/PyConJP2016/ViewController/Base/TalkDetailViewController.swift b/PyConJP2016/ViewController/Base/TalkDetailViewController.swift index 1209e6b..413f673 100644 --- a/PyConJP2016/ViewController/Base/TalkDetailViewController.swift +++ b/PyConJP2016/ViewController/Base/TalkDetailViewController.swift @@ -63,7 +63,7 @@ class TalkDetailViewController: UIViewController, TalkDetailAPIType, TwitterURLS fileprivate lazy var speakersCollectionViewHeight: CGFloat = self.speakersCollectionViewHeightConstraint.constant - class func build(_ id: Int) -> TalkDetailViewController { + class func build(id: Int) -> TalkDetailViewController { let talkDetailViewController = UIStoryboard(name: "Main", bundle: Bundle.main).instantiateViewController(withIdentifier: "TalkDetailViewController") as! TalkDetailViewController talkDetailViewController.id = id return talkDetailViewController @@ -85,7 +85,7 @@ class TalkDetailViewController: UIViewController, TalkDetailAPIType, TwitterURLS let realm = try Realm() if let talkObject = realm.object(ofType: TalkObject.self, forPrimaryKey: id as AnyObject) { talkDetail.talkObject.favorited = talkObject.favorited - toggleBookmarkBarButtonItem(talkDetail.talkObject.favorited) + toggleBookmarkBarButtonItem(isFavorite: talkDetail.talkObject.favorited) } } catch { @@ -135,12 +135,12 @@ class TalkDetailViewController: UIViewController, TalkDetailAPIType, TwitterURLS self.descriptionTextView.text = talkDetail.talkObject.descriptionText self.abstractTextView.text = talkDetail.abstract - self.toggleBookmarkBarButtonItem(talkDetail.talkObject.favorited) + self.toggleBookmarkBarButtonItem(isFavorite: talkDetail.talkObject.favorited) } } - func toggleBookmarkBarButtonItem(_ isFavorite: Bool) { + func toggleBookmarkBarButtonItem(isFavorite: Bool) { let image = isFavorite ? UIImage(named: "BookmarkOn") : UIImage(named: "BookmarkOff") DispatchQueue.main.async { self.bookmarkBarButtonItem.image = image @@ -159,7 +159,7 @@ class TalkDetailViewController: UIViewController, TalkDetailAPIType, TwitterURLS try realm.write({ realm.create(TalkObject.self, value: ["id": talkDetail.talkObject.id, "favorited": talkDetail.talkObject.favorited], update: true) }) - toggleBookmarkBarButtonItem(talkDetail.talkObject.favorited) + toggleBookmarkBarButtonItem(isFavorite: talkDetail.talkObject.favorited) } catch { } diff --git a/PyConJP2016/ViewController/Bookmark/BookmarkListViewController.swift b/PyConJP2016/ViewController/Bookmark/BookmarkListViewController.swift index 705ca24..87f294c 100644 --- a/PyConJP2016/ViewController/Bookmark/BookmarkListViewController.swift +++ b/PyConJP2016/ViewController/Bookmark/BookmarkListViewController.swift @@ -76,7 +76,7 @@ class BookmarkListViewController: UIViewController, UITableViewDelegate, ErrorAl func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) { let talkObject = bookmarkListDataSource.timelines[(indexPath as NSIndexPath).section].talks[(indexPath as NSIndexPath).row] - let talkDetailViewController = TalkDetailViewController.build(talkObject.id) + let talkDetailViewController = TalkDetailViewController.build(id: talkObject.id) self.navigationController?.pushViewController(talkDetailViewController, animated: true) } diff --git a/PyConJP2016/ViewController/Conference/ConferenceBaseViewController.swift b/PyConJP2016/ViewController/Conference/ConferenceBaseViewController.swift index 966b551..c12d301 100644 --- a/PyConJP2016/ViewController/Conference/ConferenceBaseViewController.swift +++ b/PyConJP2016/ViewController/Conference/ConferenceBaseViewController.swift @@ -25,7 +25,7 @@ class ConferenceBaseViewController: UIViewController, UIPageViewControllerDelega fileprivate var displayIndex: Int = 0 { didSet { if let conferenceDateViewProtocol = conferenceDateViewProtocol { - conferenceDateViewProtocol.changeActive(displayIndex) + conferenceDateViewProtocol.changeActive(index: displayIndex) } } } @@ -75,10 +75,10 @@ class ConferenceBaseViewController: UIViewController, UIPageViewControllerDelega } protocol ConferencePageViewProtocol { - func fowardPage(_ index: Int) - func reversePage(_ index: Int) + func fowardPage(index: Int) + func reversePage(index: Int) } protocol ConferenceDateViewProtocol { - func changeActive(_ index: Int) + func changeActive(index: Int) } diff --git a/PyConJP2016/ViewController/Conference/ConferenceDateViewController.swift b/PyConJP2016/ViewController/Conference/ConferenceDateViewController.swift index d92c6d1..e2cd4e3 100644 --- a/PyConJP2016/ViewController/Conference/ConferenceDateViewController.swift +++ b/PyConJP2016/ViewController/Conference/ConferenceDateViewController.swift @@ -40,21 +40,21 @@ class ConferenceDateViewController: UIViewController, ConferenceDateViewProtocol @IBAction func onDay1Button(_ sender: UIButton) { if let conferencePageViewProtocol = conferencePageViewProtocol { - conferencePageViewProtocol.reversePage(0) - changeActive(0) + conferencePageViewProtocol.reversePage(index: 0) + changeActive(index: 0) } } @IBAction func onDay2Button(_ sender: UIButton) { if let conferencePageViewProtocol = conferencePageViewProtocol { - conferencePageViewProtocol.fowardPage(1) - changeActive(1) + conferencePageViewProtocol.fowardPage(index: 1) + changeActive(index: 1) } } // MARK: - ConferenceDateViewProtocol - func changeActive(_ index: Int) { + func changeActive(index: Int) { func changeActiveButton(_ button: UIButton) { button.isEnabled = false diff --git a/PyConJP2016/ViewController/Conference/ConferenceListViewController.swift b/PyConJP2016/ViewController/Conference/ConferenceListViewController.swift index d552c99..d6580df 100644 --- a/PyConJP2016/ViewController/Conference/ConferenceListViewController.swift +++ b/PyConJP2016/ViewController/Conference/ConferenceListViewController.swift @@ -109,7 +109,7 @@ class ConferenceListViewController: UIViewController, UITableViewDelegate, Talks func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) { let talkObject = conferenceListDataSource.timelines[(indexPath as NSIndexPath).section].talks[(indexPath as NSIndexPath).row] - let talkDetailViewController = TalkDetailViewController.build(talkObject.id) + let talkDetailViewController = TalkDetailViewController.build(id: talkObject.id) self.navigationController?.pushViewController(talkDetailViewController, animated: true) } diff --git a/PyConJP2016/ViewController/Conference/ConferenceModelController.swift b/PyConJP2016/ViewController/Conference/ConferenceModelController.swift index b309523..16c52fc 100644 --- a/PyConJP2016/ViewController/Conference/ConferenceModelController.swift +++ b/PyConJP2016/ViewController/Conference/ConferenceModelController.swift @@ -16,7 +16,7 @@ class ConferenceModelController: NSObject, UIPageViewControllerDataSource { super.init() } - func viewControllerAtIndex(_ index: Int, storyboard: UIStoryboard) -> ConferenceListViewController? { + func viewController(index: Int, storyboard: UIStoryboard) -> ConferenceListViewController? { if self.days.isEmpty || index >= days.count { return nil @@ -27,7 +27,7 @@ class ConferenceModelController: NSObject, UIPageViewControllerDataSource { } - func indexOfViewController(_ viewController: UIViewController) -> Int { + func indexOfViewController(viewController: UIViewController) -> Int { guard let viewController = viewController as? ConferenceListViewController, let pyconJPDate = viewController.pyconJPDate else { return NSNotFound } return days.index(of: pyconJPDate) ?? NSNotFound } @@ -35,17 +35,17 @@ class ConferenceModelController: NSObject, UIPageViewControllerDataSource { // MARK: - Page View Controller Data Source func pageViewController(_ pageViewController: UIPageViewController, viewControllerBefore viewController: UIViewController) -> UIViewController? { - var index = self.indexOfViewController(viewController) + var index = self.indexOfViewController(viewController: viewController) if (index == 0) || (index == NSNotFound) { return nil } index -= 1 - return self.viewControllerAtIndex(index, storyboard: viewController.storyboard!) + return self.viewController(index: index, storyboard: viewController.storyboard!) } func pageViewController(_ pageViewController: UIPageViewController, viewControllerAfter viewController: UIViewController) -> UIViewController? { - var index = self.indexOfViewController(viewController) + var index = self.indexOfViewController(viewController: viewController) if index == NSNotFound { return nil } @@ -55,6 +55,6 @@ class ConferenceModelController: NSObject, UIPageViewControllerDataSource { return nil } - return self.viewControllerAtIndex(index, storyboard: viewController.storyboard!) + return self.viewController(index: index, storyboard: viewController.storyboard!) } } diff --git a/PyConJP2016/ViewController/Conference/ConferencePageViewController.swift b/PyConJP2016/ViewController/Conference/ConferencePageViewController.swift index 0dfa0f6..ee221aa 100644 --- a/PyConJP2016/ViewController/Conference/ConferencePageViewController.swift +++ b/PyConJP2016/ViewController/Conference/ConferencePageViewController.swift @@ -15,7 +15,7 @@ class ConferencePageViewController: UIPageViewController, ConferencePageViewProt override func viewDidLoad() { super.viewDidLoad() - let startingViewController = self.conferenceModelController.viewControllerAtIndex(0, storyboard: self.storyboard!)! + let startingViewController = self.conferenceModelController.viewController(index: 0, storyboard: self.storyboard!)! let viewControllers = [startingViewController] self.setViewControllers(viewControllers, direction: .forward, animated: false, completion: {done in }) @@ -50,16 +50,16 @@ class ConferencePageViewController: UIPageViewController, ConferencePageViewProt // MARK: - ConferencePageViewProtocol - func fowardPage(_ index: Int) { - self.movePage(index, direction: .forward) + func fowardPage(index: Int) { + self.movePage(index: index, direction: .forward) } - func reversePage(_ index: Int) { - self.movePage(index, direction: .reverse) + func reversePage(index: Int) { + self.movePage(index: index, direction: .reverse) } - fileprivate func movePage(_ index: Int, direction: UIPageViewControllerNavigationDirection) { - let viewController = conferenceModelController.viewControllerAtIndex(index, storyboard: self.storyboard!)! + fileprivate func movePage(index: Int, direction: UIPageViewControllerNavigationDirection) { + let viewController = conferenceModelController.viewController(index: index, storyboard: self.storyboard!)! let viewControllers = [viewController] self.setViewControllers(viewControllers, direction: direction, animated: true, completion: {done in}) } diff --git a/PyConJP2016/ViewController/More/FloorMapZoomableImageViewController.swift b/PyConJP2016/ViewController/More/FloorMapZoomableImageViewController.swift index 9c1c058..525afb8 100644 --- a/PyConJP2016/ViewController/More/FloorMapZoomableImageViewController.swift +++ b/PyConJP2016/ViewController/More/FloorMapZoomableImageViewController.swift @@ -26,11 +26,6 @@ class FloorMapZoomableImageViewController: ZoomableImageViewController { imageView?.image = UIImage(named: assetCatalogType.rawValue) } - override func didReceiveMemoryWarning() { - super.didReceiveMemoryWarning() - // Dispose of any resources that can be recreated. - } - enum AssetCatalogType: String { case firstFloorView = "FirstFloorMap" case secondFloorView = "SecondFloorMap" diff --git a/PyConJP2016/ViewController/More/MapListViewController.swift b/PyConJP2016/ViewController/More/MapListViewController.swift index 528f220..69423e7 100644 --- a/PyConJP2016/ViewController/More/MapListViewController.swift +++ b/PyConJP2016/ViewController/More/MapListViewController.swift @@ -27,7 +27,7 @@ class MapListViewController: UITableViewController { override func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) { switch TableViewCell(rawValue: (indexPath as NSIndexPath).row) ?? .access { case .access: - let mapViewController = MapViewController.build(MapViewController.Venue.waseda) + let mapViewController = MapViewController.build(venue: MapViewController.Venue.waseda) self.navigationController?.pushViewController(mapViewController, animated: true) case .floor: let floorListViewController = self.storyboard?.instantiateViewController(withIdentifier: "FloorMapListViewController") diff --git a/PyConJP2016/ViewController/More/MapViewController.swift b/PyConJP2016/ViewController/More/MapViewController.swift index 8270057..33d2284 100644 --- a/PyConJP2016/ViewController/More/MapViewController.swift +++ b/PyConJP2016/ViewController/More/MapViewController.swift @@ -16,7 +16,7 @@ class MapViewController: UIViewController, MKMapViewDelegate { fileprivate var venue: Venue? - class func build(_ venue: Venue) -> MapViewController { + class func build(venue: Venue) -> MapViewController { let mapViewController = UIStoryboard(name: "More", bundle: Bundle.main).instantiateViewController(withIdentifier: "MapViewController") as! MapViewController mapViewController.venue = venue return mapViewController diff --git a/PyConJP2016/ViewController/More/MoreListViewController.swift b/PyConJP2016/ViewController/More/MoreListViewController.swift index ad7f77a..933d00d 100644 --- a/PyConJP2016/ViewController/More/MoreListViewController.swift +++ b/PyConJP2016/ViewController/More/MoreListViewController.swift @@ -41,7 +41,7 @@ class MoreListViewController: UITableViewController { let mapListViewController = MapListViewController.build() self.navigationController?.pushViewController(mapListViewController, animated: true) case .sprintMap: - let mapViewController = MapViewController.build(MapViewController.Venue.microsoft) + let mapViewController = MapViewController.build(venue: MapViewController.Venue.microsoft) self.navigationController?.pushViewController(mapViewController, animated: true) case .library: let acknowledgmentsListViewController = AcknowledgmentsListViewController.build() diff --git a/PyConJP2016/ViewController/More/StaffListViewController.swift b/PyConJP2016/ViewController/More/StaffListViewController.swift index 9b8c4a4..be97aff 100644 --- a/PyConJP2016/ViewController/More/StaffListViewController.swift +++ b/PyConJP2016/ViewController/More/StaffListViewController.swift @@ -24,7 +24,7 @@ class StaffListViewController: UIViewController, TwitterURLSchemeType, ErrorAler } } - fileprivate lazy var staffListDataSource: StaffListDataSource = StaffListDataSource(facebookAction: { (url) -> (() -> Void) in { self.facebookAction(url) } }, twitterAction: { (url) -> (() -> Void) in { self.twitterAction(url) } }) + fileprivate lazy var staffListDataSource: StaffListDataSource = StaffListDataSource(facebookAction: { (url) -> (() -> Void) in { self.facebookAction(urlString: url) } }, twitterAction: { (url) -> (() -> Void) in { self.twitterAction(urlString: url) } }) fileprivate let refreshControl = UIRefreshControl() @@ -71,13 +71,13 @@ class StaffListViewController: UIViewController, TwitterURLSchemeType, ErrorAler // MARK: - StaffTableViewCell Button Action - fileprivate func facebookAction(_ urlString: String) { + fileprivate func facebookAction(urlString: String) { guard let url = URL(string: urlString) else { return } let safariViewController = SFSafariViewController(url: url) self.present(safariViewController, animated: true, completion: nil) } - fileprivate func twitterAction(_ urlString: String) { + fileprivate func twitterAction(urlString: String) { let userName = urlString.replacingOccurrences(of: "https://twitter.com/", with: "") openTwitterUser(userName, from: self) } diff --git a/PyConJP2016/ViewController/WebView/PCJWKWebViewController.swift b/PyConJP2016/ViewController/WebView/PCJWKWebViewController.swift index 62ca516..c2bed5b 100644 --- a/PyConJP2016/ViewController/WebView/PCJWKWebViewController.swift +++ b/PyConJP2016/ViewController/WebView/PCJWKWebViewController.swift @@ -15,7 +15,7 @@ class PCJWKWebViewController: UIViewController, WKNavigationDelegate, WKUIDelega fileprivate var url: String = "" - class func build(_ url: String) -> PCJWKWebViewController { + class func build(url: String) -> PCJWKWebViewController { let pcjWKWebViewController = UIStoryboard(name: "Main", bundle: Bundle.main).instantiateViewController(withIdentifier: "PCJWKWebViewController") as! PCJWKWebViewController pcjWKWebViewController.url = url return pcjWKWebViewController From 290c21ccd20eaa5ba57fe8dc0cb6f631156126be Mon Sep 17 00:00:00 2001 From: Yutaro Muta Date: Mon, 10 Oct 2016 11:56:13 +0900 Subject: [PATCH 06/26] Use colorLiteral at UIColor extension --- PyConJP2016/Application/AppDelegate.swift | 6 +- PyConJP2016/Extension/UIColorExtension.swift | 58 ++++++++----------- PyConJP2016/Model/Enum/Room.swift | 10 ++-- .../UITableViewCell/StaffTableViewCell.swift | 4 +- .../ConferenceDateViewController.swift | 2 +- 5 files changed, 34 insertions(+), 46 deletions(-) diff --git a/PyConJP2016/Application/AppDelegate.swift b/PyConJP2016/Application/AppDelegate.swift index 92f3838..ca81982 100644 --- a/PyConJP2016/Application/AppDelegate.swift +++ b/PyConJP2016/Application/AppDelegate.swift @@ -39,12 +39,12 @@ class AppDelegate: UIResponder, UIApplicationDelegate, TalksAPIType, ErrorAlertT } } - UINavigationBar.appearance().barTintColor = .pyconJP2016RedColor() + UINavigationBar.appearance().barTintColor = UIColor.PyConJP2016.red UINavigationBar.appearance().tintColor = .white UINavigationBar.appearance().titleTextAttributes = [NSForegroundColorAttributeName: UIColor.white] - UITabBar.appearance().tintColor = UIColor.pyconJP2016BlueColor() - UITabBarItem.appearance().setTitleTextAttributes([NSFontAttributeName: UIFont.boldSystemFont(ofSize: 10), NSForegroundColorAttributeName: UIColor.pyconJP2016BlueColor()], for: .selected) + UITabBar.appearance().tintColor = UIColor.PyConJP2016.blue + UITabBarItem.appearance().setTitleTextAttributes([NSFontAttributeName: UIFont.boldSystemFont(ofSize: 10), NSForegroundColorAttributeName: UIColor.PyConJP2016.blue], for: .selected) return true } diff --git a/PyConJP2016/Extension/UIColorExtension.swift b/PyConJP2016/Extension/UIColorExtension.swift index 9d09743..fcc427c 100644 --- a/PyConJP2016/Extension/UIColorExtension.swift +++ b/PyConJP2016/Extension/UIColorExtension.swift @@ -25,44 +25,32 @@ extension UIColor { } } - static func pyconJP2016RedColor() -> UIColor { - return UIColor.hexStr("#EB6D9A", alpha: 1) - } - - static func pyconJP2016OrangeColor() -> UIColor { - return UIColor.hexStr("#F19975", alpha: 1) - } - - static func pyconJP2016LightOrangeColor() -> UIColor { - return UIColor.hexStr("#F8C058", alpha: 1) - } - - static func pyconJP2016YellowColor() -> UIColor { - return UIColor.hexStr("#FFE45F", alpha: 1) - } - - static func pyconJP2016LightGreenColor() -> UIColor { - return UIColor.hexStr("#A9C952", alpha: 1) - } - - static func pyconJP2016GreenColor() -> UIColor { - return UIColor.hexStr("#86C8A0", alpha: 1) - } - - static func pyconJP2016BlueColor() -> UIColor { - return UIColor.hexStr("#54C2F0", alpha: 1) - } +} + +extension UIColor { - static func pyconJP2016GlayColor() -> UIColor { - return UIColor.hexStr("#C8C8C8", alpha: 1) + struct PyConJP2016 { + + static var red: UIColor { return #colorLiteral(red: 0.9215686275, green: 0.4274509804, blue: 0.6039215686, alpha: 1) } + + static var orange: UIColor { return #colorLiteral(red: 0.9450980392, green: 0.6, blue: 0.4588235294, alpha: 1) } + + static var lightOrange: UIColor { return #colorLiteral(red: 0.9725490196, green: 0.7529411765, blue: 0.3450980392, alpha: 1) } + + static var yellow: UIColor { return #colorLiteral(red: 1, green: 0.8941176471, blue: 0.3725490196, alpha: 1) } + + static var lightGreen: UIColor { return #colorLiteral(red: 0.662745098, green: 0.7882352941, blue: 0.3215686275, alpha: 1) } + + static var green: UIColor { return #colorLiteral(red: 0.5254901961, green: 0.7843137255, blue: 0.6274509804, alpha: 1) } + + static var blue: UIColor { return #colorLiteral(red: 0.5254901961, green: 0.7843137255, blue: 0.6274509804, alpha: 1) } + + static var gray: UIColor { return #colorLiteral(red: 0.7843137255, green: 0.7843137255, blue: 0.7843137255, alpha: 1) } + } - static func twitterColor() -> UIColor { - return UIColor.hexStr("#55ACEE", alpha: 1) - } + static var twitter: UIColor { return #colorLiteral(red: 0.3333333333, green: 0.6745098039, blue: 0.9333333333, alpha: 1) } - static func facebookColor() -> UIColor { - return UIColor.hexStr("#315096", alpha: 1) - } + static var facebook: UIColor { return #colorLiteral(red: 0.1921568627, green: 0.3137254902, blue: 0.5882352941, alpha: 1) } } diff --git a/PyConJP2016/Model/Enum/Room.swift b/PyConJP2016/Model/Enum/Room.swift index 046d440..6a2e377 100644 --- a/PyConJP2016/Model/Enum/Room.swift +++ b/PyConJP2016/Model/Enum/Room.swift @@ -27,11 +27,11 @@ enum TalkRoom: String { var color: UIColor { switch self { - case .Room201: return UIColor.pyconJP2016OrangeColor() - case .Room202: return UIColor.pyconJP2016LightOrangeColor() - case .Room203: return UIColor.pyconJP2016YellowColor() - case .Room204: return UIColor.pyconJP2016LightGreenColor() - case .Room205: return UIColor.pyconJP2016GreenColor() + case .Room201: return UIColor.PyConJP2016.orange + case .Room202: return UIColor.PyConJP2016.lightOrange + case .Room203: return UIColor.PyConJP2016.yellow + case .Room204: return UIColor.PyConJP2016.lightGreen + case .Room205: return UIColor.PyConJP2016.green } } diff --git a/PyConJP2016/View/UITableViewCell/StaffTableViewCell.swift b/PyConJP2016/View/UITableViewCell/StaffTableViewCell.swift index d0ed157..3eb8cb3 100644 --- a/PyConJP2016/View/UITableViewCell/StaffTableViewCell.swift +++ b/PyConJP2016/View/UITableViewCell/StaffTableViewCell.swift @@ -38,12 +38,12 @@ class StaffTableViewCell: UITableViewCell { fileprivate func toggleFacebookButton(enabled: Bool) { facebookButton.isEnabled = enabled - facebookButton.backgroundColor = enabled ? UIColor.facebookColor() : UIColor.pyconJP2016GlayColor() + facebookButton.backgroundColor = enabled ? UIColor.facebook : UIColor.PyConJP2016.gray } fileprivate func toggleTwitterButton(enabled: Bool) { twitterButton.isEnabled = enabled - twitterButton.backgroundColor = enabled ? UIColor.twitterColor() : UIColor.pyconJP2016GlayColor() + twitterButton.backgroundColor = enabled ? UIColor.twitter : UIColor.PyConJP2016.gray } @IBAction func onFacebookButton(_ sender: UIButton) { diff --git a/PyConJP2016/ViewController/Conference/ConferenceDateViewController.swift b/PyConJP2016/ViewController/Conference/ConferenceDateViewController.swift index e2cd4e3..0324058 100644 --- a/PyConJP2016/ViewController/Conference/ConferenceDateViewController.swift +++ b/PyConJP2016/ViewController/Conference/ConferenceDateViewController.swift @@ -64,7 +64,7 @@ class ConferenceDateViewController: UIViewController, ConferenceDateViewProtocol func changeUnactiveButton(_ button: UIButton) { button.isEnabled = true - button.backgroundColor = .pyconJP2016GlayColor() + button.backgroundColor = UIColor.PyConJP2016.gray button.setTitleColor(.white, for: UIControlState()) } From 355aacf38b907b9b007a8de39575bea1437b063d Mon Sep 17 00:00:00 2001 From: Yutaro Muta Date: Mon, 10 Oct 2016 22:15:37 +0900 Subject: [PATCH 07/26] Use imageLiteral --- .../SpeakerCollectionViewCell.swift | 2 +- .../Base/TalkDetailViewController.swift | 2 +- .../More/FloorMapListViewController.swift | 5 +- .../FloorMapZoomableImageViewController.swift | 68 ++++++++++--------- 4 files changed, 40 insertions(+), 37 deletions(-) diff --git a/PyConJP2016/View/UICollectionViewCell/SpeakerCollectionViewCell.swift b/PyConJP2016/View/UICollectionViewCell/SpeakerCollectionViewCell.swift index 5af1975..e1ed357 100644 --- a/PyConJP2016/View/UICollectionViewCell/SpeakerCollectionViewCell.swift +++ b/PyConJP2016/View/UICollectionViewCell/SpeakerCollectionViewCell.swift @@ -16,7 +16,7 @@ class SpeakerCollectionViewCell: UICollectionViewCell { @IBOutlet weak var twitterLabel: UILabel! override func prepareForReuse() { - iconImageView.image = UIImage(named: "Speaker") + iconImageView.image = #imageLiteral(resourceName: "Speaker") nameLabel.text = nil twitterLabel.text = nil } diff --git a/PyConJP2016/ViewController/Base/TalkDetailViewController.swift b/PyConJP2016/ViewController/Base/TalkDetailViewController.swift index 413f673..c169870 100644 --- a/PyConJP2016/ViewController/Base/TalkDetailViewController.swift +++ b/PyConJP2016/ViewController/Base/TalkDetailViewController.swift @@ -141,7 +141,7 @@ class TalkDetailViewController: UIViewController, TalkDetailAPIType, TwitterURLS } func toggleBookmarkBarButtonItem(isFavorite: Bool) { - let image = isFavorite ? UIImage(named: "BookmarkOn") : UIImage(named: "BookmarkOff") + let image = isFavorite ? #imageLiteral(resourceName: "BookmarkOn") : #imageLiteral(resourceName: "BookmarkOff") DispatchQueue.main.async { self.bookmarkBarButtonItem.image = image } diff --git a/PyConJP2016/ViewController/More/FloorMapListViewController.swift b/PyConJP2016/ViewController/More/FloorMapListViewController.swift index 807a7b5..67a420f 100644 --- a/PyConJP2016/ViewController/More/FloorMapListViewController.swift +++ b/PyConJP2016/ViewController/More/FloorMapListViewController.swift @@ -26,8 +26,7 @@ class FloorMapListViewController: UITableViewController { override func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) { guard let sectionType = SectionType(rawValue: (indexPath as NSIndexPath).section) else { return } - let floorMapZoomableImageViewController = UIStoryboard(name: "More", bundle: Bundle.main).instantiateViewController(withIdentifier: "FloorMapZoomableImageViewController") as! FloorMapZoomableImageViewController - floorMapZoomableImageViewController.assetCatalogType = sectionType.rows[(indexPath as NSIndexPath).row] + let floorMapZoomableImageViewController = FloorMapZoomableImageViewController.build(assetCatalog: sectionType.rows[(indexPath as NSIndexPath).row]) self.present(floorMapZoomableImageViewController, animated: true, completion: nil) } @@ -36,7 +35,7 @@ class FloorMapListViewController: UITableViewController { case secondFloor case thirdFloor - var rows: Array { + var rows: Array { switch self { case .firstFloor: return [.firstFloorView] diff --git a/PyConJP2016/ViewController/More/FloorMapZoomableImageViewController.swift b/PyConJP2016/ViewController/More/FloorMapZoomableImageViewController.swift index 525afb8..b685344 100644 --- a/PyConJP2016/ViewController/More/FloorMapZoomableImageViewController.swift +++ b/PyConJP2016/ViewController/More/FloorMapZoomableImageViewController.swift @@ -10,50 +10,54 @@ import UIKit class FloorMapZoomableImageViewController: ZoomableImageViewController { - var assetCatalogType: AssetCatalogType? + fileprivate var assetCatalog: AssetCatalog? - func build(_ assetCatalogType: AssetCatalogType) -> FloorMapZoomableImageViewController { + static func build(assetCatalog: AssetCatalog) -> FloorMapZoomableImageViewController { let floorMapImageViewController = UIStoryboard(name: "More", bundle: Bundle.main).instantiateViewController(withIdentifier: "FloorMapZoomableImageViewController") as! FloorMapZoomableImageViewController - floorMapImageViewController.assetCatalogType = assetCatalogType + floorMapImageViewController.assetCatalog = assetCatalog return floorMapImageViewController } override func viewDidLoad() { super.viewDidLoad() - guard let assetCatalogType = assetCatalogType else { return } - self.navigationItem.title = assetCatalogType.navigationItemTitle - imageView?.image = UIImage(named: assetCatalogType.rawValue) + guard let assetCatalog = assetCatalog else { return } + imageView?.image = assetCatalog.image } - enum AssetCatalogType: String { - case firstFloorView = "FirstFloorMap" - case secondFloorView = "SecondFloorMap" - case thirdFloorView = "ThirdFloorMap" - case room201 = "Room201Map" - case room202 = "Room202Map" - case room203 = "Room203Map" - case room204 = "Room204Map" - case room205 = "Room205Map" + enum AssetCatalog { + case firstFloorView + case secondFloorView + case thirdFloorView + case room201 + case room202 + case room203 + case room204 + case room205 - var navigationItemTitle: String { + var title: String { switch self { - case .firstFloorView: - return "1F" - case .secondFloorView: - return "2F" - case .thirdFloorView: - return "3F" - case .room201: - return "Room 201" - case .room202: - return "Room 202" - case .room203: - return "Room 203" - case .room204: - return "Room 204" - case .room205: - return "Room 205" + case .firstFloorView: return "1F" + case .secondFloorView: return "2F" + case .thirdFloorView: return "3F" + case .room201: return "Room 201" + case .room202: return "Room 202" + case .room203: return "Room 203" + case .room204: return "Room 204" + case .room205: return "Room 205" + } + } + + var image: UIImage { + switch self { + case .firstFloorView: return #imageLiteral(resourceName: "FirstFloorMap") + case .secondFloorView: return #imageLiteral(resourceName: "SecondFloorMap") + case .thirdFloorView: return #imageLiteral(resourceName: "ThirdFloorMap") + case .room201: return #imageLiteral(resourceName: "Room201Map") + case .room202: return #imageLiteral(resourceName: "Room202Map") + case .room203: return #imageLiteral(resourceName: "Room203Map") + case .room204: return #imageLiteral(resourceName: "Room204Map") + case .room205: return #imageLiteral(resourceName: "Room205Map") } } From f428d5f013bf5523770cdb0b726973a703a1b474 Mon Sep 17 00:00:00 2001 From: Yutaro Muta Date: Tue, 11 Oct 2016 13:52:16 +0900 Subject: [PATCH 08/26] Rename protocols with Swift3 style --- PyConJP2016.xcodeproj/project.pbxproj | 74 +++++++++---------- PyConJP2016/Application/AppDelegate.swift | 4 +- .../DataSource/More/StaffListDataSource.swift | 2 +- .../Bookmark/BookmarkListDataSource.swift | 2 +- .../Conference/ConferenceListDataSource.swift | 2 +- PyConJP2016/Model/Enum/Language.swift | 1 - PyConJP2016/Model/Struct/Category.swift | 2 + ...fireType.swift => AlamofireProtocol.swift} | 8 +- ...IType.swift => StaffListAPIProtocol.swift} | 8 +- ...Type.swift => TalkDetailAPIProtocol.swift} | 8 +- ...ksAPIType.swift => TalksAPIProtocol.swift} | 8 +- ...ertType.swift => ErrorAlertProtocol.swift} | 12 +-- PyConJP2016/Protocol/GestureProtocol.swift | 46 ++++++++++++ PyConJP2016/Protocol/GestureType.swift | 46 ------------ ...lksType.swift => RealmTalksProtocol.swift} | 6 +- .../URLScheme/MailURLSchemeProtocol.swift | 38 ++++++++++ .../URLScheme/MailURLSchemeType.swift | 38 ---------- ...e.swift => TwitterURLSchemeProtocol.swift} | 22 +++--- .../Base/TalkDetailViewController.swift | 8 +- .../Bookmark/BookmarkListViewController.swift | 4 +- .../ConferenceListViewController.swift | 6 +- .../ConferencePageViewController.swift | 2 +- .../More/MoreListViewController.swift | 4 +- .../More/StaffListViewController.swift | 6 +- 24 files changed, 180 insertions(+), 177 deletions(-) rename PyConJP2016/Protocol/Alamofire/{AlamofireType.swift => AlamofireProtocol.swift} (95%) rename PyConJP2016/Protocol/Alamofire/{StaffListAPIType.swift => StaffListAPIProtocol.swift} (85%) rename PyConJP2016/Protocol/Alamofire/{TalkDetailAPIType.swift => TalkDetailAPIProtocol.swift} (92%) rename PyConJP2016/Protocol/Alamofire/{TalksAPIType.swift => TalksAPIProtocol.swift} (96%) rename PyConJP2016/Protocol/{ErrorAlertType.swift => ErrorAlertProtocol.swift} (65%) create mode 100644 PyConJP2016/Protocol/GestureProtocol.swift delete mode 100644 PyConJP2016/Protocol/GestureType.swift rename PyConJP2016/Protocol/Realm/{RealmTalksType.swift => RealmTalksProtocol.swift} (89%) create mode 100644 PyConJP2016/Protocol/URLScheme/MailURLSchemeProtocol.swift delete mode 100644 PyConJP2016/Protocol/URLScheme/MailURLSchemeType.swift rename PyConJP2016/Protocol/URLScheme/{TwitterURLSchemeType.swift => TwitterURLSchemeProtocol.swift} (71%) diff --git a/PyConJP2016.xcodeproj/project.pbxproj b/PyConJP2016.xcodeproj/project.pbxproj index e13dd2e..7dc9430 100644 --- a/PyConJP2016.xcodeproj/project.pbxproj +++ b/PyConJP2016.xcodeproj/project.pbxproj @@ -15,11 +15,11 @@ 7F1CBEA11D52CAFA007C058D /* TalkDetail.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7F1CBE991D52CAFA007C058D /* TalkDetail.swift */; }; 7F1CBEA21D52CAFA007C058D /* Timeline.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7F1CBE9A1D52CAFA007C058D /* Timeline.swift */; }; 7F1CBEA41D52CB3C007C058D /* PyConJPDate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7F1CBEA31D52CB3C007C058D /* PyConJPDate.swift */; }; - 7F23AD441D656B8E0066771B /* AlamofireType.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7F23AD411D656B8E0066771B /* AlamofireType.swift */; }; - 7F23AD451D656B8E0066771B /* TalkDetailAPIType.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7F23AD421D656B8E0066771B /* TalkDetailAPIType.swift */; }; - 7F23AD461D656B8E0066771B /* TalksAPIType.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7F23AD431D656B8E0066771B /* TalksAPIType.swift */; }; + 7F23AD441D656B8E0066771B /* AlamofireProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7F23AD411D656B8E0066771B /* AlamofireProtocol.swift */; }; + 7F23AD451D656B8E0066771B /* TalkDetailAPIProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7F23AD421D656B8E0066771B /* TalkDetailAPIProtocol.swift */; }; + 7F23AD461D656B8E0066771B /* TalksAPIProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7F23AD431D656B8E0066771B /* TalksAPIProtocol.swift */; }; 7F2B717F1D654D44006A60BC /* BookmarkListViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7F2B717E1D654D44006A60BC /* BookmarkListViewController.swift */; }; - 7F52375D1D65917500C5A048 /* RealmTalksType.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7F52375C1D65917500C5A048 /* RealmTalksType.swift */; }; + 7F52375D1D65917500C5A048 /* RealmTalksProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7F52375C1D65917500C5A048 /* RealmTalksProtocol.swift */; }; 7F63E3E51D75556A00110E9F /* Map.strings in Resources */ = {isa = PBXBuildFile; fileRef = 7F63E3E71D75556A00110E9F /* Map.strings */; }; 7F6879031D41BE28003D5742 /* ArrayExtension.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7F6879021D41BE28003D5742 /* ArrayExtension.swift */; }; 7F6879051D420626003D5742 /* StringExtension.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7F6879041D420626003D5742 /* StringExtension.swift */; }; @@ -41,7 +41,7 @@ DB0206891D4FB8430067C94B /* ReceiveLocalNotificationManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = DB0206861D4FB8430067C94B /* ReceiveLocalNotificationManager.swift */; }; DB0A81651D463A4E0048ACB4 /* DummyTalks.json in Resources */ = {isa = PBXBuildFile; fileRef = DB0A81641D463A4E0048ACB4 /* DummyTalks.json */; }; DB0A81671D463A710048ACB4 /* DummyTalkDetail.json in Resources */ = {isa = PBXBuildFile; fileRef = DB0A81661D463A710048ACB4 /* DummyTalkDetail.json */; }; - DB1347E01CCB27D900CA0539 /* ErrorAlertType.swift in Sources */ = {isa = PBXBuildFile; fileRef = DB1347DF1CCB27D900CA0539 /* ErrorAlertType.swift */; }; + DB1347E01CCB27D900CA0539 /* ErrorAlertProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = DB1347DF1CCB27D900CA0539 /* ErrorAlertProtocol.swift */; }; DB23836E1D563BFE00DA5376 /* Room.swift in Sources */ = {isa = PBXBuildFile; fileRef = DB23836D1D563BFE00DA5376 /* Room.swift */; }; DB3146B71C7C7C6600AA7333 /* TalkDetailViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = DB3146B61C7C7C6600AA7333 /* TalkDetailViewController.swift */; }; DB384C861D75ED1D00EC1B33 /* Language.strings in Resources */ = {isa = PBXBuildFile; fileRef = DB384C881D75ED1D00EC1B33 /* Language.strings */; }; @@ -63,7 +63,7 @@ DB90E0A51D84022500F2172F /* StaffListDataSource.swift in Sources */ = {isa = PBXBuildFile; fileRef = DB90E0A41D84022500F2172F /* StaffListDataSource.swift */; }; DB90E0A71D8402EF00F2172F /* Staff.swift in Sources */ = {isa = PBXBuildFile; fileRef = DB90E0A61D8402EF00F2172F /* Staff.swift */; }; DB90E0A91D8404D200F2172F /* Team.swift in Sources */ = {isa = PBXBuildFile; fileRef = DB90E0A81D8404D200F2172F /* Team.swift */; }; - DB90E0AB1D84070A00F2172F /* StaffListAPIType.swift in Sources */ = {isa = PBXBuildFile; fileRef = DB90E0AA1D84070A00F2172F /* StaffListAPIType.swift */; }; + DB90E0AB1D84070A00F2172F /* StaffListAPIProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = DB90E0AA1D84070A00F2172F /* StaffListAPIProtocol.swift */; }; DB90E0AE1D8410A700F2172F /* StaffTableViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = DB90E0AC1D8410A700F2172F /* StaffTableViewCell.swift */; }; DB90E0AF1D8410A700F2172F /* StaffTableViewCell.xib in Resources */ = {isa = PBXBuildFile; fileRef = DB90E0AD1D8410A700F2172F /* StaffTableViewCell.xib */; }; DBA1C0B41C7228E2004F0C8D /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = DBA1C0B31C7228E2004F0C8D /* Assets.xcassets */; }; @@ -93,9 +93,9 @@ DBE6120D1D6DFFBF0043F2DF /* ConferencePageViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = DBE612081D6DFFBF0043F2DF /* ConferencePageViewController.swift */; }; DBEBDB481C8C89FC002B25B3 /* MoreListViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = DBEBDB471C8C89FC002B25B3 /* MoreListViewController.swift */; }; DBF32BB51CD48C4C004E7F3B /* AppDelegateExtension.swift in Sources */ = {isa = PBXBuildFile; fileRef = DBF32BB41CD48C4C004E7F3B /* AppDelegateExtension.swift */; }; - DBF6D89F1D870E1300F9DAE5 /* GestureType.swift in Sources */ = {isa = PBXBuildFile; fileRef = DBF6D89E1D870E1300F9DAE5 /* GestureType.swift */; }; - DBF78FCD1D8CF52B00EA66E4 /* TwitterURLSchemeType.swift in Sources */ = {isa = PBXBuildFile; fileRef = DBF78FCC1D8CF52B00EA66E4 /* TwitterURLSchemeType.swift */; }; - DBF78FCF1D8CF56600EA66E4 /* MailURLSchemeType.swift in Sources */ = {isa = PBXBuildFile; fileRef = DBF78FCE1D8CF56600EA66E4 /* MailURLSchemeType.swift */; }; + DBF6D89F1D870E1300F9DAE5 /* GestureProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = DBF6D89E1D870E1300F9DAE5 /* GestureProtocol.swift */; }; + DBF78FCD1D8CF52B00EA66E4 /* TwitterURLSchemeProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = DBF78FCC1D8CF52B00EA66E4 /* TwitterURLSchemeProtocol.swift */; }; + DBF78FCF1D8CF56600EA66E4 /* MailURLSchemeProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = DBF78FCE1D8CF56600EA66E4 /* MailURLSchemeProtocol.swift */; }; DBFAEC551D3CF7AD00BCC880 /* NSDateExtension.swift in Sources */ = {isa = PBXBuildFile; fileRef = DBFAEC541D3CF7AD00BCC880 /* NSDateExtension.swift */; }; DBFE922E1D66136B00327F74 /* BookmarkListDataSource.swift in Sources */ = {isa = PBXBuildFile; fileRef = DBFE922B1D66136B00327F74 /* BookmarkListDataSource.swift */; }; DBFE92311D6613C300327F74 /* TimelineDataSource.swift in Sources */ = {isa = PBXBuildFile; fileRef = DBFE92301D6613C300327F74 /* TimelineDataSource.swift */; }; @@ -144,11 +144,11 @@ 7F1CBE991D52CAFA007C058D /* TalkDetail.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TalkDetail.swift; sourceTree = ""; }; 7F1CBE9A1D52CAFA007C058D /* Timeline.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Timeline.swift; sourceTree = ""; }; 7F1CBEA31D52CB3C007C058D /* PyConJPDate.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PyConJPDate.swift; sourceTree = ""; }; - 7F23AD411D656B8E0066771B /* AlamofireType.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AlamofireType.swift; sourceTree = ""; }; - 7F23AD421D656B8E0066771B /* TalkDetailAPIType.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TalkDetailAPIType.swift; sourceTree = ""; }; - 7F23AD431D656B8E0066771B /* TalksAPIType.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TalksAPIType.swift; sourceTree = ""; }; + 7F23AD411D656B8E0066771B /* AlamofireProtocol.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AlamofireProtocol.swift; sourceTree = ""; }; + 7F23AD421D656B8E0066771B /* TalkDetailAPIProtocol.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TalkDetailAPIProtocol.swift; sourceTree = ""; }; + 7F23AD431D656B8E0066771B /* TalksAPIProtocol.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TalksAPIProtocol.swift; sourceTree = ""; }; 7F2B717E1D654D44006A60BC /* BookmarkListViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = BookmarkListViewController.swift; sourceTree = ""; }; - 7F52375C1D65917500C5A048 /* RealmTalksType.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = RealmTalksType.swift; sourceTree = ""; }; + 7F52375C1D65917500C5A048 /* RealmTalksProtocol.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = RealmTalksProtocol.swift; sourceTree = ""; }; 7F63E3E61D75556A00110E9F /* Base */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = Base; path = Base.lproj/Map.strings; sourceTree = ""; }; 7F63E3E81D75557500110E9F /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/Map.strings; sourceTree = ""; }; 7F63E3E91D75557600110E9F /* ja */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = ja; path = ja.lproj/Map.strings; sourceTree = ""; }; @@ -172,7 +172,7 @@ DB0206861D4FB8430067C94B /* ReceiveLocalNotificationManager.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ReceiveLocalNotificationManager.swift; sourceTree = ""; }; DB0A81641D463A4E0048ACB4 /* DummyTalks.json */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.json; path = DummyTalks.json; sourceTree = ""; }; DB0A81661D463A710048ACB4 /* DummyTalkDetail.json */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.json; path = DummyTalkDetail.json; sourceTree = ""; }; - DB1347DF1CCB27D900CA0539 /* ErrorAlertType.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ErrorAlertType.swift; sourceTree = ""; }; + DB1347DF1CCB27D900CA0539 /* ErrorAlertProtocol.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ErrorAlertProtocol.swift; sourceTree = ""; }; DB23836D1D563BFE00DA5376 /* Room.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Room.swift; sourceTree = ""; }; DB3146B61C7C7C6600AA7333 /* TalkDetailViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TalkDetailViewController.swift; sourceTree = ""; }; DB384C871D75ED1D00EC1B33 /* Base */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = Base; path = Base.lproj/Language.strings; sourceTree = ""; }; @@ -201,7 +201,7 @@ DB90E0A41D84022500F2172F /* StaffListDataSource.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = StaffListDataSource.swift; sourceTree = ""; }; DB90E0A61D8402EF00F2172F /* Staff.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Staff.swift; sourceTree = ""; }; DB90E0A81D8404D200F2172F /* Team.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Team.swift; sourceTree = ""; }; - DB90E0AA1D84070A00F2172F /* StaffListAPIType.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = StaffListAPIType.swift; sourceTree = ""; }; + DB90E0AA1D84070A00F2172F /* StaffListAPIProtocol.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = StaffListAPIProtocol.swift; sourceTree = ""; }; DB90E0AC1D8410A700F2172F /* StaffTableViewCell.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = StaffTableViewCell.swift; sourceTree = ""; }; DB90E0AD1D8410A700F2172F /* StaffTableViewCell.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = StaffTableViewCell.xib; sourceTree = ""; }; DBA1C0A91C7228E2004F0C8D /* PyConJP2016.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = PyConJP2016.app; sourceTree = BUILT_PRODUCTS_DIR; }; @@ -244,9 +244,9 @@ DBE612081D6DFFBF0043F2DF /* ConferencePageViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ConferencePageViewController.swift; sourceTree = ""; }; DBEBDB471C8C89FC002B25B3 /* MoreListViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MoreListViewController.swift; sourceTree = ""; }; DBF32BB41CD48C4C004E7F3B /* AppDelegateExtension.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AppDelegateExtension.swift; sourceTree = ""; }; - DBF6D89E1D870E1300F9DAE5 /* GestureType.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = GestureType.swift; sourceTree = ""; }; - DBF78FCC1D8CF52B00EA66E4 /* TwitterURLSchemeType.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TwitterURLSchemeType.swift; sourceTree = ""; }; - DBF78FCE1D8CF56600EA66E4 /* MailURLSchemeType.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MailURLSchemeType.swift; sourceTree = ""; }; + DBF6D89E1D870E1300F9DAE5 /* GestureProtocol.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = GestureProtocol.swift; sourceTree = ""; }; + DBF78FCC1D8CF52B00EA66E4 /* TwitterURLSchemeProtocol.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TwitterURLSchemeProtocol.swift; sourceTree = ""; }; + DBF78FCE1D8CF56600EA66E4 /* MailURLSchemeProtocol.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MailURLSchemeProtocol.swift; sourceTree = ""; }; DBFAEC541D3CF7AD00BCC880 /* NSDateExtension.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = NSDateExtension.swift; sourceTree = ""; }; DBFE922B1D66136B00327F74 /* BookmarkListDataSource.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = BookmarkListDataSource.swift; sourceTree = ""; }; DBFE92301D6613C300327F74 /* TimelineDataSource.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TimelineDataSource.swift; sourceTree = ""; }; @@ -320,10 +320,10 @@ 7F23AD401D656B8E0066771B /* Alamofire */ = { isa = PBXGroup; children = ( - 7F23AD411D656B8E0066771B /* AlamofireType.swift */, - 7F23AD421D656B8E0066771B /* TalkDetailAPIType.swift */, - 7F23AD431D656B8E0066771B /* TalksAPIType.swift */, - DB90E0AA1D84070A00F2172F /* StaffListAPIType.swift */, + 7F23AD411D656B8E0066771B /* AlamofireProtocol.swift */, + 7F23AD421D656B8E0066771B /* TalkDetailAPIProtocol.swift */, + 7F23AD431D656B8E0066771B /* TalksAPIProtocol.swift */, + DB90E0AA1D84070A00F2172F /* StaffListAPIProtocol.swift */, ); path = Alamofire; sourceTree = ""; @@ -339,7 +339,7 @@ 7F5237591D6590D900C5A048 /* Realm */ = { isa = PBXGroup; children = ( - 7F52375C1D65917500C5A048 /* RealmTalksType.swift */, + 7F52375C1D65917500C5A048 /* RealmTalksProtocol.swift */, ); path = Realm; sourceTree = ""; @@ -438,8 +438,8 @@ 7F23AD401D656B8E0066771B /* Alamofire */, 7F5237591D6590D900C5A048 /* Realm */, DBF78FCB1D8CF52B00EA66E4 /* URLScheme */, - DB1347DF1CCB27D900CA0539 /* ErrorAlertType.swift */, - DBF6D89E1D870E1300F9DAE5 /* GestureType.swift */, + DB1347DF1CCB27D900CA0539 /* ErrorAlertProtocol.swift */, + DBF6D89E1D870E1300F9DAE5 /* GestureProtocol.swift */, ); path = Protocol; sourceTree = ""; @@ -447,8 +447,8 @@ DB43FCF31D8064DC00BB45EC /* UICollectionViewCell */ = { isa = PBXGroup; children = ( - DB43FCF91D80650800BB45EC /* SpeakerCollectionViewCell.xib */, DB43FCFB1D80656100BB45EC /* SpeakerCollectionViewCell.swift */, + DB43FCF91D80650800BB45EC /* SpeakerCollectionViewCell.xib */, ); path = UICollectionViewCell; sourceTree = ""; @@ -647,8 +647,8 @@ DBF78FCB1D8CF52B00EA66E4 /* URLScheme */ = { isa = PBXGroup; children = ( - DBF78FCC1D8CF52B00EA66E4 /* TwitterURLSchemeType.swift */, - DBF78FCE1D8CF56600EA66E4 /* MailURLSchemeType.swift */, + DBF78FCC1D8CF52B00EA66E4 /* TwitterURLSchemeProtocol.swift */, + DBF78FCE1D8CF56600EA66E4 /* MailURLSchemeProtocol.swift */, ); path = URLScheme; sourceTree = ""; @@ -859,23 +859,23 @@ buildActionMask = 2147483647; files = ( DBE6120D1D6DFFBF0043F2DF /* ConferencePageViewController.swift in Sources */, - DBF78FCD1D8CF52B00EA66E4 /* TwitterURLSchemeType.swift in Sources */, + DBF78FCD1D8CF52B00EA66E4 /* TwitterURLSchemeProtocol.swift in Sources */, DB0206891D4FB8430067C94B /* ReceiveLocalNotificationManager.swift in Sources */, 7F6879031D41BE28003D5742 /* ArrayExtension.swift in Sources */, DBE6120A1D6DFFBF0043F2DF /* ConferenceDateViewController.swift in Sources */, DBE6120B1D6DFFBF0043F2DF /* ConferenceListViewController.swift in Sources */, - DBF6D89F1D870E1300F9DAE5 /* GestureType.swift in Sources */, + DBF6D89F1D870E1300F9DAE5 /* GestureProtocol.swift in Sources */, DBE612091D6DFFBF0043F2DF /* ConferenceBaseViewController.swift in Sources */, DB43FCFC1D80656100BB45EC /* SpeakerCollectionViewCell.swift in Sources */, DB90E0A21D83FC8500F2172F /* StaffListViewController.swift in Sources */, DB8C1B041D5392BE00221F36 /* MapListViewController.swift in Sources */, DB90E0A91D8404D200F2172F /* Team.swift in Sources */, - 7F23AD461D656B8E0066771B /* TalksAPIType.swift in Sources */, + 7F23AD461D656B8E0066771B /* TalksAPIProtocol.swift in Sources */, DB0206881D4FB8430067C94B /* LocalNotificationManager.swift in Sources */, DB0159D31D4DB7B500B17018 /* PCJWKWebViewController.swift in Sources */, - DB90E0AB1D84070A00F2172F /* StaffListAPIType.swift in Sources */, + DB90E0AB1D84070A00F2172F /* StaffListAPIProtocol.swift in Sources */, 7F1CBEA41D52CB3C007C058D /* PyConJPDate.swift in Sources */, - 7F52375D1D65917500C5A048 /* RealmTalksType.swift in Sources */, + 7F52375D1D65917500C5A048 /* RealmTalksProtocol.swift in Sources */, 7FB4D3051D5433CA005F314E /* DetailImageViewController.swift in Sources */, 7F2B717F1D654D44006A60BC /* BookmarkListViewController.swift in Sources */, DB3A77B01D5631F200C25D8D /* Talk.swift in Sources */, @@ -889,7 +889,7 @@ 7F1CBE9E1D52CAFA007C058D /* Level.swift in Sources */, DBC748181C76254000895D4A /* BaseTabBarController.swift in Sources */, 7FBC34CF1D40F956002919B1 /* AppDelegate.swift in Sources */, - DBF78FCF1D8CF56600EA66E4 /* MailURLSchemeType.swift in Sources */, + DBF78FCF1D8CF56600EA66E4 /* MailURLSchemeProtocol.swift in Sources */, 7F1CBEA11D52CAFA007C058D /* TalkDetail.swift in Sources */, 7F8443CE1D50320400A0BCBA /* UIViewExtension.swift in Sources */, DB90E0A51D84022500F2172F /* StaffListDataSource.swift in Sources */, @@ -902,15 +902,15 @@ DB43FCFF1D806AA400BB45EC /* SpeakersCollectionViewDataSource.swift in Sources */, 7F7EBFE21D75308400F1EE30 /* PCJConfig.swift in Sources */, DB90E0AE1D8410A700F2172F /* StaffTableViewCell.swift in Sources */, - 7F23AD441D656B8E0066771B /* AlamofireType.swift in Sources */, - 7F23AD451D656B8E0066771B /* TalkDetailAPIType.swift in Sources */, + 7F23AD441D656B8E0066771B /* AlamofireProtocol.swift in Sources */, + 7F23AD451D656B8E0066771B /* TalkDetailAPIProtocol.swift in Sources */, DBE611F71D6DF8F10043F2DF /* ConferenceListDataSource.swift in Sources */, DBB2538B1CCB700400AA17C8 /* UIColorExtension.swift in Sources */, DBA2534E1D71D39C00FE9DC5 /* ConferenceViewController.swift in Sources */, 7FB4D3101D546269005F314E /* CustomImageView.swift in Sources */, 7F1CBE9F1D52CAFA007C058D /* Place.swift in Sources */, 7FB4D3031D542DD2005F314E /* FloorMapListViewController.swift in Sources */, - DB1347E01CCB27D900CA0539 /* ErrorAlertType.swift in Sources */, + DB1347E01CCB27D900CA0539 /* ErrorAlertProtocol.swift in Sources */, 7FFF87EE1D5AF2070093E316 /* Result.swift in Sources */, 7F6879051D420626003D5742 /* StringExtension.swift in Sources */, DB90E0A71D8402EF00F2172F /* Staff.swift in Sources */, diff --git a/PyConJP2016/Application/AppDelegate.swift b/PyConJP2016/Application/AppDelegate.swift index ca81982..879998d 100644 --- a/PyConJP2016/Application/AppDelegate.swift +++ b/PyConJP2016/Application/AppDelegate.swift @@ -10,7 +10,7 @@ import UIKit import RealmSwift @UIApplicationMain -class AppDelegate: UIResponder, UIApplicationDelegate, TalksAPIType, ErrorAlertType { +class AppDelegate: UIResponder, UIApplicationDelegate, TalksAPIProtocol, ErrorAlertProtocol { var window: UIWindow? @@ -35,7 +35,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate, TalksAPIType, ErrorAlertT case .success: NotificationCenter.default.post(name: Notification.Name(rawValue: PCJNotificationConfig.CompleteFetchDataNotification), object: nil) case .failure(let error): - self.showErrorAlartWith(error) + self.showErrorAlart(with: error) } } diff --git a/PyConJP2016/DataSource/More/StaffListDataSource.swift b/PyConJP2016/DataSource/More/StaffListDataSource.swift index e2ef97b..0118b47 100644 --- a/PyConJP2016/DataSource/More/StaffListDataSource.swift +++ b/PyConJP2016/DataSource/More/StaffListDataSource.swift @@ -8,7 +8,7 @@ import UIKit -class StaffListDataSource: NSObject, UITableViewDataSource, StaffListAPIType { +class StaffListDataSource: NSObject, UITableViewDataSource, StaffListAPIProtocol { let reuseIdentifier = "StaffTableViewCell" diff --git a/PyConJP2016/DataSource/Timeline/Bookmark/BookmarkListDataSource.swift b/PyConJP2016/DataSource/Timeline/Bookmark/BookmarkListDataSource.swift index d5ae6de..c86c905 100644 --- a/PyConJP2016/DataSource/Timeline/Bookmark/BookmarkListDataSource.swift +++ b/PyConJP2016/DataSource/Timeline/Bookmark/BookmarkListDataSource.swift @@ -9,7 +9,7 @@ import UIKit import RealmSwift -class BookmarkListDataSource: TimelineDataSource, RealmTalksType { +class BookmarkListDataSource: TimelineDataSource, RealmTalksProtocol { let filterPredicate = NSPredicate(format: "favorited == %@", true as CVarArg) let sortProperties = [SortDescriptor(property: "date", ascending: true), SortDescriptor(property: "place", ascending: true)] diff --git a/PyConJP2016/DataSource/Timeline/Conference/ConferenceListDataSource.swift b/PyConJP2016/DataSource/Timeline/Conference/ConferenceListDataSource.swift index e8b37b9..e8dd632 100644 --- a/PyConJP2016/DataSource/Timeline/Conference/ConferenceListDataSource.swift +++ b/PyConJP2016/DataSource/Timeline/Conference/ConferenceListDataSource.swift @@ -9,7 +9,7 @@ import UIKit import RealmSwift -class ConferenceListDataSource: TimelineDataSource, RealmTalksType { +class ConferenceListDataSource: TimelineDataSource, RealmTalksProtocol { let filterPredicate: NSPredicate let sortProperties = [SortDescriptor(property: "date", ascending: true), SortDescriptor(property: "place", ascending: true)] diff --git a/PyConJP2016/Model/Enum/Language.swift b/PyConJP2016/Model/Enum/Language.swift index c40d97b..32d9f17 100644 --- a/PyConJP2016/Model/Enum/Language.swift +++ b/PyConJP2016/Model/Enum/Language.swift @@ -12,7 +12,6 @@ enum Language: String { case En = "en" case Ja = "ja" - var localized: String { switch self { case .En: return NSLocalizedString("English", tableName: "Language", comment: "") diff --git a/PyConJP2016/Model/Struct/Category.swift b/PyConJP2016/Model/Struct/Category.swift index 62761ea..1dd663d 100644 --- a/PyConJP2016/Model/Struct/Category.swift +++ b/PyConJP2016/Model/Struct/Category.swift @@ -16,8 +16,10 @@ struct Category { } extension Category { + init(dictionary: [String : AnyObject]) { id = dictionary["id"] as? Int ?? 0 name = dictionary["name"] as? String ?? "" } + } diff --git a/PyConJP2016/Protocol/Alamofire/AlamofireType.swift b/PyConJP2016/Protocol/Alamofire/AlamofireProtocol.swift similarity index 95% rename from PyConJP2016/Protocol/Alamofire/AlamofireType.swift rename to PyConJP2016/Protocol/Alamofire/AlamofireProtocol.swift index 46c59e2..56407d6 100644 --- a/PyConJP2016/Protocol/Alamofire/AlamofireType.swift +++ b/PyConJP2016/Protocol/Alamofire/AlamofireProtocol.swift @@ -1,5 +1,5 @@ // -// AlamofireType.swift +// AlamofireProtocol.swift // PyConJP2016 // // Created by Yutaro Muta on 4/21/16. @@ -9,7 +9,7 @@ import UIKit import Alamofire -protocol AlamofireType { +protocol AlamofireProtocol { var baseURL: String { get } var path: String { get } var authUser: String { get } @@ -19,7 +19,7 @@ protocol AlamofireType { func get(parameter: Dictionary?, completionHandler: @escaping ((Result>) -> Void)) -> Void } -extension AlamofireType { +extension AlamofireProtocol { var baseURL: String { return PCJConfig.apiURL @@ -35,7 +35,7 @@ extension AlamofireType { } -extension AlamofireType { +extension AlamofireProtocol { func get(parameter: Dictionary? = nil, successClosure success: @escaping (Dictionary) -> Void, failClosure fail: @escaping (Error) -> Void) -> Void { let url = baseURL + path diff --git a/PyConJP2016/Protocol/Alamofire/StaffListAPIType.swift b/PyConJP2016/Protocol/Alamofire/StaffListAPIProtocol.swift similarity index 85% rename from PyConJP2016/Protocol/Alamofire/StaffListAPIType.swift rename to PyConJP2016/Protocol/Alamofire/StaffListAPIProtocol.swift index 7b9b28c..b5cee87 100644 --- a/PyConJP2016/Protocol/Alamofire/StaffListAPIType.swift +++ b/PyConJP2016/Protocol/Alamofire/StaffListAPIProtocol.swift @@ -1,5 +1,5 @@ // -// StaffListAPIType.swift +// StaffListAPIProtocol.swift // PyConJP2016 // // Created by Yutaro Muta on 9/10/16. @@ -8,11 +8,11 @@ import UIKit -protocol StaffListAPIType: AlamofireType { +protocol StaffListAPIProtocol: AlamofireProtocol { func getStaffs(completionHandler: @escaping ((Result>) -> Void)) -> Void } -extension StaffListAPIType { +extension StaffListAPIProtocol { var baseURL: String { return "https://pyconjp.github.io/" @@ -24,7 +24,7 @@ extension StaffListAPIType { } -extension StaffListAPIType { +extension StaffListAPIProtocol { func getStaffs(completionHandler: @escaping ((Result>) -> Void)) -> Void { get() { result in diff --git a/PyConJP2016/Protocol/Alamofire/TalkDetailAPIType.swift b/PyConJP2016/Protocol/Alamofire/TalkDetailAPIProtocol.swift similarity index 92% rename from PyConJP2016/Protocol/Alamofire/TalkDetailAPIType.swift rename to PyConJP2016/Protocol/Alamofire/TalkDetailAPIProtocol.swift index a1237b7..4ec04ae 100644 --- a/PyConJP2016/Protocol/Alamofire/TalkDetailAPIType.swift +++ b/PyConJP2016/Protocol/Alamofire/TalkDetailAPIProtocol.swift @@ -1,5 +1,5 @@ // -// TalkDetailAPIType.swift +// TalkDetailAPIProtocol.swift // PyConJP2016 // // Created by Yutaro Muta on 7/25/16. @@ -9,7 +9,7 @@ import UIKit import RealmSwift -protocol TalkDetailAPIType: AlamofireType { +protocol TalkDetailAPIProtocol: AlamofireProtocol { var id: Int? { get set } func getTalkDetail(successClosure success: @escaping (TalkDetail) -> Void, failClosure fail: @escaping (Error) -> Void) -> Void @@ -17,7 +17,7 @@ protocol TalkDetailAPIType: AlamofireType { func getTalkDetailFromLocalDummyJson(completionHandler: ((Result) -> Void)) -> Void } -extension TalkDetailAPIType { +extension TalkDetailAPIProtocol { var path: String { guard let id = id else { return "" } @@ -26,7 +26,7 @@ extension TalkDetailAPIType { } -extension TalkDetailAPIType { +extension TalkDetailAPIProtocol { func getTalkDetail(successClosure success: @escaping (TalkDetail) -> Void, failClosure fail: @escaping (Error) -> Void) -> Void { get(successClosure: { dictionary in diff --git a/PyConJP2016/Protocol/Alamofire/TalksAPIType.swift b/PyConJP2016/Protocol/Alamofire/TalksAPIProtocol.swift similarity index 96% rename from PyConJP2016/Protocol/Alamofire/TalksAPIType.swift rename to PyConJP2016/Protocol/Alamofire/TalksAPIProtocol.swift index a6a80ea..142a2bb 100644 --- a/PyConJP2016/Protocol/Alamofire/TalksAPIType.swift +++ b/PyConJP2016/Protocol/Alamofire/TalksAPIProtocol.swift @@ -1,5 +1,5 @@ // -// TalksAPIType.swift +// TalksAPIProtocol.swift // PyConJP2016 // // Created by Yutaro Muta on 4/23/16. @@ -9,13 +9,13 @@ import UIKit import RealmSwift -protocol TalksAPIType: AlamofireType { +protocol TalksAPIProtocol: AlamofireProtocol { func getTalks(successClosure success: @escaping () -> Void, failClosure fail: @escaping (Error) -> Void) -> Void func getTalks(completionHandler: @escaping ((Result) -> Void)) -> Void func getTalksFromLocalDummyJson(completionHandler: ((Result) -> Void)) -> Void } -extension TalksAPIType { +extension TalksAPIProtocol { var path: String { return "talks/list/" @@ -23,7 +23,7 @@ extension TalksAPIType { } -extension TalksAPIType { +extension TalksAPIProtocol { func getTalks(successClosure success: @escaping () -> Void, failClosure fail: @escaping (Error) -> Void) -> Void { get(successClosure: { dictionary in diff --git a/PyConJP2016/Protocol/ErrorAlertType.swift b/PyConJP2016/Protocol/ErrorAlertProtocol.swift similarity index 65% rename from PyConJP2016/Protocol/ErrorAlertType.swift rename to PyConJP2016/Protocol/ErrorAlertProtocol.swift index 047ea6e..e184982 100644 --- a/PyConJP2016/Protocol/ErrorAlertType.swift +++ b/PyConJP2016/Protocol/ErrorAlertProtocol.swift @@ -1,5 +1,5 @@ // -// ErrorAlertType.swift +// ErrorAlertProtocol.swift // PyConJP2016 // // Created by Yutaro Muta on 4/23/16. @@ -8,12 +8,13 @@ import UIKit -protocol ErrorAlertType { - func showErrorAlartWith(_ error: Error, parent viewController: UIViewController?) -> Void +protocol ErrorAlertProtocol { + func showErrorAlart(with error: Error, parent viewController: UIViewController?) -> Void } -extension ErrorAlertType { - func showErrorAlartWith(_ error: Error, parent viewController: UIViewController? = nil) -> Void { +extension ErrorAlertProtocol { + + func showErrorAlart(with error: Error, parent viewController: UIViewController? = nil) -> Void { let rootViewController = viewController != nil ? viewController! : UIApplication.shared.keyWindow!.rootViewController! @@ -21,4 +22,5 @@ extension ErrorAlertType { alert.addAction(UIAlertAction(title: "OK", style: .default, handler: nil)) rootViewController.present(alert, animated: true, completion: nil) } + } diff --git a/PyConJP2016/Protocol/GestureProtocol.swift b/PyConJP2016/Protocol/GestureProtocol.swift new file mode 100644 index 0000000..50bf1ae --- /dev/null +++ b/PyConJP2016/Protocol/GestureProtocol.swift @@ -0,0 +1,46 @@ +// +// GestureProtocol.swift +// PyConJP2016 +// +// Created by Yutaro Muta on 9/13/16. +// Copyright © 2016 PyCon JP. All rights reserved. +// + +import UIKit + +protocol GestureProtocol { + func handle(gesture: UIGestureRecognizer) + func singleTap(gesture: UITapGestureRecognizer) + func doubleTap(gesture: UITapGestureRecognizer) + func pinch(gesture: UIPinchGestureRecognizer) + func pan(gesture: UIPanGestureRecognizer) + func longPress(gesture: UILongPressGestureRecognizer) +} + +extension GestureProtocol { + + func handle(gesture: UIGestureRecognizer) { + if let singleTapGesture = gesture as? UITapGestureRecognizer, singleTapGesture.numberOfTapsRequired == 1 { + singleTap(gesture: singleTapGesture) + } else if let doubleTapGesture = gesture as? UITapGestureRecognizer, doubleTapGesture.numberOfTapsRequired == 2 { + doubleTap(gesture: doubleTapGesture) + } else if let pinchGesture = gesture as? UIPinchGestureRecognizer { + pinch(gesture: pinchGesture) + } else if let panGesture = gesture as? UIPanGestureRecognizer { + pan(gesture: panGesture) + } else if let longPressGesture = gesture as? UILongPressGestureRecognizer { + longPress(gesture: longPressGesture) + } + } + + func singleTap(gesture: UITapGestureRecognizer) {} + + func doubleTap(gesture: UITapGestureRecognizer) {} + + func pinch(gesture: UIPinchGestureRecognizer) {} + + func pan(gesture: UIPanGestureRecognizer) {} + + func longPress(gesture: UILongPressGestureRecognizer) {} + +} diff --git a/PyConJP2016/Protocol/GestureType.swift b/PyConJP2016/Protocol/GestureType.swift deleted file mode 100644 index 4a45a80..0000000 --- a/PyConJP2016/Protocol/GestureType.swift +++ /dev/null @@ -1,46 +0,0 @@ -// -// GestureType.swift -// PyConJP2016 -// -// Created by Yutaro Muta on 9/13/16. -// Copyright © 2016 PyCon JP. All rights reserved. -// - -import UIKit - -protocol GestureType { - func handleGesture(_ gesture: UIGestureRecognizer) - func singleTap(_ gesture: UITapGestureRecognizer) - func doubleTap(_ gesture: UITapGestureRecognizer) - func pinch(_ gesture: UIPinchGestureRecognizer) - func pan(_ gesture: UIPanGestureRecognizer) - func longPress(_ gesture: UILongPressGestureRecognizer) -} - -extension GestureType { - - func handleGesture(_ gesture: UIGestureRecognizer) { - if let singleTapGesture = gesture as? UITapGestureRecognizer, singleTapGesture.numberOfTapsRequired == 1 { - singleTap(singleTapGesture) - } else if let doubleTapGesture = gesture as? UITapGestureRecognizer, doubleTapGesture.numberOfTapsRequired == 2 { - doubleTap(doubleTapGesture) - } else if let pinchGesture = gesture as? UIPinchGestureRecognizer { - pinch(pinchGesture) - } else if let panGesture = gesture as? UIPanGestureRecognizer { - pan(panGesture) - } else if let longPressGesture = gesture as? UILongPressGestureRecognizer { - longPress(longPressGesture) - } - } - - func singleTap(_ gesture: UITapGestureRecognizer) {} - - func doubleTap(_ gesture: UITapGestureRecognizer) {} - - func pinch(_ gesture: UIPinchGestureRecognizer) {} - - func pan(_ gesture: UIPanGestureRecognizer) {} - - func longPress(_ gesture: UILongPressGestureRecognizer) {} - -} diff --git a/PyConJP2016/Protocol/Realm/RealmTalksType.swift b/PyConJP2016/Protocol/Realm/RealmTalksProtocol.swift similarity index 89% rename from PyConJP2016/Protocol/Realm/RealmTalksType.swift rename to PyConJP2016/Protocol/Realm/RealmTalksProtocol.swift index c18eea6..cb0a5ce 100644 --- a/PyConJP2016/Protocol/Realm/RealmTalksType.swift +++ b/PyConJP2016/Protocol/Realm/RealmTalksProtocol.swift @@ -1,5 +1,5 @@ // -// RealmTalksType.swift +// RealmTalksProtocol.swift // PyConJP2016 // // Created by Yutaro Muta on 2016/08/18. @@ -9,14 +9,14 @@ import UIKit import RealmSwift -protocol RealmTalksType { +protocol RealmTalksProtocol { var filterPredicate: NSPredicate { get } var sortProperties: Array { get } func loadTalkObjects(_ completionHandler: ((Result>) -> Void)) -> Void } -extension RealmTalksType { +extension RealmTalksProtocol { func loadTalkObjects(_ completionHandler: ((Result>) -> Void)) -> Void { do { diff --git a/PyConJP2016/Protocol/URLScheme/MailURLSchemeProtocol.swift b/PyConJP2016/Protocol/URLScheme/MailURLSchemeProtocol.swift new file mode 100644 index 0000000..2ab7e14 --- /dev/null +++ b/PyConJP2016/Protocol/URLScheme/MailURLSchemeProtocol.swift @@ -0,0 +1,38 @@ +// +// MailURLSchemeProtocol.swift +// PyConJP2016 +// +// Created by Yutaro Muta on 9/17/16. +// Copyright © 2016 PyCon JP. All rights reserved. +// + +import UIKit + +protocol MailURLSchemeProtocol { + + func mailURLScheme(to address: String, subject: String, body: String) -> URL? + func openMail(to address: String, subject: String, body: String) + +} + +extension MailURLSchemeProtocol { + + fileprivate var urlScheme: URL { + return URL(string: "mailto://")! + } + +} + +extension MailURLSchemeProtocol { + + func mailURLScheme(to address: String, subject: String, body: String) -> URL? { + if !UIApplication.shared.canOpenURL(urlScheme) { return nil } + return URL(string: String(format: "mailto:%@?subject=%@&body=%@", arguments: [address, subject.addingPercentEncoding(withAllowedCharacters: CharacterSet.alphanumerics)!, body.addingPercentEncoding(withAllowedCharacters: CharacterSet.alphanumerics)!])) + } + + func openMail(to address: String, subject: String, body: String) { + guard let url = mailURLScheme(to: address, subject: subject, body: body) else { return } + UIApplication.shared.openURL(url) + } + +} diff --git a/PyConJP2016/Protocol/URLScheme/MailURLSchemeType.swift b/PyConJP2016/Protocol/URLScheme/MailURLSchemeType.swift deleted file mode 100644 index 4d29d3e..0000000 --- a/PyConJP2016/Protocol/URLScheme/MailURLSchemeType.swift +++ /dev/null @@ -1,38 +0,0 @@ -// -// MailURLSchemeType.swift -// PyConJP2016 -// -// Created by Yutaro Muta on 9/17/16. -// Copyright © 2016 PyCon JP. All rights reserved. -// - -import UIKit - -protocol MailURLSchemeType { - - func mailURLScheme(_ to: String, subject: String, body: String) -> URL? - func openMail(_ to: String, subject: String, body: String) - -} - -extension MailURLSchemeType { - - fileprivate var urlScheme: URL { - return URL(string: "mailto://")! - } - -} - -extension MailURLSchemeType { - - func mailURLScheme(_ to: String, subject: String, body: String) -> URL? { - if !UIApplication.shared.canOpenURL(urlScheme) { return nil } - return URL(string: String(format: "mailto:%@?subject=%@&body=%@", arguments: [to, subject.addingPercentEncoding(withAllowedCharacters: CharacterSet.alphanumerics)!, body.addingPercentEncoding(withAllowedCharacters: CharacterSet.alphanumerics)!])) - } - - func openMail(_ to: String, subject: String, body: String) { - guard let url = mailURLScheme(to, subject: subject, body: body) else { return } - UIApplication.shared.openURL(url) - } - -} diff --git a/PyConJP2016/Protocol/URLScheme/TwitterURLSchemeType.swift b/PyConJP2016/Protocol/URLScheme/TwitterURLSchemeProtocol.swift similarity index 71% rename from PyConJP2016/Protocol/URLScheme/TwitterURLSchemeType.swift rename to PyConJP2016/Protocol/URLScheme/TwitterURLSchemeProtocol.swift index cc7ad81..23179a0 100644 --- a/PyConJP2016/Protocol/URLScheme/TwitterURLSchemeType.swift +++ b/PyConJP2016/Protocol/URLScheme/TwitterURLSchemeProtocol.swift @@ -1,5 +1,5 @@ // -// TwitterURLSchemeType.swift +// TwitterURLSchemeProtocol.swift // PyConJP2016 // // Created by Yutaro Muta on 9/11/16. @@ -9,20 +9,20 @@ import UIKit import SafariServices -protocol TwitterURLSchemeType { +protocol TwitterURLSchemeProtocol { - func openTwitterUser(_ userName: String, from viewController: UIViewController, alertBefore: Bool) -> Void - func openTwitterHashTag(_ hashTag: String, from viewController: UIViewController, alertBefore: Bool) -> Void + func openTwitter(userName: String, from viewController: UIViewController, alertBefore: Bool) -> Void + func openTwitter(hashTag: String, from viewController: UIViewController, alertBefore: Bool) -> Void } -extension TwitterURLSchemeType { +extension TwitterURLSchemeProtocol { fileprivate var urlScheme: URL { return URL(string: "twitter://")! } - fileprivate func openTwitterAppWithAlert(_ targetName: String, url: URL, from viewController: UIViewController) { + fileprivate func openTwitterAppWithAlert(targetName: String, url: URL, from viewController: UIViewController) { let alertController = UIAlertController(title: NSLocalizedString("TwitterAlertTitle", tableName: "URLScheme", comment: ""), message: String(format: NSLocalizedString("TwitterAlertMessage", tableName: "URLScheme", comment: ""), arguments: [targetName]), preferredStyle: .alert) @@ -35,13 +35,13 @@ extension TwitterURLSchemeType { } -extension TwitterURLSchemeType { +extension TwitterURLSchemeProtocol { - func openTwitterUser(_ userName: String, from viewController: UIViewController, alertBefore: Bool = false) -> Void { + func openTwitter(userName: String, from viewController: UIViewController, alertBefore: Bool = false) -> Void { if UIApplication.shared.canOpenURL(urlScheme) { guard let url = URL(string: "twitter://user?screen_name=" + userName) else { return } if alertBefore { - openTwitterAppWithAlert("@\(userName)", url: url, from: viewController) + openTwitterAppWithAlert(targetName: "@\(userName)", url: url, from: viewController) } else { UIApplication.shared.openURL(url) } @@ -52,11 +52,11 @@ extension TwitterURLSchemeType { } } - func openTwitterHashTag(_ hashTag: String, from viewController: UIViewController, alertBefore: Bool = false) -> Void { + func openTwitter(hashTag: String, from viewController: UIViewController, alertBefore: Bool = false) -> Void { if UIApplication.shared.canOpenURL(urlScheme) { guard let url = URL(string: "twitter://search?query=%23" + hashTag) else { return } if alertBefore { - openTwitterAppWithAlert("#\(hashTag)", url: url, from: viewController) + openTwitterAppWithAlert(targetName: "#\(hashTag)", url: url, from: viewController) } else { UIApplication.shared.openURL(url) } diff --git a/PyConJP2016/ViewController/Base/TalkDetailViewController.swift b/PyConJP2016/ViewController/Base/TalkDetailViewController.swift index c169870..e1cea36 100644 --- a/PyConJP2016/ViewController/Base/TalkDetailViewController.swift +++ b/PyConJP2016/ViewController/Base/TalkDetailViewController.swift @@ -10,7 +10,7 @@ import UIKit import SafariServices import RealmSwift -class TalkDetailViewController: UIViewController, TalkDetailAPIType, TwitterURLSchemeType, ErrorAlertType { +class TalkDetailViewController: UIViewController, TalkDetailAPIProtocol, TwitterURLSchemeProtocol, ErrorAlertProtocol { @IBOutlet weak var baseScrollView: UIScrollView! { didSet { @@ -108,7 +108,7 @@ class TalkDetailViewController: UIViewController, TalkDetailAPIType, TwitterURLS weakSelf.refreshControl.endRefreshing() case .failure(let error): weakSelf.refreshControl.endRefreshing() - weakSelf.showErrorAlartWith(error, parent: weakSelf) + weakSelf.showErrorAlart(with: error, parent: weakSelf) } } } @@ -167,11 +167,11 @@ class TalkDetailViewController: UIViewController, TalkDetailAPIType, TwitterURLS @IBAction func onHashTagButton(_ sender: UIButton) { let hashTag = (talkDetail?.talkObject.room?.hashTag ?? "pyconjp").replacingOccurrences(of: "#", with: "") - openTwitterHashTag(hashTag, from: self) + openTwitter(hashTag: hashTag, from: self) } func collectionView(_ collectionView: UICollectionView, didSelectItemAtIndexPath indexPath: IndexPath) { guard let userName = speakersCollectionViewDataSource.speakers[(indexPath as NSIndexPath).row].twitterName else { return } - openTwitterUser(userName, from: self) + openTwitter(userName: userName, from: self) } } diff --git a/PyConJP2016/ViewController/Bookmark/BookmarkListViewController.swift b/PyConJP2016/ViewController/Bookmark/BookmarkListViewController.swift index 87f294c..37f5cd9 100644 --- a/PyConJP2016/ViewController/Bookmark/BookmarkListViewController.swift +++ b/PyConJP2016/ViewController/Bookmark/BookmarkListViewController.swift @@ -8,7 +8,7 @@ import UIKit -class BookmarkListViewController: UIViewController, UITableViewDelegate, ErrorAlertType { +class BookmarkListViewController: UIViewController, UITableViewDelegate, ErrorAlertProtocol { @IBOutlet weak var tableView: UITableView! { didSet { @@ -61,7 +61,7 @@ class BookmarkListViewController: UIViewController, UITableViewDelegate, ErrorAl } case .failure(let error): DispatchQueue.main.async { - weakSelf.showErrorAlartWith(error, parent: weakSelf) + weakSelf.showErrorAlart(with: error, parent: weakSelf) } } } diff --git a/PyConJP2016/ViewController/Conference/ConferenceListViewController.swift b/PyConJP2016/ViewController/Conference/ConferenceListViewController.swift index d6580df..97ada01 100644 --- a/PyConJP2016/ViewController/Conference/ConferenceListViewController.swift +++ b/PyConJP2016/ViewController/Conference/ConferenceListViewController.swift @@ -8,7 +8,7 @@ import UIKit -class ConferenceListViewController: UIViewController, UITableViewDelegate, TalksAPIType, ErrorAlertType { +class ConferenceListViewController: UIViewController, UITableViewDelegate, TalksAPIProtocol, ErrorAlertProtocol { @IBOutlet weak var tableView: UITableView! { didSet { @@ -71,7 +71,7 @@ class ConferenceListViewController: UIViewController, UITableViewDelegate, Talks weakSelf.refresh() case .failure(let error): weakSelf.refreshControl.endRefreshing() - weakSelf.showErrorAlartWith(error, parent: weakSelf) + weakSelf.showErrorAlart(with: error, parent: weakSelf) } } } @@ -93,7 +93,7 @@ class ConferenceListViewController: UIViewController, UITableViewDelegate, Talks } case .failure(let error): DispatchQueue.main.async { - weakSelf.showErrorAlartWith(error, parent: weakSelf) + weakSelf.showErrorAlart(with: error, parent: weakSelf) weakSelf.refreshControl.endRefreshing() } } diff --git a/PyConJP2016/ViewController/Conference/ConferencePageViewController.swift b/PyConJP2016/ViewController/Conference/ConferencePageViewController.swift index ee221aa..16fe803 100644 --- a/PyConJP2016/ViewController/Conference/ConferencePageViewController.swift +++ b/PyConJP2016/ViewController/Conference/ConferencePageViewController.swift @@ -8,7 +8,7 @@ import UIKit -class ConferencePageViewController: UIPageViewController, ConferencePageViewProtocol, ErrorAlertType { +class ConferencePageViewController: UIPageViewController, ConferencePageViewProtocol, ErrorAlertProtocol { fileprivate var conferenceModelViewProtocol: ConferenceModelViewProtocol? diff --git a/PyConJP2016/ViewController/More/MoreListViewController.swift b/PyConJP2016/ViewController/More/MoreListViewController.swift index 933d00d..0e32a51 100644 --- a/PyConJP2016/ViewController/More/MoreListViewController.swift +++ b/PyConJP2016/ViewController/More/MoreListViewController.swift @@ -71,7 +71,7 @@ class MoreListViewController: UITableViewController { } - fileprivate enum RowType: MailURLSchemeType { + fileprivate enum RowType: MailURLSchemeProtocol { case participantsInformation case whatsPyConJP case codeOfConduct @@ -111,7 +111,7 @@ class MoreListViewController: UITableViewController { var urlSheme: URL? { switch self { - case .feedback: return mailURLScheme(PCJConfig.mailAddress, + case .feedback: return mailURLScheme(to: PCJConfig.mailAddress, subject: "Feedback for PyCon JP 2016 App", body: String(format: "iOS version: %@\nDevice Model: %@\nReply-to:\n\nFeedback:", arguments: [UIDevice.current.systemVersion, UIDevice.current.modelType])) default: return nil diff --git a/PyConJP2016/ViewController/More/StaffListViewController.swift b/PyConJP2016/ViewController/More/StaffListViewController.swift index be97aff..8659ab8 100644 --- a/PyConJP2016/ViewController/More/StaffListViewController.swift +++ b/PyConJP2016/ViewController/More/StaffListViewController.swift @@ -9,7 +9,7 @@ import UIKit import SafariServices -class StaffListViewController: UIViewController, TwitterURLSchemeType, ErrorAlertType { +class StaffListViewController: UIViewController, TwitterURLSchemeProtocol, ErrorAlertProtocol { @IBOutlet weak var tableView: UITableView! { didSet { @@ -62,7 +62,7 @@ class StaffListViewController: UIViewController, TwitterURLSchemeType, ErrorAler } case .failure(let error): DispatchQueue.main.async(execute: { - self.showErrorAlartWith(error, parent: self) + self.showErrorAlart(with: error, parent: self) self.refreshControl.endRefreshing() }) } @@ -79,7 +79,7 @@ class StaffListViewController: UIViewController, TwitterURLSchemeType, ErrorAler fileprivate func twitterAction(urlString: String) { let userName = urlString.replacingOccurrences(of: "https://twitter.com/", with: "") - openTwitterUser(userName, from: self) + openTwitter(userName: userName, from: self) } } From 319f6df8ed44b60ba920b0cea446895cd0bca4c7 Mon Sep 17 00:00:00 2001 From: Yutaro Muta Date: Wed, 12 Oct 2016 14:22:50 +0900 Subject: [PATCH 09/26] Fix method arguments --- .../Conference/ConferenceListViewController.swift | 2 +- .../ViewController/Conference/ConferenceModelController.swift | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/PyConJP2016/ViewController/Conference/ConferenceListViewController.swift b/PyConJP2016/ViewController/Conference/ConferenceListViewController.swift index 97ada01..02958b4 100644 --- a/PyConJP2016/ViewController/Conference/ConferenceListViewController.swift +++ b/PyConJP2016/ViewController/Conference/ConferenceListViewController.swift @@ -35,7 +35,7 @@ class ConferenceListViewController: UIViewController, UITableViewDelegate, Talks NotificationCenter.default.removeObserver(self) } - class func build(_ index: Int, storyboard: UIStoryboard, pyconJPDate: PyConJPDate) -> ConferenceListViewController { + class func build(at index: Int, storyboard: UIStoryboard, pyconJPDate: PyConJPDate) -> ConferenceListViewController { let conferenceListViewController = storyboard.instantiateViewController(withIdentifier: "ConferenceListViewController") as! ConferenceListViewController conferenceListViewController.viewControllerIndex = index conferenceListViewController.pyconJPDate = pyconJPDate diff --git a/PyConJP2016/ViewController/Conference/ConferenceModelController.swift b/PyConJP2016/ViewController/Conference/ConferenceModelController.swift index 16c52fc..14d4642 100644 --- a/PyConJP2016/ViewController/Conference/ConferenceModelController.swift +++ b/PyConJP2016/ViewController/Conference/ConferenceModelController.swift @@ -22,7 +22,7 @@ class ConferenceModelController: NSObject, UIPageViewControllerDataSource { return nil } - let conferenceListViewController = ConferenceListViewController.build(index, storyboard: storyboard, pyconJPDate: days[index]) + let conferenceListViewController = ConferenceListViewController.build(at: index, storyboard: storyboard, pyconJPDate: days[index]) return conferenceListViewController } From 42f5bd43313c0e0388fe5cc206d0f74636673d4d Mon Sep 17 00:00:00 2001 From: Yutaro Muta Date: Thu, 13 Oct 2016 00:32:48 +0900 Subject: [PATCH 10/26] Fix Access Control --- .../Notification/LocalNotificationManager.swift | 2 +- .../Protocol/URLScheme/MailURLSchemeProtocol.swift | 6 +----- .../URLScheme/TwitterURLSchemeProtocol.swift | 10 +++------- PyConJP2016/View/CustomImageView.swift | 8 ++++---- .../View/UITableViewCell/StaffTableViewCell.swift | 8 ++++---- .../ViewController/Base/BaseTabBarController.swift | 6 +++--- .../Base/TalkDetailViewController.swift | 12 ++++++------ .../Base/ZoomableImageViewController.swift | 4 ++-- .../Bookmark/BookmarkListViewController.swift | 2 +- .../Conference/ConferenceBaseViewController.swift | 4 ++-- .../Conference/ConferenceDateViewController.swift | 4 ++-- .../Conference/ConferenceListViewController.swift | 8 ++++---- .../Conference/ConferenceModelController.swift | 2 +- .../Conference/ConferencePageViewController.swift | 8 ++++---- .../Events/EventsListViewController.swift | 4 ++-- .../More/AcknowledgmentsListViewController.swift | 2 +- .../More/FloorMapListViewController.swift | 2 +- .../More/FloorMapZoomableImageViewController.swift | 2 +- .../ViewController/More/MapListViewController.swift | 2 +- .../ViewController/More/MapViewController.swift | 2 +- .../ViewController/More/MoreListViewController.swift | 4 ++-- .../More/StaffListViewController.swift | 8 ++++---- .../WebView/PCJWKWebViewController.swift | 2 +- 23 files changed, 52 insertions(+), 60 deletions(-) diff --git a/PyConJP2016/Manager/Notification/LocalNotificationManager.swift b/PyConJP2016/Manager/Notification/LocalNotificationManager.swift index 5b793f5..13447ed 100644 --- a/PyConJP2016/Manager/Notification/LocalNotificationManager.swift +++ b/PyConJP2016/Manager/Notification/LocalNotificationManager.swift @@ -25,7 +25,7 @@ class LocalNotificationManager: NSObject { } } - fileprivate func schedule(talkDetail: TalkDetail) { + private func schedule(talkDetail: TalkDetail) { guard let date = talkDetail.talkObject.date else { return } diff --git a/PyConJP2016/Protocol/URLScheme/MailURLSchemeProtocol.swift b/PyConJP2016/Protocol/URLScheme/MailURLSchemeProtocol.swift index 2ab7e14..66e3d65 100644 --- a/PyConJP2016/Protocol/URLScheme/MailURLSchemeProtocol.swift +++ b/PyConJP2016/Protocol/URLScheme/MailURLSchemeProtocol.swift @@ -17,14 +17,10 @@ protocol MailURLSchemeProtocol { extension MailURLSchemeProtocol { - fileprivate var urlScheme: URL { + private var urlScheme: URL { return URL(string: "mailto://")! } -} - -extension MailURLSchemeProtocol { - func mailURLScheme(to address: String, subject: String, body: String) -> URL? { if !UIApplication.shared.canOpenURL(urlScheme) { return nil } return URL(string: String(format: "mailto:%@?subject=%@&body=%@", arguments: [address, subject.addingPercentEncoding(withAllowedCharacters: CharacterSet.alphanumerics)!, body.addingPercentEncoding(withAllowedCharacters: CharacterSet.alphanumerics)!])) diff --git a/PyConJP2016/Protocol/URLScheme/TwitterURLSchemeProtocol.swift b/PyConJP2016/Protocol/URLScheme/TwitterURLSchemeProtocol.swift index 23179a0..85245c6 100644 --- a/PyConJP2016/Protocol/URLScheme/TwitterURLSchemeProtocol.swift +++ b/PyConJP2016/Protocol/URLScheme/TwitterURLSchemeProtocol.swift @@ -13,16 +13,16 @@ protocol TwitterURLSchemeProtocol { func openTwitter(userName: String, from viewController: UIViewController, alertBefore: Bool) -> Void func openTwitter(hashTag: String, from viewController: UIViewController, alertBefore: Bool) -> Void - + } extension TwitterURLSchemeProtocol { - fileprivate var urlScheme: URL { + private var urlScheme: URL { return URL(string: "twitter://")! } - fileprivate func openTwitterAppWithAlert(targetName: String, url: URL, from viewController: UIViewController) { + private func openTwitterAppWithAlert(targetName: String, url: URL, from viewController: UIViewController) { let alertController = UIAlertController(title: NSLocalizedString("TwitterAlertTitle", tableName: "URLScheme", comment: ""), message: String(format: NSLocalizedString("TwitterAlertMessage", tableName: "URLScheme", comment: ""), arguments: [targetName]), preferredStyle: .alert) @@ -33,10 +33,6 @@ extension TwitterURLSchemeProtocol { viewController.present(alertController, animated: true, completion: nil) } -} - -extension TwitterURLSchemeProtocol { - func openTwitter(userName: String, from viewController: UIViewController, alertBefore: Bool = false) -> Void { if UIApplication.shared.canOpenURL(urlScheme) { guard let url = URL(string: "twitter://user?screen_name=" + userName) else { return } diff --git a/PyConJP2016/View/CustomImageView.swift b/PyConJP2016/View/CustomImageView.swift index 377c2bb..beac53b 100644 --- a/PyConJP2016/View/CustomImageView.swift +++ b/PyConJP2016/View/CustomImageView.swift @@ -13,8 +13,8 @@ class CustomImageView: UIImageView { //* Gesture Enabled Whether or not */ var gestureEnabled = true - fileprivate var beforePoint = CGPoint(x: 0.0, y: 0.0) - fileprivate var currentScale: CGFloat = 1.0 + private var beforePoint = CGPoint(x: 0.0, y: 0.0) + private var currentScale: CGFloat = 1.0 required init?(coder aDecoder: NSCoder) { super.init(coder: aDecoder) @@ -55,7 +55,7 @@ class CustomImageView: UIImageView { } } - fileprivate func pinch(gesture: UIPinchGestureRecognizer) { + private func pinch(gesture: UIPinchGestureRecognizer) { if gestureEnabled { var scale = gesture.scale if currentScale > 1.0 { @@ -83,7 +83,7 @@ class CustomImageView: UIImageView { } } - fileprivate func pan(gesture: UIPanGestureRecognizer) { + private func pan(gesture: UIPanGestureRecognizer) { if currentScale == 1.0 { return } if let gestureView = gesture.view, gestureEnabled { diff --git a/PyConJP2016/View/UITableViewCell/StaffTableViewCell.swift b/PyConJP2016/View/UITableViewCell/StaffTableViewCell.swift index 3eb8cb3..f6a5ed4 100644 --- a/PyConJP2016/View/UITableViewCell/StaffTableViewCell.swift +++ b/PyConJP2016/View/UITableViewCell/StaffTableViewCell.swift @@ -17,8 +17,8 @@ class StaffTableViewCell: UITableViewCell { static let estimatedRowHeight: CGFloat = 100 - fileprivate var facebookAction: (() -> Void)? - fileprivate var twitterAction: (() -> Void)? + private var facebookAction: (() -> Void)? + private var twitterAction: (() -> Void)? override func prepareForReuse() { nameLabel.text = nil @@ -36,12 +36,12 @@ class StaffTableViewCell: UITableViewCell { twitterAction = onTwitterButton } - fileprivate func toggleFacebookButton(enabled: Bool) { + private func toggleFacebookButton(enabled: Bool) { facebookButton.isEnabled = enabled facebookButton.backgroundColor = enabled ? UIColor.facebook : UIColor.PyConJP2016.gray } - fileprivate func toggleTwitterButton(enabled: Bool) { + private func toggleTwitterButton(enabled: Bool) { twitterButton.isEnabled = enabled twitterButton.backgroundColor = enabled ? UIColor.twitter : UIColor.PyConJP2016.gray } diff --git a/PyConJP2016/ViewController/Base/BaseTabBarController.swift b/PyConJP2016/ViewController/Base/BaseTabBarController.swift index 876152f..8b3d53d 100644 --- a/PyConJP2016/ViewController/Base/BaseTabBarController.swift +++ b/PyConJP2016/ViewController/Base/BaseTabBarController.swift @@ -10,9 +10,9 @@ import UIKit class BaseTabBarController: UITabBarController { - fileprivate var eventsTabNavigationController: UINavigationController? - fileprivate var conferenceTabNavigationController: UINavigationController? - fileprivate var moreTabNavigationController: UINavigationController? + private var eventsTabNavigationController: UINavigationController? + private var conferenceTabNavigationController: UINavigationController? + private var moreTabNavigationController: UINavigationController? override func viewDidLoad() { super.viewDidLoad() diff --git a/PyConJP2016/ViewController/Base/TalkDetailViewController.swift b/PyConJP2016/ViewController/Base/TalkDetailViewController.swift index e1cea36..3dbc0c4 100644 --- a/PyConJP2016/ViewController/Base/TalkDetailViewController.swift +++ b/PyConJP2016/ViewController/Base/TalkDetailViewController.swift @@ -47,7 +47,7 @@ class TalkDetailViewController: UIViewController, TalkDetailAPIProtocol, Twitter @IBOutlet weak var abstractTextView: UITextView! var id: Int? - fileprivate var talkDetail: TalkDetail? { + private var talkDetail: TalkDetail? { didSet { if let talkDetail = talkDetail { speakersCollectionViewDataSource.speakers = talkDetail.speakers @@ -57,11 +57,11 @@ class TalkDetailViewController: UIViewController, TalkDetailAPIProtocol, Twitter } } - fileprivate let refreshControl = UIRefreshControl() + private let refreshControl = UIRefreshControl() - fileprivate let speakersCollectionViewDataSource = SpeakersCollectionViewDataSource() + private let speakersCollectionViewDataSource = SpeakersCollectionViewDataSource() - fileprivate lazy var speakersCollectionViewHeight: CGFloat = self.speakersCollectionViewHeightConstraint.constant + private lazy var speakersCollectionViewHeight: CGFloat = self.speakersCollectionViewHeightConstraint.constant class func build(id: Int) -> TalkDetailViewController { let talkDetailViewController = UIStoryboard(name: "Main", bundle: Bundle.main).instantiateViewController(withIdentifier: "TalkDetailViewController") as! TalkDetailViewController @@ -98,7 +98,7 @@ class TalkDetailViewController: UIViewController, TalkDetailAPIProtocol, Twitter getDetail() } - fileprivate func getDetail() { + private func getDetail() { getTalkDetail { [weak self](result) in guard let weakSelf = self else { return } switch result { @@ -113,7 +113,7 @@ class TalkDetailViewController: UIViewController, TalkDetailAPIProtocol, Twitter } } - fileprivate func fillData() { + private func fillData() { guard let talkDetail = talkDetail else { return } DispatchQueue.main.async { self.titleLabel.text = talkDetail.talkObject.title diff --git a/PyConJP2016/ViewController/Base/ZoomableImageViewController.swift b/PyConJP2016/ViewController/Base/ZoomableImageViewController.swift index e71b785..76031f7 100644 --- a/PyConJP2016/ViewController/Base/ZoomableImageViewController.swift +++ b/PyConJP2016/ViewController/Base/ZoomableImageViewController.swift @@ -15,7 +15,7 @@ class ZoomableImageViewController: UIViewController, UIScrollViewDelegate { @IBOutlet weak var baseScrollView: UIScrollView? @IBOutlet weak var imageView: UIImageView? - fileprivate var isCompletedLayoutSubviews = false + private var isCompletedLayoutSubviews = false class func build() -> ZoomableImageViewController { return UIStoryboard(name: "Main", bundle: Bundle.main).instantiateViewController(withIdentifier: "ZoomableImageViewController") as! ZoomableImageViewController @@ -47,7 +47,7 @@ class ZoomableImageViewController: UIViewController, UIScrollViewDelegate { toggleToolBarHiddenWithAnimation(false) } - fileprivate func toggleToolBarHiddenWithAnimation(_ toHidden: Bool) { + private func toggleToolBarHiddenWithAnimation(_ toHidden: Bool) { if toHidden { UIView.animate(withDuration: 0.2, animations: { self.toolBar.alpha = 0 diff --git a/PyConJP2016/ViewController/Bookmark/BookmarkListViewController.swift b/PyConJP2016/ViewController/Bookmark/BookmarkListViewController.swift index 37f5cd9..c20e60a 100644 --- a/PyConJP2016/ViewController/Bookmark/BookmarkListViewController.swift +++ b/PyConJP2016/ViewController/Bookmark/BookmarkListViewController.swift @@ -20,7 +20,7 @@ class BookmarkListViewController: UIViewController, UITableViewDelegate, ErrorAl } } - fileprivate let bookmarkListDataSource = BookmarkListDataSource() + private let bookmarkListDataSource = BookmarkListDataSource() deinit { NotificationCenter.default.removeObserver(self) diff --git a/PyConJP2016/ViewController/Conference/ConferenceBaseViewController.swift b/PyConJP2016/ViewController/Conference/ConferenceBaseViewController.swift index c12d301..f658e51 100644 --- a/PyConJP2016/ViewController/Conference/ConferenceBaseViewController.swift +++ b/PyConJP2016/ViewController/Conference/ConferenceBaseViewController.swift @@ -16,13 +16,13 @@ class ConferenceBaseViewController: UIViewController, UIPageViewControllerDelega var conferenceDateViewProtocol: ConferenceDateViewProtocol? var conferencePageViewProtocol: ConferencePageViewProtocol? - fileprivate var offsetToChange: CGFloat = 0.0 { + private var offsetToChange: CGFloat = 0.0 { didSet { } } - fileprivate var displayIndex: Int = 0 { + private var displayIndex: Int = 0 { didSet { if let conferenceDateViewProtocol = conferenceDateViewProtocol { conferenceDateViewProtocol.changeActive(index: displayIndex) diff --git a/PyConJP2016/ViewController/Conference/ConferenceDateViewController.swift b/PyConJP2016/ViewController/Conference/ConferenceDateViewController.swift index 0324058..73d3c90 100644 --- a/PyConJP2016/ViewController/Conference/ConferenceDateViewController.swift +++ b/PyConJP2016/ViewController/Conference/ConferenceDateViewController.swift @@ -14,9 +14,9 @@ class ConferenceDateViewController: UIViewController, ConferenceDateViewProtocol @IBOutlet weak var day1Button: UIButton! @IBOutlet weak var day2Button: UIButton! - fileprivate var buttonOriginXArray: [CGFloat] = [] + private var buttonOriginXArray: [CGFloat] = [] - fileprivate var conferencePageViewProtocol: ConferencePageViewProtocol? + private var conferencePageViewProtocol: ConferencePageViewProtocol? override func viewDidLoad() { super.viewDidLoad() diff --git a/PyConJP2016/ViewController/Conference/ConferenceListViewController.swift b/PyConJP2016/ViewController/Conference/ConferenceListViewController.swift index 02958b4..f45d476 100644 --- a/PyConJP2016/ViewController/Conference/ConferenceListViewController.swift +++ b/PyConJP2016/ViewController/Conference/ConferenceListViewController.swift @@ -24,12 +24,12 @@ class ConferenceListViewController: UIViewController, UITableViewDelegate, Talks } } - fileprivate(set) var viewControllerIndex: Int = 0 - fileprivate(set) var pyconJPDate: PyConJPDate? + private(set) var viewControllerIndex: Int = 0 + private(set) var pyconJPDate: PyConJPDate? - fileprivate lazy var conferenceListDataSource: ConferenceListDataSource = ConferenceListDataSource(day: self.pyconJPDate?.rawValue) + private lazy var conferenceListDataSource: ConferenceListDataSource = ConferenceListDataSource(day: self.pyconJPDate?.rawValue) - fileprivate let refreshControl = UIRefreshControl() + private let refreshControl = UIRefreshControl() deinit { NotificationCenter.default.removeObserver(self) diff --git a/PyConJP2016/ViewController/Conference/ConferenceModelController.swift b/PyConJP2016/ViewController/Conference/ConferenceModelController.swift index 14d4642..8482b7b 100644 --- a/PyConJP2016/ViewController/Conference/ConferenceModelController.swift +++ b/PyConJP2016/ViewController/Conference/ConferenceModelController.swift @@ -10,7 +10,7 @@ import UIKit class ConferenceModelController: NSObject, UIPageViewControllerDataSource { - fileprivate let days: Array = PyConJPDate.confarenceDate() + private let days: Array = PyConJPDate.confarenceDate() override init() { super.init() diff --git a/PyConJP2016/ViewController/Conference/ConferencePageViewController.swift b/PyConJP2016/ViewController/Conference/ConferencePageViewController.swift index 16fe803..36e66bc 100644 --- a/PyConJP2016/ViewController/Conference/ConferencePageViewController.swift +++ b/PyConJP2016/ViewController/Conference/ConferencePageViewController.swift @@ -10,7 +10,7 @@ import UIKit class ConferencePageViewController: UIPageViewController, ConferencePageViewProtocol, ErrorAlertProtocol { - fileprivate var conferenceModelViewProtocol: ConferenceModelViewProtocol? + private var conferenceModelViewProtocol: ConferenceModelViewProtocol? override func viewDidLoad() { super.viewDidLoad() @@ -23,9 +23,9 @@ class ConferencePageViewController: UIPageViewController, ConferencePageViewProt } - fileprivate var _conferenceModelController: ConferenceModelController? = nil + private var _conferenceModelController: ConferenceModelController? = nil - fileprivate var conferenceModelController: ConferenceModelController { + private var conferenceModelController: ConferenceModelController { if _conferenceModelController == nil { _conferenceModelController = ConferenceModelController() } @@ -58,7 +58,7 @@ class ConferencePageViewController: UIPageViewController, ConferencePageViewProt self.movePage(index: index, direction: .reverse) } - fileprivate func movePage(index: Int, direction: UIPageViewControllerNavigationDirection) { + private func movePage(index: Int, direction: UIPageViewControllerNavigationDirection) { let viewController = conferenceModelController.viewController(index: index, storyboard: self.storyboard!)! let viewControllers = [viewController] self.setViewControllers(viewControllers, direction: direction, animated: true, completion: {done in}) diff --git a/PyConJP2016/ViewController/Events/EventsListViewController.swift b/PyConJP2016/ViewController/Events/EventsListViewController.swift index 84ad54d..e418057 100644 --- a/PyConJP2016/ViewController/Events/EventsListViewController.swift +++ b/PyConJP2016/ViewController/Events/EventsListViewController.swift @@ -28,7 +28,7 @@ class EventsListViewController: UITableViewController { self.present(safariViewController, animated: true, completion: nil) } - fileprivate enum SectionType: Int { + private enum SectionType: Int { case tutorialsDay case conferenseDay case sprintsDay @@ -46,7 +46,7 @@ class EventsListViewController: UITableViewController { } - fileprivate enum RowType { + private enum RowType { case tutorial case keynote diff --git a/PyConJP2016/ViewController/More/AcknowledgmentsListViewController.swift b/PyConJP2016/ViewController/More/AcknowledgmentsListViewController.swift index f59c4d7..1c45aa5 100644 --- a/PyConJP2016/ViewController/More/AcknowledgmentsListViewController.swift +++ b/PyConJP2016/ViewController/More/AcknowledgmentsListViewController.swift @@ -39,7 +39,7 @@ class AcknowledgmentsListViewController: UITableViewController { } } - fileprivate enum RowType: Int { + private enum RowType: Int { case alamofire = 0 case alamofireImage = 1 case realmSwift = 2 diff --git a/PyConJP2016/ViewController/More/FloorMapListViewController.swift b/PyConJP2016/ViewController/More/FloorMapListViewController.swift index 67a420f..2e4b945 100644 --- a/PyConJP2016/ViewController/More/FloorMapListViewController.swift +++ b/PyConJP2016/ViewController/More/FloorMapListViewController.swift @@ -30,7 +30,7 @@ class FloorMapListViewController: UITableViewController { self.present(floorMapZoomableImageViewController, animated: true, completion: nil) } - fileprivate enum SectionType: Int { + private enum SectionType: Int { case firstFloor case secondFloor case thirdFloor diff --git a/PyConJP2016/ViewController/More/FloorMapZoomableImageViewController.swift b/PyConJP2016/ViewController/More/FloorMapZoomableImageViewController.swift index b685344..ae174f0 100644 --- a/PyConJP2016/ViewController/More/FloorMapZoomableImageViewController.swift +++ b/PyConJP2016/ViewController/More/FloorMapZoomableImageViewController.swift @@ -10,7 +10,7 @@ import UIKit class FloorMapZoomableImageViewController: ZoomableImageViewController { - fileprivate var assetCatalog: AssetCatalog? + private var assetCatalog: AssetCatalog? static func build(assetCatalog: AssetCatalog) -> FloorMapZoomableImageViewController { let floorMapImageViewController = UIStoryboard(name: "More", bundle: Bundle.main).instantiateViewController(withIdentifier: "FloorMapZoomableImageViewController") as! FloorMapZoomableImageViewController diff --git a/PyConJP2016/ViewController/More/MapListViewController.swift b/PyConJP2016/ViewController/More/MapListViewController.swift index 69423e7..cd8e14e 100644 --- a/PyConJP2016/ViewController/More/MapListViewController.swift +++ b/PyConJP2016/ViewController/More/MapListViewController.swift @@ -35,7 +35,7 @@ class MapListViewController: UITableViewController { } } - fileprivate enum TableViewCell: Int { + private enum TableViewCell: Int { case access = 0 case floor = 1 } diff --git a/PyConJP2016/ViewController/More/MapViewController.swift b/PyConJP2016/ViewController/More/MapViewController.swift index 33d2284..8229c36 100644 --- a/PyConJP2016/ViewController/More/MapViewController.swift +++ b/PyConJP2016/ViewController/More/MapViewController.swift @@ -14,7 +14,7 @@ class MapViewController: UIViewController, MKMapViewDelegate { @IBOutlet weak var textView: UITextView! @IBOutlet weak var mapView: MKMapView! - fileprivate var venue: Venue? + private var venue: Venue? class func build(venue: Venue) -> MapViewController { let mapViewController = UIStoryboard(name: "More", bundle: Bundle.main).instantiateViewController(withIdentifier: "MapViewController") as! MapViewController diff --git a/PyConJP2016/ViewController/More/MoreListViewController.swift b/PyConJP2016/ViewController/More/MoreListViewController.swift index 0e32a51..819732a 100644 --- a/PyConJP2016/ViewController/More/MoreListViewController.swift +++ b/PyConJP2016/ViewController/More/MoreListViewController.swift @@ -53,7 +53,7 @@ class MoreListViewController: UITableViewController { } } - fileprivate enum SectionType: Int { + private enum SectionType: Int { case about case map case application @@ -71,7 +71,7 @@ class MoreListViewController: UITableViewController { } - fileprivate enum RowType: MailURLSchemeProtocol { + private enum RowType: MailURLSchemeProtocol { case participantsInformation case whatsPyConJP case codeOfConduct diff --git a/PyConJP2016/ViewController/More/StaffListViewController.swift b/PyConJP2016/ViewController/More/StaffListViewController.swift index 8659ab8..b083b18 100644 --- a/PyConJP2016/ViewController/More/StaffListViewController.swift +++ b/PyConJP2016/ViewController/More/StaffListViewController.swift @@ -24,9 +24,9 @@ class StaffListViewController: UIViewController, TwitterURLSchemeProtocol, Error } } - fileprivate lazy var staffListDataSource: StaffListDataSource = StaffListDataSource(facebookAction: { (url) -> (() -> Void) in { self.facebookAction(urlString: url) } }, twitterAction: { (url) -> (() -> Void) in { self.twitterAction(urlString: url) } }) + private lazy var staffListDataSource: StaffListDataSource = StaffListDataSource(facebookAction: { (url) -> (() -> Void) in { self.facebookAction(urlString: url) } }, twitterAction: { (url) -> (() -> Void) in { self.twitterAction(urlString: url) } }) - fileprivate let refreshControl = UIRefreshControl() + private let refreshControl = UIRefreshControl() static func build() -> StaffListViewController { return UIStoryboard(name: "More", bundle: Bundle.main).instantiateViewController(withIdentifier: "StaffListViewController") as! StaffListViewController @@ -71,13 +71,13 @@ class StaffListViewController: UIViewController, TwitterURLSchemeProtocol, Error // MARK: - StaffTableViewCell Button Action - fileprivate func facebookAction(urlString: String) { + private func facebookAction(urlString: String) { guard let url = URL(string: urlString) else { return } let safariViewController = SFSafariViewController(url: url) self.present(safariViewController, animated: true, completion: nil) } - fileprivate func twitterAction(urlString: String) { + private func twitterAction(urlString: String) { let userName = urlString.replacingOccurrences(of: "https://twitter.com/", with: "") openTwitter(userName: userName, from: self) } diff --git a/PyConJP2016/ViewController/WebView/PCJWKWebViewController.swift b/PyConJP2016/ViewController/WebView/PCJWKWebViewController.swift index c2bed5b..c44c5fe 100644 --- a/PyConJP2016/ViewController/WebView/PCJWKWebViewController.swift +++ b/PyConJP2016/ViewController/WebView/PCJWKWebViewController.swift @@ -13,7 +13,7 @@ class PCJWKWebViewController: UIViewController, WKNavigationDelegate, WKUIDelega @IBOutlet weak var webContentView: UIView! - fileprivate var url: String = "" + private var url: String = "" class func build(url: String) -> PCJWKWebViewController { let pcjWKWebViewController = UIStoryboard(name: "Main", bundle: Bundle.main).instantiateViewController(withIdentifier: "PCJWKWebViewController") as! PCJWKWebViewController From 87f43d2dd0b3a7b4026d9784c4d8ad16876d7134 Mon Sep 17 00:00:00 2001 From: Yutaro Muta Date: Thu, 13 Oct 2016 00:33:37 +0900 Subject: [PATCH 11/26] Fix method arguments style at UIColor extension --- PyConJP2016/Extension/UIColorExtension.swift | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/PyConJP2016/Extension/UIColorExtension.swift b/PyConJP2016/Extension/UIColorExtension.swift index fcc427c..a40d7c6 100644 --- a/PyConJP2016/Extension/UIColorExtension.swift +++ b/PyConJP2016/Extension/UIColorExtension.swift @@ -10,8 +10,8 @@ import UIKit extension UIColor { - static func hexStr(_ hexStr: NSString, alpha: CGFloat) -> UIColor { - let hex = hexStr.replacingOccurrences(of: "#", with: "") + static func hex(string: NSString, alpha: CGFloat) -> UIColor { + let hex = string.replacingOccurrences(of: "#", with: "") let scanner = Scanner(string: hex) var color: UInt32 = 0 if scanner.scanHexInt32(&color) { From 6accfb44bd530ef3bc49c572ade8019e2a3678c9 Mon Sep 17 00:00:00 2001 From: Yutaro Muta Date: Thu, 13 Oct 2016 01:22:39 +0900 Subject: [PATCH 12/26] Update Readme --- README.md | 38 +++++++++++++++++++++++++++----------- 1 file changed, 27 insertions(+), 11 deletions(-) diff --git a/README.md b/README.md index 81566b5..cdc17cb 100644 --- a/README.md +++ b/README.md @@ -1,27 +1,43 @@ -## PyCon JPのガイド用iOSアプリ +![](PyConJP2016/Assets.xcassets/App/Image/Launch.imageset/launch@2x.png) -|Swift 2.x| -|:--------| -|iOS 9.0~ | +# PyCon JP Official Guile App [![GitHub license](https://img.shields.io/badge/license-MIT-lightgrey.svg)](https://raw.githubusercontent.com/pyconjp/pyconjp-ios/develop/LICENSE) -### SwiftLintを導入推奨 +* Swift 3.x +* Xcode8.x +* iOS 9.0~ + +## SwiftLint推奨 https://github.com/realm/SwiftLint +```sh +$brew install swiftlint +``` -### ライブラリはCarthageで管理しています +## ライブラリはCarthageで管理しています https://github.com/Carthage/Carthage +```sh +$brew install carthage +$carthage update --platform iOS +``` + +### 以下のライブラリを使用しています * [Alamofire](https://github.com/Alamofire/Alamofire) +* [AlamofireImage](https://github.com/Alamofire/AlamofireImage) * [RealmSwift](https://realm.io/docs/swift/latest/) - -###ステージングAPIのURL、basic認証 +## ステージングAPIのURL、basic認証 +**ステージングの認証情報はスタッフ内シークレットです** APIのURL、basic認証のユーザー名、パスワードはSchemeの環境変数を参照しています -ステージングへの接続は、以下の設定をしてください (本番環境へは、設定せずに接続できます) +ステージングへの接続は、以下の設定をしてください (本番環境へは、設定せずに接続できます) 1. `New Scheme` から新しいSchemeを作成 (非共有設定、git管理にしない) -2. `Edit Scheme` > `Run` > `Arguments` > `Enviroment Variables` に以下を追加 +2. `Edit Scheme` > `Run` > `Arguments` > `Enviroment Variables` に以下の項目を追加 * APIBaseURL * APIAuthUser * APIAuthPassword - + +## License +[pyconjp-ios](https://github.com/pyconjp/pyconjp-ios) is released under the [MIT License](LICENSE.md). + + From edad0d63bf57a8b88fac6f4f058228f9797e7668 Mon Sep 17 00:00:00 2001 From: Yutaro Muta Date: Tue, 18 Oct 2016 00:39:17 +0900 Subject: [PATCH 13/26] Fix typo --- PyConJP2016/Extension/StringExtension.swift | 2 +- PyConJP2016/Model/Class/TalkObject.swift | 2 +- PyConJP2016/Model/Struct/Talk.swift | 2 +- PyConJP2016/Model/Struct/Timeline.swift | 2 +- PyConJP2016/Protocol/Alamofire/AlamofireProtocol.swift | 4 ++-- PyConJP2016/Protocol/Alamofire/TalkDetailAPIProtocol.swift | 2 +- PyConJP2016/Protocol/Alamofire/TalksAPIProtocol.swift | 2 +- 7 files changed, 8 insertions(+), 8 deletions(-) diff --git a/PyConJP2016/Extension/StringExtension.swift b/PyConJP2016/Extension/StringExtension.swift index 9a1afcb..48d8c0d 100644 --- a/PyConJP2016/Extension/StringExtension.swift +++ b/PyConJP2016/Extension/StringExtension.swift @@ -20,7 +20,7 @@ extension String { return String.dateFormatterInstance.date(from: self) } - func timeStringByTrimingSecond() -> String { + func timeStringByTrimmingSecond() -> String { let dateString = "2000-01-01 " + self guard let date = Date.date(from: dateString) else { return self } return date.convertToTime() diff --git a/PyConJP2016/Model/Class/TalkObject.swift b/PyConJP2016/Model/Class/TalkObject.swift index c774d7b..33112a5 100644 --- a/PyConJP2016/Model/Class/TalkObject.swift +++ b/PyConJP2016/Model/Class/TalkObject.swift @@ -36,7 +36,7 @@ class TalkObject: RealmSwift.Object { day = dictionary["day"] as? String ?? "" startTime = dictionary["start"] as? String ?? "" endTime = dictionary["end"] as? String ?? "" - periodTime = (dictionary["start"] as? String ?? "").timeStringByTrimingSecond() + " ~ " + (dictionary["end"] as? String ?? "").timeStringByTrimingSecond() + periodTime = (dictionary["start"] as? String ?? "").timeStringByTrimmingSecond() + " ~ " + (dictionary["end"] as? String ?? "").timeStringByTrimmingSecond() category = dictionary["category"] as? String ?? "" place = dictionary["rooms"] as? String ?? "" language = dictionary["language"] as? String ?? "" diff --git a/PyConJP2016/Model/Struct/Talk.swift b/PyConJP2016/Model/Struct/Talk.swift index 1dc5727..6dbef9b 100644 --- a/PyConJP2016/Model/Struct/Talk.swift +++ b/PyConJP2016/Model/Struct/Talk.swift @@ -36,7 +36,7 @@ extension Talk { self.day = day self.startTime = startTime self.endTime = endTime - self.periodTime = startTime.timeStringByTrimingSecond() + " ~ " + endTime.timeStringByTrimingSecond() + self.periodTime = startTime.timeStringByTrimmingSecond() + " ~ " + endTime.timeStringByTrimmingSecond() self.category = category self.place = place self.language = Language(rawValue: language) ?? .En diff --git a/PyConJP2016/Model/Struct/Timeline.swift b/PyConJP2016/Model/Struct/Timeline.swift index d0b7c09..a5f8739 100644 --- a/PyConJP2016/Model/Struct/Timeline.swift +++ b/PyConJP2016/Model/Struct/Timeline.swift @@ -18,7 +18,7 @@ struct Timeline { extension Timeline { init(time: String, talks: Array) { - self.key = time.timeStringByTrimingSecond() + self.key = time.timeStringByTrimmingSecond() self.talks = talks } diff --git a/PyConJP2016/Protocol/Alamofire/AlamofireProtocol.swift b/PyConJP2016/Protocol/Alamofire/AlamofireProtocol.swift index 56407d6..f06da80 100644 --- a/PyConJP2016/Protocol/Alamofire/AlamofireProtocol.swift +++ b/PyConJP2016/Protocol/Alamofire/AlamofireProtocol.swift @@ -15,7 +15,7 @@ protocol AlamofireProtocol { var authUser: String { get } var authPassword: String { get } - func get(parameter: Dictionary?, successClosure success: @escaping (Dictionary) -> Void, failClosure fail: @escaping (Error) -> Void) -> Void + func get(parameter: Dictionary?, successClosure success: @escaping (Dictionary) -> Void, failureClosure fail: @escaping (Error) -> Void) -> Void func get(parameter: Dictionary?, completionHandler: @escaping ((Result>) -> Void)) -> Void } @@ -37,7 +37,7 @@ extension AlamofireProtocol { extension AlamofireProtocol { - func get(parameter: Dictionary? = nil, successClosure success: @escaping (Dictionary) -> Void, failClosure fail: @escaping (Error) -> Void) -> Void { + func get(parameter: Dictionary? = nil, successClosure success: @escaping (Dictionary) -> Void, failureClosure fail: @escaping (Error) -> Void) -> Void { let url = baseURL + path let responseClosure = { (response: DataResponse) in switch response.result { diff --git a/PyConJP2016/Protocol/Alamofire/TalkDetailAPIProtocol.swift b/PyConJP2016/Protocol/Alamofire/TalkDetailAPIProtocol.swift index 4ec04ae..b4f1300 100644 --- a/PyConJP2016/Protocol/Alamofire/TalkDetailAPIProtocol.swift +++ b/PyConJP2016/Protocol/Alamofire/TalkDetailAPIProtocol.swift @@ -32,7 +32,7 @@ extension TalkDetailAPIProtocol { get(successClosure: { dictionary in let talkDetail = TalkDetail(dictionary: dictionary) success(talkDetail) - }, failClosure: { error in + }, failureClosure: { error in fail(error) }) } diff --git a/PyConJP2016/Protocol/Alamofire/TalksAPIProtocol.swift b/PyConJP2016/Protocol/Alamofire/TalksAPIProtocol.swift index 142a2bb..8b5dc25 100644 --- a/PyConJP2016/Protocol/Alamofire/TalksAPIProtocol.swift +++ b/PyConJP2016/Protocol/Alamofire/TalksAPIProtocol.swift @@ -44,7 +44,7 @@ extension TalksAPIProtocol { fail(error) } - }, failClosure: { error in + }, failureClosure: { error in fail(error) }) } From ca5c15edac1584f0c4d1e80a3df93b5fb4837c20 Mon Sep 17 00:00:00 2001 From: Yutaro Muta Date: Thu, 3 Nov 2016 23:44:45 +0900 Subject: [PATCH 14/26] Add fastlane --- .gitignore | 26 ++++++++++------ Gemfile | 4 +++ README.md | 8 +++++ fastlane/Fastfile | 78 +++++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 106 insertions(+), 10 deletions(-) create mode 100644 Gemfile create mode 100644 fastlane/Fastfile diff --git a/.gitignore b/.gitignore index 9db69f7..0b1799b 100644 --- a/.gitignore +++ b/.gitignore @@ -1,9 +1,9 @@ -##Xcode -#BuildFile +# Xcode +## BuildFile build/ DerivedData -#PrivateSetting +## PrivateSetting *.pbxuser *mode1v3 *mode2v3 @@ -12,29 +12,35 @@ DerivedData *xcuserstate *xccheckout -#DefaultSetting +## DefaultSetting !default.pbxuser !default.mode1v3 !default.mode2v3 !default.perspectivev3 -#CustomScheme -PyConJP2016.xcodeproj/xcuserdata -PyConJP2016.xcworkspace/xcuserdata +## CustomScheme +*.xcodeproj/xcuserdata +*.xcworkspace/xcuserdata -#Bundler +## Bundler +.bundle/* Gemfile.lock +vendor/* -##cocoaPods +## CocoaPods Pods/* Podfile.lock !default.xcworkspace *.xcworkspace -#Carthage +## Carthage Carthage/* Cartfile.resolved +## fastlane +fastlane/* +!fastlane/Fastfile + ##AppCode .idea diff --git a/Gemfile b/Gemfile new file mode 100644 index 0000000..b6a60d9 --- /dev/null +++ b/Gemfile @@ -0,0 +1,4 @@ +# frozen_string_literal: true +source "https://rubygems.org" + + gem "fastlane" diff --git a/README.md b/README.md index cdc17cb..7641ada 100644 --- a/README.md +++ b/README.md @@ -13,6 +13,14 @@ https://github.com/realm/SwiftLint $brew install swiftlint ``` +## fastlane + +```sh +$gem install bundler +$bundle install --path vendor/bundle +$bundle exec fastlane init +``` + ## ライブラリはCarthageで管理しています https://github.com/Carthage/Carthage diff --git a/fastlane/Fastfile b/fastlane/Fastfile new file mode 100644 index 0000000..17bd477 --- /dev/null +++ b/fastlane/Fastfile @@ -0,0 +1,78 @@ +# Customise this file, documentation can be found here: +# https://github.com/fastlane/fastlane/tree/master/fastlane/docs +# All available actions: https://github.com/fastlane/fastlane/blob/master/fastlane/docs/Actions.md +# can also be listed using the `fastlane actions` command + +# Change the syntax highlighting to Ruby +# All lines starting with a # are ignored when running `fastlane` + +# If you want to automatically update fastlane if a new version is available: +# update_fastlane + +# This is the minimum version number required. +# Update this, if you use features of a newer version +fastlane_version "1.106.2" + +default_platform :ios + +platform :ios do + before_all do + # ENV["SLACK_URL"] = "https://hooks.slack.com/services/..." + + setup_library + end + + desc "Runs all the tests" + lane :test do + scan + end + + desc "Set up libraries" + lane :setup_library do + carthage + end + + desc "Submit a new Beta Build to Apple TestFlight" + desc "This will also make sure the profile is up to date" + lane :beta do + # match(type: "appstore") # more information: https://codesigning.guide + gym(scheme: "PyConJP2016") # Build your app - more options available + pilot + + # sh "your_script.sh" + # You can also use other beta testing services here (run `fastlane actions`) + end + + desc "Deploy a new version to the App Store" + lane :release do + # match(type: "appstore") + # snapshot + gym(scheme: "PyConJP2016") # Build your app - more options available + deliver(force: true) + # frameit + end + + # You can define as many lanes as you want + + after_all do |lane| + # This block is called, only if the executed lane was successful + + # slack( + # message: "Successfully deployed new App Update." + # ) + end + + error do |lane, exception| + # slack( + # message: exception.message, + # success: false + # ) + end +end + + +# More information about multiple platforms in fastlane: https://github.com/fastlane/fastlane/blob/master/fastlane/docs/Platforms.md +# All available actions: https://github.com/fastlane/fastlane/blob/master/fastlane/docs/Actions.md + +# fastlane reports which actions are used +# No personal data is recorded. Learn more at https://github.com/fastlane/enhancer From ced14277ec1c23d39963c72acd315e458f079cca Mon Sep 17 00:00:00 2001 From: Yutaro Muta Date: Fri, 4 Nov 2016 01:28:59 +0900 Subject: [PATCH 15/26] Fix PRODUCT_BUNDLE_IDENTIFIER --- PyConJP2016.xcodeproj/project.pbxproj | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/PyConJP2016.xcodeproj/project.pbxproj b/PyConJP2016.xcodeproj/project.pbxproj index 7dc9430..b793dad 100644 --- a/PyConJP2016.xcodeproj/project.pbxproj +++ b/PyConJP2016.xcodeproj/project.pbxproj @@ -1165,7 +1165,7 @@ INFOPLIST_FILE = PyConJP2016/Info.plist; IPHONEOS_DEPLOYMENT_TARGET = 9.0; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; - PRODUCT_BUNDLE_IDENTIFIER = PyConJP2016; + PRODUCT_BUNDLE_IDENTIFIER = jp.pycon.pyconjp; PRODUCT_NAME = "$(TARGET_NAME)"; PROVISIONING_PROFILE = ""; SWIFT_VERSION = 3.0; @@ -1187,7 +1187,7 @@ INFOPLIST_FILE = PyConJP2016/Info.plist; IPHONEOS_DEPLOYMENT_TARGET = 9.0; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; - PRODUCT_BUNDLE_IDENTIFIER = PyConJP2016; + PRODUCT_BUNDLE_IDENTIFIER = jp.pycon.pyconjp; PRODUCT_NAME = "$(TARGET_NAME)"; PROVISIONING_PROFILE = ""; SWIFT_VERSION = 3.0; From 94be5f7cd21b17752d1bd4dad31af97d97245811 Mon Sep 17 00:00:00 2001 From: Yutaro Muta Date: Wed, 9 Nov 2016 09:27:57 +0900 Subject: [PATCH 16/26] Update gitignore --- .gitignore | 50 ++++++++++++++++++++++++++++++++++---------------- 1 file changed, 34 insertions(+), 16 deletions(-) diff --git a/.gitignore b/.gitignore index 0b1799b..f62eb34 100644 --- a/.gitignore +++ b/.gitignore @@ -1,48 +1,66 @@ # Xcode -## BuildFile +## Build generated build/ -DerivedData +DerivedData/ -## PrivateSetting +## Various settings +xcuserdata/ + +## Private setting *.pbxuser *mode1v3 *mode2v3 *perspectivev3 -*moved-aside -*xcuserstate -*xccheckout -## DefaultSetting +## Default setting !default.pbxuser !default.mode1v3 !default.mode2v3 !default.perspectivev3 +## Other +*.moved-aside +*.xccheckout +*.xcscmblueprint + ## CustomScheme *.xcodeproj/xcuserdata *.xcworkspace/xcuserdata -## Bundler -.bundle/* +# Bundler +.bundle Gemfile.lock -vendor/* +vendor -## CocoaPods +# CocoaPods Pods/* Podfile.lock !default.xcworkspace *.xcworkspace -## Carthage +# Carthage Carthage/* Cartfile.resolved -## fastlane +# fastlane fastlane/* !fastlane/Fastfile -##AppCode -.idea +# AppCode +## User-specific stuff: +.idea/workspace.xml +.idea/tasks.xml -##OSX +## Sensitive or high-churn files: +.idea/dataSources.ids +.idea/dataSources.xml +.idea/dataSources.local.xml +.idea/sqlDataSources.xml +.idea/dynamic.xml +.idea/uiDesigner.xml + +# macOS .DS_Store +.AppleDouble +.LSOverride + From c954375dd9314f35184d95fa7c0cceacdaf4a0e7 Mon Sep 17 00:00:00 2001 From: Yutaro Muta Date: Wed, 9 Nov 2016 13:50:50 +0900 Subject: [PATCH 17/26] Fix story boards and xib files --- .../Storyboard/Base.lproj/Bookmark.storyboard | 19 +- .../Base.lproj/Conference.storyboard | 43 +-- .../Storyboard/Base.lproj/Events.storyboard | 120 +++---- .../Base.lproj/LaunchScreen.storyboard | 12 +- .../Storyboard/Base.lproj/Main.storyboard | 123 +++---- .../Storyboard/Base.lproj/More.storyboard | 333 ++++++++---------- .../SpeakerCollectionViewCell.xib | 14 +- .../UITableViewCell/StaffTableViewCell.xib | 28 +- .../UITableViewCell/TalkTableViewCell.xib | 24 +- 9 files changed, 330 insertions(+), 386 deletions(-) diff --git a/PyConJP2016/Storyboard/Base.lproj/Bookmark.storyboard b/PyConJP2016/Storyboard/Base.lproj/Bookmark.storyboard index 8902c3c..81dc69c 100644 --- a/PyConJP2016/Storyboard/Base.lproj/Bookmark.storyboard +++ b/PyConJP2016/Storyboard/Base.lproj/Bookmark.storyboard @@ -1,7 +1,8 @@ - - + + - + + @@ -33,17 +34,16 @@ - + - - + @@ -68,18 +68,17 @@ - + - - + - + diff --git a/PyConJP2016/Storyboard/Base.lproj/Conference.storyboard b/PyConJP2016/Storyboard/Base.lproj/Conference.storyboard index 49c0d45..b48613d 100644 --- a/PyConJP2016/Storyboard/Base.lproj/Conference.storyboard +++ b/PyConJP2016/Storyboard/Base.lproj/Conference.storyboard @@ -1,7 +1,8 @@ - - + + - + + @@ -33,22 +34,20 @@ - + - - + - - + - + @@ -81,17 +80,16 @@ - + - - + @@ -121,18 +119,17 @@ - + - - + - + @@ -157,15 +154,13 @@ - + - - - + @@ -176,19 +171,17 @@ - + @@ -127,11 +115,9 @@ - - - + @@ -145,7 +131,6 @@ - @@ -154,7 +139,7 @@ - + @@ -164,25 +149,21 @@ - - - + @@ -194,22 +175,19 @@ - - + @@ -221,22 +199,19 @@ - - + @@ -259,23 +234,20 @@ - - - + - + @@ -293,23 +265,20 @@ - - - + - + @@ -321,7 +290,7 @@ - + @@ -356,7 +325,7 @@ - + @@ -405,11 +374,10 @@ - + - @@ -425,11 +393,10 @@ - - + - + @@ -457,13 +424,13 @@ - + - - + + - + @@ -482,23 +449,23 @@ - - + diff --git a/PyConJP2016/Storyboard/Base.lproj/More.storyboard b/PyConJP2016/Storyboard/Base.lproj/More.storyboard index 0e13888..c4978ce 100644 --- a/PyConJP2016/Storyboard/Base.lproj/More.storyboard +++ b/PyConJP2016/Storyboard/Base.lproj/More.storyboard @@ -1,7 +1,8 @@ - - + + - + + @@ -31,17 +32,14 @@ - + - - @@ -90,7 +88,7 @@ Cohost: Global Software Engineering Laboratory, Waseda University - + @@ -117,15 +115,14 @@ Cohost: Global Software Engineering Laboratory, Waseda University - + - - + - + @@ -155,23 +152,21 @@ Cohost: Global Software Engineering Laboratory, Waseda University - + - - - + @@ -199,41 +194,41 @@ Cohost: Global Software Engineering Laboratory, Waseda University - + - + - + - + - + - + @@ -260,126 +255,126 @@ Cohost: Global Software Engineering Laboratory, Waseda University - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + @@ -390,34 +385,34 @@ Cohost: Global Software Engineering Laboratory, Waseda University - + - + - + - + @@ -428,68 +423,68 @@ Cohost: Global Software Engineering Laboratory, Waseda University - + - + - + - + - + - + - + - + @@ -520,17 +515,16 @@ Cohost: Global Software Engineering Laboratory, Waseda University - + - - + @@ -555,17 +549,14 @@ Cohost: Global Software Engineering Laboratory, Waseda University - + - - @@ -614,7 +605,7 @@ Sprint is a software development event which is held during 9/23 - 9/24, the sec - + @@ -641,17 +632,14 @@ Sprint is a software development event which is held during 9/23 - 9/24, the sec - + - - @@ -694,7 +682,7 @@ SOFTWARE. - + @@ -721,14 +709,12 @@ SOFTWARE. - + - - - + - + @@ -750,31 +736,31 @@ SOFTWARE. - + - + - + - + @@ -785,109 +771,109 @@ SOFTWARE. - + - + - + - + - + - + - + - + - + - + - + - + @@ -898,24 +884,24 @@ SOFTWARE. - + - + @@ -942,58 +928,58 @@ SOFTWARE. - + - + - + - + - + - + - + - + @@ -1024,17 +1010,14 @@ SOFTWARE. - + - - @@ -1071,7 +1054,7 @@ We expect participants to follow these rules at conference and workshop venues a - + @@ -1098,17 +1081,14 @@ We expect participants to follow these rules at conference and workshop venues a - + - - - Copyright (c) 2014-2016 Alamofire Software Foundation (http://alamofire.org/) Permission is hereby granted, free of charge, to any person obtaining a copy @@ -1149,7 +1129,7 @@ THE SOFTWARE. - + @@ -1176,17 +1156,14 @@ THE SOFTWARE. - + - - - Copyright (c) 2015-2016 Alamofire Software Foundation (http://alamofire.org/) Permission is hereby granted, free of charge, to any person obtaining a copy @@ -1227,7 +1204,7 @@ THE SOFTWARE. - + @@ -1254,15 +1231,12 @@ THE SOFTWARE. - + - - - - + @@ -1280,22 +1254,21 @@ THE SOFTWARE. - + diff --git a/PyConJP2016/View/UICollectionViewCell/SpeakerCollectionViewCell.xib b/PyConJP2016/View/UICollectionViewCell/SpeakerCollectionViewCell.xib index 965787a..e3049e3 100644 --- a/PyConJP2016/View/UICollectionViewCell/SpeakerCollectionViewCell.xib +++ b/PyConJP2016/View/UICollectionViewCell/SpeakerCollectionViewCell.xib @@ -1,8 +1,12 @@ - - + + + + + - + + @@ -33,13 +37,13 @@ diff --git a/PyConJP2016/View/UITableViewCell/StaffTableViewCell.xib b/PyConJP2016/View/UITableViewCell/StaffTableViewCell.xib index ff315a4..ad4deb5 100644 --- a/PyConJP2016/View/UITableViewCell/StaffTableViewCell.xib +++ b/PyConJP2016/View/UITableViewCell/StaffTableViewCell.xib @@ -1,7 +1,11 @@ - - + + + + + - + + @@ -10,29 +14,29 @@ - + - +