Commit 0a88d466 by Daniel Dahan

issue-7: merged new-cards

parents 459aef04 dc320969
...@@ -12,7 +12,7 @@ ...@@ -12,7 +12,7 @@
657CD02B1B8EE0D3008C0029 /* MaterialViewController.swift in Headers */ = {isa = PBXBuildFile; fileRef = 65B965711B8A578D0055B139 /* MaterialViewController.swift */; settings = {ATTRIBUTES = (Public, ); }; }; 657CD02B1B8EE0D3008C0029 /* MaterialViewController.swift in Headers */ = {isa = PBXBuildFile; fileRef = 65B965711B8A578D0055B139 /* MaterialViewController.swift */; settings = {ATTRIBUTES = (Public, ); }; };
657CD02C1B8EE0D3008C0029 /* SideNavController.swift in Headers */ = {isa = PBXBuildFile; fileRef = 65B965861B8BEEC60055B139 /* SideNavController.swift */; settings = {ATTRIBUTES = (Public, ); }; }; 657CD02C1B8EE0D3008C0029 /* SideNavController.swift in Headers */ = {isa = PBXBuildFile; fileRef = 65B965861B8BEEC60055B139 /* SideNavController.swift */; settings = {ATTRIBUTES = (Public, ); }; };
657CD02D1B8EE0D3008C0029 /* MaterialButton.swift in Headers */ = {isa = PBXBuildFile; fileRef = 65B9657D1B8A7C330055B139 /* MaterialButton.swift */; settings = {ATTRIBUTES = (Public, ); }; }; 657CD02D1B8EE0D3008C0029 /* MaterialButton.swift in Headers */ = {isa = PBXBuildFile; fileRef = 65B9657D1B8A7C330055B139 /* MaterialButton.swift */; settings = {ATTRIBUTES = (Public, ); }; };
657CD02E1B8EE0D3008C0029 /* AddFabButton.swift in Headers */ = {isa = PBXBuildFile; fileRef = 9638329D1B8EC34D0015F710 /* AddFabButton.swift */; settings = {ATTRIBUTES = (Public, ); }; }; 657CD02E1B8EE0D3008C0029 /* (null) in Headers */ = {isa = PBXBuildFile; settings = {ATTRIBUTES = (Public, ); }; };
657CD02F1B8EE0D3008C0029 /* ImageCard.swift in Headers */ = {isa = PBXBuildFile; fileRef = 9A94D10A1B8A485C00F586A5 /* ImageCard.swift */; settings = {ATTRIBUTES = (Public, ); }; }; 657CD02F1B8EE0D3008C0029 /* ImageCard.swift in Headers */ = {isa = PBXBuildFile; fileRef = 9A94D10A1B8A485C00F586A5 /* ImageCard.swift */; settings = {ATTRIBUTES = (Public, ); }; };
65B965721B8A578D0055B139 /* MaterialViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 65B965711B8A578D0055B139 /* MaterialViewController.swift */; }; 65B965721B8A578D0055B139 /* MaterialViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 65B965711B8A578D0055B139 /* MaterialViewController.swift */; };
65B965751B8A60A00055B139 /* MaterialView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 65B965741B8A60A00055B139 /* MaterialView.swift */; }; 65B965751B8A60A00055B139 /* MaterialView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 65B965741B8A60A00055B139 /* MaterialView.swift */; };
...@@ -38,7 +38,10 @@ ...@@ -38,7 +38,10 @@
963832851B89070E0015F710 /* CapturePreview.swift in Headers */ = {isa = PBXBuildFile; fileRef = 9638325F1B88E5BF0015F710 /* CapturePreview.swift */; settings = {ATTRIBUTES = (Public, ); }; }; 963832851B89070E0015F710 /* CapturePreview.swift in Headers */ = {isa = PBXBuildFile; fileRef = 9638325F1B88E5BF0015F710 /* CapturePreview.swift */; settings = {ATTRIBUTES = (Public, ); }; };
963832881B8908180015F710 /* Layout.swift in Sources */ = {isa = PBXBuildFile; fileRef = 963832871B8908180015F710 /* Layout.swift */; }; 963832881B8908180015F710 /* Layout.swift in Sources */ = {isa = PBXBuildFile; fileRef = 963832871B8908180015F710 /* Layout.swift */; };
963832891B89097D0015F710 /* Layout.swift in Headers */ = {isa = PBXBuildFile; fileRef = 963832871B8908180015F710 /* Layout.swift */; settings = {ATTRIBUTES = (Public, ); }; }; 963832891B89097D0015F710 /* Layout.swift in Headers */ = {isa = PBXBuildFile; fileRef = 963832871B8908180015F710 /* Layout.swift */; settings = {ATTRIBUTES = (Public, ); }; };
9638329E1B8EC34D0015F710 /* AddFabButton.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9638329D1B8EC34D0015F710 /* AddFabButton.swift */; }; 96B57D4B1B90A88F00DE7BBB /* AddFabButton.swift in Sources */ = {isa = PBXBuildFile; fileRef = 96B57D4A1B90A88F00DE7BBB /* AddFabButton.swift */; };
9A3A3B6A1B8E992F005F16BC /* ImageTextCard.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9A3A3B691B8E992F005F16BC /* ImageTextCard.swift */; };
9A3A3B6E1B8EA7A5005F16BC /* ImageTextButtonCard.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9A3A3B6D1B8EA7A5005F16BC /* ImageTextButtonCard.swift */; };
9A3A3B701B8EB582005F16BC /* ImageRevealCard.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9A3A3B6F1B8EB582005F16BC /* ImageRevealCard.swift */; };
9A94D0F91B895C8C00F586A5 /* Roboto.swift in Headers */ = {isa = PBXBuildFile; fileRef = 9AAC38531B89559900FE6B2D /* Roboto.swift */; settings = {ATTRIBUTES = (Public, ); }; }; 9A94D0F91B895C8C00F586A5 /* Roboto.swift in Headers */ = {isa = PBXBuildFile; fileRef = 9AAC38531B89559900FE6B2D /* Roboto.swift */; settings = {ATTRIBUTES = (Public, ); }; };
9A94D0FA1B895EA500F586A5 /* LICENSE in Resources */ = {isa = PBXBuildFile; fileRef = 963832631B88E5BF0015F710 /* LICENSE */; }; 9A94D0FA1B895EA500F586A5 /* LICENSE in Resources */ = {isa = PBXBuildFile; fileRef = 963832631B88E5BF0015F710 /* LICENSE */; };
9A94D0FB1B895EA500F586A5 /* Roboto-Regular.ttf in Resources */ = {isa = PBXBuildFile; fileRef = 9AAC38591B8956E300FE6B2D /* Roboto-Regular.ttf */; }; 9A94D0FB1B895EA500F586A5 /* Roboto-Regular.ttf in Resources */ = {isa = PBXBuildFile; fileRef = 9AAC38591B8956E300FE6B2D /* Roboto-Regular.ttf */; };
...@@ -81,7 +84,10 @@ ...@@ -81,7 +84,10 @@
963832671B88E5BF0015F710 /* TextStorage.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TextStorage.swift; sourceTree = "<group>"; }; 963832671B88E5BF0015F710 /* TextStorage.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TextStorage.swift; sourceTree = "<group>"; };
963832681B88E5BF0015F710 /* TextView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TextView.swift; sourceTree = "<group>"; }; 963832681B88E5BF0015F710 /* TextView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TextView.swift; sourceTree = "<group>"; };
963832871B8908180015F710 /* Layout.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Layout.swift; sourceTree = "<group>"; }; 963832871B8908180015F710 /* Layout.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Layout.swift; sourceTree = "<group>"; };
9638329D1B8EC34D0015F710 /* AddFabButton.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AddFabButton.swift; sourceTree = "<group>"; }; 96B57D4A1B90A88F00DE7BBB /* AddFabButton.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AddFabButton.swift; sourceTree = "<group>"; };
9A3A3B691B8E992F005F16BC /* ImageTextCard.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ImageTextCard.swift; sourceTree = "<group>"; };
9A3A3B6D1B8EA7A5005F16BC /* ImageTextButtonCard.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ImageTextButtonCard.swift; sourceTree = "<group>"; };
9A3A3B6F1B8EB582005F16BC /* ImageRevealCard.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ImageRevealCard.swift; sourceTree = "<group>"; };
9A94D1081B8A3F5100F586A5 /* MaterialPulseView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MaterialPulseView.swift; sourceTree = "<group>"; }; 9A94D1081B8A3F5100F586A5 /* MaterialPulseView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MaterialPulseView.swift; sourceTree = "<group>"; };
9A94D10A1B8A485C00F586A5 /* ImageCard.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ImageCard.swift; sourceTree = "<group>"; }; 9A94D10A1B8A485C00F586A5 /* ImageCard.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ImageCard.swift; sourceTree = "<group>"; };
9AAC384C1B89528900FE6B2D /* BasicCard.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = BasicCard.swift; sourceTree = "<group>"; }; 9AAC384C1B89528900FE6B2D /* BasicCard.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = BasicCard.swift; sourceTree = "<group>"; };
...@@ -202,9 +208,9 @@ ...@@ -202,9 +208,9 @@
children = ( children = (
65B9657D1B8A7C330055B139 /* MaterialButton.swift */, 65B9657D1B8A7C330055B139 /* MaterialButton.swift */,
963832601B88E5BF0015F710 /* FabButton.swift */, 963832601B88E5BF0015F710 /* FabButton.swift */,
9638329D1B8EC34D0015F710 /* AddFabButton.swift */,
963832611B88E5BF0015F710 /* FlatButton.swift */, 963832611B88E5BF0015F710 /* FlatButton.swift */,
963832651B88E5BF0015F710 /* RaisedButton.swift */, 963832651B88E5BF0015F710 /* RaisedButton.swift */,
96B57D4A1B90A88F00DE7BBB /* AddFabButton.swift */,
); );
name = Button; name = Button;
sourceTree = "<group>"; sourceTree = "<group>";
...@@ -232,6 +238,9 @@ ...@@ -232,6 +238,9 @@
children = ( children = (
9AAC384C1B89528900FE6B2D /* BasicCard.swift */, 9AAC384C1B89528900FE6B2D /* BasicCard.swift */,
9A94D10A1B8A485C00F586A5 /* ImageCard.swift */, 9A94D10A1B8A485C00F586A5 /* ImageCard.swift */,
9A3A3B691B8E992F005F16BC /* ImageTextCard.swift */,
9A3A3B6D1B8EA7A5005F16BC /* ImageTextButtonCard.swift */,
9A3A3B6F1B8EB582005F16BC /* ImageRevealCard.swift */,
); );
name = Card; name = Card;
sourceTree = "<group>"; sourceTree = "<group>";
...@@ -270,7 +279,7 @@ ...@@ -270,7 +279,7 @@
657CD02B1B8EE0D3008C0029 /* MaterialViewController.swift in Headers */, 657CD02B1B8EE0D3008C0029 /* MaterialViewController.swift in Headers */,
657CD02C1B8EE0D3008C0029 /* SideNavController.swift in Headers */, 657CD02C1B8EE0D3008C0029 /* SideNavController.swift in Headers */,
657CD02D1B8EE0D3008C0029 /* MaterialButton.swift in Headers */, 657CD02D1B8EE0D3008C0029 /* MaterialButton.swift in Headers */,
657CD02E1B8EE0D3008C0029 /* AddFabButton.swift in Headers */, 657CD02E1B8EE0D3008C0029 /* (null) in Headers */,
657CD02F1B8EE0D3008C0029 /* ImageCard.swift in Headers */, 657CD02F1B8EE0D3008C0029 /* ImageCard.swift in Headers */,
); );
runOnlyForDeploymentPostprocessing = 0; runOnlyForDeploymentPostprocessing = 0;
...@@ -379,15 +388,18 @@ ...@@ -379,15 +388,18 @@
9A94D10B1B8A485C00F586A5 /* ImageCard.swift in Sources */, 9A94D10B1B8A485C00F586A5 /* ImageCard.swift in Sources */,
9638326B1B88E5BF0015F710 /* FabButton.swift in Sources */, 9638326B1B88E5BF0015F710 /* FabButton.swift in Sources */,
9A94D1091B8A3F5100F586A5 /* MaterialPulseView.swift in Sources */, 9A94D1091B8A3F5100F586A5 /* MaterialPulseView.swift in Sources */,
9A3A3B701B8EB582005F16BC /* ImageRevealCard.swift in Sources */,
9A3A3B6A1B8E992F005F16BC /* ImageTextCard.swift in Sources */,
65B965871B8BEEC60055B139 /* SideNavController.swift in Sources */, 65B965871B8BEEC60055B139 /* SideNavController.swift in Sources */,
9638326C1B88E5BF0015F710 /* FlatButton.swift in Sources */, 9638326C1B88E5BF0015F710 /* FlatButton.swift in Sources */,
65B965751B8A60A00055B139 /* MaterialView.swift in Sources */, 65B965751B8A60A00055B139 /* MaterialView.swift in Sources */,
963832711B88E5BF0015F710 /* Text.swift in Sources */, 963832711B88E5BF0015F710 /* Text.swift in Sources */,
9638326A1B88E5BF0015F710 /* CapturePreview.swift in Sources */, 9638326A1B88E5BF0015F710 /* CapturePreview.swift in Sources */,
9638329E1B8EC34D0015F710 /* AddFabButton.swift in Sources */,
65B965721B8A578D0055B139 /* MaterialViewController.swift in Sources */, 65B965721B8A578D0055B139 /* MaterialViewController.swift in Sources */,
9A3A3B6E1B8EA7A5005F16BC /* ImageTextButtonCard.swift in Sources */,
9AAC38541B89559900FE6B2D /* Roboto.swift in Sources */, 9AAC38541B89559900FE6B2D /* Roboto.swift in Sources */,
65B9657E1B8A7C330055B139 /* MaterialButton.swift in Sources */, 65B9657E1B8A7C330055B139 /* MaterialButton.swift in Sources */,
96B57D4B1B90A88F00DE7BBB /* AddFabButton.swift in Sources */,
963832881B8908180015F710 /* Layout.swift in Sources */, 963832881B8908180015F710 /* Layout.swift in Sources */,
9AAC384D1B89528900FE6B2D /* BasicCard.swift in Sources */, 9AAC384D1B89528900FE6B2D /* BasicCard.swift in Sources */,
963832731B88E5BF0015F710 /* TextView.swift in Sources */, 963832731B88E5BF0015F710 /* TextView.swift in Sources */,
......
...@@ -36,10 +36,10 @@ public class BasicCard : MaterialPulseView { ...@@ -36,10 +36,10 @@ public class BasicCard : MaterialPulseView {
} }
internal override func initialize() { internal override func initialize() {
setupTitleLabel() prepareTitleLabel()
setupDetailTextLabel() prepareDetailTextLabel()
setupHorizontalLineSeparator() prepareHorizontalSeparator()
setupButtons() prepareButtons()
super.initialize() super.initialize()
} }
...@@ -49,11 +49,11 @@ public class BasicCard : MaterialPulseView { ...@@ -49,11 +49,11 @@ public class BasicCard : MaterialPulseView {
addConstraints(Layout.constraint("H:|-(20)-[detailTextLabel]-(20)-|", options: nil, metrics: nil, views: views)) addConstraints(Layout.constraint("H:|-(20)-[detailTextLabel]-(20)-|", options: nil, metrics: nil, views: views))
addConstraints(Layout.constraint("H:|[horizontalSeparator]|", options: nil, metrics: nil, views: views)) addConstraints(Layout.constraint("H:|[horizontalSeparator]|", options: nil, metrics: nil, views: views))
addConstraints(Layout.constraint("H:|-(10)-[cancelButton(80)]-(10)-[otherButton(80)]", options: nil, metrics: nil, views: views)) addConstraints(Layout.constraint("H:|-(10)-[cancelButton(80)]-(10)-[otherButton(80)]", options: nil, metrics: nil, views: views))
addConstraints(Layout.constraint("V:|-(20)-[titleLabel(22)]-(10)-[detailTextLabel]-(20)-[line(1)]-(10)-[cancelButton]-(10)-|", options: nil, metrics: nil, views: views)) addConstraints(Layout.constraint("V:|-(20)-[titleLabel(22)]-(10)-[detailTextLabel]-(20)-[horizontalSeparator(1)]-(10)-[cancelButton]-(10)-|", options: nil, metrics: nil, views: views))
addConstraints(Layout.constraint("V:|-(20)-[titleLabel(22)]-(10)-[detailTextLabel]-(20)-[line(1)]-(10)-[otherButton]-(10)-|", options: nil, metrics: nil, views: views)) addConstraints(Layout.constraint("V:|-(20)-[titleLabel(22)]-(10)-[detailTextLabel]-(20)-[horizontalSeparator(1)]-(10)-[otherButton]-(10)-|", options: nil, metrics: nil, views: views))
} }
private func setupTitleLabel() { private func prepareTitleLabel() {
titleLabel.setTranslatesAutoresizingMaskIntoConstraints(false) titleLabel.setTranslatesAutoresizingMaskIntoConstraints(false)
titleLabel.font = Roboto.regularWithSize(22.0) titleLabel.font = Roboto.regularWithSize(22.0)
titleLabel.textColor = UIColor.whiteColor() titleLabel.textColor = UIColor.whiteColor()
...@@ -62,7 +62,7 @@ public class BasicCard : MaterialPulseView { ...@@ -62,7 +62,7 @@ public class BasicCard : MaterialPulseView {
views["titleLabel"] = titleLabel views["titleLabel"] = titleLabel
} }
private func setupDetailTextLabel() { private func prepareDetailTextLabel() {
detailTextLabel.setTranslatesAutoresizingMaskIntoConstraints(false) detailTextLabel.setTranslatesAutoresizingMaskIntoConstraints(false)
detailTextLabel.font = Roboto.lightWithSize(16.0) detailTextLabel.font = Roboto.lightWithSize(16.0)
detailTextLabel.textColor = UIColor.whiteColor() detailTextLabel.textColor = UIColor.whiteColor()
...@@ -73,7 +73,7 @@ public class BasicCard : MaterialPulseView { ...@@ -73,7 +73,7 @@ public class BasicCard : MaterialPulseView {
views["detailTextLabel"] = detailTextLabel views["detailTextLabel"] = detailTextLabel
} }
private func setupHorizontalLineSeparator() { private func prepareHorizontalSeparator() {
horizontalSeparator.setTranslatesAutoresizingMaskIntoConstraints(false) horizontalSeparator.setTranslatesAutoresizingMaskIntoConstraints(false)
horizontalSeparator.backgroundColor = UIColor.whiteColor() horizontalSeparator.backgroundColor = UIColor.whiteColor()
horizontalSeparator.alpha = 0.2 horizontalSeparator.alpha = 0.2
...@@ -81,12 +81,12 @@ public class BasicCard : MaterialPulseView { ...@@ -81,12 +81,12 @@ public class BasicCard : MaterialPulseView {
views["horizontalSeparator"] = horizontalSeparator views["horizontalSeparator"] = horizontalSeparator
} }
private func setupButtons() { private func prepareButtons() {
setupCancelButton() prepareCancelButton()
setupOtherButton() prepareOtherButton()
} }
private func setupCancelButton() { private func prepareCancelButton() {
cancelButton.setTranslatesAutoresizingMaskIntoConstraints(false) cancelButton.setTranslatesAutoresizingMaskIntoConstraints(false)
cancelButton.setTitle("Cancel", forState: .Normal) cancelButton.setTitle("Cancel", forState: .Normal)
cancelButton.setTitleColor(buttonColor, forState: .Normal) cancelButton.setTitleColor(buttonColor, forState: .Normal)
...@@ -95,7 +95,7 @@ public class BasicCard : MaterialPulseView { ...@@ -95,7 +95,7 @@ public class BasicCard : MaterialPulseView {
views["cancelButton"] = cancelButton views["cancelButton"] = cancelButton
} }
private func setupOtherButton() { private func prepareOtherButton() {
otherButton.setTranslatesAutoresizingMaskIntoConstraints(false) otherButton.setTranslatesAutoresizingMaskIntoConstraints(false)
otherButton.setTitle("Confirm", forState: .Normal) otherButton.setTitle("Confirm", forState: .Normal)
otherButton.setTitleColor(buttonColor, forState: .Normal) otherButton.setTitleColor(buttonColor, forState: .Normal)
......
...@@ -30,7 +30,7 @@ public class ImageCard : MaterialPulseView { ...@@ -30,7 +30,7 @@ public class ImageCard : MaterialPulseView {
} }
internal override func initialize() { internal override func initialize() {
setupImageView() prepareImageView()
super.initialize() super.initialize()
} }
...@@ -40,7 +40,7 @@ public class ImageCard : MaterialPulseView { ...@@ -40,7 +40,7 @@ public class ImageCard : MaterialPulseView {
addConstraints(Layout.constraint("V:|[imageView]|", options: nil, metrics: nil, views: views)) addConstraints(Layout.constraint("V:|[imageView]|", options: nil, metrics: nil, views: views))
} }
private func setupImageView() { private func prepareImageView() {
imageView.setTranslatesAutoresizingMaskIntoConstraints(false) imageView.setTranslatesAutoresizingMaskIntoConstraints(false)
imageView.contentMode = .ScaleAspectFill imageView.contentMode = .ScaleAspectFill
imageView.userInteractionEnabled = false imageView.userInteractionEnabled = false
......
//
// RevealCard.swift
// MaterialKit
//
// Created by Adam Dahan on 2015-08-26.
// Copyright (c) 2015 GraphKit Inc. All rights reserved.
//
import UIKit
public class ImageRevealCard : ImageCard {
private lazy var revealView: UIView = UIView()
private lazy var tapGesture: UITapGestureRecognizer = UITapGestureRecognizer()
private lazy var metrics: Dictionary <String, AnyObject> = Dictionary <String, AnyObject>()
private var topLayoutConstraint: NSLayoutConstraint!
private lazy var hideRevealViewButton: UIButton = UIButton()
public required init(coder aDecoder: NSCoder) {
super.init(coder: aDecoder)
}
public required init(frame: CGRect) {
super.init(frame: frame)
}
internal override func initialize() {
prepareTapGestures()
prepareRevealView()
prepareHideRevealViewButton()
super.initialize()
}
public override func layoutSubviews() {
super.layoutSubviews()
revealView.frame = CGRectMake(0, 0, bounds.width, bounds.height)
hideRevealViewButton.frame = CGRectMake(CGRectGetMaxX(revealView.frame) - 50, 10, 40, 40)
}
private func prepareTapGestures() {
tapGesture.addTarget(self, action: "showRevealView")
imageView.userInteractionEnabled = true
addGestureRecognizer(tapGesture)
}
private func prepareRevealView() {
revealView.backgroundColor = .whiteColor()
revealView.hidden = true
imageView.addSubview(revealView)
}
private func prepareHideRevealViewButton() {
hideRevealViewButton.setImage(UIImage(named: "ic_clear"), forState: .Normal)
hideRevealViewButton.tintColor = .whiteColor()
hideRevealViewButton.addTarget(self, action: "hideRevealView", forControlEvents: UIControlEvents.TouchUpInside)
revealView.addSubview(hideRevealViewButton)
}
internal func showRevealView() {
removeTapGestures()
revealView.hidden = false
revealView.frame = CGRectMake(0, bounds.height, bounds.width, bounds.height)
UIView.animateWithDuration(0.3, animations: { () -> Void in
var frame = self.revealView.frame
frame.origin.y -= self.bounds.height
self.revealView.frame = frame
})
}
internal func hideRevealView() {
UIView.animateWithDuration(0.3, animations: { () -> Void in
var frame = self.revealView.frame
frame.origin.y = self.bounds.height
self.revealView.frame = frame
}) { (finished) -> Void in
self.revealView.hidden = true
self.prepareTapGestures()
}
}
private func removeTapGestures() {
removeGestureRecognizer(tapGesture)
}
}
//
// ImageTextButtonCard.swift
// MaterialKit
//
// Created by Adam Dahan on 2015-08-26.
// Copyright (c) 2015 GraphKit Inc. All rights reserved.
//
import UIKit
public class ImageTextButtonCard : MaterialPulseView {
public lazy var imageView: UIImageView = UIImageView()
public lazy var titleLabel: UILabel = UILabel()
public lazy var descriptionContainerView: UIView = UIView()
public lazy var descriptionLabel: UILabel = UILabel()
public lazy var horizontalSeparator: UIView = UIView()
public lazy var button: FlatButton = FlatButton()
public required init(coder aDecoder: NSCoder) {
super.init(coder: aDecoder)
}
public required init(frame: CGRect) {
super.init(frame: frame)
}
internal override func initialize() {
prepareImageView()
prepareTitleLabel()
prepareDescriptionContainerView()
prepareDescriptionLabel()
prepareHorizontalSeparator()
prepareButton()
super.initialize()
}
internal override func constrainSubviews() {
super.constrainSubviews()
addConstraints(Layout.constraint("H:|[imageView]|", options: nil, metrics: nil, views: views))
imageView.addConstraints(Layout.constraint("H:|-20-[titleLabel]-(20)-|", options: nil, metrics: nil, views: views))
imageView.addConstraints(Layout.constraint("V:[titleLabel(45)]|", options: nil, metrics: nil, views: views))
addConstraints(Layout.constraint("H:|[descriptionContainerView]|", options: nil, metrics: nil, views: views))
descriptionContainerView.addConstraints(Layout.constraint("H:|-20-[descriptionLabel]-(20)-|", options: nil, metrics: nil, views: views))
addConstraints(Layout.constraint("V:|[imageView][descriptionContainerView(160)]|", options: nil, metrics: nil, views: views))
descriptionContainerView.addConstraints(Layout.constraint("H:|[horizontalSeparator]|", options: nil, metrics: nil, views: views))
descriptionContainerView.addConstraints(Layout.constraint("H:|-(10)-[button(70)]", options: nil, metrics: nil, views: views))
descriptionContainerView.addConstraints(Layout.constraint("V:|-(20)-[descriptionLabel]-(20)-[horizontalSeparator(1)]-(10)-[button(30)]-(10)-|", options: nil, metrics: nil, views: views))
}
private func prepareImageView() {
imageView.setTranslatesAutoresizingMaskIntoConstraints(false)
imageView.contentMode = .ScaleAspectFill
imageView.userInteractionEnabled = false
imageView.clipsToBounds = true
addSubview(imageView)
views["imageView"] = imageView
}
private func prepareTitleLabel() {
titleLabel.setTranslatesAutoresizingMaskIntoConstraints(false)
titleLabel.font = Roboto.mediumWithSize(18)
titleLabel.textColor = .whiteColor()
titleLabel.text = "Card Title"
titleLabel.layer.shadowOffset = CGSizeMake(1, 1)
titleLabel.layer.shadowOpacity = 0.4
titleLabel.layer.shadowRadius = 5.0
imageView.addSubview(titleLabel)
views["titleLabel"] = titleLabel
}
private func prepareDescriptionContainerView() {
descriptionContainerView.setTranslatesAutoresizingMaskIntoConstraints(false)
descriptionContainerView.backgroundColor = UIColor.whiteColor()
addSubview(descriptionContainerView)
views["descriptionContainerView"] = descriptionContainerView
}
private func prepareDescriptionLabel() {
descriptionLabel.setTranslatesAutoresizingMaskIntoConstraints(false)
descriptionLabel.font = Roboto.lightWithSize(14)
descriptionLabel.textColor = .darkTextColor()
descriptionLabel.numberOfLines = 0
descriptionLabel.lineBreakMode = NSLineBreakMode.ByWordWrapping
descriptionLabel.text = "I am a very simple card. I am good at containing small bits of information. I am convenient because I require little markup to use effectively."
descriptionContainerView.addSubview(descriptionLabel)
views["descriptionLabel"] = descriptionLabel
}
private func prepareHorizontalSeparator() {
horizontalSeparator.setTranslatesAutoresizingMaskIntoConstraints(false)
horizontalSeparator.backgroundColor = UIColor.darkGrayColor()
horizontalSeparator.alpha = 0.2
descriptionContainerView.addSubview(horizontalSeparator)
views["horizontalSeparator"] = horizontalSeparator
}
private func prepareButton() {
button.setTranslatesAutoresizingMaskIntoConstraints(false)
button.setTitle("Cancel", forState: .Normal)
button.setTitleColor(UIColor(red: 255.0/255.0, green: 156.0/255.0, blue: 38.0/255.0, alpha: 1.0), forState: .Normal)
button.layer.shadowOpacity = 0
button.titleLabel!.font = Roboto.lightWithSize(16.0)
button.pulseColor = UIColor(red: 255.0/255.0, green: 156.0/255.0, blue: 38.0/255.0, alpha: 1.0)
descriptionContainerView.addSubview(button)
views["button"] = button
}
}
//
// ImageTextCard.swift
// MaterialKit
//
// Created by Adam Dahan on 2015-08-26.
// Copyright (c) 2015 GraphKit Inc. All rights reserved.
//
import UIKit
public class ImageTextCard : MaterialPulseView {
public lazy var imageView: UIImageView = UIImageView()
public lazy var titleLabel: UILabel = UILabel()
public lazy var descriptionContainerView: UIView = UIView()
public lazy var descriptionLabel: UILabel = UILabel()
public lazy var horizontalSeparator: UIView = UIView()
public lazy var ctaButton: FlatButton = FlatButton()
public lazy var showsCTA: Bool = false
public required init(coder aDecoder: NSCoder) {
super.init(coder: aDecoder)
}
public required init(frame: CGRect) {
super.init(frame: frame)
}
internal override func initialize() {
prepareImageView()
prepareTitleLabel()
prepareDescriptionContainerView()
prepareDescriptionLabel()
if showsCTA {
prepareHorizontalSeparator()
prepareCTAButton()
}
super.initialize()
}
internal override func constrainSubviews() {
super.constrainSubviews()
addConstraints(Layout.constraint("H:|[imageView]|", options: nil, metrics: nil, views: views))
imageView.addConstraints(Layout.constraint("H:|-20-[titleLabel]-(20)-|", options: nil, metrics: nil, views: views))
imageView.addConstraints(Layout.constraint("V:[titleLabel(45)]|", options: nil, metrics: nil, views: views))
addConstraints(Layout.constraint("H:|[descriptionContainerView]|", options: nil, metrics: nil, views: views))
descriptionContainerView.addConstraints(Layout.constraint("H:|-20-[descriptionLabel]-(20)-|", options: nil, metrics: nil, views: views))
descriptionContainerView.addConstraints(Layout.constraint("V:|-(20)-[descriptionLabel]-(20)-|", options: nil, metrics: nil, views: views))
addConstraints(Layout.constraint("V:|[imageView][descriptionContainerView(120)]|", options: nil, metrics: nil, views: views))
if showsCTA {
descriptionContainerView.addConstraints(Layout.constraint("H:|[horizontalSeparator]|", options: nil, metrics: nil, views: views))
descriptionContainerView.addConstraints(Layout.constraint("V:|-(20)-[descriptionLabel]-(20)-[horizontalSeparator(1)]-(20)-|", options: nil, metrics: nil, views: views))
}
}
private func prepareImageView() {
imageView.setTranslatesAutoresizingMaskIntoConstraints(false)
imageView.contentMode = .ScaleAspectFill
imageView.userInteractionEnabled = false
imageView.clipsToBounds = true
addSubview(imageView)
views["imageView"] = imageView
}
private func prepareTitleLabel() {
titleLabel.setTranslatesAutoresizingMaskIntoConstraints(false)
titleLabel.font = Roboto.mediumWithSize(18)
titleLabel.textColor = .whiteColor()
titleLabel.text = "Card Title"
titleLabel.layer.shadowOffset = CGSizeMake(1, 1)
titleLabel.layer.shadowOpacity = 0.4
titleLabel.layer.shadowRadius = 5.0
imageView.addSubview(titleLabel)
views["titleLabel"] = titleLabel
}
private func prepareDescriptionContainerView() {
descriptionContainerView.setTranslatesAutoresizingMaskIntoConstraints(false)
descriptionContainerView.backgroundColor = UIColor.whiteColor()
addSubview(descriptionContainerView)
views["descriptionContainerView"] = descriptionContainerView
}
private func prepareDescriptionLabel() {
descriptionLabel.setTranslatesAutoresizingMaskIntoConstraints(false)
descriptionLabel.font = Roboto.lightWithSize(14)
descriptionLabel.textColor = .darkTextColor()
descriptionLabel.numberOfLines = 0
descriptionLabel.lineBreakMode = NSLineBreakMode.ByWordWrapping
descriptionLabel.text = "I am a very simple card. I am good at containing small bits of information. I am convenient because I require little markup to use effectively."
descriptionContainerView.addSubview(descriptionLabel)
views["descriptionLabel"] = descriptionLabel
}
private func prepareHorizontalSeparator() {
horizontalSeparator.setTranslatesAutoresizingMaskIntoConstraints(false)
horizontalSeparator.backgroundColor = UIColor.whiteColor()
horizontalSeparator.alpha = 0.2
descriptionContainerView.addSubview(horizontalSeparator)
views["horizontalSeparator"] = horizontalSeparator
}
private func prepareCTAButton() {
}
}
...@@ -86,6 +86,15 @@ public struct Layout { ...@@ -86,6 +86,15 @@ public struct Layout {
} }
/** /**
:name: alignAllSides
*/
public static func alignAllSides(parent: UIView, child: UIView) {
let views: Dictionary<String, AnyObject> = ["child" : child]
parent.addConstraints(constraint("H:|[child]|", options: nil, metrics: nil, views: views))
parent.addConstraints(constraint("V:|[child]|", options: nil, metrics: nil, views: views))
}
/**
:name: constraint :name: constraint
*/ */
public static func constraint(format: String, options: NSLayoutFormatOptions, metrics: Dictionary<String, AnyObject>?, views: Dictionary<String, AnyObject>) -> Array<NSLayoutConstraint> { public static func constraint(format: String, options: NSLayoutFormatOptions, metrics: Dictionary<String, AnyObject>?, views: Dictionary<String, AnyObject>) -> Array<NSLayoutConstraint> {
......
...@@ -81,6 +81,11 @@ public class MaterialPulseView : MaterialView { ...@@ -81,6 +81,11 @@ public class MaterialPulseView : MaterialView {
layer.cornerRadius = 2.0 layer.cornerRadius = 2.0
} }
public override func layoutSubviews() {
super.layoutSubviews()
layer.shadowPath = UIBezierPath(rect: bounds).CGPath
}
// 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 setupBackgroundColorView() { private func setupBackgroundColorView() {
......
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