Commit ca1719c3 by Daniel Dahan

development: updated Card internals

parent 141e5838
...@@ -51,6 +51,7 @@ class ViewController: UIViewController { ...@@ -51,6 +51,7 @@ class ViewController: UIViewController {
private func prepareTitleBar() { private func prepareTitleBar() {
titleBar = Toolbar() titleBar = Toolbar()
titleBar.title = "Title" titleBar.title = "Title"
titleBar.detail = "Detail Description"
titleBar.backgroundColor = nil titleBar.backgroundColor = nil
} }
...@@ -75,7 +76,6 @@ class ViewController: UIViewController { ...@@ -75,7 +76,6 @@ class ViewController: UIViewController {
private func prepareCard() { private func prepareCard() {
let card = Card() let card = Card()
card.pulseAnimation = .pointWithBacking card.pulseAnimation = .pointWithBacking
card.titleBar = titleBar card.titleBar = titleBar
card.contentView = contentView card.contentView = contentView
card.bottomBar = bottomBar card.bottomBar = bottomBar
......
...@@ -43,6 +43,7 @@ open class Card: PulseView { ...@@ -43,6 +43,7 @@ open class Card: PulseView {
} }
set(value) { set(value) {
grid.contentEdgeInsetsPreset = value grid.contentEdgeInsetsPreset = value
layoutSubviews()
} }
} }
...@@ -54,6 +55,7 @@ open class Card: PulseView { ...@@ -54,6 +55,7 @@ open class Card: PulseView {
} }
set(value) { set(value) {
grid.contentEdgeInsets = value grid.contentEdgeInsets = value
layoutSubviews()
} }
} }
...@@ -72,6 +74,7 @@ open class Card: PulseView { ...@@ -72,6 +74,7 @@ open class Card: PulseView {
} }
set(value) { set(value) {
grid.interimSpace = value grid.interimSpace = value
layoutSubviews()
} }
} }
...@@ -143,13 +146,8 @@ open class Card: PulseView { ...@@ -143,13 +146,8 @@ open class Card: PulseView {
v.removeFromSuperview() v.removeFromSuperview()
} }
var format = "V:|-(insetTop)" var format = "V:|-(top)"
var views = [String: Any]() var views = [String: Any]()
var metrics = [String: Any]()
metrics["insetTop"] = contentEdgeInsets.top
metrics["insetBottom"] = contentEdgeInsets.bottom
metrics["interimSpace"] = interimSpace
if let v = titleBar { if let v = titleBar {
format += "-[titleBar]" format += "-[titleBar]"
...@@ -158,22 +156,27 @@ open class Card: PulseView { ...@@ -158,22 +156,27 @@ open class Card: PulseView {
} }
if let v = contentView { if let v = contentView {
format += "-(interimSpace)-[contentView]" format += (nil == titleBar ? "" : "-(interimSpace)") + "-[contentView]"
views["contentView"] = v views["contentView"] = v
layout(v).horizontally(left: contentEdgeInsets.left, right: contentEdgeInsets.right) layout(v).horizontally(left: contentEdgeInsets.left, right: contentEdgeInsets.right)
} }
if let v = bottomBar { if let v = bottomBar {
format += "-(interimSpace)-[bottomBar]" format += (nil == titleBar && nil == contentView ? "" : "-(interimSpace)") + "-[bottomBar]"
views["bottomBar"] = v views["bottomBar"] = v
layout(v).horizontally(left: contentEdgeInsets.left, right: contentEdgeInsets.right) layout(v).horizontally(left: contentEdgeInsets.left, right: contentEdgeInsets.right)
} }
format += "-(insetBottom)-|" guard 0 < views.count else {
return
if 0 < views.count {
addConstraints(Layout.constraint(format: format, options: [], metrics: metrics, views: views))
} }
var metrics = [String: Any]()
metrics["top"] = contentEdgeInsets.top
metrics["bottom"] = contentEdgeInsets.bottom
metrics["interimSpace"] = interimSpace
addConstraints(Layout.constraint(format: "\(format)-(bottom)-|", options: [], metrics: metrics, views: views))
} }
/** /**
...@@ -186,10 +189,10 @@ open class Card: PulseView { ...@@ -186,10 +189,10 @@ open class Card: PulseView {
open override func prepare() { open override func prepare() {
super.prepare() super.prepare()
depthPreset = .depth1 depthPreset = .depth1
pulseAnimation = .none
contentEdgeInsetsPreset = .square1
interimSpacePreset = .interimSpace3 interimSpacePreset = .interimSpace3
contentEdgeInsetsPreset = .wideRectangle3
cornerRadiusPreset = .cornerRadius1 cornerRadiusPreset = .cornerRadius1
pulseAnimation = .none
} }
/** /**
......
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