Skip to content

Commit

Permalink
Merge pull request #18 from skytoup/master
Browse files Browse the repository at this point in the history
Swift 3.0+ Support
  • Loading branch information
shaps80 committed Apr 3, 2017
2 parents d86693e + 0447376 commit 87fcdc2
Show file tree
Hide file tree
Showing 169 changed files with 6,481 additions and 3,746 deletions.
2 changes: 1 addition & 1 deletion .swift-version
@@ -1 +1 @@
2.3
3.1
17 changes: 10 additions & 7 deletions Example/Peek.xcodeproj/project.pbxproj
Expand Up @@ -44,7 +44,7 @@
542E834C1CBA67FA00598A9F /* UIProgressView+Peekable.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "UIProgressView+Peekable.swift"; sourceTree = "<group>"; };
542E83501CBA683100598A9F /* UIActivityIndicatorView+Peekable.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "UIActivityIndicatorView+Peekable.swift"; sourceTree = "<group>"; };
542E83521CBAA4CC00598A9F /* UIColor+Peekable.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "UIColor+Peekable.swift"; sourceTree = "<group>"; };
542E83541CBAB9AE00598A9F /* InspectorHeader.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = InspectorHeader.swift; sourceTree = "<group>"; };
542E83541CBAB9AE00598A9F /* InspectorHeader.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; lineEnding = 0; path = InspectorHeader.swift; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.swift; };
542E83561CBADC9100598A9F /* OpenSans-Bold.ttf */ = {isa = PBXFileReference; lastKnownFileType = file; name = "OpenSans-Bold.ttf"; path = "Fonts/OpenSans-Bold.ttf"; sourceTree = "<group>"; };
542E83571CBADC9100598A9F /* OpenSans-BoldItalic.ttf */ = {isa = PBXFileReference; lastKnownFileType = file; name = "OpenSans-BoldItalic.ttf"; path = "Fonts/OpenSans-BoldItalic.ttf"; sourceTree = "<group>"; };
542E83581CBADC9100598A9F /* OpenSans-ExtraBold.ttf */ = {isa = PBXFileReference; lastKnownFileType = file; name = "OpenSans-ExtraBold.ttf"; path = "Fonts/OpenSans-ExtraBold.ttf"; sourceTree = "<group>"; };
Expand All @@ -70,7 +70,7 @@
54534FA81CB9601E00BA67D3 /* RectAccessoryView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RectAccessoryView.swift; sourceTree = "<group>"; };
54534FAB1CB9601E00BA67D3 /* InspectorCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = InspectorCell.swift; sourceTree = "<group>"; };
54534FAC1CB9601E00BA67D3 /* InspectorsTabBarController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = InspectorsTabBarController.swift; sourceTree = "<group>"; };
54534FAD1CB9601E00BA67D3 /* InspectorViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = InspectorViewController.swift; sourceTree = "<group>"; };
54534FAD1CB9601E00BA67D3 /* InspectorViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; lineEnding = 0; path = InspectorViewController.swift; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.swift; };
54534FAF1CB9601E00BA67D3 /* HighlightView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HighlightView.swift; sourceTree = "<group>"; };
54534FB01CB9601E00BA67D3 /* OverlayView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = OverlayView.swift; sourceTree = "<group>"; };
54534FB11CB9601E00BA67D3 /* PeekViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PeekViewController.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -447,7 +447,8 @@
TargetAttributes = {
607FACCF1AFB9204008FA782 = {
CreatedOnToolsVersion = 6.3.1;
DevelopmentTeam = V2CWYL9AN8;
DevelopmentTeam = ED4MS6929N;
LastSwiftMigration = 0830;
};
};
};
Expand Down Expand Up @@ -674,16 +675,17 @@
ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES;
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CLANG_ENABLE_MODULES = YES;
DEVELOPMENT_TEAM = ED4MS6929N;
INFOPLIST_FILE = Peek/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
MODULE_NAME = ExampleApp;
OTHER_SWIFT_FLAGS = "$(inherited) \"-D\" \"COCOAPODS\" -D DEBUG";
PRODUCT_BUNDLE_IDENTIFIER = uk.co.snippex.ios.Peek;
PRODUCT_BUNDLE_IDENTIFIER = uk.co.snippex.ios.Peek.sky;
PRODUCT_NAME = "Peek-Example";
SWIFT_OBJC_BRIDGING_HEADER = "Peek/Peek-Example-Bridging-Header.h";
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
SWIFT_VERSION = 2.3;
SWIFT_VERSION = 3.0;
TARGETED_DEVICE_FAMILY = "1,2";
};
name = Debug;
Expand All @@ -695,16 +697,17 @@
ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES;
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CLANG_ENABLE_MODULES = YES;
DEVELOPMENT_TEAM = ED4MS6929N;
GCC_OPTIMIZATION_LEVEL = 0;
INFOPLIST_FILE = Peek/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
MODULE_NAME = ExampleApp;
PRODUCT_BUNDLE_IDENTIFIER = uk.co.snippex.ios.Peek;
PRODUCT_BUNDLE_IDENTIFIER = uk.co.snippex.ios.Peek.sky;
PRODUCT_NAME = "Peek-Example";
SWIFT_OBJC_BRIDGING_HEADER = "Peek/Peek-Example-Bridging-Header.h";
SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
SWIFT_VERSION = 2.3;
SWIFT_VERSION = 3.0;
TARGETED_DEVICE_FAMILY = "1,2";
};
name = Release;
Expand Down
@@ -0,0 +1,22 @@
<?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>SchemeUserState</key>
<dict>
<key>Peek-Example.xcscheme_^#shared#^_</key>
<dict>
<key>orderHint</key>
<integer>0</integer>
</dict>
</dict>
<key>SuppressBuildableAutocreation</key>
<dict>
<key>607FACCF1AFB9204008FA782</key>
<dict>
<key>primary</key>
<true/>
</dict>
</dict>
</dict>
</plist>
Binary file not shown.
@@ -0,0 +1,25 @@
<?xml version="1.0" encoding="UTF-8"?>
<Bucket
type = "0"
version = "2.0">
<Breakpoints>
<BreakpointProxy
BreakpointExtensionID = "Xcode.Breakpoint.SwiftErrorBreakpoint">
<BreakpointContent
shouldBeEnabled = "Yes"
ignoreCount = "0"
continueAfterRunningActions = "No">
</BreakpointContent>
</BreakpointProxy>
<BreakpointProxy
BreakpointExtensionID = "Xcode.Breakpoint.ExceptionBreakpoint">
<BreakpointContent
shouldBeEnabled = "Yes"
ignoreCount = "0"
continueAfterRunningActions = "No"
scope = "0"
stopOnStyle = "0">
</BreakpointContent>
</BreakpointProxy>
</Breakpoints>
</Bucket>
6 changes: 3 additions & 3 deletions Example/Peek/AppDelegate.swift
Expand Up @@ -28,9 +28,9 @@ class AppDelegate: UIResponder, UIApplicationDelegate {

var window: UIWindow?

func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
window?.peek.enableWithOptions { options in
options.activationMode = .Auto
options.activationMode = .auto
options.shouldIgnoreContainers = true

/*
Expand Down Expand Up @@ -72,7 +72,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
return true
}

override func motionBegan(motion: UIEventSubtype, withEvent event: UIEvent?) {
override func motionBegan(_ motion: UIEventSubtype, with event: UIEvent?) {
window?.peek.handleShake(motion)
}

Expand Down
90 changes: 45 additions & 45 deletions Example/Peek/Button.swift
Expand Up @@ -24,7 +24,7 @@ import UIKit
import pop

protocol ButtonDelegate: class {
func button(button: Button, didChangeValue value: Double?)
func button(_ button: Button, didChangeValue value: Double?)
}

@IBDesignable
Expand All @@ -42,49 +42,49 @@ class Button: UIControl, UITextFieldDelegate {
override func awakeFromNib() {
super.awakeFromNib()

textField.enabled = false
textField.isEnabled = false

tapGesture = UITapGestureRecognizer(target: self, action: #selector(Button.handleTap(_:)))
addGestureRecognizer(tapGesture)

tintColor = UIColor.clearColor()
tintColor = UIColor.clear
}

func handleTap(gesture: UITapGestureRecognizer) {
func handleTap(_ gesture: UITapGestureRecognizer) {
switch gesture.state {
case .Ended:
textField.enabled = true
case .ended:
textField.isEnabled = true
textField.becomeFirstResponder()

let animation = POPSpringAnimation(propertyNamed: kPOPViewScaleXY)
animation.springBounciness = 20
animation.toValue = NSValue(CGPoint: CGPointMake(1, 1))
pop_addAnimation(animation, forKey: "pop")
animation?.springBounciness = 20
animation?.toValue = NSValue(cgPoint: CGPoint(x: 1, y: 1))
pop_add(animation, forKey: "pop")
default:
break
}
}

override func touchesBegan(touches: Set<UITouch>, withEvent event: UIEvent?) {
super.touchesBegan(touches, withEvent: event)
override func touchesBegan(_ touches: Set<UITouch>, with event: UIEvent?) {
super.touchesBegan(touches, with: event)

if textField.isFirstResponder() {
if textField.isFirstResponder {
return
}

let animation = POPSpringAnimation(propertyNamed: kPOPViewScaleXY)
animation.springBounciness = 20
animation.toValue = NSValue(CGPoint: CGPointMake(0.8, 0.8))
pop_addAnimation(animation, forKey: "pop")
animation?.springBounciness = 20
animation?.toValue = NSValue(cgPoint: CGPoint(x: 0.8, y: 0.8))
pop_add(animation, forKey: "pop")
}

override func touchesEnded(touches: Set<UITouch>, withEvent event: UIEvent?) {
super.touchesEnded(touches, withEvent: event)
override func touchesEnded(_ touches: Set<UITouch>, with event: UIEvent?) {
super.touchesEnded(touches, with: event)

let animation = POPSpringAnimation(propertyNamed: kPOPViewScaleXY)
animation.springBounciness = 20
animation.toValue = NSValue(CGPoint: CGPointMake(1, 1))
pop_addAnimation(animation, forKey: "pop")
animation?.springBounciness = 20
animation?.toValue = NSValue(cgPoint: CGPoint(x: 1, y: 1))
pop_add(animation, forKey: "pop")
}

override var tintColor: UIColor! {
Expand All @@ -105,19 +105,19 @@ class Button: UIControl, UITextFieldDelegate {
}
}

func textFieldDidEndEditing(textField: UITextField) {
textField.enabled = false
func textFieldDidEndEditing(_ textField: UITextField) {
textField.isEnabled = false

if textField.text?.lengthOfBytesUsingEncoding(NSUTF8StringEncoding) == 0 {
if textField.text?.lengthOfBytes(using: String.Encoding.utf8) == 0 {
delegate?.button(self, didChangeValue: nil)
} else {
delegate?.button(self, didChangeValue: NSString(string: textField.text!).doubleValue)
}
}

static let formatter = NSNumberFormatter()
static let formatter = NumberFormatter()

func setValue(value: Double?, animated: Bool) {
func setValue(_ value: Double?, animated: Bool) {

Button.formatter.minimumFractionDigits = 0
Button.formatter.maximumFractionDigits = 1
Expand All @@ -126,55 +126,55 @@ class Button: UIControl, UITextFieldDelegate {
fade.type = kCATransitionFade
fade.duration = animated ? 0.2 : 0

textField.layer.addAnimation(fade, forKey: "fade")
textField.layer.add(fade, forKey: "fade")

if let value = value {
let animation = POPBasicAnimation(propertyNamed: kPOPViewTintColor)

animation.duration = animated ? 0.3 : 0
animation.toValue = UIColor(red: 0.302, green: 0.922, blue: 0.169, alpha: 1.00)
pop_addAnimation(animation, forKey: "color")
animation?.duration = animated ? 0.3 : 0
animation?.toValue = UIColor(red: 0.302, green: 0.922, blue: 0.169, alpha: 1.00)
pop_add(animation, forKey: "color")

textField.text = Button.formatter.stringFromNumber(value)
textField.text = Button.formatter.string(from: NSNumber(value: value))
} else {
let animation = POPBasicAnimation(propertyNamed: kPOPViewTintColor)

animation.duration = animated ? 0.3 : 0
animation.toValue = UIColor(red: 1.000, green: 0.224, blue: 0.624, alpha: 1.00)
pop_addAnimation(animation, forKey: "color")
animation?.duration = animated ? 0.3 : 0
animation?.toValue = UIColor(red: 1.000, green: 0.224, blue: 0.624, alpha: 1.00)
pop_add(animation, forKey: "color")

textField.text = nil
}

let animation = POPSpringAnimation(propertyNamed: kPOPViewScaleXY)

animation.springBounciness = 15
animation.springSpeed = 10
animation.toValue = NSValue(CGPoint: CGPointMake(1.1, 1.1))
animation?.springBounciness = 15
animation?.springSpeed = 10
animation?.toValue = NSValue(cgPoint: CGPoint(x: 1.1, y: 1.1))

if !animated {
return
}

pop_addAnimation(animation, forKey: "pop")
pop_add(animation, forKey: "pop")

dispatch_after(dispatch_time(DISPATCH_TIME_NOW, Int64(0.2 * Double(NSEC_PER_SEC))), dispatch_get_main_queue()) { () -> Void in
DispatchQueue.main.asyncAfter(deadline: DispatchTime.now() + Double(Int64(0.2 * Double(NSEC_PER_SEC))) / Double(NSEC_PER_SEC)) { () -> Void in
let animation = POPSpringAnimation(propertyNamed: kPOPViewScaleXY)

animation.springBounciness = 15
animation.springSpeed = 20
animation.toValue = NSValue(CGPoint: CGPointMake(1, 1))
animation?.springBounciness = 15
animation?.springSpeed = 20
animation?.toValue = NSValue(cgPoint: CGPoint(x: 1, y: 1))

self.pop_addAnimation(animation, forKey: "pop")
self.pop_add(animation, forKey: "pop")
}
}

override func drawRect(rect: CGRect) {
super.drawRect(rect)
override func draw(_ rect: CGRect) {
super.draw(rect)
guard let context = UIGraphicsGetCurrentContext() else { return }

tintColor.set()
CGContextSetLineWidth(context, borderWidth)
context.setLineWidth(borderWidth)

var frame = rect.insetBy(dx: 2, dy: 2)
var path = UIBezierPath(roundedRect: frame, cornerRadius: frame.width / 2)
Expand Down

0 comments on commit 87fcdc2

Please sign in to comment.