diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..9bea433 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ + +.DS_Store diff --git a/FLOPageViewController.xcodeproj/project.pbxproj b/FLOPageViewController.xcodeproj/project.pbxproj index 0693754..c974175 100644 --- a/FLOPageViewController.xcodeproj/project.pbxproj +++ b/FLOPageViewController.xcodeproj/project.pbxproj @@ -227,30 +227,31 @@ isa = PBXProject; attributes = { LastSwiftUpdateCheck = 0720; - LastUpgradeCheck = 0930; + LastUpgradeCheck = 1320; ORGANIZATIONNAME = "Florian Schliep"; TargetAttributes = { 13773EB71C4E936A003FF521 = { CreatedOnToolsVersion = 7.2; - LastSwiftMigration = 0900; + LastSwiftMigration = 1320; + ProvisioningStyle = Manual; }; 13773EC81C4E936A003FF521 = { CreatedOnToolsVersion = 7.2; - LastSwiftMigration = 0900; + LastSwiftMigration = 1320; TestTargetID = 13773EB71C4E936A003FF521; }; 138929301F70075200DE6DFB = { CreatedOnToolsVersion = 9.0; + LastSwiftMigration = 1320; ProvisioningStyle = Automatic; }; }; }; buildConfigurationList = 13773EB31C4E936A003FF521 /* Build configuration list for PBXProject "FLOPageViewController" */; compatibilityVersion = "Xcode 3.2"; - developmentRegion = English; + developmentRegion = en; hasScannedForEncodings = 0; knownRegions = ( - English, en, Base, ); @@ -352,6 +353,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; @@ -370,6 +372,7 @@ CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES; CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; CLANG_WARN_STRICT_PROTOTYPES = YES; CLANG_WARN_SUSPICIOUS_MOVE = YES; @@ -406,6 +409,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; @@ -424,6 +428,7 @@ CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES; CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; CLANG_WARN_STRICT_PROTOTYPES = YES; CLANG_WARN_SUSPICIOUS_MOVE = YES; @@ -455,7 +460,11 @@ ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES; ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; CLANG_WARN_STRICT_PROTOTYPES = NO; + CODE_SIGN_ENTITLEMENTS = ""; + CODE_SIGN_IDENTITY = "-"; + CODE_SIGN_STYLE = Manual; COMBINE_HIDPI_IMAGES = YES; + DEVELOPMENT_TEAM = ""; ENABLE_HARDENED_RUNTIME = YES; FRAMEWORK_SEARCH_PATHS = ""; INFOPLIST_FILE = "Sample App/Info.plist"; @@ -463,8 +472,9 @@ OTHER_LDFLAGS = ""; PRODUCT_BUNDLE_IDENTIFIER = com.floschliep.FLOPageViewController; PRODUCT_NAME = "$(TARGET_NAME)"; + PROVISIONING_PROFILE_SPECIFIER = ""; SWIFT_SWIFT3_OBJC_INFERENCE = Default; - SWIFT_VERSION = 4.0; + SWIFT_VERSION = 5.0; }; name = Debug; }; @@ -474,7 +484,11 @@ ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES; ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; CLANG_WARN_STRICT_PROTOTYPES = NO; + CODE_SIGN_ENTITLEMENTS = ""; + CODE_SIGN_IDENTITY = "-"; + CODE_SIGN_STYLE = Manual; COMBINE_HIDPI_IMAGES = YES; + DEVELOPMENT_TEAM = ""; ENABLE_HARDENED_RUNTIME = YES; FRAMEWORK_SEARCH_PATHS = ""; INFOPLIST_FILE = "Sample App/Info.plist"; @@ -482,8 +496,9 @@ OTHER_LDFLAGS = ""; PRODUCT_BUNDLE_IDENTIFIER = com.floschliep.FLOPageViewController; PRODUCT_NAME = "$(TARGET_NAME)"; + PROVISIONING_PROFILE_SPECIFIER = ""; SWIFT_SWIFT3_OBJC_INFERENCE = Default; - SWIFT_VERSION = 4.0; + SWIFT_VERSION = 5.0; }; name = Release; }; @@ -496,7 +511,7 @@ PRODUCT_BUNDLE_IDENTIFIER = com.floschliep.FLOPageViewControllerUITests; PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_SWIFT3_OBJC_INFERENCE = On; - SWIFT_VERSION = 4.0; + SWIFT_VERSION = 5.0; TEST_TARGET_NAME = FLOPageViewController; USES_XCTRUNNER = YES; }; @@ -511,7 +526,7 @@ PRODUCT_BUNDLE_IDENTIFIER = com.floschliep.FLOPageViewControllerUITests; PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_SWIFT3_OBJC_INFERENCE = On; - SWIFT_VERSION = 4.0; + SWIFT_VERSION = 5.0; TEST_TARGET_NAME = FLOPageViewController; USES_XCTRUNNER = YES; }; @@ -543,7 +558,7 @@ PRODUCT_NAME = "$(TARGET_NAME:c99extidentifier)"; SKIP_INSTALL = YES; SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG; - SWIFT_VERSION = 4.0; + SWIFT_VERSION = 5.0; VERSIONING_SYSTEM = "apple-generic"; VERSION_INFO_PREFIX = ""; }; @@ -574,7 +589,7 @@ PRODUCT_BUNDLE_IDENTIFIER = com.appiculous.FLOPageViewController; PRODUCT_NAME = "$(TARGET_NAME:c99extidentifier)"; SKIP_INSTALL = YES; - SWIFT_VERSION = 4.0; + SWIFT_VERSION = 5.0; VERSIONING_SYSTEM = "apple-generic"; VERSION_INFO_PREFIX = ""; }; diff --git a/FLOPageViewController.xcodeproj/project.xcworkspace/xcuserdata/vincentneo.xcuserdatad/UserInterfaceState.xcuserstate b/FLOPageViewController.xcodeproj/project.xcworkspace/xcuserdata/vincentneo.xcuserdatad/UserInterfaceState.xcuserstate new file mode 100644 index 0000000..dbdd9b6 Binary files /dev/null and b/FLOPageViewController.xcodeproj/project.xcworkspace/xcuserdata/vincentneo.xcuserdatad/UserInterfaceState.xcuserstate differ diff --git a/FLOPageViewController.xcodeproj/xcuserdata/vincentneo.xcuserdatad/xcschemes/xcschememanagement.plist b/FLOPageViewController.xcodeproj/xcuserdata/vincentneo.xcuserdatad/xcschemes/xcschememanagement.plist new file mode 100644 index 0000000..1d8585b --- /dev/null +++ b/FLOPageViewController.xcodeproj/xcuserdata/vincentneo.xcuserdatad/xcschemes/xcschememanagement.plist @@ -0,0 +1,19 @@ + + + + + SchemeUserState + + FLOPageViewController.xcscheme_^#shared#^_ + + orderHint + 0 + + FLOPageViewControllerSample.xcscheme_^#shared#^_ + + orderHint + 1 + + + + diff --git a/FLOPageViewController/ArrowControl.swift b/FLOPageViewController/ArrowControl.swift index 6f1d9eb..1b887ec 100644 --- a/FLOPageViewController/ArrowControl.swift +++ b/FLOPageViewController/ArrowControl.swift @@ -47,8 +47,8 @@ public class ArrowControl: NSControl { bezierPath.line(to: NSPoint(x: drawRightArrow ? NSMaxX(self.bounds)-lineWidth*0.5 : NSMinX(self.bounds)+lineWidth*0.5, y: NSMidY(self.bounds))) bezierPath.line(to: NSPoint(x: drawRightArrow ? NSMinX(self.bounds) : NSMaxX(self.bounds), y: NSMinY(self.bounds))) bezierPath.lineWidth = lineWidth - bezierPath.lineCapStyle = .roundLineCapStyle - bezierPath.lineJoinStyle = .roundLineJoinStyle + bezierPath.lineCapStyle = .round + bezierPath.lineJoinStyle = .round (self.mouseDown ? self.color : self.color.withAlphaComponent(0.33)).setStroke() bezierPath.stroke() } diff --git a/FLOPageViewController/PageControl.swift b/FLOPageViewController/PageControl.swift index 9701a8d..4a75e88 100644 --- a/FLOPageViewController/PageControl.swift +++ b/FLOPageViewController/PageControl.swift @@ -69,7 +69,7 @@ public class PageControl: NSControl { if self.numberOfPages > 1 { for index in 0...self.numberOfPages-1 { var fill = true - let frame = self.frameOfIndicator(at: index) + var frame = self.frameOfIndicator(at: index) let lineWidth: CGFloat = 1 switch (self.style, index == self.selectedPage) { @@ -80,7 +80,7 @@ public class PageControl: NSControl { case (.circle, false): self.color.setStroke() fill = false - frame.insetBy(dx: lineWidth*0.5, dy: lineWidth*0.5) + frame = frame.insetBy(dx: lineWidth*0.5, dy: lineWidth*0.5) } let path = NSBezierPath(ovalIn: frame) diff --git a/FLOPageViewController/PageViewController.swift b/FLOPageViewController/PageViewController.swift index 993d04d..7b1f186 100644 --- a/FLOPageViewController/PageViewController.swift +++ b/FLOPageViewController/PageViewController.swift @@ -11,7 +11,7 @@ import Cocoa private let ArrowSize = NSSize(width: 20, height: 40) @objc(FLOPageViewControllerDelegate) -public protocol PageViewControllerDelegate: class { +public protocol PageViewControllerDelegate: AnyObject { func pageViewController(_ pageViewController: PageViewController, didSelectPage pageIndex: Int) } @@ -60,7 +60,7 @@ public class PageViewController: NSViewController { pageController.delegate = self pageController.transitionStyle = .horizontalStrip - self.addChildViewController(pageController) + self.addChild(pageController) self.pageController = pageController } @@ -106,7 +106,7 @@ public class PageViewController: NSViewController { if reverse { self.viewControllers.reverseInPlace() } - self.pageController.arrangedObjects = self.viewControllers.map({ NSNumber(value: self.viewControllers.index(of: $0)!) }) + self.pageController.arrangedObjects = self.viewControllers.map({ NSNumber(value: self.viewControllers.firstIndex(of: $0)!) }) self.pageController.scrollingEnabled = (self.viewControllers.count > 1) if reverse { @@ -120,7 +120,7 @@ public class PageViewController: NSViewController { @objc public func loadViewControllers(_ viewControllerIdentifiers: [String], from storyboard: NSStoryboard) { self.viewControllers = viewControllerIdentifiers.map({ - storyboard.instantiateController(withIdentifier: NSStoryboard.SceneIdentifier($0)) as! NSViewController + storyboard.instantiateController(withIdentifier: $0) as! NSViewController }) } @@ -432,7 +432,7 @@ extension PageViewController: NSPageControllerDelegate { public func pageController(_ pageController: NSPageController, identifierFor object: Any) -> NSPageController.ObjectIdentifier { guard let number = object as? NSNumber else { fatalError("The arrangedObjects array has been changed manually. This is not allowed! Please use the viewControllers array to manage the pages.") } - return NSPageController.ObjectIdentifier(number.stringValue) + return number.stringValue } public func pageController(_ pageController: NSPageController, viewControllerForIdentifier identifier: NSPageController.ObjectIdentifier) -> NSViewController { @@ -443,7 +443,7 @@ extension PageViewController: NSPageControllerDelegate { public func pageController(_ pageController: NSPageController, didTransitionTo object: Any) { let identifier = self.pageController(pageController, identifierFor: object) let viewController = self.pageController(pageController, viewControllerForIdentifier: identifier) - guard let index = self.viewControllers.index(of: viewController) else { return } + guard let index = self.viewControllers.firstIndex(of: viewController) else { return } self.pageControl?.selectedPage = UInt(index) self.hideArrowControls(false) diff --git a/Sample App/Base.lproj/Main.storyboard b/Sample App/Base.lproj/Main.storyboard index bc62965..776c066 100644 --- a/Sample App/Base.lproj/Main.storyboard +++ b/Sample App/Base.lproj/Main.storyboard @@ -1,7 +1,8 @@ - + - + + @@ -642,7 +643,7 @@ - + @@ -651,8 +652,8 @@ - - + + @@ -671,14 +672,13 @@ - + - + - - - - - - - + + - - - + + - - - - + + - - - + + + + + + - - - + + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -807,12 +836,12 @@ - + - + @@ -833,18 +862,18 @@ - + - + - + @@ -871,12 +900,12 @@ - + - + diff --git a/Sample App/Info.plist b/Sample App/Info.plist index b26ced3..fcc08f8 100644 --- a/Sample App/Info.plist +++ b/Sample App/Info.plist @@ -1,34 +1,34 @@ - - CFBundleDevelopmentRegion - en - CFBundleExecutable - $(EXECUTABLE_NAME) - CFBundleIconFile - - CFBundleIdentifier - $(PRODUCT_BUNDLE_IDENTIFIER) - CFBundleInfoDictionaryVersion - 6.0 - CFBundleName - $(PRODUCT_NAME) - CFBundlePackageType - APPL - CFBundleShortVersionString - 1.0 - CFBundleSignature - ???? - CFBundleVersion - 1 - LSMinimumSystemVersion - $(MACOSX_DEPLOYMENT_TARGET) - NSHumanReadableCopyright - Copyright © 2016 Florian Schliep. All rights reserved. - NSMainStoryboardFile - Main - NSPrincipalClass - NSApplication - + + CFBundleDevelopmentRegion + en + CFBundleExecutable + $(EXECUTABLE_NAME) + CFBundleIconFile + + CFBundleIdentifier + $(PRODUCT_BUNDLE_IDENTIFIER) + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + $(PRODUCT_NAME) + CFBundlePackageType + APPL + CFBundleShortVersionString + 1.0 + CFBundleSignature + ???? + CFBundleVersion + 1 + LSMinimumSystemVersion + $(MACOSX_DEPLOYMENT_TARGET) + NSHumanReadableCopyright + Copyright © 2016 Florian Schliep. All rights reserved. + NSMainStoryboardFile + Main + NSPrincipalClass + NSApplication + diff --git a/Sample App/ViewController.swift b/Sample App/ViewController.swift index 9357a32..b4547f0 100644 --- a/Sample App/ViewController.swift +++ b/Sample App/ViewController.swift @@ -19,7 +19,7 @@ class ViewController: NSViewController { super.prepare(for: segue, sender: sender) guard let pageViewController = segue.destinationController as? PageViewController else { return } - let storyboard = NSStoryboard(name: NSStoryboard.Name(rawValue: "Main"), bundle: nil) + let storyboard = NSStoryboard(name: "Main", bundle: nil) pageViewController.loadViewControllers(["1", "2", "3"], from: storyboard) self.pageViewController = pageViewController }