Commit 4ee81dce by Daniel Dahan

development: progression commit on Cards

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