Commit 2c82f509 by Daniel Dahan

development: working cards :)

parent 9e453dbe
...@@ -69,7 +69,7 @@ public class ImageCard : MaterialCard, Comparable, Equatable { ...@@ -69,7 +69,7 @@ public class ImageCard : MaterialCard, Comparable, Equatable {
imageViewContainer = UIView() imageViewContainer = UIView()
imageViewContainer!.setTranslatesAutoresizingMaskIntoConstraints(false) imageViewContainer!.setTranslatesAutoresizingMaskIntoConstraints(false)
imageViewContainer!.backgroundColor = MaterialTheme.clear.color imageViewContainer!.backgroundColor = MaterialTheme.clear.color
insertSubview(imageViewContainer!, belowSubview: backgroundColorView) addSubview(imageViewContainer!)
} }
// text // text
......
...@@ -25,6 +25,11 @@ public class MaterialCard : UIView { ...@@ -25,6 +25,11 @@ public class MaterialCard : UIView {
internal lazy var backgroundColorView: UIView = UIView() internal lazy var backgroundColorView: UIView = UIView()
// //
// :name: pulseViewContainer
//
internal lazy var pulseViewContainer: UIView = UIView()
//
// :name: pulseView // :name: pulseView
// //
internal var pulseView: UIView? internal var pulseView: UIView?
...@@ -101,6 +106,7 @@ public class MaterialCard : UIView { ...@@ -101,6 +106,7 @@ public class MaterialCard : UIView {
internal func prepareView() { internal func prepareView() {
setTranslatesAutoresizingMaskIntoConstraints(false) setTranslatesAutoresizingMaskIntoConstraints(false)
prepareBackgroundColorView() prepareBackgroundColorView()
preparePulseViewContainer()
prepareCard() prepareCard()
} }
...@@ -145,8 +151,10 @@ public class MaterialCard : UIView { ...@@ -145,8 +151,10 @@ public class MaterialCard : UIView {
pulseView = UIView(frame: CGRectMake(0, 0, width, width)) pulseView = UIView(frame: CGRectMake(0, 0, width, width))
pulseView!.layer.cornerRadius = width / 2 pulseView!.layer.cornerRadius = width / 2
pulseView!.center = (touches.first as! UITouch).locationInView(self) pulseView!.center = (touches.first as! UITouch).locationInView(self)
pulseView!.backgroundColor = pulseColor.colorWithAlphaComponent(0.5) pulseView!.backgroundColor = pulseColor.colorWithAlphaComponent(0.3)
backgroundColorView.addSubview(pulseView!) addSubview(pulseViewContainer)
Layout.expandToParent(self, child: pulseViewContainer)
pulseViewContainer.addSubview(pulseView!)
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.05, 1.05) self.transform = CGAffineTransformMakeScale(1.05, 1.05)
...@@ -162,6 +170,7 @@ public class MaterialCard : UIView { ...@@ -162,6 +170,7 @@ public class MaterialCard : UIView {
self.pulseView?.alpha = 0 self.pulseView?.alpha = 0
} }
) { _ in ) { _ in
self.pulseViewContainer.removeFromSuperview()
self.pulseView?.removeFromSuperview() self.pulseView?.removeFromSuperview()
self.pulseView = nil self.pulseView = nil
} }
...@@ -183,6 +192,19 @@ public class MaterialCard : UIView { ...@@ -183,6 +192,19 @@ public class MaterialCard : UIView {
} }
// //
// :name: preparePulseViewContainer
//
// We need this view so we can use the masksToBounds
// so the pulse doesn't animate off the button
private func preparePulseViewContainer() {
pulseViewContainer.setTranslatesAutoresizingMaskIntoConstraints(false)
pulseViewContainer.layer.cornerRadius = 2
pulseViewContainer.layer.masksToBounds = true
pulseViewContainer.clipsToBounds = true
pulseViewContainer.userInteractionEnabled = false
}
//
// :name: shrink // :name: shrink
// //
private func shrink() { private func shrink() {
......
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