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()
public required init(frame: CGRect) {
super.init(frame: frame)
}
internal override func initialize() {
prepareTitleLabel() 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.
// //
// This program is distributed in the hope that it will be useful, // public required init(coder aDecoder: NSCoder) {
// but WITHOUT ANY WARRANTY; without even the implied warranty of // super.init(coder: aDecoder)
// 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 // public required init(frame: CGRect) {
// along with this program located at the root of the software package // super.init(frame: frame)
// in a file called LICENSE. If not, see <http://www.gnu.org/licenses/>. // }
// //
// internal override func initialize() {
import UIKit // prepareImageView()
// super.initialize()
public class ImageCard : MaterialPulseView { // }
public lazy var imageView: UIImageView = UIImageView() //
// internal override func constrainSubviews() {
public required init(coder aDecoder: NSCoder) { // super.constrainSubviews()
super.init(coder: aDecoder) // 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(frame: CGRect) { //
super.init(frame: frame) // private func prepareImageView() {
} // imageView.setTranslatesAutoresizingMaskIntoConstraints(false)
// imageView.contentMode = .ScaleAspectFill
internal override func initialize() { // imageView.userInteractionEnabled = false
prepareImageView() // imageView.clipsToBounds = true
super.initialize() // addSubview(imageView)
} // views["imageView"] = imageView
// }
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 //import UIKit
// MaterialKit
// //
// Created by Adam Dahan on 2015-08-26. //public class ImageTextButtonCard : 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()
// public lazy var descriptionLabel: UILabel = UILabel()
// public lazy var horizontalSeparator: UIView = UIView()
// public lazy var button: FlatButton = FlatButton()
// //
// public required init(coder aDecoder: NSCoder) {
import UIKit // super.init(coder: aDecoder)
// }
public class ImageTextButtonCard : MaterialPulseView { //
public lazy var imageView: UIImageView = UIImageView() // public required init(frame: CGRect) {
public lazy var titleLabel: UILabel = UILabel() // super.init(frame: frame)
public lazy var descriptionContainerView: UIView = UIView() // }
public lazy var descriptionLabel: UILabel = UILabel() //
public lazy var horizontalSeparator: UIView = UIView() // internal override func initialize() {
public lazy var button: FlatButton = FlatButton() // prepareImageView()
// prepareTitleLabel()
public required init(coder aDecoder: NSCoder) { // prepareDescriptionContainerView()
super.init(coder: aDecoder) // prepareDescriptionLabel()
} // prepareHorizontalSeparator()
// prepareButton()
public required init(frame: CGRect) { // super.initialize()
super.init(frame: frame) // }
} //
// internal override func constrainSubviews() {
internal override func initialize() { // super.constrainSubviews()
prepareImageView() // addConstraints(Layout.constraint("H:|[imageView]|", options: nil, metrics: nil, views: views))
prepareTitleLabel() // imageView.addConstraints(Layout.constraint("H:|-20-[titleLabel]-(20)-|", options: nil, metrics: nil, views: views))
prepareDescriptionContainerView() // imageView.addConstraints(Layout.constraint("V:[titleLabel(45)]|", options: nil, metrics: nil, views: views))
prepareDescriptionLabel() // addConstraints(Layout.constraint("H:|[descriptionContainerView]|", options: nil, metrics: nil, views: views))
prepareHorizontalSeparator() // descriptionContainerView.addConstraints(Layout.constraint("H:|-20-[descriptionLabel]-(20)-|", options: nil, metrics: nil, views: views))
prepareButton() // addConstraints(Layout.constraint("V:|[imageView][descriptionContainerView(160)]|", options: nil, metrics: nil, views: views))
super.initialize() // 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))
internal override func constrainSubviews() { // }
super.constrainSubviews() //
addConstraints(Layout.constraint("H:|[imageView]|", options: nil, metrics: nil, views: views)) // private func prepareImageView() {
imageView.addConstraints(Layout.constraint("H:|-20-[titleLabel]-(20)-|", options: nil, metrics: nil, views: views)) // imageView.setTranslatesAutoresizingMaskIntoConstraints(false)
imageView.addConstraints(Layout.constraint("V:[titleLabel(45)]|", options: nil, metrics: nil, views: views)) // imageView.contentMode = .ScaleAspectFill
addConstraints(Layout.constraint("H:|[descriptionContainerView]|", options: nil, metrics: nil, views: views)) // imageView.userInteractionEnabled = false
descriptionContainerView.addConstraints(Layout.constraint("H:|-20-[descriptionLabel]-(20)-|", options: nil, metrics: nil, views: views)) // imageView.clipsToBounds = true
addConstraints(Layout.constraint("V:|[imageView][descriptionContainerView(160)]|", options: nil, metrics: nil, views: views)) // addSubview(imageView)
descriptionContainerView.addConstraints(Layout.constraint("H:|[horizontalSeparator]|", options: nil, metrics: nil, views: views)) // views["imageView"] = imageView
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 prepareTitleLabel() {
// titleLabel.setTranslatesAutoresizingMaskIntoConstraints(false)
private func prepareImageView() { // titleLabel.font = Roboto.mediumWithSize(18)
imageView.setTranslatesAutoresizingMaskIntoConstraints(false) // titleLabel.textColor = .whiteColor()
imageView.contentMode = .ScaleAspectFill // titleLabel.text = "Card Title"
imageView.userInteractionEnabled = false // titleLabel.layer.shadowOffset = CGSizeMake(1, 1)
imageView.clipsToBounds = true // titleLabel.layer.shadowOpacity = 0.4
addSubview(imageView) // titleLabel.layer.shadowRadius = 5.0
views["imageView"] = imageView // imageView.addSubview(titleLabel)
} // views["titleLabel"] = titleLabel
// }
private func prepareTitleLabel() { //
titleLabel.setTranslatesAutoresizingMaskIntoConstraints(false) // private func prepareDescriptionContainerView() {
titleLabel.font = Roboto.mediumWithSize(18) // descriptionContainerView.setTranslatesAutoresizingMaskIntoConstraints(false)
titleLabel.textColor = .whiteColor() // descriptionContainerView.backgroundColor = UIColor.whiteColor()
titleLabel.text = "Card Title" // addSubview(descriptionContainerView)
titleLabel.layer.shadowOffset = CGSizeMake(1, 1) // views["descriptionContainerView"] = descriptionContainerView
titleLabel.layer.shadowOpacity = 0.4 // }
titleLabel.layer.shadowRadius = 5.0 //
imageView.addSubview(titleLabel) // private func prepareDescriptionLabel() {
views["titleLabel"] = titleLabel // descriptionLabel.setTranslatesAutoresizingMaskIntoConstraints(false)
} // descriptionLabel.font = Roboto.lightWithSize(14)
// descriptionLabel.textColor = .darkTextColor()
private func prepareDescriptionContainerView() { // descriptionLabel.numberOfLines = 0
descriptionContainerView.setTranslatesAutoresizingMaskIntoConstraints(false) // descriptionLabel.lineBreakMode = NSLineBreakMode.ByWordWrapping
descriptionContainerView.backgroundColor = UIColor.whiteColor() // 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."
addSubview(descriptionContainerView) // descriptionContainerView.addSubview(descriptionLabel)
views["descriptionContainerView"] = descriptionContainerView // views["descriptionLabel"] = descriptionLabel
} // }
//
private func prepareDescriptionLabel() { // private func prepareHorizontalSeparator() {
descriptionLabel.setTranslatesAutoresizingMaskIntoConstraints(false) // horizontalSeparator.setTranslatesAutoresizingMaskIntoConstraints(false)
descriptionLabel.font = Roboto.lightWithSize(14) // horizontalSeparator.backgroundColor = UIColor.darkGrayColor()
descriptionLabel.textColor = .darkTextColor() // horizontalSeparator.alpha = 0.2
descriptionLabel.numberOfLines = 0 // descriptionContainerView.addSubview(horizontalSeparator)
descriptionLabel.lineBreakMode = NSLineBreakMode.ByWordWrapping // views["horizontalSeparator"] = horizontalSeparator
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 prepareButton() {
} // button.setTranslatesAutoresizingMaskIntoConstraints(false)
// button.setTitle("Cancel", forState: .Normal)
private func prepareHorizontalSeparator() { // button.setTitleColor(UIColor(red: 255.0/255.0, green: 156.0/255.0, blue: 38.0/255.0, alpha: 1.0), forState: .Normal)
horizontalSeparator.setTranslatesAutoresizingMaskIntoConstraints(false) // button.layer.shadowOpacity = 0
horizontalSeparator.backgroundColor = UIColor.darkGrayColor() // button.titleLabel!.font = Roboto.lightWithSize(16.0)
horizontalSeparator.alpha = 0.2 // button.pulseColor = UIColor(red: 255.0/255.0, green: 156.0/255.0, blue: 38.0/255.0, alpha: 1.0)
descriptionContainerView.addSubview(horizontalSeparator) // descriptionContainerView.addSubview(button)
views["horizontalSeparator"] = horizontalSeparator // views["button"] = button
} // }
//}
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 //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()
// 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) {
import UIKit // super.init(coder: aDecoder)
// }
public class ImageTextCard : MaterialPulseView { //
public lazy var imageView: UIImageView = UIImageView() // public required init(frame: CGRect) {
public lazy var titleLabel: UILabel = UILabel() // super.init(frame: frame)
public lazy var descriptionContainerView: UIView = UIView() // }
public lazy var descriptionLabel: UILabel = UILabel() //
public lazy var horizontalSeparator: UIView = UIView() // internal override func initialize() {
public lazy var ctaButton: FlatButton = FlatButton() // prepareImageView()
public lazy var showsCTA: Bool = false // prepareTitleLabel()
// prepareDescriptionContainerView()
public required init(coder aDecoder: NSCoder) { // prepareDescriptionLabel()
super.init(coder: aDecoder) // if showsCTA {
} // prepareHorizontalSeparator()
// prepareCTAButton()
public required init(frame: CGRect) { // }
super.init(frame: frame) // super.initialize()
} // }
//
internal override func initialize() { // internal override func constrainSubviews() {
prepareImageView() // super.constrainSubviews()
prepareTitleLabel() // addConstraints(Layout.constraint("H:|[imageView]|", options: nil, metrics: nil, views: views))
prepareDescriptionContainerView() // imageView.addConstraints(Layout.constraint("H:|-20-[titleLabel]-(20)-|", options: nil, metrics: nil, views: views))
prepareDescriptionLabel() // imageView.addConstraints(Layout.constraint("V:[titleLabel(45)]|", options: nil, metrics: nil, views: views))
if showsCTA { // addConstraints(Layout.constraint("H:|[descriptionContainerView]|", options: nil, metrics: nil, views: views))
prepareHorizontalSeparator() // descriptionContainerView.addConstraints(Layout.constraint("H:|-20-[descriptionLabel]-(20)-|", options: nil, metrics: nil, views: views))
prepareCTAButton() // 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))
super.initialize() // 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))
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)) // private func prepareImageView() {
imageView.addConstraints(Layout.constraint("V:[titleLabel(45)]|", options: nil, metrics: nil, views: views)) // imageView.setTranslatesAutoresizingMaskIntoConstraints(false)
addConstraints(Layout.constraint("H:|[descriptionContainerView]|", options: nil, metrics: nil, views: views)) // imageView.contentMode = .ScaleAspectFill
descriptionContainerView.addConstraints(Layout.constraint("H:|-20-[descriptionLabel]-(20)-|", options: nil, metrics: nil, views: views)) // imageView.userInteractionEnabled = false
descriptionContainerView.addConstraints(Layout.constraint("V:|-(20)-[descriptionLabel]-(20)-|", options: nil, metrics: nil, views: views)) // imageView.clipsToBounds = true
addConstraints(Layout.constraint("V:|[imageView][descriptionContainerView(120)]|", options: nil, metrics: nil, views: views)) // addSubview(imageView)
if showsCTA { // views["imageView"] = imageView
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 prepareTitleLabel() {
} // titleLabel.setTranslatesAutoresizingMaskIntoConstraints(false)
// titleLabel.font = Roboto.mediumWithSize(18)
private func prepareImageView() { // titleLabel.textColor = .whiteColor()
imageView.setTranslatesAutoresizingMaskIntoConstraints(false) // titleLabel.text = "Card Title"
imageView.contentMode = .ScaleAspectFill // titleLabel.layer.shadowOffset = CGSizeMake(1, 1)
imageView.userInteractionEnabled = false // titleLabel.layer.shadowOpacity = 0.4
imageView.clipsToBounds = true // titleLabel.layer.shadowRadius = 5.0
addSubview(imageView) // imageView.addSubview(titleLabel)
views["imageView"] = imageView // views["titleLabel"] = titleLabel
} // }
//
private func prepareTitleLabel() { // private func prepareDescriptionContainerView() {
titleLabel.setTranslatesAutoresizingMaskIntoConstraints(false) // descriptionContainerView.setTranslatesAutoresizingMaskIntoConstraints(false)
titleLabel.font = Roboto.mediumWithSize(18) // descriptionContainerView.backgroundColor = UIColor.whiteColor()
titleLabel.textColor = .whiteColor() // addSubview(descriptionContainerView)
titleLabel.text = "Card Title" // views["descriptionContainerView"] = descriptionContainerView
titleLabel.layer.shadowOffset = CGSizeMake(1, 1) // }
titleLabel.layer.shadowOpacity = 0.4 //
titleLabel.layer.shadowRadius = 5.0 // private func prepareDescriptionLabel() {
imageView.addSubview(titleLabel) // descriptionLabel.setTranslatesAutoresizingMaskIntoConstraints(false)
views["titleLabel"] = titleLabel // descriptionLabel.font = Roboto.lightWithSize(14)
} // descriptionLabel.textColor = .darkTextColor()
// descriptionLabel.numberOfLines = 0
private func prepareDescriptionContainerView() { // descriptionLabel.lineBreakMode = NSLineBreakMode.ByWordWrapping
descriptionContainerView.setTranslatesAutoresizingMaskIntoConstraints(false) // 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.backgroundColor = UIColor.whiteColor() // descriptionContainerView.addSubview(descriptionLabel)
addSubview(descriptionContainerView) // views["descriptionLabel"] = descriptionLabel
views["descriptionContainerView"] = descriptionContainerView // }
} //
// private func prepareHorizontalSeparator() {
private func prepareDescriptionLabel() { // horizontalSeparator.setTranslatesAutoresizingMaskIntoConstraints(false)
descriptionLabel.setTranslatesAutoresizingMaskIntoConstraints(false) // horizontalSeparator.backgroundColor = UIColor.whiteColor()
descriptionLabel.font = Roboto.lightWithSize(14) // horizontalSeparator.alpha = 0.2
descriptionLabel.textColor = .darkTextColor() // descriptionContainerView.addSubview(horizontalSeparator)
descriptionLabel.numberOfLines = 0 // views["horizontalSeparator"] = horizontalSeparator
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) // private func prepareCTAButton() {
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 { ...@@ -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