Commit 676b31ec by Daniel Dahan

issue-7: removed AddFabButton

parent abfcc37d
...@@ -34,7 +34,6 @@ ...@@ -34,7 +34,6 @@
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, ); }; };
96B57D4B1B90A88F00DE7BBB /* AddFabButton.swift in Sources */ = {isa = PBXBuildFile; fileRef = 96B57D4A1B90A88F00DE7BBB /* AddFabButton.swift */; };
96B57D4E1B90AF7D00DE7BBB /* MaterialTheme.swift in Sources */ = {isa = PBXBuildFile; fileRef = 96B57D4D1B90AF7D00DE7BBB /* MaterialTheme.swift */; }; 96B57D4E1B90AF7D00DE7BBB /* MaterialTheme.swift in Sources */ = {isa = PBXBuildFile; fileRef = 96B57D4D1B90AF7D00DE7BBB /* MaterialTheme.swift */; };
9A3A3B6A1B8E992F005F16BC /* ImageTextCard.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9A3A3B691B8E992F005F16BC /* ImageTextCard.swift */; }; 9A3A3B6A1B8E992F005F16BC /* ImageTextCard.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9A3A3B691B8E992F005F16BC /* ImageTextCard.swift */; };
9A3A3B6E1B8EA7A5005F16BC /* ImageTextButtonCard.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9A3A3B6D1B8EA7A5005F16BC /* ImageTextButtonCard.swift */; }; 9A3A3B6E1B8EA7A5005F16BC /* ImageTextButtonCard.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9A3A3B6D1B8EA7A5005F16BC /* ImageTextButtonCard.swift */; };
...@@ -79,7 +78,6 @@ ...@@ -79,7 +78,6 @@
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>"; };
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>"; }; 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>"; }; 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>"; }; 9A3A3B6D1B8EA7A5005F16BC /* ImageTextButtonCard.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ImageTextButtonCard.swift; sourceTree = "<group>"; };
...@@ -204,7 +202,6 @@ ...@@ -204,7 +202,6 @@
963832601B88E5BF0015F710 /* FabButton.swift */, 963832601B88E5BF0015F710 /* FabButton.swift */,
963832611B88E5BF0015F710 /* FlatButton.swift */, 963832611B88E5BF0015F710 /* FlatButton.swift */,
963832651B88E5BF0015F710 /* RaisedButton.swift */, 963832651B88E5BF0015F710 /* RaisedButton.swift */,
96B57D4A1B90A88F00DE7BBB /* AddFabButton.swift */,
); );
name = Button; name = Button;
sourceTree = "<group>"; sourceTree = "<group>";
...@@ -399,7 +396,6 @@ ...@@ -399,7 +396,6 @@
9A3A3B6E1B8EA7A5005F16BC /* ImageTextButtonCard.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 */,
......
//
// 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 @@ ...@@ -19,7 +19,7 @@
import UIKit import UIKit
import QuartzCore import QuartzCore
public class BasicCard : MaterialPulseView { public class BasicCard : MaterialCard {
public lazy var cancelButton: FlatButton = FlatButton() public lazy var cancelButton: FlatButton = FlatButton()
public lazy var otherButton: 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) 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 { ...@@ -27,30 +27,20 @@ public class BasicCard : MaterialPulseView {
public lazy var detailTextLabel: UILabel = UILabel() public lazy var detailTextLabel: UILabel = UILabel()
public lazy var horizontalSeparator: UIView = UIView() public lazy var horizontalSeparator: UIView = UIView()
public required init(coder aDecoder: NSCoder) { internal override func prepareCard() {
super.init(coder: aDecoder) super.prepareCard()
} prepareShadow()
prepareTitleLabel()
public required init(frame: CGRect) {
super.init(frame: frame)
}
internal override func initialize() {
prepareTitleLabel()
prepareDetailTextLabel() prepareDetailTextLabel()
prepareHorizontalSeparator() prepareHorizontalSeparator()
prepareButtons() prepareButtons()
super.initialize() // 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))
internal override func constrainSubviews() { // addConstraints(Layout.constraint("H:|[horizontalSeparator]|", options: nil, metrics: nil, views: views))
super.constrainSubviews() // addConstraints(Layout.constraint("H:|-(10)-[cancelButton(80)]-(10)-[otherButton(80)]", options: nil, metrics: nil, views: views))
addConstraints(Layout.constraint("H:|-(20)-[titleLabel]-(20)-|", 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("H:|-(20)-[detailTextLabel]-(20)-|", 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))
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() { 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 //public class ImageCard : MaterialPulseView {
// it under the terms of the GNU Affero General Public License as published // public lazy var imageView: UIImageView = UIImageView()
// by the Free Software Foundation, either version 3 of the License, or //
// (at your option) any later version. // public required init(coder aDecoder: NSCoder) {
// // super.init(coder: aDecoder)
// 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 // public required init(frame: CGRect) {
// GNU Affero General Public License for more details. // super.init(frame: frame)
// // }
// 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 // internal override func initialize() {
// in a file called LICENSE. If not, see <http://www.gnu.org/licenses/>. // prepareImageView()
// // super.initialize()
// }
import UIKit //
// internal override func constrainSubviews() {
public class ImageCard : MaterialPulseView { // super.constrainSubviews()
public lazy var imageView: UIImageView = UIImageView() // addConstraints(Layout.constraint("H:|[imageView]|", options: nil, metrics: nil, views: views))
// addConstraints(Layout.constraint("V:|[imageView]|", options: nil, metrics: nil, views: views))
public required init(coder aDecoder: NSCoder) { // }
super.init(coder: aDecoder) //
} // private func prepareImageView() {
// imageView.setTranslatesAutoresizingMaskIntoConstraints(false)
public required init(frame: CGRect) { // imageView.contentMode = .ScaleAspectFill
super.init(frame: frame) // imageView.userInteractionEnabled = false
} // imageView.clipsToBounds = true
// addSubview(imageView)
internal override func initialize() { // views["imageView"] = imageView
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)
}
}
////
//// ImageTextCard.swift
//// MaterialKit
////
//// Created by Adam Dahan on 2015-08-26.
//// Copyright (c) 2015 GraphKit Inc. All rights reserved.
////
// //
// ImageTextCard.swift //import UIKit
// MaterialKit
// //
// Created by Adam Dahan on 2015-08-26. //public class ImageTextCard : MaterialPulseView {
// Copyright (c) 2015 GraphKit Inc. All rights reserved. // public lazy var imageView: UIImageView = UIImageView()
// // public lazy var titleLabel: UILabel = UILabel()
// public lazy var descriptionContainerView: UIView = UIView()
import UIKit // public lazy var descriptionLabel: UILabel = UILabel()
// public lazy var horizontalSeparator: UIView = UIView()
public class ImageTextCard : MaterialPulseView { // public lazy var ctaButton: FlatButton = FlatButton()
public lazy var imageView: UIImageView = UIImageView() // public lazy var showsCTA: Bool = false
public lazy var titleLabel: UILabel = UILabel() //
public lazy var descriptionContainerView: UIView = UIView() // public required init(coder aDecoder: NSCoder) {
public lazy var descriptionLabel: UILabel = UILabel() // super.init(coder: aDecoder)
public lazy var horizontalSeparator: UIView = UIView() // }
public lazy var ctaButton: FlatButton = FlatButton() //
public lazy var showsCTA: Bool = false // public required init(frame: CGRect) {
// super.init(frame: frame)
public required init(coder aDecoder: NSCoder) { // }
super.init(coder: aDecoder) //
} // internal override func initialize() {
// prepareImageView()
public required init(frame: CGRect) { // prepareTitleLabel()
super.init(frame: frame) // prepareDescriptionContainerView()
} // prepareDescriptionLabel()
// if showsCTA {
internal override func initialize() { // prepareHorizontalSeparator()
prepareImageView() // prepareCTAButton()
prepareTitleLabel() // }
prepareDescriptionContainerView() // super.initialize()
prepareDescriptionLabel() // }
if showsCTA { //
prepareHorizontalSeparator() // internal override func constrainSubviews() {
prepareCTAButton() // super.constrainSubviews()
} // addConstraints(Layout.constraint("H:|[imageView]|", options: nil, metrics: nil, views: views))
super.initialize() // 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))
internal override func constrainSubviews() { // descriptionContainerView.addConstraints(Layout.constraint("H:|-20-[descriptionLabel]-(20)-|", options: nil, metrics: nil, views: views))
super.constrainSubviews() // descriptionContainerView.addConstraints(Layout.constraint("V:|-(20)-[descriptionLabel]-(20)-|", options: nil, metrics: nil, views: views))
addConstraints(Layout.constraint("H:|[imageView]|", options: nil, metrics: nil, views: views)) // addConstraints(Layout.constraint("V:|[imageView][descriptionContainerView(120)]|", options: nil, metrics: nil, views: views))
imageView.addConstraints(Layout.constraint("H:|-20-[titleLabel]-(20)-|", options: nil, metrics: nil, views: views)) // if showsCTA {
imageView.addConstraints(Layout.constraint("V:[titleLabel(45)]|", options: nil, metrics: nil, views: views)) // descriptionContainerView.addConstraints(Layout.constraint("H:|[horizontalSeparator]|", options: nil, metrics: nil, views: views))
addConstraints(Layout.constraint("H:|[descriptionContainerView]|", options: nil, metrics: nil, views: views)) // descriptionContainerView.addConstraints(Layout.constraint("V:|-(20)-[descriptionLabel]-(20)-[horizontalSeparator(1)]-(20)-|", 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 { // private func prepareImageView() {
descriptionContainerView.addConstraints(Layout.constraint("H:|[horizontalSeparator]|", options: nil, metrics: nil, views: views)) // imageView.setTranslatesAutoresizingMaskIntoConstraints(false)
descriptionContainerView.addConstraints(Layout.constraint("V:|-(20)-[descriptionLabel]-(20)-[horizontalSeparator(1)]-(20)-|", options: nil, metrics: nil, views: views)) // imageView.contentMode = .ScaleAspectFill
} // imageView.userInteractionEnabled = false
} // imageView.clipsToBounds = true
// addSubview(imageView)
private func prepareImageView() { // views["imageView"] = imageView
imageView.setTranslatesAutoresizingMaskIntoConstraints(false) // }
imageView.contentMode = .ScaleAspectFill //
imageView.userInteractionEnabled = false // private func prepareTitleLabel() {
imageView.clipsToBounds = true // titleLabel.setTranslatesAutoresizingMaskIntoConstraints(false)
addSubview(imageView) // titleLabel.font = Roboto.mediumWithSize(18)
views["imageView"] = imageView // titleLabel.textColor = .whiteColor()
} // titleLabel.text = "Card Title"
// titleLabel.layer.shadowOffset = CGSizeMake(1, 1)
private func prepareTitleLabel() { // titleLabel.layer.shadowOpacity = 0.4
titleLabel.setTranslatesAutoresizingMaskIntoConstraints(false) // titleLabel.layer.shadowRadius = 5.0
titleLabel.font = Roboto.mediumWithSize(18) // imageView.addSubview(titleLabel)
titleLabel.textColor = .whiteColor() // views["titleLabel"] = titleLabel
titleLabel.text = "Card Title" // }
titleLabel.layer.shadowOffset = CGSizeMake(1, 1) //
titleLabel.layer.shadowOpacity = 0.4 // private func prepareDescriptionContainerView() {
titleLabel.layer.shadowRadius = 5.0 // descriptionContainerView.setTranslatesAutoresizingMaskIntoConstraints(false)
imageView.addSubview(titleLabel) // descriptionContainerView.backgroundColor = UIColor.whiteColor()
views["titleLabel"] = titleLabel // addSubview(descriptionContainerView)
} // views["descriptionContainerView"] = descriptionContainerView
// }
private func prepareDescriptionContainerView() { //
descriptionContainerView.setTranslatesAutoresizingMaskIntoConstraints(false) // private func prepareDescriptionLabel() {
descriptionContainerView.backgroundColor = UIColor.whiteColor() // descriptionLabel.setTranslatesAutoresizingMaskIntoConstraints(false)
addSubview(descriptionContainerView) // descriptionLabel.font = Roboto.lightWithSize(14)
views["descriptionContainerView"] = descriptionContainerView // descriptionLabel.textColor = .darkTextColor()
} // descriptionLabel.numberOfLines = 0
// descriptionLabel.lineBreakMode = NSLineBreakMode.ByWordWrapping
private func prepareDescriptionLabel() { // 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."
descriptionLabel.setTranslatesAutoresizingMaskIntoConstraints(false) // descriptionContainerView.addSubview(descriptionLabel)
descriptionLabel.font = Roboto.lightWithSize(14) // views["descriptionLabel"] = descriptionLabel
descriptionLabel.textColor = .darkTextColor() // }
descriptionLabel.numberOfLines = 0 //
descriptionLabel.lineBreakMode = NSLineBreakMode.ByWordWrapping // private func prepareHorizontalSeparator() {
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." // horizontalSeparator.setTranslatesAutoresizingMaskIntoConstraints(false)
descriptionContainerView.addSubview(descriptionLabel) // horizontalSeparator.backgroundColor = UIColor.whiteColor()
views["descriptionLabel"] = descriptionLabel // horizontalSeparator.alpha = 0.2
} // descriptionContainerView.addSubview(horizontalSeparator)
// views["horizontalSeparator"] = horizontalSeparator
private func prepareHorizontalSeparator() { // }
horizontalSeparator.setTranslatesAutoresizingMaskIntoConstraints(false) //
horizontalSeparator.backgroundColor = UIColor.whiteColor() // private func prepareCTAButton() {
horizontalSeparator.alpha = 0.2 //
descriptionContainerView.addSubview(horizontalSeparator) // }
views["horizontalSeparator"] = horizontalSeparator //}
}
private func prepareCTAButton() {
}
}
...@@ -71,6 +71,7 @@ public class MaterialCard : UIView { ...@@ -71,6 +71,7 @@ public class MaterialCard : UIView {
// //
private func prepareView() { private func prepareView() {
setTranslatesAutoresizingMaskIntoConstraints(false) setTranslatesAutoresizingMaskIntoConstraints(false)
prepareBackgroundColorView()
prepareCard() prepareCard()
} }
...@@ -103,10 +104,7 @@ public class MaterialCard : UIView { ...@@ -103,10 +104,7 @@ public class MaterialCard : UIView {
// //
// :name: prepareCard // :name: prepareCard
// //
internal func prepareCard() { internal func prepareCard() {}
prepareShadow()
prepareBackgroundColorView()
}
// //
// :name: prepareShadow // :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