Commit 4ee81dce by Daniel Dahan

development: progression commit on Cards

parent 7aee3d67
...@@ -292,7 +292,7 @@ extension Animation { ...@@ -292,7 +292,7 @@ extension Animation {
animation.toValue = path animation.toValue = path
animation.fillMode = AnimationFillModeToValue(mode: .forwards) animation.fillMode = AnimationFillModeToValue(mode: .forwards)
animation.isRemovedOnCompletion = false animation.isRemovedOnCompletion = false
animation.timingFunction = CAMediaTimingFunction(name: kCAMediaTimingFunctionEaseInEaseOut) animation.timingFunction = CAMediaTimingFunction(name: kCAMediaTimingFunctionLinear)
if let v = duration { if let v = duration {
animation.duration = v animation.duration = v
} }
......
...@@ -195,9 +195,6 @@ open class Card: PulseView { ...@@ -195,9 +195,6 @@ open class Card: PulseView {
open func reload() { open func reload() {
// Clear constraints so new ones do not conflict. // Clear constraints so new ones do not conflict.
container.removeConstraints(container.constraints) container.removeConstraints(container.constraints)
for v in container.subviews {
v.removeFromSuperview()
}
var format = "V:|" var format = "V:|"
var views = [String: Any]() var views = [String: Any]()
...@@ -209,7 +206,7 @@ open class Card: PulseView { ...@@ -209,7 +206,7 @@ open class Card: PulseView {
format += "-(toolbarTop)-[toolbar]-(toolbarBottom)" format += "-(toolbarTop)-[toolbar]-(toolbarBottom)"
views["toolbar"] = v views["toolbar"] = v
container.layout(v).horizontally(left: toolbarEdgeInsets.left, right: toolbarEdgeInsets.right).height(v.height) container.layout(v).horizontally(left: toolbarEdgeInsets.left, right: toolbarEdgeInsets.right)
} }
if let v = contentView { if let v = contentView {
...@@ -231,6 +228,8 @@ open class Card: PulseView { ...@@ -231,6 +228,8 @@ open class Card: PulseView {
} }
if let v = bottomBar { if let v = bottomBar {
metrics["bottomBarBottom"] = bottomBarEdgeInsets.bottom
if nil != contentView { if nil != contentView {
metrics["contentViewBottom"] = (metrics["contentViewBottom"] as! CGFloat) + bottomBarEdgeInsets.top metrics["contentViewBottom"] = (metrics["contentViewBottom"] as! CGFloat) + bottomBarEdgeInsets.top
format += "-[bottomBar]-(bottomBarBottom)" format += "-[bottomBar]-(bottomBarBottom)"
...@@ -239,18 +238,18 @@ open class Card: PulseView { ...@@ -239,18 +238,18 @@ open class Card: PulseView {
format += "-[bottomBar]-(bottomBarBottom)" format += "-[bottomBar]-(bottomBarBottom)"
} else { } else {
metrics["bottomBarTop"] = bottomBarEdgeInsets.top metrics["bottomBarTop"] = bottomBarEdgeInsets.top
format += "-(bottomBarTop)-[bottomBar]" format += "-(bottomBarTop)-[bottomBar]-(bottomBarBottom)"
} }
views["bottomBar"] = v views["bottomBar"] = v
container.layout(v).horizontally(left: bottomBarEdgeInsets.left, right: bottomBarEdgeInsets.right).height(v.height).bottom(bottomBarEdgeInsets.bottom) container.layout(v).horizontally(left: bottomBarEdgeInsets.left, right: bottomBarEdgeInsets.right)
} }
guard 0 < views.count else { guard 0 < views.count else {
return return
} }
container.addConstraints(Layout.constraint(format: "\(format)|", options: [], metrics: metrics, views: views)) container.addConstraints(Layout.constraint(format: "\(format)-|", options: [], metrics: metrics, views: views))
} }
/** /**
......
...@@ -121,6 +121,7 @@ open class CollectionViewLayout: UICollectionViewLayout { ...@@ -121,6 +121,7 @@ open class CollectionViewLayout: UICollectionViewLayout {
guard let dataSource = collectionView?.dataSource as? CollectionViewDataSource else { guard let dataSource = collectionView?.dataSource as? CollectionViewDataSource else {
return return
} }
prepareLayoutForItems(dataSourceItems: dataSource.dataSourceItems) prepareLayoutForItems(dataSourceItems: dataSource.dataSourceItems)
} }
......
...@@ -56,6 +56,10 @@ open class ImageCard: Card { ...@@ -56,6 +56,10 @@ open class ImageCard: Card {
@IBInspectable @IBInspectable
open var imageView: UIImageView? { open var imageView: UIImageView? {
didSet { didSet {
oldValue?.removeFromSuperview()
if let v = imageView {
container.addSubview(v)
}
layoutSubviews() layoutSubviews()
} }
} }
...@@ -68,71 +72,16 @@ open class ImageCard: Card { ...@@ -68,71 +72,16 @@ open class ImageCard: Card {
} }
open override func reload() { open override func reload() {
guard let iv = imageView else { var h: CGFloat = 0
super.reload()
return
}
// Clear constraints so new ones do not conflict.
container.removeConstraints(container.constraints)
for v in container.subviews {
v.removeFromSuperview()
}
var format = "V:|"
var views = [String: Any]()
var metrics = [String: Any]()
metrics["imageViewTop"] = imageViewEdgeInsets.top
metrics["imageViewBottom"] = imageViewEdgeInsets.bottom
format += "-(imageViewTop)-[imageView]-(imageViewBottom)"
views["imageView"] = iv
container.layout(iv).horizontally(left: imageViewEdgeInsets.left, right: imageViewEdgeInsets.right)
iv.grid.reload() h = prepare(view: imageView, with: imageViewEdgeInsets, from: h)
iv.divider.reload()
if let v = toolbar { h = prepare(view: toolbar, with: toolbarEdgeInsets, from: h)
iv.layoutIfNeeded()
container.layout(v)
.horizontally(left: toolbarEdgeInsets.left, right: toolbarEdgeInsets.right)
.top(.top == toolbarAlignment ? toolbarEdgeInsets.top : iv.height - v.height - toolbarEdgeInsets.bottom)
.height(v.height)
}
if let v = contentView {
metrics["imageViewBottom"] = (metrics["imageViewBottom"] as! CGFloat) + contentViewEdgeInsets.top
metrics["contentViewBottom"] = contentViewEdgeInsets.bottom
format += "-[contentView]-(contentViewBottom)"
views["contentView"] = v
container.layout(v).horizontally(left: contentViewEdgeInsets.left, right: contentViewEdgeInsets.right)
v.grid.reload()
v.divider.reload()
}
if let v = bottomBar { h = prepare(view: contentView, with: contentViewEdgeInsets, from: h)
metrics["bottomBarBottom"] = bottomBarEdgeInsets.bottom h = prepare(view: bottomBar, with: bottomBarEdgeInsets, from: h)
if nil != contentView {
metrics["contentViewBottom"] = (metrics["contentViewBottom"] as! CGFloat) + bottomBarEdgeInsets.top
format += "-[bottomBar]-(bottomBarBottom)"
} else {
metrics["imageViewBottom"] = (metrics["imageViewBottom"] as! CGFloat) + bottomBarEdgeInsets.top
format += "-[bottomBar]-(bottomBarBottom)"
}
views["bottomBar"] = v
container.layout(v).horizontally(left: bottomBarEdgeInsets.left, right: bottomBarEdgeInsets.right).height(v.height)
}
guard 0 < views.count else {
return
}
container.addConstraints(Layout.constraint(format: "\(format)-|", options: [], metrics: metrics, views: views)) container.height = h
height = h
} }
} }
...@@ -315,13 +315,15 @@ extension CALayer { ...@@ -315,13 +315,15 @@ extension CALayer {
guard isShadowPathAutoSizing else { guard isShadowPathAutoSizing else {
return return
} }
z
if .none == depthPreset { if .none == depthPreset {
shadowPath = nil shadowPath = nil
} else if nil == shadowPath { } else if nil == shadowPath {
shadowPath = UIBezierPath(roundedRect: bounds, cornerRadius: cornerRadius).cgPath shadowPath = UIBezierPath(roundedRect: bounds, cornerRadius: cornerRadius).cgPath
} else { } else {
animate(animation: Animation.shadowPath(path: UIBezierPath(roundedRect: bounds, cornerRadius: cornerRadius).cgPath, duration: 0)) let a = Animation.shadowPath(path: UIBezierPath(roundedRect: bounds, cornerRadius: cornerRadius).cgPath)
a.fromValue = shadowPath
animate(animation: a)
} }
} }
} }
...@@ -64,7 +64,7 @@ open class MenuController: RootController { ...@@ -64,7 +64,7 @@ open class MenuController: RootController {
guard let s = self else { guard let s = self else {
return return
} }
s.rootViewController.view.alpha = 0.25 s.rootViewController.view.alpha = 0.15
}) })
menu.open { [completion = completion] (view) in menu.open { [completion = completion] (view) in
completion?(view) completion?(view)
......
...@@ -30,7 +30,6 @@ ...@@ -30,7 +30,6 @@
import UIKit import UIKit
@available(iOS 9.0, *)
open class PresenterCard: Card { open class PresenterCard: Card {
/// A preset wrapper around presenterViewEdgeInsets. /// A preset wrapper around presenterViewEdgeInsets.
open var presenterViewEdgeInsetsPreset = EdgeInsetsPreset.none { open var presenterViewEdgeInsetsPreset = EdgeInsetsPreset.none {
...@@ -61,14 +60,14 @@ open class PresenterCard: Card { ...@@ -61,14 +60,14 @@ open class PresenterCard: Card {
} }
open override func reload() { open override func reload() {
var top: CGFloat = 0 var h: CGFloat = 0
top = prepare(view: toolbar, with: toolbarEdgeInsets, from: top) h = prepare(view: toolbar, with: toolbarEdgeInsets, from: h)
top = prepare(view: presenterView, with: presenterViewEdgeInsets, from: top) h = prepare(view: presenterView, with: presenterViewEdgeInsets, from: h)
top = prepare(view: contentView, with: contentViewEdgeInsets, from: top) h = prepare(view: contentView, with: contentViewEdgeInsets, from: h)
top = prepare(view: bottomBar, with: bottomBarEdgeInsets, from: top) h = prepare(view: bottomBar, with: bottomBarEdgeInsets, from: h)
container.height = top container.height = h
height = top height = h
} }
} }
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