Commit cefc7cb0 by adamdahan

new card with button + image

parent 51dbc2fa
......@@ -32,6 +32,7 @@
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, ); }; };
9A3A3B6A1B8E992F005F16BC /* ImageTextCard.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9A3A3B691B8E992F005F16BC /* ImageTextCard.swift */; };
9A3A3B6E1B8EA7A5005F16BC /* ImageTextButtonCard.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9A3A3B6D1B8EA7A5005F16BC /* ImageTextButtonCard.swift */; };
9A94D0F91B895C8C00F586A5 /* Roboto.swift in Headers */ = {isa = PBXBuildFile; fileRef = 9AAC38531B89559900FE6B2D /* Roboto.swift */; settings = {ATTRIBUTES = (Public, ); }; };
9A94D0FA1B895EA500F586A5 /* LICENSE in Resources */ = {isa = PBXBuildFile; fileRef = 963832631B88E5BF0015F710 /* LICENSE */; };
9A94D0FB1B895EA500F586A5 /* Roboto-Regular.ttf in Resources */ = {isa = PBXBuildFile; fileRef = 9AAC38591B8956E300FE6B2D /* Roboto-Regular.ttf */; };
......@@ -75,6 +76,7 @@
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>"; };
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>"; };
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>"; };
9AAC384C1B89528900FE6B2D /* BasicCard.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = BasicCard.swift; sourceTree = "<group>"; };
......@@ -225,6 +227,7 @@
9AAC384C1B89528900FE6B2D /* BasicCard.swift */,
9A94D10A1B8A485C00F586A5 /* ImageCard.swift */,
9A3A3B691B8E992F005F16BC /* ImageTextCard.swift */,
9A3A3B6D1B8EA7A5005F16BC /* ImageTextButtonCard.swift */,
);
name = Card;
sourceTree = "<group>";
......@@ -372,6 +375,7 @@
963832711B88E5BF0015F710 /* Text.swift in Sources */,
9638326A1B88E5BF0015F710 /* CapturePreview.swift in Sources */,
65B965721B8A578D0055B139 /* MaterialViewController.swift in Sources */,
9A3A3B6E1B8EA7A5005F16BC /* ImageTextButtonCard.swift in Sources */,
9AAC38541B89559900FE6B2D /* Roboto.swift in Sources */,
65B9657E1B8A7C330055B139 /* MaterialButton.swift in Sources */,
963832881B8908180015F710 /* Layout.swift in Sources */,
......
......@@ -36,10 +36,10 @@ public class BasicCard : MaterialPulseView {
}
internal override func initialize() {
setupTitleLabel()
setupDetailTextLabel()
setupHorizontalLineSeparator()
setupButtons()
prepareTitleLabel()
prepareDetailTextLabel()
prepareHorizontalSeparator()
prepareButtons()
super.initialize()
}
......@@ -53,7 +53,7 @@ public class BasicCard : MaterialPulseView {
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.font = Roboto.regularWithSize(22.0)
titleLabel.textColor = UIColor.whiteColor()
......@@ -62,7 +62,7 @@ public class BasicCard : MaterialPulseView {
views["titleLabel"] = titleLabel
}
private func setupDetailTextLabel() {
private func prepareDetailTextLabel() {
detailTextLabel.setTranslatesAutoresizingMaskIntoConstraints(false)
detailTextLabel.font = Roboto.lightWithSize(16.0)
detailTextLabel.textColor = UIColor.whiteColor()
......@@ -73,7 +73,7 @@ public class BasicCard : MaterialPulseView {
views["detailTextLabel"] = detailTextLabel
}
private func setupHorizontalLineSeparator() {
private func prepareHorizontalSeparator() {
horizontalSeparator.setTranslatesAutoresizingMaskIntoConstraints(false)
horizontalSeparator.backgroundColor = UIColor.whiteColor()
horizontalSeparator.alpha = 0.2
......@@ -81,12 +81,12 @@ public class BasicCard : MaterialPulseView {
views["horizontalSeparator"] = horizontalSeparator
}
private func setupButtons() {
setupCancelButton()
setupOtherButton()
private func prepareButtons() {
prepareCancelButton()
prepareOtherButton()
}
private func setupCancelButton() {
private func prepareCancelButton() {
cancelButton.setTranslatesAutoresizingMaskIntoConstraints(false)
cancelButton.setTitle("Cancel", forState: .Normal)
cancelButton.setTitleColor(buttonColor, forState: .Normal)
......@@ -95,7 +95,7 @@ public class BasicCard : MaterialPulseView {
views["cancelButton"] = cancelButton
}
private func setupOtherButton() {
private func prepareOtherButton() {
otherButton.setTranslatesAutoresizingMaskIntoConstraints(false)
otherButton.setTitle("Confirm", forState: .Normal)
otherButton.setTitleColor(buttonColor, forState: .Normal)
......
//
// 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
}
}
......@@ -13,6 +13,9 @@ public class ImageTextCard : MaterialPulseView {
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)
......@@ -27,6 +30,10 @@ public class ImageTextCard : MaterialPulseView {
prepareTitleLabel()
prepareDescriptionContainerView()
prepareDescriptionLabel()
if showsCTA {
prepareHorizontalSeparator()
prepareCTAButton()
}
super.initialize()
}
......@@ -39,6 +46,10 @@ public class ImageTextCard : MaterialPulseView {
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() {
......@@ -79,4 +90,16 @@ public class ImageTextCard : MaterialPulseView {
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() {
}
}
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