Commit 676b31ec by Daniel Dahan

issue-7: removed AddFabButton

parent abfcc37d
......@@ -34,7 +34,6 @@
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 */; };
963832891B89097D0015F710 /* Layout.swift in Headers */ = {isa = PBXBuildFile; fileRef = 963832871B8908180015F710 /* Layout.swift */; settings = {ATTRIBUTES = (Public, ); }; };
96B57D4B1B90A88F00DE7BBB /* AddFabButton.swift in Sources */ = {isa = PBXBuildFile; fileRef = 96B57D4A1B90A88F00DE7BBB /* AddFabButton.swift */; };
96B57D4E1B90AF7D00DE7BBB /* MaterialTheme.swift in Sources */ = {isa = PBXBuildFile; fileRef = 96B57D4D1B90AF7D00DE7BBB /* MaterialTheme.swift */; };
9A3A3B6A1B8E992F005F16BC /* ImageTextCard.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9A3A3B691B8E992F005F16BC /* ImageTextCard.swift */; };
9A3A3B6E1B8EA7A5005F16BC /* ImageTextButtonCard.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9A3A3B6D1B8EA7A5005F16BC /* ImageTextButtonCard.swift */; };
......@@ -79,7 +78,6 @@
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>"; };
963832871B8908180015F710 /* Layout.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Layout.swift; sourceTree = "<group>"; };
96B57D4A1B90A88F00DE7BBB /* AddFabButton.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AddFabButton.swift; sourceTree = "<group>"; };
96B57D4D1B90AF7D00DE7BBB /* MaterialTheme.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MaterialTheme.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>"; };
......@@ -204,7 +202,6 @@
963832601B88E5BF0015F710 /* FabButton.swift */,
963832611B88E5BF0015F710 /* FlatButton.swift */,
963832651B88E5BF0015F710 /* RaisedButton.swift */,
96B57D4A1B90A88F00DE7BBB /* AddFabButton.swift */,
);
name = Button;
sourceTree = "<group>";
......@@ -399,7 +396,6 @@
9A3A3B6E1B8EA7A5005F16BC /* ImageTextButtonCard.swift in Sources */,
9AAC38541B89559900FE6B2D /* Roboto.swift in Sources */,
65B9657E1B8A7C330055B139 /* MaterialButton.swift in Sources */,
96B57D4B1B90A88F00DE7BBB /* AddFabButton.swift in Sources */,
963832881B8908180015F710 /* Layout.swift in Sources */,
9AAC384D1B89528900FE6B2D /* BasicCard.swift in Sources */,
963832731B88E5BF0015F710 /* TextView.swift in Sources */,
......
//
// Copyright (C) 2015 GraphKit, Inc. <http://graphkit.io> and other GraphKit contributors.
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as published
// by the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program located at the root of the software package
// in a file called LICENSE. If not, see <http://www.gnu.org/licenses/>.
//
import UIKit
public class AddFabButton : FabButton {
/**
:name: lineWidth
*/
public var lineWidth: CGFloat = 2
//
// :name: verticalLine
//
private var verticalLine: UIView!
//
// :name: horizontalLine
//
private var horizontalLine: UIView!
//
// :name: prepareButton
//
public override func prepareButton() {
super.prepareButton()
prepareVerticalLine()
prepareHorizontalLine()
}
//
// :name: prepareVerticalLine
//
private func prepareVerticalLine() {
verticalLine = UIView(frame: CGRectMake(0, 0, lineWidth, CGRectGetHeight(backgroundColorView.frame) / 3))
verticalLine.backgroundColor = MaterialTheme.white.color
verticalLine.center = backgroundColorView.center
backgroundColorView.addSubview(verticalLine)
}
//
// :name: prepareHorizontalLine
//
private func prepareHorizontalLine() {
horizontalLine = UIView(frame: CGRectMake(0, 0, CGRectGetWidth(backgroundColorView.frame) / 3, lineWidth))
horizontalLine.backgroundColor = MaterialTheme.white.color
horizontalLine.center = backgroundColorView.center
backgroundColorView.addSubview(horizontalLine)
}
}
......@@ -19,7 +19,7 @@
import UIKit
import QuartzCore
public class BasicCard : MaterialPulseView {
public class BasicCard : MaterialCard {
public lazy var cancelButton: FlatButton = FlatButton()
public lazy var otherButton: FlatButton = FlatButton()
public lazy var buttonColor: UIColor = UIColor(red: 255.0/255.0, green: 156.0/255.0, blue: 38.0/255.0, alpha: 1.0)
......@@ -27,30 +27,20 @@ public class BasicCard : MaterialPulseView {
public lazy var detailTextLabel: UILabel = UILabel()
public lazy var horizontalSeparator: UIView = UIView()
public required init(coder aDecoder: NSCoder) {
super.init(coder: aDecoder)
}
public required init(frame: CGRect) {
super.init(frame: frame)
}
internal override func initialize() {
prepareTitleLabel()
internal override func prepareCard() {
super.prepareCard()
prepareShadow()
prepareTitleLabel()
prepareDetailTextLabel()
prepareHorizontalSeparator()
prepareButtons()
super.initialize()
}
internal override func constrainSubviews() {
super.constrainSubviews()
addConstraints(Layout.constraint("H:|-(20)-[titleLabel]-(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:|-(10)-[cancelButton(80)]-(10)-[otherButton(80)]", 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)-[horizontalSeparator(1)]-(10)-[otherButton]-(10)-|", options: nil, metrics: nil, views: views))
// super.constrainSubviews()
// addConstraints(Layout.constraint("H:|-(20)-[titleLabel]-(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:|-(10)-[cancelButton(80)]-(10)-[otherButton(80)]", 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)-[horizontalSeparator(1)]-(10)-[otherButton]-(10)-|", options: nil, metrics: nil, views: views))
}
private func prepareTitleLabel() {
......
////
//// Copyright (C) 2015 GraphKit, Inc. <http://graphkit.io> and other GraphKit contributors.
////
//// This program is free software: you can redistribute it and/or modify
//// it under the terms of the GNU Affero General Public License as published
//// by the Free Software Foundation, either version 3 of the License, or
//// (at your option) any later version.
////
//// This program is distributed in the hope that it will be useful,
//// but WITHOUT ANY WARRANTY; without even the implied warranty of
//// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
//// GNU Affero General Public License for more details.
////
//// You should have received a copy of the GNU Affero General Public License
//// along with this program located at the root of the software package
//// in a file called LICENSE. If not, see <http://www.gnu.org/licenses/>.
////
//
// Copyright (C) 2015 GraphKit, Inc. <http://graphkit.io> and other GraphKit contributors.
//import UIKit
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as published
// by the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program located at the root of the software package
// in a file called LICENSE. If not, see <http://www.gnu.org/licenses/>.
//
import UIKit
public class ImageCard : MaterialPulseView {
public lazy var imageView: UIImageView = UIImageView()
public required init(coder aDecoder: NSCoder) {
super.init(coder: aDecoder)
}
public required init(frame: CGRect) {
super.init(frame: frame)
}
internal override func initialize() {
prepareImageView()
super.initialize()
}
internal override func constrainSubviews() {
super.constrainSubviews()
addConstraints(Layout.constraint("H:|[imageView]|", options: nil, metrics: nil, views: views))
addConstraints(Layout.constraint("V:|[imageView]|", 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
}
}
//public class ImageCard : MaterialPulseView {
// public lazy var imageView: UIImageView = UIImageView()
//
// public required init(coder aDecoder: NSCoder) {
// super.init(coder: aDecoder)
// }
//
// public required init(frame: CGRect) {
// super.init(frame: frame)
// }
//
// internal override func initialize() {
// prepareImageView()
// super.initialize()
// }
//
// internal override func constrainSubviews() {
// super.constrainSubviews()
// addConstraints(Layout.constraint("H:|[imageView]|", options: nil, metrics: nil, views: views))
// addConstraints(Layout.constraint("V:|[imageView]|", 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
// }
//}
////
//// 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)
// }
//}
//
// 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.
////
//
// ImageTextButtonCard.swift
// MaterialKit
//import UIKit
//
// 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
}
}
//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.
////
//
// ImageTextCard.swift
// MaterialKit
//import UIKit
//
// 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() {
}
}
//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() {
//
// }
//}
......@@ -71,6 +71,7 @@ public class MaterialCard : UIView {
//
private func prepareView() {
setTranslatesAutoresizingMaskIntoConstraints(false)
prepareBackgroundColorView()
prepareCard()
}
......@@ -103,10 +104,7 @@ public class MaterialCard : UIView {
//
// :name: prepareCard
//
internal func prepareCard() {
prepareShadow()
prepareBackgroundColorView()
}
internal func prepareCard() {}
//
// :name: prepareShadow
......
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