Commit 994edd5b by Daniel Dahan

master: merged development

parents a199e889 459aef04
Pod::Spec.new do |s| Pod::Spec.new do |s|
s.name = 'MK' s.name = 'MK'
s.version = '1.2.0' s.version = '1.3.0'
s.license = { :type => "AGPLv3+", :file => "LICENSE" } s.license = { :type => "AGPLv3+", :file => "LICENSE" }
s.summary = 'A Material Design Framework In Swift' s.summary = 'A Material Design Framework In Swift'
s.homepage = 'http://materialkit.io' s.homepage = 'http://materialkit.io'
......
...@@ -19,7 +19,19 @@ ...@@ -19,7 +19,19 @@
import UIKit import UIKit
public class AddFabButton : FabButton { public class AddFabButton : FabButton {
/**
:name: lineWidth
*/
public var lineWidth: CGFloat = 2
//
// :name: verticalLine
//
private var verticalLine: UIView! private var verticalLine: UIView!
//
// :name: horizontalLine
//
private var horizontalLine: UIView! private var horizontalLine: UIView!
// //
......
...@@ -19,26 +19,22 @@ ...@@ -19,26 +19,22 @@
import UIKit import UIKit
public class FabButton : MaterialButton { public class FabButton : MaterialButton {
/**
:name: lineWidth
*/
public var lineWidth: CGFloat = 2
// //
// :name: prepareButton // :name: prepareButton
// //
internal override func prepareButton() { internal override func prepareButton() {
super.prepareButton() super.prepareButton()
color = .redColor() prepareShadow()
backgroundColor = .redColor()
pulseColor = .whiteColor() pulseColor = .whiteColor()
backgroundColorView.layer.cornerRadius = bounds.width / 2 backgroundColorView.layer.cornerRadius = bounds.width / 2
} }
// //
// :name: pulseTouches // :name: pulseBegan
// //
internal override func pulseTouches(touches: Set<NSObject>) { internal override func pulseBegan(touches: Set<NSObject>, withEvent event: UIEvent) {
super.pulseTouches(touches) super.pulseBegan(touches, withEvent: event)
UIView.animateWithDuration(0.3, animations: { UIView.animateWithDuration(0.3, animations: {
self.pulseView!.transform = CGAffineTransformMakeScale(3, 3) self.pulseView!.transform = CGAffineTransformMakeScale(3, 3)
self.transform = CGAffineTransformMakeScale(1.1, 1.1) self.transform = CGAffineTransformMakeScale(1.1, 1.1)
......
...@@ -19,30 +19,25 @@ ...@@ -19,30 +19,25 @@
import UIKit import UIKit
public class FlatButton : MaterialButton { public class FlatButton : MaterialButton {
/**
:name: textColor
*/
public var textColor: UIColor?
// //
// :name: prepareButton // :name: prepareButton
// //
internal override func prepareButton() { internal override func prepareButton() {
super.prepareButton() super.prepareButton()
pulseColor = .whiteColor() setTitleColor(UIColor.purpleColor(), forState: .Normal)
pulseColor = .purpleColor()
backgroundColor = .clearColor()
backgroundColorView.layer.cornerRadius = 3 backgroundColorView.layer.cornerRadius = 3
} }
// //
// :name: pulseTouches // :name: pulseBegan
// //
internal override func pulseTouches(touches: Set<NSObject>) { internal override func pulseBegan(touches: Set<NSObject>, withEvent event: UIEvent) {
super.pulseTouches(touches) super.pulseBegan(touches, withEvent: event)
textColor = titleLabel?.textColor
UIView.animateWithDuration(0.3, animations: { UIView.animateWithDuration(0.3, animations: {
self.pulseView!.transform = CGAffineTransformMakeScale(10, 10) self.pulseView!.transform = CGAffineTransformMakeScale(10, 10)
self.transform = CGAffineTransformMakeScale(1.05, 1.1) self.transform = CGAffineTransformMakeScale(1.05, 1.1)
self.setTitleColor(UIColor.whiteColor(), forState: .Normal)
}) })
} }
} }
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
<key>CFBundlePackageType</key> <key>CFBundlePackageType</key>
<string>FMWK</string> <string>FMWK</string>
<key>CFBundleShortVersionString</key> <key>CFBundleShortVersionString</key>
<string>1.2.0</string> <string>1.3.0</string>
<key>CFBundleSignature</key> <key>CFBundleSignature</key>
<string>????</string> <string>????</string>
<key>CFBundleVersion</key> <key>CFBundleVersion</key>
......
...@@ -30,9 +30,13 @@ public class MaterialButton : UIButton { ...@@ -30,9 +30,13 @@ public class MaterialButton : UIButton {
internal var pulseView: UIView? internal var pulseView: UIView?
/** /**
:name: color :name: backgroundColor
*/ */
public var color: UIColor? public override var backgroundColor: UIColor? {
didSet {
backgroundColorView.backgroundColor = backgroundColor
}
}
/** /**
:name: pulseColor :name: pulseColor
...@@ -67,7 +71,7 @@ public class MaterialButton : UIButton { ...@@ -67,7 +71,7 @@ public class MaterialButton : UIButton {
*/ */
public override func touchesBegan(touches: Set<NSObject>, withEvent event: UIEvent) { public override func touchesBegan(touches: Set<NSObject>, withEvent event: UIEvent) {
super.touchesBegan(touches, withEvent: event) super.touchesBegan(touches, withEvent: event)
pulseTouches(touches) pulseBegan(touches, withEvent: event)
} }
/** /**
...@@ -76,16 +80,16 @@ public class MaterialButton : UIButton { ...@@ -76,16 +80,16 @@ public class MaterialButton : UIButton {
public override func touchesEnded(touches: Set<NSObject>, withEvent event: UIEvent) { public override func touchesEnded(touches: Set<NSObject>, withEvent event: UIEvent) {
super.touchesEnded(touches, withEvent: event) super.touchesEnded(touches, withEvent: event)
shrink() shrink()
removePulse() pulseEnded(touches, withEvent: event)
} }
/** /**
:name: touchesCancelled :name: touchesCancelled
*/ */
public override func touchesCancelled(touches: Set<NSObject>, withEvent event: UIEvent!) { public override func touchesCancelled(touches: Set<NSObject>!, withEvent event: UIEvent!) {
super.touchesCancelled(touches, withEvent: event) super.touchesCancelled(touches, withEvent: event)
shrink() shrink()
removePulse() pulseEnded(touches, withEvent: event)
} }
/** /**
...@@ -93,7 +97,6 @@ public class MaterialButton : UIButton { ...@@ -93,7 +97,6 @@ public class MaterialButton : UIButton {
*/ */
final public override func drawRect(rect: CGRect) { final public override func drawRect(rect: CGRect) {
prepareContext(rect) prepareContext(rect)
prepareShadow()
prepareButton() prepareButton()
prepareBackgroundColorView() prepareBackgroundColorView()
} }
...@@ -106,27 +109,51 @@ public class MaterialButton : UIButton { ...@@ -106,27 +109,51 @@ public class MaterialButton : UIButton {
} }
// //
// :name: pulseTouches // :name: pulseBegan
// //
internal func pulseTouches(touches: Set<NSObject>) { internal func pulseBegan(touches: Set<NSObject>, withEvent event: UIEvent) {
let touch = touches.first as! UITouch let touch = touches.first as! UITouch
let touchLocation = touch.locationInView(self) let touchLocation = touch.locationInView(self)
pulseView = UIView() pulseView = UIView()
pulseView!.frame = CGRectMake(0, 0, bounds.width, bounds.height) pulseView!.frame = CGRectMake(0, 0, bounds.height, bounds.height)
pulseView!.layer.cornerRadius = bounds.width / 2 pulseView!.layer.cornerRadius = bounds.height / 2
pulseView!.center = touchLocation pulseView!.center = touchLocation
pulseView!.backgroundColor = pulseColor?.colorWithAlphaComponent(0.5) pulseView!.backgroundColor = pulseColor?.colorWithAlphaComponent(0.5)
backgroundColorView.addSubview(pulseView!) backgroundColorView.addSubview(pulseView!)
} }
// //
// :name: pulseEnded
//
internal func pulseEnded(touches: Set<NSObject>, withEvent event: UIEvent) {
UIView.animateWithDuration(0.3,
animations: { _ in
self.pulseView?.alpha = 0
}
) { _ in
self.pulseView?.removeFromSuperview()
self.pulseView = nil
}
}
//
// :name: prepareShadow
//
internal func prepareShadow() {
layer.shadowOffset = CGSizeMake(1, 1)
layer.shadowColor = UIColor.blackColor().CGColor
layer.shadowOpacity = 0.5
layer.shadowRadius = 5
}
//
// :name: prepareBackgroundColorView // :name: prepareBackgroundColorView
// //
// We need this view so we can use the masksToBounds // We need this view so we can use the masksToBounds
// so the pulse doesn't animate off the button // so the pulse doesn't animate off the button
private func prepareBackgroundColorView() { private func prepareBackgroundColorView() {
backgroundColorView.backgroundColor = color
backgroundColorView.layer.masksToBounds = true backgroundColorView.layer.masksToBounds = true
backgroundColorView.clipsToBounds = true
backgroundColorView.userInteractionEnabled = false backgroundColorView.userInteractionEnabled = false
insertSubview(backgroundColorView, atIndex: 0) insertSubview(backgroundColorView, atIndex: 0)
} }
...@@ -139,16 +166,6 @@ public class MaterialButton : UIButton { ...@@ -139,16 +166,6 @@ public class MaterialButton : UIButton {
} }
// //
// :name: prepareShadow
//
private func prepareShadow() {
layer.shadowOffset = CGSizeMake(1, 1)
layer.shadowColor = UIColor.blackColor().CGColor
layer.shadowOpacity = 0.5
layer.shadowRadius = 5
}
//
// :name: prepareContext // :name: prepareContext
// //
private func prepareContext(rect: CGRect) { private func prepareContext(rect: CGRect) {
...@@ -175,18 +192,4 @@ public class MaterialButton : UIButton { ...@@ -175,18 +192,4 @@ public class MaterialButton : UIButton {
completion: nil completion: nil
) )
} }
//
// :name: removePulse
//
private func removePulse() {
UIView.animateWithDuration(0.3,
animations: { _ in
self.pulseView?.alpha = 0
}
) { _ in
self.pulseView?.removeFromSuperview()
self.pulseView = nil
}
}
} }
...@@ -19,31 +19,26 @@ ...@@ -19,31 +19,26 @@
import UIKit import UIKit
public class RaisedButton : MaterialButton { public class RaisedButton : MaterialButton {
/**
:name: textColor
*/
public var textColor: UIColor?
// //
// :name: prepareButton // :name: prepareButton
// //
internal override func prepareButton() { internal override func prepareButton() {
super.prepareButton() super.prepareButton()
color = .redColor() prepareShadow()
setTitleColor(UIColor.whiteColor(), forState: .Normal)
pulseColor = .whiteColor() pulseColor = .whiteColor()
backgroundColor = .purpleColor()
backgroundColorView.layer.cornerRadius = 3 backgroundColorView.layer.cornerRadius = 3
} }
// //
// :name: pulseTouches // :name: pulseBegan
// //
internal override func pulseTouches(touches: Set<NSObject>) { internal override func pulseBegan(touches: Set<NSObject>, withEvent event: UIEvent) {
super.pulseTouches(touches) super.pulseBegan(touches, withEvent: event)
textColor = titleLabel?.textColor
UIView.animateWithDuration(0.3, animations: { UIView.animateWithDuration(0.3, animations: {
self.pulseView!.transform = CGAffineTransformMakeScale(10, 10) self.pulseView!.transform = CGAffineTransformMakeScale(10, 10)
self.transform = CGAffineTransformMakeScale(1.05, 1.1) self.transform = CGAffineTransformMakeScale(1.05, 1.1)
self.setTitleColor(UIColor.whiteColor(), forState: .Normal)
}) })
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment