Skip to content

Commit

Permalink
Swift Version Up
Browse files Browse the repository at this point in the history
  • Loading branch information
Eomkicheol committed Jul 19, 2020
1 parent accfd39 commit 72140d7
Show file tree
Hide file tree
Showing 9 changed files with 87 additions and 51 deletions.
49 changes: 39 additions & 10 deletions PagingMenuController.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@
isa = PBXProject;
attributes = {
LastSwiftUpdateCheck = 0700;
LastUpgradeCheck = 0640;
LastUpgradeCheck = 1130;
ORGANIZATIONNAME = kitasuke;
TargetAttributes = {
ECE530661B6DEB18001CF201 = {
Expand All @@ -142,10 +142,11 @@
};
buildConfigurationList = ECE530611B6DEB18001CF201 /* Build configuration list for PBXProject "PagingMenuController" */;
compatibilityVersion = "Xcode 3.2";
developmentRegion = English;
developmentRegion = en;
hasScannedForEncodings = 0;
knownRegions = (
en,
Base,
);
mainGroup = ECE5305D1B6DEB18001CF201;
productRefGroup = ECE530681B6DEB18001CF201 /* Products */;
Expand Down Expand Up @@ -194,20 +195,31 @@
CLANG_CXX_LIBRARY = "libc++";
CLANG_ENABLE_MODULES = YES;
CLANG_ENABLE_OBJC_ARC = YES;
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
CLANG_WARN_BOOL_CONVERSION = YES;
CLANG_WARN_COMMA = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
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_NON_LITERAL_NULL_CONVERSION = YES;
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
CLANG_WARN_STRICT_PROTOTYPES = YES;
CLANG_WARN_SUSPICIOUS_MOVE = YES;
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
COPY_PHASE_STRIP = NO;
CURRENT_PROJECT_VERSION = 1;
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
ENABLE_STRICT_OBJC_MSGSEND = YES;
ENABLE_TESTABILITY = YES;
GCC_C_LANGUAGE_STANDARD = gnu99;
GCC_DYNAMIC_NO_PIC = NO;
GCC_NO_COMMON_BLOCKS = YES;
Expand All @@ -223,12 +235,12 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 9.0;
IPHONEOS_DEPLOYMENT_TARGET = 11.0;
MTL_ENABLE_DEBUG_INFO = YES;
ONLY_ACTIVE_ARCH = YES;
SDKROOT = iphoneos;
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
SWIFT_VERSION = 3.0;
SWIFT_VERSION = 5.0;
TARGETED_DEVICE_FAMILY = "1,2";
VERSIONING_SYSTEM = "apple-generic";
VERSION_INFO_PREFIX = "";
Expand All @@ -243,13 +255,23 @@
CLANG_CXX_LIBRARY = "libc++";
CLANG_ENABLE_MODULES = YES;
CLANG_ENABLE_OBJC_ARC = YES;
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
CLANG_WARN_BOOL_CONVERSION = YES;
CLANG_WARN_COMMA = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
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_NON_LITERAL_NULL_CONVERSION = YES;
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
CLANG_WARN_STRICT_PROTOTYPES = YES;
CLANG_WARN_SUSPICIOUS_MOVE = YES;
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
Expand All @@ -266,10 +288,11 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 9.0;
IPHONEOS_DEPLOYMENT_TARGET = 11.0;
MTL_ENABLE_DEBUG_INFO = NO;
SDKROOT = iphoneos;
SWIFT_VERSION = 3.0;
SWIFT_COMPILATION_MODE = wholemodule;
SWIFT_VERSION = 5.0;
TARGETED_DEVICE_FAMILY = "1,2";
VALIDATE_PRODUCT = YES;
VERSIONING_SYSTEM = "apple-generic";
Expand All @@ -287,12 +310,15 @@
DYLIB_INSTALL_NAME_BASE = "@rpath";
INFOPLIST_FILE = PagingMenuController/Info.plist;
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
IPHONEOS_DEPLOYMENT_TARGET = 9.0;
IPHONEOS_DEPLOYMENT_TARGET = 11.0;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = "com.yusuke.$(PRODUCT_NAME:rfc1034identifier)";
PRODUCT_NAME = "$(TARGET_NAME)";
SKIP_INSTALL = YES;
SUPPORTS_MACCATALYST = NO;
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
SWIFT_VERSION = 3.0;
SWIFT_VERSION = 5.0;
TARGETED_DEVICE_FAMILY = 1;
};
name = Debug;
};
Expand All @@ -306,11 +332,14 @@
DYLIB_INSTALL_NAME_BASE = "@rpath";
INFOPLIST_FILE = PagingMenuController/Info.plist;
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
IPHONEOS_DEPLOYMENT_TARGET = 9.0;
IPHONEOS_DEPLOYMENT_TARGET = 11.0;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = "com.yusuke.$(PRODUCT_NAME:rfc1034identifier)";
PRODUCT_NAME = "$(TARGET_NAME)";
SKIP_INSTALL = YES;
SWIFT_VERSION = 3.0;
SUPPORTS_MACCATALYST = NO;
SWIFT_VERSION = 5.0;
TARGETED_DEVICE_FAMILY = 1;
};
name = Release;
};
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>IDEDidComputeMac32BitWarning</key>
<true/>
</dict>
</plist>
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0640"
LastUpgradeVersion = "1130"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand Down Expand Up @@ -37,10 +37,19 @@
</BuildActionEntries>
</BuildAction>
<TestAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES"
buildConfiguration = "Debug">
shouldUseLaunchSchemeArgsEnv = "YES">
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "ECE530661B6DEB18001CF201"
BuildableName = "PagingMenuController.framework"
BlueprintName = "PagingMenuController"
ReferencedContainer = "container:PagingMenuController.xcodeproj">
</BuildableReference>
</MacroExpansion>
<Testables>
<TestableReference
skipped = "NO">
Expand All @@ -53,24 +62,16 @@
</BuildableReference>
</TestableReference>
</Testables>
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "ECE530661B6DEB18001CF201"
BuildableName = "PagingMenuController.framework"
BlueprintName = "PagingMenuController"
ReferencedContainer = "container:PagingMenuController.xcodeproj">
</BuildableReference>
</MacroExpansion>
</TestAction>
<LaunchAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
launchStyle = "0"
useCustomWorkingDirectory = "NO"
buildConfiguration = "Debug"
ignoresPersistentStateOnLaunch = "NO"
debugDocumentVersioning = "YES"
debugServiceExtension = "internal"
allowLocationSimulation = "YES">
<MacroExpansion>
<BuildableReference
Expand All @@ -81,14 +82,12 @@
ReferencedContainer = "container:PagingMenuController.xcodeproj">
</BuildableReference>
</MacroExpansion>
<AdditionalOptions>
</AdditionalOptions>
</LaunchAction>
<ProfileAction
buildConfiguration = "Release"
shouldUseLaunchSchemeArgsEnv = "YES"
savedToolIdentifier = ""
useCustomWorkingDirectory = "NO"
buildConfiguration = "Release"
debugDocumentVersioning = "YES">
<MacroExpansion>
<BuildableReference
Expand Down
2 changes: 1 addition & 1 deletion PagingMenuController/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<key>CFBundleExecutable</key>
<string>$(EXECUTABLE_NAME)</string>
<key>CFBundleIdentifier</key>
<string>com.yusuke.$(PRODUCT_NAME:rfc1034identifier)</string>
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
Expand Down
2 changes: 1 addition & 1 deletion Pod/Classes/MenuItemView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,7 @@ extension MenuItemView {

fileprivate func estimatedLabelSize(_ label: UILabel) -> CGSize {
guard let text = label.text else { return .zero }
return NSString(string: text).boundingRect(with: CGSize(width: CGFloat.greatestFiniteMagnitude, height: CGFloat.greatestFiniteMagnitude), options: .usesLineFragmentOrigin, attributes: [NSFontAttributeName: label.font], context: nil).size
return NSString(string: text).boundingRect(with: CGSize(width: CGFloat.greatestFiniteMagnitude, height: CGFloat.greatestFiniteMagnitude), options: .usesLineFragmentOrigin, attributes: [NSAttributedString.Key.font: label.font ?? UIFont()], context: nil).size
}

fileprivate func calculateLabelSize(_ label: UILabel, maxWidth: CGFloat) -> CGSize {
Expand Down
4 changes: 2 additions & 2 deletions Pod/Classes/MenuView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ open class MenuView: UIScrollView {
bounces = menuViewBounces
isScrollEnabled = menuViewScrollEnabled
isDirectionalLockEnabled = true
decelerationRate = menuOptions.deceleratingRate
decelerationRate = UIScrollView.DecelerationRate(rawValue: menuOptions.deceleratingRate)
scrollsToTop = false
translatesAutoresizingMaskIntoConstraints = false
}
Expand Down Expand Up @@ -347,7 +347,7 @@ open class MenuView: UIScrollView {
}

fileprivate func focusMenuItem() {
let isSelected: (MenuItemView) -> Bool = { self.menuItemViews.index(of: $0) == self.currentPage }
let isSelected: (MenuItemView) -> Bool = { self.menuItemViews.firstIndex(of: $0) == self.currentPage }

// make selected item focused
menuItemViews.forEach {
Expand Down
22 changes: 11 additions & 11 deletions Pod/Classes/PagingMenuController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ open class PagingMenuController: UIViewController {

pagingViewController.contentScrollView.delegate = self
view.addSubview(pagingViewController.view)
addChildViewController(pagingViewController)
pagingViewController.didMove(toParentViewController: self)
addChild(pagingViewController)
pagingViewController.didMove(toParent: self)
}
}
public var onMove: ((MenuMoveState) -> Void)? {
Expand Down Expand Up @@ -478,10 +478,10 @@ extension PagingMenuController {
menuView?.addGestureRecognizer(rightSwipeGestureRecognizer)
}

internal func handleTapGesture(_ recognizer: UITapGestureRecognizer) {
@objc internal func handleTapGesture(_ recognizer: UITapGestureRecognizer) {
guard let menuItemView = recognizer.view as? MenuItemView,
let menuView = menuView,
let page = menuView.menuItemViews.index(of: menuItemView),
let page = menuView.menuItemViews.firstIndex(of: menuItemView),
page != menuView.currentPage,
let menuOptions = menuOptions else { return }

Expand All @@ -503,19 +503,19 @@ extension PagingMenuController {
move(toPage: newPage)
}

internal func handleSwipeGesture(_ recognizer: UISwipeGestureRecognizer) {
@objc internal func handleSwipeGesture(_ recognizer: UISwipeGestureRecognizer) {
guard let menuView = recognizer.view as? MenuView,
let menuOptions = menuOptions else { return }

let newPage: Int
switch (recognizer.direction, menuOptions.displayMode) {
case (UISwipeGestureRecognizerDirection.left, .infinite):
case (UISwipeGestureRecognizer.Direction.left, .infinite):
newPage = menuView.nextPage
case (UISwipeGestureRecognizerDirection.left, _):
case (UISwipeGestureRecognizer.Direction.left, _):
newPage = min(nextPage, menuOptions.itemsOptions.count - 1)
case (UISwipeGestureRecognizerDirection.right, .infinite):
case (UISwipeGestureRecognizer.Direction.right, .infinite):
newPage = menuView.previousPage
case (UISwipeGestureRecognizerDirection.right, _):
case (UISwipeGestureRecognizer.Direction.right, _):
newPage = max(previousPage, 0)
default: return
}
Expand All @@ -533,8 +533,8 @@ extension PagingMenuController {
if let pagingViewController = self.pagingViewController {
pagingViewController.cleanup()
pagingViewController.view.removeFromSuperview()
pagingViewController.removeFromParentViewController()
pagingViewController.willMove(toParentViewController: nil)
pagingViewController.removeFromParent()
pagingViewController.willMove(toParent: nil)
}
}
}
Expand Down
18 changes: 9 additions & 9 deletions Pod/Classes/PagingViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -95,11 +95,11 @@ open class PagingViewController: UIViewController {
if !shouldLoad(page: index) {
// remove unnecessary child view controllers
if isVisible(controller: controller) {
controller.willMove(toParentViewController: nil)
controller.willMove(toParent: nil)
controller.view!.removeFromSuperview()
controller.removeFromParentViewController()
controller.removeFromParent()

let _ = visibleControllers.index(of: controller).flatMap { visibleControllers.remove(at: $0) }
let _ = visibleControllers.firstIndex(of: controller).flatMap { visibleControllers.remove(at: $0) }
}
continue
}
Expand All @@ -118,8 +118,8 @@ open class PagingViewController: UIViewController {
pagingView.translatesAutoresizingMaskIntoConstraints = false

contentScrollView.addSubview(pagingView)
addChildViewController(controller as UIViewController)
controller.didMove(toParentViewController: self)
addChild(controller as UIViewController)
controller.didMove(toParent: self)

visibleControllers.append(controller)
}
Expand Down Expand Up @@ -242,10 +242,10 @@ extension PagingViewController {
visibleControllers.removeAll(keepingCapacity: true)
currentViewController = nil

childViewControllers.forEach {
$0.willMove(toParentViewController: nil)
children.forEach {
$0.willMove(toParent: nil)
$0.view.removeFromSuperview()
$0.removeFromParentViewController()
$0.removeFromParent()
}

contentScrollView.removeFromSuperview()
Expand Down Expand Up @@ -276,7 +276,7 @@ extension PagingViewController {
}

fileprivate func isVisible(controller: UIViewController) -> Bool {
return self.childViewControllers.contains(controller)
return self.children.contains(controller)
}

fileprivate func hideVisibleControllers() {
Expand Down
2 changes: 1 addition & 1 deletion Pod/Classes/Protocols/MenuViewCustomizable.swift
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public extension MenuViewCustomizable {
return 0.3
}
var deceleratingRate: CGFloat {
return UIScrollViewDecelerationRateFast
return UIScrollView.DecelerationRate.fast.rawValue
}
var selectedItemCenter: Bool {
return true
Expand Down

0 comments on commit 72140d7

Please sign in to comment.