Skip to content

Commit

Permalink
Migrating to Swift3 #7
Browse files Browse the repository at this point in the history
  • Loading branch information
yannickl committed Sep 15, 2016
1 parent 8a5f9b6 commit 4966262
Show file tree
Hide file tree
Showing 18 changed files with 220 additions and 201 deletions.
2 changes: 1 addition & 1 deletion Example/Podfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ source 'https://github.com/CocoaPods/Specs.git'
use_frameworks!

def shared_pods
pod 'DynamicColor', '~> 2.4'
pod 'DynamicColor', '~> 3.1'
end

target 'SnappingStepper' do
Expand Down
27 changes: 23 additions & 4 deletions Example/SnappingStepperExample.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -352,14 +352,16 @@
attributes = {
LastSwiftMigration = 0700;
LastSwiftUpdateCheck = 0710;
LastUpgradeCheck = 0700;
LastUpgradeCheck = 0800;
ORGANIZATIONNAME = "Yannick Loriot";
TargetAttributes = {
CE6F72371AF513810019CB55 = {
CreatedOnToolsVersion = 6.3;
LastSwiftMigration = 0800;
};
CE8FFEAE1BAB22C100D43F38 = {
CreatedOnToolsVersion = 7.0;
LastSwiftMigration = 0800;
};
CEB21D5E1B18C169003E9EEC = {
CreatedOnToolsVersion = 6.3.2;
Expand Down Expand Up @@ -472,7 +474,7 @@
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "diff \"${PODS_ROOT}/../Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [[ $? != 0 ]] ; then\n cat << EOM\nerror: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\nEOM\n exit 1\nfi\n";
shellScript = "diff \"${PODS_ROOT}/../Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n";
showEnvVarsInLog = 0;
};
666D2E74D033AC04D04D82D1 /* [CP] Copy Pods Resources */ = {
Expand Down Expand Up @@ -502,7 +504,7 @@
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "diff \"${PODS_ROOT}/../Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [[ $? != 0 ]] ; then\n cat << EOM\nerror: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\nEOM\n exit 1\nfi\n";
shellScript = "diff \"${PODS_ROOT}/../Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n";
showEnvVarsInLog = 0;
};
AEABFEC876ECB92809E6C351 /* [CP] Check Pods Manifest.lock */ = {
Expand All @@ -517,7 +519,7 @@
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "diff \"${PODS_ROOT}/../Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [[ $? != 0 ]] ; then\n cat << EOM\nerror: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\nEOM\n exit 1\nfi\n";
shellScript = "diff \"${PODS_ROOT}/../Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n";
showEnvVarsInLog = 0;
};
E7EF272C918D680CE186A483 /* [CP] Copy Pods Resources */ = {
Expand Down Expand Up @@ -640,8 +642,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";
Expand Down Expand Up @@ -669,6 +673,7 @@
ONLY_ACTIVE_ARCH = YES;
SDKROOT = iphoneos;
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
SWIFT_VERSION = 3.0;
TARGETED_DEVICE_FAMILY = "1,2";
};
name = Debug;
Expand All @@ -686,8 +691,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";
Expand All @@ -706,6 +713,8 @@
IPHONEOS_DEPLOYMENT_TARGET = 9.0;
MTL_ENABLE_DEBUG_INFO = NO;
SDKROOT = iphoneos;
SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
SWIFT_VERSION = 3.0;
TARGETED_DEVICE_FAMILY = "1,2";
VALIDATE_PRODUCT = YES;
};
Expand All @@ -715,30 +724,35 @@
isa = XCBuildConfiguration;
baseConfigurationReference = B2E3DBDEDC6BE1779FC7B5FA /* Pods-SnappingStepperExample.debug.xcconfig */;
buildSettings = {
ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES;
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
INFOPLIST_FILE = SnappingStepperExample/Info.plist;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = "com.yannickloriot.$(PRODUCT_NAME:rfc1034identifier)";
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 3.0;
};
name = Debug;
};
CE6F72591AF513810019CB55 /* Release */ = {
isa = XCBuildConfiguration;
baseConfigurationReference = 8B6D05BEEE35E75A880B7639 /* Pods-SnappingStepperExample.release.xcconfig */;
buildSettings = {
ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES;
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
INFOPLIST_FILE = SnappingStepperExample/Info.plist;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = "com.yannickloriot.$(PRODUCT_NAME:rfc1034identifier)";
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 3.0;
};
name = Release;
};
CE8FFEC71BAB22C100D43F38 /* Debug */ = {
isa = XCBuildConfiguration;
baseConfigurationReference = B096075174A29C2DEC848639 /* Pods-SnappingStepper.debug.xcconfig */;
buildSettings = {
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "";
CURRENT_PROJECT_VERSION = 1;
DEBUG_INFORMATION_FORMAT = dwarf;
DEFINES_MODULE = YES;
Expand All @@ -752,6 +766,7 @@
PRODUCT_BUNDLE_IDENTIFIER = com.yannickloriot.SnappingStepper;
PRODUCT_NAME = "$(TARGET_NAME)";
SKIP_INSTALL = YES;
SWIFT_VERSION = 3.0;
VERSIONING_SYSTEM = "apple-generic";
VERSION_INFO_PREFIX = "";
};
Expand All @@ -761,6 +776,7 @@
isa = XCBuildConfiguration;
baseConfigurationReference = AA5888D5090F31444D20DBDA /* Pods-SnappingStepper.release.xcconfig */;
buildSettings = {
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "";
CURRENT_PROJECT_VERSION = 1;
DEFINES_MODULE = YES;
DYLIB_COMPATIBILITY_VERSION = 1;
Expand All @@ -773,6 +789,7 @@
PRODUCT_BUNDLE_IDENTIFIER = com.yannickloriot.SnappingStepper;
PRODUCT_NAME = "$(TARGET_NAME)";
SKIP_INSTALL = YES;
SWIFT_VERSION = 3.0;
VERSIONING_SYSTEM = "apple-generic";
VERSION_INFO_PREFIX = "";
};
Expand All @@ -782,6 +799,7 @@
isa = XCBuildConfiguration;
baseConfigurationReference = FA07CA8AF812FD143261A66A /* Pods-Tests.debug.xcconfig */;
buildSettings = {
ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES;
FRAMEWORK_SEARCH_PATHS = (
"$(SDKROOT)/Developer/Library/Frameworks",
"$(inherited)",
Expand All @@ -805,6 +823,7 @@
isa = XCBuildConfiguration;
baseConfigurationReference = 7C4C30B228B621354D490313 /* Pods-Tests.release.xcconfig */;
buildSettings = {
ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES;
FRAMEWORK_SEARCH_PATHS = (
"$(SDKROOT)/Developer/Library/Frameworks",
"$(inherited)",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0700"
LastUpgradeVersion = "0800"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0700"
LastUpgradeVersion = "0800"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0700"
LastUpgradeVersion = "0800"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand Down
14 changes: 7 additions & 7 deletions Example/SnappingStepperExample/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,32 +14,32 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
var window: UIWindow?


func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
application.statusBarHidden = true
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
application.isStatusBarHidden = true

// Override point for customization after application launch.
return true
}

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

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

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

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

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

Expand Down
70 changes: 35 additions & 35 deletions Example/SnappingStepperExample/ViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -24,50 +24,50 @@ class ViewController: UIViewController {
assignStepperDefaultSettings(classicStepper)

assignStepperDefaultSettings(tubeStepper)
tubeStepper.style = .Tube
tubeStepper.thumbStyle = .Tube
tubeStepper.style = .tube
tubeStepper.thumbStyle = .tube
tubeStepper.backgroundColor = UIColor(hex: 0xB2DFDB)
tubeStepper.thumbBackgroundColor = UIColor(hex: 0x009688)
tubeStepper.hintStyle = .Box
tubeStepper.hintStyle = .box

assignStepperDefaultSettings(roundedStepper)
roundedStepper.style = .Rounded
roundedStepper.thumbStyle = .Rounded
roundedStepper.backgroundColor = .clearColor()
roundedStepper.style = .rounded
roundedStepper.thumbStyle = .rounded
roundedStepper.backgroundColor = .clear
roundedStepper.thumbBackgroundColor = UIColor(hex: 0xFFC107)
roundedStepper.borderColor = UIColor(hex: 0xFFC107)
roundedStepper.borderWidth = 0.5
roundedStepper.hintStyle = .Thumb
roundedStepper.hintStyle = .thumb

assignStepperDefaultSettings(customStepper)
customStepper.style = .Custom(path: customDoubleArrowPath())
customStepper.thumbStyle = .Thumb
customStepper.backgroundColor = .clearColor()
customStepper.style = .custom(path: customDoubleArrowPath())
customStepper.thumbStyle = .thumb
customStepper.backgroundColor = .clear
customStepper.borderColor = UIColor(hex: 0x607D8B)
customStepper.thumbBackgroundColor = UIColor(hex: 0x607D8B)
customStepper.borderWidth = 0.5
customStepper.hintStyle = .Rounded
customStepper.hintStyle = .rounded

assignStepperDefaultSettings(verticalRoundedStepper)
verticalRoundedStepper.style = .Rounded
verticalRoundedStepper.thumbStyle = .Rounded
verticalRoundedStepper.backgroundColor = .clearColor()
verticalRoundedStepper.style = .rounded
verticalRoundedStepper.thumbStyle = .rounded
verticalRoundedStepper.backgroundColor = .clear
verticalRoundedStepper.thumbBackgroundColor = UIColor(hex: 0xFFC107)
verticalRoundedStepper.borderColor = UIColor(hex: 0xFFC107)
verticalRoundedStepper.borderWidth = 0.5
verticalRoundedStepper.hintStyle = .Thumb
verticalRoundedStepper.direction = .Vertical
verticalRoundedStepper.hintStyle = .thumb
verticalRoundedStepper.direction = .vertical
}

func assignStepperDefaultSettings(snappingStepper: SnappingStepper) {
func assignStepperDefaultSettings(_ snappingStepper: SnappingStepper) {
snappingStepper.symbolFont = UIFont(name: "TrebuchetMS-Bold", size: 20)
snappingStepper.symbolFontColor = .blackColor()
snappingStepper.symbolFontColor = .black
snappingStepper.backgroundColor = UIColor(hex: 0xc0392b)
snappingStepper.thumbWidthRatio = 0.4
snappingStepper.thumbText = nil
snappingStepper.thumbFont = UIFont(name: "TrebuchetMS-Bold", size: 18)
snappingStepper.thumbBackgroundColor = UIColor(hex: 0xe74c3c)
snappingStepper.thumbTextColor = .blackColor()
snappingStepper.thumbTextColor = .black

snappingStepper.continuous = true
snappingStepper.autorepeat = true
Expand All @@ -80,23 +80,23 @@ class ViewController: UIViewController {
func customDoubleArrowPath() -> UIBezierPath {
let da = UIBezierPath()

da.moveToPoint(CGPoint(x: 232, y: 969))
da.addLineToPoint(CGPoint(x: 189, y: 941))
da.addLineToPoint(CGPoint(x: 189, y: 955))
da.addLineToPoint(CGPoint(x: 62, y: 955))
da.addLineToPoint(CGPoint(x: 62, y: 941))
da.addLineToPoint(CGPoint(x: 17, y: 972))
da.addLineToPoint(CGPoint(x: 62, y: 1000))
da.addLineToPoint(CGPoint(x: 62, y: 986))
da.addLineToPoint(CGPoint(x: 189, y: 986))
da.addLineToPoint(CGPoint(x: 189, y: 1000))
da.addLineToPoint(CGPoint(x: 232, y: 972))
da.closePath()
da.move(to: CGPoint(x: 232, y: 969))
da.addLine(to: CGPoint(x: 189, y: 941))
da.addLine(to: CGPoint(x: 189, y: 955))
da.addLine(to: CGPoint(x: 62, y: 955))
da.addLine(to: CGPoint(x: 62, y: 941))
da.addLine(to: CGPoint(x: 17, y: 972))
da.addLine(to: CGPoint(x: 62, y: 1000))
da.addLine(to: CGPoint(x: 62, y: 986))
da.addLine(to: CGPoint(x: 189, y: 986))
da.addLine(to: CGPoint(x: 189, y: 1000))
da.addLine(to: CGPoint(x: 232, y: 972))
da.close()

return da
}

func updateThumbAttributes(snappingStepper: SnappingStepper, index: Int) {
func updateThumbAttributes(_ snappingStepper: SnappingStepper, index: Int) {
switch index {
case 1:
snappingStepper.thumbText = ""
Expand All @@ -109,17 +109,17 @@ class ViewController: UIViewController {
}
}

@IBAction func stepperValueChangedAction(sender: SnappingStepper) {
@IBAction func stepperValueChangedAction(_ sender: SnappingStepper) {
for stepper in [classicStepper, tubeStepper, roundedStepper, verticalRoundedStepper, customStepper] {
if stepper != sender {
stepper.value = sender.value
stepper?.value = sender.value
}
}

valueLabel.text = "\(sender.value)"
}

@IBAction func segmentedValueChangedAction(sender: UISegmentedControl) {
@IBAction func segmentedValueChangedAction(_ sender: UISegmentedControl) {
updateThumbAttributes(classicStepper, index: sender.selectedSegmentIndex)
updateThumbAttributes(customStepper, index: sender.selectedSegmentIndex)
updateThumbAttributes(tubeStepper, index: sender.selectedSegmentIndex)
Expand Down

0 comments on commit 4966262

Please sign in to comment.