Commit 12fd3d0c by Daniel Dahan

development: progression updates

parent 4683c8fa
......@@ -10,7 +10,6 @@
657CD02A1B8EE0D3008C0029 /* MaterialCard.swift in Headers */ = {isa = PBXBuildFile; fileRef = 9A94D1081B8A3F5100F586A5 /* MaterialCard.swift */; settings = {ATTRIBUTES = (Public, ); }; };
657CD02C1B8EE0D3008C0029 /* SideNavController.swift in Headers */ = {isa = PBXBuildFile; fileRef = 65B965861B8BEEC60055B139 /* SideNavController.swift */; settings = {ATTRIBUTES = (Public, ); }; };
657CD02D1B8EE0D3008C0029 /* MaterialButton.swift in Headers */ = {isa = PBXBuildFile; fileRef = 65B9657D1B8A7C330055B139 /* MaterialButton.swift */; settings = {ATTRIBUTES = (Public, ); }; };
657CD02E1B8EE0D3008C0029 /* (null) in Headers */ = {isa = PBXBuildFile; settings = {ATTRIBUTES = (Public, ); }; };
657CD02F1B8EE0D3008C0029 /* ImageCard.swift in Headers */ = {isa = PBXBuildFile; fileRef = 9A94D10A1B8A485C00F586A5 /* ImageCard.swift */; settings = {ATTRIBUTES = (Public, ); }; };
65B9657E1B8A7C330055B139 /* MaterialButton.swift in Sources */ = {isa = PBXBuildFile; fileRef = 65B9657D1B8A7C330055B139 /* MaterialButton.swift */; };
65B965871B8BEEC60055B139 /* SideNavController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 65B965861B8BEEC60055B139 /* SideNavController.swift */; };
......@@ -35,6 +34,8 @@
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, ); }; };
96B57D4E1B90AF7D00DE7BBB /* MaterialTheme.swift in Sources */ = {isa = PBXBuildFile; fileRef = 96B57D4D1B90AF7D00DE7BBB /* MaterialTheme.swift */; };
96C910ED1B95804B00E7CE5C /* MaterialTheme.swift in Headers */ = {isa = PBXBuildFile; fileRef = 96B57D4D1B90AF7D00DE7BBB /* MaterialTheme.swift */; settings = {ATTRIBUTES = (Public, ); }; };
96C910EE1B95804B00E7CE5C /* ImageRevealCard.swift in Headers */ = {isa = PBXBuildFile; fileRef = 9A3A3B6F1B8EB582005F16BC /* ImageRevealCard.swift */; settings = {ATTRIBUTES = (Public, ); }; };
9A3A3B701B8EB582005F16BC /* ImageRevealCard.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9A3A3B6F1B8EB582005F16BC /* ImageRevealCard.swift */; };
9A94D0F91B895C8C00F586A5 /* Roboto.swift in Headers */ = {isa = PBXBuildFile; fileRef = 9AAC38531B89559900FE6B2D /* Roboto.swift */; settings = {ATTRIBUTES = (Public, ); }; };
9A94D0FA1B895EA500F586A5 /* LICENSE in Resources */ = {isa = PBXBuildFile; fileRef = 963832631B88E5BF0015F710 /* LICENSE */; };
......@@ -271,7 +272,8 @@
657CD02A1B8EE0D3008C0029 /* MaterialCard.swift in Headers */,
657CD02C1B8EE0D3008C0029 /* SideNavController.swift in Headers */,
657CD02D1B8EE0D3008C0029 /* MaterialButton.swift in Headers */,
657CD02E1B8EE0D3008C0029 /* (null) in Headers */,
96C910ED1B95804B00E7CE5C /* MaterialTheme.swift in Headers */,
96C910EE1B95804B00E7CE5C /* ImageRevealCard.swift in Headers */,
657CD02F1B8EE0D3008C0029 /* ImageCard.swift in Headers */,
);
runOnlyForDeploymentPostprocessing = 0;
......
......@@ -18,7 +18,7 @@
import UIKit
public class BasicCard : MaterialCard {
public class BasicCard : MaterialCard, Comparable, Equatable {
//
// :name: layoutConstraints
//
......@@ -104,7 +104,7 @@ public class BasicCard : MaterialCard {
l.setTranslatesAutoresizingMaskIntoConstraints(false)
l.textColor = MaterialTheme.white.color
l.backgroundColor = MaterialTheme.clear.color
l.font = Roboto.lightWithSize(12)
l.font = Roboto.lightWithSize(16)
l.numberOfLines = 0
l.lineBreakMode = .ByWordWrapping
prepareCard()
......@@ -204,7 +204,7 @@ public class BasicCard : MaterialCard {
// text
titleLabelContainer!.addConstraints(Layout.constraint("H:|-(verticalSpace)-[titleLabel]-(verticalSpace)-|", options: nil, metrics: ["verticalSpace": verticalSpace], views: ["titleLabel": titleLabel!]))
titleLabelContainer!.addConstraints(Layout.constraint("V:|-(verticalSpace)-[titleLabel(height)]-(verticalSpace)-|", options: nil, metrics: ["verticalSpace": verticalSpace, "height": titleLabel!.font.pointSize], views: ["titleLabel": titleLabel!]))
titleLabelContainer!.addConstraints(Layout.constraint("V:|-(verticalSpace)-[titleLabel(height)]-(verticalSpace)-|", options: nil, metrics: ["verticalSpace": verticalSpace, "height": titleLabel!.font.pointSize + verticalSpace], views: ["titleLabel": titleLabel!]))
}
// detail
......@@ -270,3 +270,23 @@ public class BasicCard : MaterialCard {
}
}
}
public func ==(lhs: BasicCard, rhs: BasicCard) -> Bool {
return lhs.tag == rhs.tag
}
public func <=(lhs: BasicCard, rhs: BasicCard) -> Bool {
return lhs.tag <= rhs.tag
}
public func >=(lhs: BasicCard, rhs: BasicCard) -> Bool {
return lhs.tag >= rhs.tag
}
public func >(lhs: BasicCard, rhs: BasicCard) -> Bool {
return lhs.tag > rhs.tag
}
public func <(lhs: BasicCard, rhs: BasicCard) -> Bool {
return lhs.tag < rhs.tag
}
......@@ -18,7 +18,7 @@
import UIKit
public class ImageCard : MaterialCard {
public class ImageCard : MaterialCard, Comparable, Equatable {
//
// :name: layoutConstraints
//
......@@ -29,99 +29,147 @@ public class ImageCard : MaterialCard {
//
internal lazy var views: Dictionary<String, AnyObject> = Dictionary<String, AnyObject>()
//
// :name: detailTextContainer
//
internal var detailTextContainer: UIView?
/**
:name: verticalSpace
*/
public var verticalSpace: CGFloat = 8
//
// :name: buttonsContainer
//
internal var buttonsContainer: UIView?
/**
:name: maximumDetailHeight
*/
public var maximumDetailHeight: CGFloat = 144
/**
:name: titleLabelContainer
*/
public private(set) var titleLabelContainer: UIView?
/**
:name: imageView
:name: shadow
*/
public var imageView: UIImageView? {
public var shadow: Bool = true {
didSet {
imageView!.setTranslatesAutoresizingMaskIntoConstraints(false)
imageView!.contentMode = .ScaleAspectFill
imageView!.userInteractionEnabled = false
imageView!.clipsToBounds = true
insertSubview(imageView!, belowSubview: backgroundColorView)
if nil != titleLabel {
titleLabel!.removeFromSuperview()
imageView!.addSubview(titleLabel!)
}
prepareCard()
false == shadow ? removeShadow() : prepareShadow()
}
}
/**
:name: titleLabel
:name: titleLabel
*/
public var titleLabel: UILabel? {
didSet {
titleLabel!.setTranslatesAutoresizingMaskIntoConstraints(false)
titleLabel!.textColor = MaterialTheme.white.color
titleLabel!.font = Roboto.regularWithSize(22)
if nil == imageView {
addSubview(titleLabel!)
if let t = titleLabel {
// container
if nil == titleLabelContainer {
titleLabelContainer = UIView()
titleLabelContainer!.setTranslatesAutoresizingMaskIntoConstraints(false)
titleLabelContainer!.backgroundColor = MaterialTheme.clear.color
addSubview(titleLabelContainer!)
}
// text
titleLabelContainer!.addSubview(t)
t.setTranslatesAutoresizingMaskIntoConstraints(false)
t.textColor = MaterialTheme.white.color
t.backgroundColor = MaterialTheme.clear.color
t.font = Roboto.mediumWithSize(18)
t.numberOfLines = 1
} else {
imageView!.addSubview(titleLabel!)
titleLabelContainer?.removeFromSuperview()
}
prepareCard()
}
}
/**
:name: detailTextLabel
:name: detailLabelContainer
*/
public var detailTextLabel: UILabel? {
public private(set) var detailLabelContainer: UIView?
/**
:name: detailLabel
*/
public var detailLabel: UILabel? {
didSet {
// container
if nil == detailTextContainer {
detailTextContainer = UIView()
detailTextContainer!.setTranslatesAutoresizingMaskIntoConstraints(false)
detailTextContainer!.backgroundColor = MaterialTheme.white.color
addSubview(detailTextContainer!)
if let l = detailLabel {
// container
if nil == detailLabelContainer {
detailLabelContainer = UIView()
detailLabelContainer!.setTranslatesAutoresizingMaskIntoConstraints(false)
detailLabelContainer!.backgroundColor = MaterialTheme.clear.color
addSubview(detailLabelContainer!)
}
// text
detailLabelContainer!.addSubview(l)
l.setTranslatesAutoresizingMaskIntoConstraints(false)
l.textColor = MaterialTheme.white.color
l.backgroundColor = MaterialTheme.clear.color
l.font = Roboto.lightWithSize(12)
l.numberOfLines = 0
l.lineBreakMode = .ByWordWrapping
prepareCard()
} else {
detailLabelContainer?.removeFromSuperview()
}
// text
detailTextContainer!.addSubview(detailTextLabel!)
detailTextLabel!.setTranslatesAutoresizingMaskIntoConstraints(false)
detailTextLabel!.textColor = MaterialTheme.black.color
detailTextLabel!.font = Roboto.lightWithSize(16)
detailTextLabel!.numberOfLines = 0
detailTextLabel!.lineBreakMode = .ByWordWrapping
prepareCard()
}
}
/**
:name: divider
:name: divider
*/
public var divider: UIView? {
didSet {
divider!.setTranslatesAutoresizingMaskIntoConstraints(false)
divider!.backgroundColor = MaterialTheme.blueGrey.lighten4
addSubview(divider!)
prepareCard()
if let d = divider {
d.setTranslatesAutoresizingMaskIntoConstraints(false)
d.backgroundColor = MaterialTheme.blueGrey.color
addSubview(d)
prepareCard()
} else {
divider?.removeFromSuperview()
}
}
}
/**
:name: buttons
:name: buttonsContainer
*/
public var buttons: Array<MaterialButton>? {
public private(set) var buttonsContainer: UIView?
/**
:name: leftButtons
*/
public var leftButtons: Array<MaterialButton>? {
didSet {
if nil == buttonsContainer {
buttonsContainer = UIView()
buttonsContainer!.setTranslatesAutoresizingMaskIntoConstraints(false)
buttonsContainer!.backgroundColor = MaterialTheme.white.color
addSubview(buttonsContainer!)
if let b = leftButtons {
if nil == buttonsContainer {
buttonsContainer = UIView()
buttonsContainer!.setTranslatesAutoresizingMaskIntoConstraints(false)
buttonsContainer!.backgroundColor = MaterialTheme.clear.color
addSubview(buttonsContainer!)
}
prepareCard()
} else {
buttonsContainer?.removeFromSuperview()
}
}
}
/**
:name: rightButtons
*/
public var rightButtons: Array<MaterialButton>? {
didSet {
if let b = rightButtons {
if nil == buttonsContainer {
buttonsContainer = UIView()
buttonsContainer!.setTranslatesAutoresizingMaskIntoConstraints(false)
buttonsContainer!.backgroundColor = MaterialTheme.clear.color
addSubview(buttonsContainer!)
}
prepareCard()
} else {
buttonsContainer?.removeFromSuperview()
}
prepareCard()
}
}
......@@ -131,7 +179,7 @@ public class ImageCard : MaterialCard {
internal override func prepareView() {
super.prepareView()
prepareShadow()
backgroundColor = MaterialTheme.clear.color
backgroundColor = MaterialTheme.blueGrey.darken1
}
//
......@@ -139,6 +187,7 @@ public class ImageCard : MaterialCard {
//
internal override func prepareCard() {
super.prepareCard()
// deactivate and clear all constraints
NSLayoutConstraint.deactivateConstraints(layoutConstraints)
layoutConstraints.removeAll(keepCapacity: false)
......@@ -146,67 +195,74 @@ public class ImageCard : MaterialCard {
// detect all components and create constraints
var verticalFormat: String = "V:|"
if nil != imageView {
layoutConstraints += Layout.constraint("H:|[imageView]|", options: nil, metrics: nil, views: ["imageView": imageView!])
verticalFormat += "[imageView(200)]"
views["imageView"] = imageView!
}
// title
if nil != titleLabel {
if nil == imageView {
layoutConstraints += Layout.constraint("H:|-(16)-[titleLabel]-(16)-|", options: nil, metrics: nil, views: ["titleLabel": titleLabel!])
verticalFormat += "-(16)-[titleLabel(22)]"
} else {
layoutConstraints += Layout.constraint("H:[titleLabel]-(16)-|", options: nil, metrics: nil, views: ["titleLabel": titleLabel!])
Layout.alignFromBottomLeft(imageView!, child: titleLabel!, bottom: 16, left: 16)
}
views["titleLabel"] = titleLabel!
if nil != titleLabelContainer && nil != titleLabel {
// container
layoutConstraints += Layout.constraint("H:|[titleLabelContainer]|", options: nil, metrics: nil, views: ["titleLabelContainer": titleLabelContainer!])
verticalFormat += "[titleLabelContainer]"
views["titleLabelContainer"] = titleLabelContainer!
// text
titleLabelContainer!.addConstraints(Layout.constraint("H:|-(verticalSpace)-[titleLabel]-(verticalSpace)-|", options: nil, metrics: ["verticalSpace": verticalSpace], views: ["titleLabel": titleLabel!]))
titleLabelContainer!.addConstraints(Layout.constraint("V:|-(verticalSpace)-[titleLabel(height)]-(verticalSpace)-|", options: nil, metrics: ["verticalSpace": verticalSpace, "height": titleLabel!.font.pointSize], views: ["titleLabel": titleLabel!]))
}
// details
if nil != detailTextContainer && nil != detailTextLabel {
// detail
if nil != detailLabelContainer && nil != detailLabel {
// container
layoutConstraints += Layout.constraint("H:|[detailTextContainer]|", options: nil, metrics: nil, views: ["detailTextContainer": detailTextContainer!])
verticalFormat += "-(0)-[detailTextContainer]"
views["detailTextContainer"] = detailTextContainer!
layoutConstraints += Layout.constraint("H:|[detailLabelContainer]|", options: nil, metrics: nil, views: ["detailLabelContainer": detailLabelContainer!])
verticalFormat += "[detailLabelContainer]"
views["detailLabelContainer"] = detailLabelContainer!
// text
layoutConstraints += Layout.constraint("H:|-(16)-[detailTextLabel]-(16)-|", options: nil, metrics: nil, views: ["detailTextLabel": detailTextLabel!])
layoutConstraints += Layout.constraint("V:|-(16)-[detailTextLabel(<=128)]-(16)-|", options: nil, metrics: nil, views: ["detailTextLabel": detailTextLabel!])
views["detailTextLabel"] = detailTextLabel!
detailLabelContainer!.addConstraints(Layout.constraint("H:|-(verticalSpace)-[detailLabel]-(verticalSpace)-|", options: nil, metrics: ["verticalSpace": verticalSpace], views: ["detailLabel": detailLabel!]))
detailLabelContainer!.addConstraints(Layout.constraint("V:|-(verticalSpace)-[detailLabel(<=maximumDetailHeight)]-(verticalSpace)-|", options: nil, metrics: ["verticalSpace": verticalSpace, "maximumDetailHeight": maximumDetailHeight], views: ["detailLabel": detailLabel!]))
}
if nil != buttons && nil != buttonsContainer {
if nil != buttonsContainer && (nil != leftButtons || nil != rightButtons) {
// divider
if nil != divider {
layoutConstraints += Layout.constraint("H:|[divider]|", options: nil, metrics: nil, views: ["divider": divider!])
views["divider"] = divider!
verticalFormat += "-(0)-[divider(1)]"
verticalFormat += "[divider(1)]"
}
//container
layoutConstraints += Layout.constraint("H:|[buttonsContainer]|", options: nil, metrics: nil, views: ["buttonsContainer": buttonsContainer!])
verticalFormat += "-(0)-[buttonsContainer]|"
verticalFormat += "[buttonsContainer]"
views["buttonsContainer"] = buttonsContainer!
// buttons
var horizontalFormat: String = "H:|"
var buttonViews: Dictionary<String, AnyObject> = Dictionary<String, AnyObject>()
for var i: Int = 0, l: Int = buttons!.count; i < l; ++i {
let button: MaterialButton = buttons![i]
buttonsContainer!.addSubview(button)
buttonViews["button\(i)"] = button
views["button\(i)"] = button as AnyObject
horizontalFormat += "-(8)-[button\(i)]"
layoutConstraints += Layout.constraint("V:|-(8)-[button\(i)]-(8)-|", options: nil, metrics: nil, views: views)
// leftButtons
if nil != leftButtons {
var horizontalFormat: String = "H:|"
var buttonViews: Dictionary<String, AnyObject> = Dictionary<String, AnyObject>()
for var i: Int = 0, l: Int = leftButtons!.count; i < l; ++i {
let button: MaterialButton = leftButtons![i]
buttonsContainer!.addSubview(button)
buttonViews["button\(i)"] = button
horizontalFormat += "-(verticalSpace)-[button\(i)]"
Layout.expandToParentVerticallyWithPad(buttonsContainer!, child: button, top: verticalSpace, bottom: verticalSpace)
}
buttonsContainer!.addConstraints(Layout.constraint(horizontalFormat, options: nil, metrics: ["verticalSpace": verticalSpace], views: buttonViews))
}
layoutConstraints += Layout.constraint(horizontalFormat, options: nil, metrics: nil, views: buttonViews)
} else {
verticalFormat += "|"
// rightButtons
if nil != rightButtons {
var horizontalFormat: String = "H:"
var buttonViews: Dictionary<String, AnyObject> = Dictionary<String, AnyObject>()
for var i: Int = 0, l: Int = rightButtons!.count; i < l; ++i {
let button: MaterialButton = rightButtons![i]
buttonsContainer!.addSubview(button)
buttonViews["button\(i)"] = button
horizontalFormat += "[button\(i)]-(verticalSpace)-"
Layout.expandToParentVerticallyWithPad(buttonsContainer!, child: button, top: verticalSpace, bottom: verticalSpace)
}
buttonsContainer!.addConstraints(Layout.constraint(horizontalFormat + "|", options: nil, metrics: ["verticalSpace": verticalSpace], views: buttonViews))
}
}
verticalFormat += "|"
// combine constraints
if 0 < layoutConstraints.count {
layoutConstraints += Layout.constraint(verticalFormat, options: nil, metrics: nil, views: views)
......@@ -214,3 +270,23 @@ public class ImageCard : MaterialCard {
}
}
}
public func ==(lhs: ImageCard, rhs: ImageCard) -> Bool {
return lhs.tag == rhs.tag
}
public func <=(lhs: ImageCard, rhs: ImageCard) -> Bool {
return lhs.tag <= rhs.tag
}
public func >=(lhs: ImageCard, rhs: ImageCard) -> Bool {
return lhs.tag >= rhs.tag
}
public func >(lhs: ImageCard, rhs: ImageCard) -> Bool {
return lhs.tag > rhs.tag
}
public func <(lhs: ImageCard, rhs: ImageCard) -> Bool {
return lhs.tag < rhs.tag
}
......@@ -85,7 +85,7 @@ public struct Layout {
/**
:name: expandToParentWithPad
*/
public static func expandToParentWithPad(parent: UIView, child: UIView, left: CGFloat = 0, bottom: CGFloat = 0, right: CGFloat = 0, top: CGFloat = 0) {
public static func expandToParentWithPad(parent: UIView, child: UIView, top: CGFloat = 0, left: CGFloat = 0, bottom: CGFloat = 0, right: CGFloat = 0) {
let views: Dictionary<String, AnyObject> = ["child" : child]
parent.addConstraints(constraint("H:|-(left)-[child]-(right)-|", options: nil, metrics: ["left": left, "right": right], views: views))
parent.addConstraints(constraint("V:|-(top)-[child]-(bottom)-|", options: nil, metrics: ["bottom": bottom, "top": top], views: views))
......
......@@ -20,22 +20,22 @@ import UIKit
public struct Roboto {
public static func lightWithSize(size: CGFloat) -> UIFont {
if let light = UIFont(name: "Roboto-Light", size: size) {
return light
if let f = UIFont(name: "Roboto-Light", size: size) {
return f
}
return UIFont.systemFontOfSize(size)
}
public static func mediumWithSize(size: CGFloat) -> UIFont {
if let light = UIFont(name: "Roboto-Medium", size: size) {
return light
if let f = UIFont(name: "Roboto-Medium", size: size) {
return f
}
return UIFont.systemFontOfSize(size)
}
public static func regularWithSize(size: CGFloat) -> UIFont {
if let light = UIFont(name: "Roboto-Regular", size: size) {
return light
if let f = UIFont(name: "Roboto-Regular", size: size) {
return f
}
return UIFont.systemFontOfSize(size)
}
......
......@@ -66,7 +66,7 @@ public class TextView: UITextView {
:name: placeholderColor
:description: The placeholder color.
*/
public var placeholderColor: UIColor = MaterialTheme.blueGrey.lighten3 {
public var placeholderColor: UIColor = MaterialTheme.blueGrey.lighten1 {
didSet {
label.textColor = placeholderColor
}
......@@ -143,7 +143,7 @@ public class TextView: UITextView {
backgroundColor = MaterialTheme.clear.color
textColor = MaterialTheme.black.color
label.font = font
label.textColor = MaterialTheme.blueGrey.lighten3
label.textColor = placeholderColor
label.textAlignment = textAlignment
label.text = placeholder
label.numberOfLines = 0
......
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