Commit b45ffad6 by Daniel Dahan

updated Cards for final release

parent 0efb8f93
......@@ -52,10 +52,7 @@ class ViewController: UIViewController {
prepareMenuButton()
prepareFavoriteButton()
prepareShareButton()
prepareTitleLabel()
prepareBar()
layoutSubviews()
}
private func prepareMenuButton() {
......@@ -73,24 +70,17 @@ class ViewController: UIViewController {
shareButton.pulseColor = Color.white
}
private func prepareTitleLabel() {
titleLabel = UILabel()
titleLabel.text = "Title"
titleLabel.font = RobotoFont.bold(with: 17)
titleLabel.textColor = Color.white
}
private func prepareBar() {
bar = Bar()
bar.contentEdgeInsetsPreset = .square1
bar.backgroundColor = Color.blue.base
bar.contentView.cornerRadiusPreset = .cornerRadius1
bar.contentView.backgroundColor = Color.blue.lighten3
bar.leftViews = [menuButton]
bar.rightViews = [favoriteButton, shareButton]
}
private func layoutSubviews() {
view.layout(bar).horizontally().center()
bar.contentView.layout(titleLabel).edges()
}
}
......@@ -32,17 +32,16 @@ import UIKit
import Material
class ViewController: UIViewController {
/// Card reference.
private lazy var card: Card = Card()
private var card: Card!
/// Conent area.
private var contentView: UILabel!
/// Bottom Bar views.
private var bottomBar: Bar!
private var favoriteButton: FlatButton!
private var shareButton: FlatButton!
private var starButton: FlatButton!
private var dateFormatter: DateFormatter!
private var dateLabel: UILabel!
private var favoriteButton: IconButton!
/// Toolbar views.
private var toolbar: Toolbar!
......@@ -51,11 +50,11 @@ class ViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
view.backgroundColor = Color.white
view.backgroundColor = Color.grey.lighten5
prepareDateFormatter()
prepareDateLabel()
prepareFavoriteButton()
prepareShareButton()
prepareStarButton()
prepareMoreButton()
prepareAuthorView()
prepareToolbar()
......@@ -64,27 +63,25 @@ class ViewController: UIViewController {
prepareImageCard()
}
override func viewWillLayoutSubviews() {
super.viewWillLayoutSubviews()
private func prepareDateFormatter() {
dateFormatter = DateFormatter()
dateFormatter.dateStyle = .medium
dateFormatter.timeStyle = .none
}
private func prepareDateLabel() {
dateLabel = UILabel()
dateLabel.font = RobotoFont.regular(with: 12)
dateLabel.textColor = Color.blueGrey.base
dateLabel.text = dateFormatter.string(from: Date.distantFuture)
}
private func prepareFavoriteButton() {
favoriteButton = FlatButton(image: Icon.favorite, tintColor: Color.grey.base)
favoriteButton = IconButton(image: Icon.favorite, tintColor: Color.red.base)
favoriteButton.grid.columns = 4
}
private func prepareShareButton() {
shareButton = FlatButton(image: Icon.cm.share, tintColor: Color.grey.base)
shareButton.grid.columns = 4
}
private func prepareStarButton() {
starButton = FlatButton(image: Icon.cm.star, tintColor: Color.grey.base)
starButton.grid.columns = 4
}
private func prepareMoreButton() {
moreButton = IconButton(image: Icon.cm.moreVertical, tintColor: Color.grey.base)
moreButton = IconButton(image: Icon.cm.moreVertical, tintColor: Color.blueGrey.base)
}
private func prepareAuthorView() {
......@@ -104,38 +101,39 @@ class ViewController: UIViewController {
toolbar.detail = "Build Beautiful Software"
toolbar.detailLabel.textAlignment = .left
toolbar.detailLabel.textColor = Color.blueGrey.base
toolbar.contentEdgeInsetsPreset = .square2
toolbar.leftViews.append(authorView)
toolbar.rightViews.append(moreButton)
toolbar.leftViews = [authorView]
toolbar.rightViews = [moreButton]
}
private func prepareContentView() {
contentView = UILabel()
contentView.numberOfLines = 0
contentView.text = "It’s been a while, have you read any new books lately?"
contentView.text = "Material is an animation and graphics framework that is the foundation for creating beautiful applications."
contentView.font = RobotoFont.regular(with: 14)
}
private func prepareBottomBar() {
bottomBar = Bar()
bottomBar.backgroundColor = Color.grey.lighten4
bottomBar.contentEdgeInsetsPreset = .square1
bottomBar.cornerRadiusPreset = .cornerRadius1
bottomBar.dividerColor = Color.grey.lighten3
bottomBar.dividerAlignment = .top
bottomBar.contentView.grid.views = [favoriteButton, shareButton, starButton]
bottomBar.leftViews = [dateLabel]
bottomBar.rightViews = [favoriteButton]
}
private func prepareImageCard() {
card = Card()
card.cornerRadiusPreset = .cornerRadius1
card.toolbar = toolbar
card.toolbarEdgeInsetsPreset = .square1
card.contentView = contentView
card.contentViewEdgeInsetsPreset = .square3
card.bottomBar = bottomBar
card.cornerRadiusPreset = .cornerRadius1
card.contentEdgeInsetsPreset = .square3
card.bottomBarEdgeInsetsPreset = .square1
view.layout(card).horizontally(left: 20, right: 20).center()
}
......
......@@ -32,6 +32,9 @@ import UIKit
import Material
class ViewController: UIViewController {
private var card: ImageCard!
/// Conent area.
private var imageView: UIImageView!
private var contentView: UILabel!
......@@ -47,7 +50,7 @@ class ViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
view.backgroundColor = Color.white
view.backgroundColor = Color.grey.lighten5
prepareImageView()
prepareFavoriteButton()
......@@ -69,17 +72,17 @@ class ViewController: UIViewController {
}
private func prepareFavoriteButton() {
favoriteButton = FlatButton(image: Icon.favorite, tintColor: Color.grey.base)
favoriteButton = FlatButton(image: Icon.favorite, tintColor: Color.blueGrey.base)
favoriteButton.grid.columns = 4
}
private func prepareShareButton() {
shareButton = FlatButton(image: Icon.cm.share, tintColor: Color.grey.base)
shareButton = FlatButton(image: Icon.cm.share, tintColor: Color.blueGrey.base)
shareButton.grid.columns = 4
}
private func prepareStarButton() {
starButton = FlatButton(image: Icon.cm.star, tintColor: Color.grey.base)
starButton = FlatButton(image: Icon.cm.star, tintColor: Color.blueGrey.base)
starButton.grid.columns = 4
}
......@@ -92,47 +95,38 @@ class ViewController: UIViewController {
toolbar.backgroundColor = nil
toolbar.title = "CosmicMind"
toolbar.titleLabel.textAlignment = .left
toolbar.titleLabel.textColor = Color.white
toolbar.detail = "Build Beautiful Software"
toolbar.detailLabel.textAlignment = .left
toolbar.detailLabel.textColor = Color.white
let insets = EdgeInsetsPresetToValue(preset: .square3)
toolbar.height += insets.top + insets.bottom
toolbar.contentEdgeInsetsPreset = .square3
toolbar.rightViews.append(moreButton)
}
private func prepareContentView() {
contentView = UILabel()
contentView.numberOfLines = 0
contentView.text = "It’s been a while, have you read any new books lately?"
contentView.text = "Material is an animation and graphics framework that is the foundation for creating beautiful applications."
contentView.font = RobotoFont.regular(with: 14)
}
private func prepareBottomBar() {
bottomBar = Bar()
bottomBar.backgroundColor = Color.grey.lighten4
bottomBar.contentEdgeInsetsPreset = .square1
bottomBar.cornerRadiusPreset = .cornerRadius1
bottomBar.dividerColor = Color.grey.lighten3
bottomBar.dividerAlignment = .top
bottomBar.backgroundColor = nil
bottomBar.contentView.grid.views = [favoriteButton, shareButton, starButton]
}
private func prepareImageCard() {
let card = ImageCard()
card = ImageCard()
card.imageView = imageView
card.toolbar = toolbar
card.toolbarEdgeInsetsPreset = .square3
card.contentView = contentView
card.contentViewEdgeInsetsPreset = .square3
card.bottomBar = bottomBar
card.cornerRadiusPreset = .cornerRadius1
card.contentEdgeInsetsPreset = .square3
view.layout(card).horizontally(left: 20, right: 20).center()
}
......
{
"images" : [
{
"idiom" : "universal",
"filename" : "frontier.jpg",
"scale" : "1x"
},
{
"idiom" : "universal",
"scale" : "2x"
},
{
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
\ No newline at end of file
This image diff could not be displayed because it is too large. You can view the blob instead.
......@@ -32,115 +32,117 @@ import UIKit
import Material
class ViewController: UIViewController {
private var imageView: UIImageView!
private var card: PresenterCard!
/// Conent area.
private var presenterView: UIImageView!
private var contentView: UILabel!
/// Bottom Bar views.
private var bottomBar: Bar!
private var favoriteButton: FlatButton!
private var shareButton: FlatButton!
private var starButton: FlatButton!
private var dateFormatter: DateFormatter!
private var dateLabel: UILabel!
private var favoriteButton: IconButton!
private var shareButton: IconButton!
/// Toolbar views.
private var toolbar: Toolbar!
private var moreButton: IconButton!
private var authorView: View!
override func viewDidLoad() {
super.viewDidLoad()
view.backgroundColor = Color.white
view.backgroundColor = Color.grey.lighten5
prepareImageView()
preparePresenterView()
prepareDateFormatter()
prepareDateLabel()
prepareFavoriteButton()
prepareShareButton()
prepareStarButton()
prepareMoreButton()
prepareAuthorView()
prepareToolbar()
prepareContentView()
prepareBottomBar()
prepareImageCard()
}
private func prepareImageView() {
imageView = UIImageView()
imageView.image = UIImage(named: "frontier.jpg")?.resize(toWidth: view.width)
imageView.clipsToBounds = true
imageView.contentMode = .scaleAspectFill
private func preparePresenterView() {
presenterView = UIImageView()
presenterView.image = UIImage(named: "dreamer.jpg")?.resize(toWidth: view.width)
presenterView.clipsToBounds = true
presenterView.contentMode = .scaleAspectFill
}
private func prepareDateFormatter() {
dateFormatter = DateFormatter()
dateFormatter.dateStyle = .medium
dateFormatter.timeStyle = .none
}
private func prepareDateLabel() {
dateLabel = UILabel()
dateLabel.font = RobotoFont.regular(with: 12)
dateLabel.textColor = Color.blueGrey.base
dateLabel.textAlignment = .center
dateLabel.text = dateFormatter.string(from: Date.distantFuture)
}
private func prepareFavoriteButton() {
favoriteButton = FlatButton(image: Icon.favorite, tintColor: Color.grey.base)
favoriteButton = IconButton(image: Icon.favorite, tintColor: Color.red.base)
favoriteButton.grid.columns = 4
}
private func prepareShareButton() {
shareButton = FlatButton(image: Icon.cm.share, tintColor: Color.grey.base)
shareButton = IconButton(image: Icon.cm.share, tintColor: Color.blueGrey.base)
shareButton.grid.columns = 4
}
private func prepareStarButton() {
starButton = FlatButton(image: Icon.cm.star, tintColor: Color.grey.base)
starButton.grid.columns = 4
}
private func prepareMoreButton() {
moreButton = IconButton(image: Icon.cm.moreVertical, tintColor: Color.grey.base)
}
private func prepareAuthorView() {
authorView = View()
authorView.width = 24
authorView.image = UIImage(named: "CosmicMind")
authorView.backgroundColor = nil
authorView.contentsGravityPreset = .ResizeAspect
moreButton = IconButton(image: Icon.cm.moreHorizontal, tintColor: Color.blueGrey.base)
}
private func prepareToolbar() {
toolbar = Toolbar()
toolbar.backgroundColor = nil
toolbar.title = "CosmicMind"
toolbar.title = "Material"
toolbar.titleLabel.textAlignment = .left
toolbar.detail = "Build Beautiful Software"
toolbar.detailLabel.textAlignment = .left
toolbar.detailLabel.textColor = Color.blueGrey.base
let insets = EdgeInsetsPresetToValue(preset: .square2)
toolbar.height += insets.top + insets.bottom
toolbar.contentEdgeInsetsPreset = .square2
toolbar.leftViews.append(authorView)
toolbar.rightViews.append(moreButton)
toolbar.rightViews = [moreButton]
}
private func prepareContentView() {
contentView = UILabel()
contentView.numberOfLines = 0
contentView.text = "It’s been a while, have you read any new books lately?"
contentView.text = "Material is an animation and graphics framework that is the foundation for creating beautiful applications."
contentView.font = RobotoFont.regular(with: 14)
}
private func prepareBottomBar() {
bottomBar = Bar()
bottomBar.backgroundColor = Color.grey.lighten4
bottomBar.contentEdgeInsetsPreset = .square1
bottomBar.cornerRadiusPreset = .cornerRadius1
bottomBar.dividerColor = Color.grey.lighten3
bottomBar.dividerAlignment = .top
bottomBar.backgroundColor = nil
bottomBar.contentView.grid.views = [favoriteButton, shareButton, starButton]
bottomBar.leftViews = [favoriteButton]
bottomBar.rightViews = [shareButton]
bottomBar.contentView.grid.views = [dateLabel]
}
private func prepareImageCard() {
let card = PresenterCard()
card.presenterView = imageView
card = PresenterCard()
card.cornerRadiusPreset = .cornerRadius1
card.toolbar = toolbar
card.toolbarEdgeInsetsPreset = .square2
card.presenterView = presenterView
card.contentView = contentView
card.contentViewEdgeInsetsPreset = .square3
card.bottomBar = bottomBar
card.cornerRadiusPreset = .cornerRadius1
card.contentEdgeInsetsPreset = .square3
card.bottomBarEdgeInsetsPreset = .square1
view.layout(card).horizontally(left: 20, right: 20).center()
}
......
......@@ -81,25 +81,25 @@
location = "container:"
name = "Storyboards">
<FileRef
location = "group:Examples/Storyboards/SearchBarController/SearchBarController.xcodeproj">
location = "group:Examples/Storyboards/BottomNavigationController/BottomNavigationController.xcodeproj">
</FileRef>
<FileRef
location = "group:Examples/Storyboards/StatusBarController/StatusBarController.xcodeproj">
location = "group:Examples/Storyboards/Button/Button.xcodeproj">
</FileRef>
<FileRef
location = "group:Examples/Storyboards/SnackbarController/SnackbarController.xcodeproj">
location = "group:Examples/Storyboards/NavigationDrawerController/NavigationDrawerController.xcodeproj">
</FileRef>
<FileRef
location = "group:Examples/Storyboards/BottomNavigationController/BottomNavigationController.xcodeproj">
location = "group:Examples/Storyboards/PageTabBarController/PageTabBarController.xcodeproj">
</FileRef>
<FileRef
location = "group:Examples/Storyboards/PageTabBarController/PageTabBarController.xcodeproj">
location = "group:Examples/Storyboards/SearchBarController/SearchBarController.xcodeproj">
</FileRef>
<FileRef
location = "group:Examples/Storyboards/Button/Button.xcodeproj">
location = "group:Examples/Storyboards/SnackbarController/SnackbarController.xcodeproj">
</FileRef>
<FileRef
location = "group:Examples/Storyboards/NavigationDrawerController/NavigationDrawerController.xcodeproj">
location = "group:Examples/Storyboards/StatusBarController/StatusBarController.xcodeproj">
</FileRef>
</Group>
</Group>
......
......@@ -25,6 +25,7 @@ CosmicMind is setting out to build a seamless application platform, and Material
- [x] Cards
- [x] Menus
- [x] Icons
- [x] Text
- [x] Navigation Controls
- [x] Example Projects
- [x] And More...
......@@ -86,7 +87,7 @@ Icons is a library of Google and CosmicMind icons that are available for use wit
## Bar
A Bar is a foundation component that organizes a set of left and right views around a centered content view. Bars are great for building layouts that are combined with buttons and switches.
A Bar is a foundation component that organizes a set of left and right views around a content area. Bars are great for building layouts that are combined with buttons and switches.
![Material Image](http://www.cosmicmind.io/material/white/bar.gif)
......
......@@ -49,7 +49,7 @@ open class Bar: View {
return 0 < width && 0 < height && nil != superview
}
/// A preset wrapper around contentInset.
/// A preset wrapper around contentEdgeInsets.
open var contentEdgeInsetsPreset: EdgeInsetsPreset {
get {
return grid.contentEdgeInsetsPreset
......@@ -59,7 +59,7 @@ open class Bar: View {
}
}
/// A wrapper around grid.contentInset.
/// A reference to EdgeInsets.
@IBInspectable
open var contentEdgeInsets: EdgeInsets {
get {
......@@ -229,6 +229,9 @@ open class Bar: View {
*/
open override func prepare() {
super.prepare()
interimSpacePreset = .interimSpace3
contentEdgeInsetsPreset = .square1
prepareContentView()
}
......
......@@ -36,25 +36,17 @@ open class Card: PulseView {
return 0 < width && nil != superview
}
/// A preset wrapper around contentInset.
open var contentEdgeInsetsPreset: EdgeInsetsPreset {
get {
return grid.contentEdgeInsetsPreset
}
set(value) {
grid.contentEdgeInsetsPreset = value
layoutSubviews()
/// A preset wrapper around toolbarEdgeInsets.
open var toolbarEdgeInsetsPreset = EdgeInsetsPreset.none {
didSet {
toolbarEdgeInsets = EdgeInsetsPresetToValue(preset: toolbarEdgeInsetsPreset)
}
}
/// A wrapper around grid.contentInset.
/// A reference to toolbarEdgeInsets.
@IBInspectable
open var contentEdgeInsets: EdgeInsets {
get {
return grid.contentEdgeInsets
}
set(value) {
grid.contentEdgeInsets = value
open var toolbarEdgeInsets = EdgeInsets.zero {
didSet {
layoutSubviews()
}
}
......@@ -67,6 +59,21 @@ open class Card: PulseView {
}
}
/// A preset wrapper around contentViewEdgeInsets.
open var contentViewEdgeInsetsPreset = EdgeInsetsPreset.none {
didSet {
contentViewEdgeInsets = EdgeInsetsPresetToValue(preset: contentViewEdgeInsetsPreset)
}
}
/// A reference to contentViewEdgeInsets.
@IBInspectable
open var contentViewEdgeInsets = EdgeInsets.zero {
didSet {
layoutSubviews()
}
}
/// A reference to the contentView.
@IBInspectable
open var contentView: UIView? {
......@@ -75,6 +82,21 @@ open class Card: PulseView {
}
}
/// A preset wrapper around bottomBarEdgeInsets.
open var bottomBarEdgeInsetsPreset = EdgeInsetsPreset.none {
didSet {
bottomBarEdgeInsets = EdgeInsetsPresetToValue(preset: bottomBarEdgeInsetsPreset)
}
}
/// A reference to bottomBarEdgeInsets.
@IBInspectable
open var bottomBarEdgeInsets = EdgeInsets.zero {
didSet {
layoutSubviews()
}
}
/// A reference to the bottomBar.
@IBInspectable
open var bottomBar: Bar? {
......@@ -139,35 +161,61 @@ open class Card: PulseView {
open func layout() {
var format = "V:|"
var views = [String: Any]()
var metrics = [String: Any]()
if let v = toolbar {
format += "[toolbar]"
metrics["toolbarTop"] = toolbarEdgeInsets.top
metrics["toolbarBottom"] = toolbarEdgeInsets.bottom
format += "-(toolbarTop)-[toolbar]-(toolbarBottom)"
views["toolbar"] = v
layout(v).horizontally().height(v.height)
layout(v).horizontally(left: toolbarEdgeInsets.left, right: toolbarEdgeInsets.right).height(v.height)
v.grid.reload()
v.divider.reload()
}
if let v = contentView {
format += "-(top)-[contentView]-(bottom)-"
metrics["contentViewBottom"] = contentViewEdgeInsets.bottom
if nil != toolbar {
metrics["toolbarBottom"] = (metrics["toolbarBottom"] as! CGFloat) + contentViewEdgeInsets.top
format += "-[contentView]-(contentViewBottom)"
} else {
metrics["contentViewTop"] = contentViewEdgeInsets.top
format += "-(contentViewTop)-[contentView]-(contentViewBottom)"
}
views["contentView"] = v
layout(v).horizontally(left: contentEdgeInsets.left, right: contentEdgeInsets.right)
layout(v).horizontally(left: contentViewEdgeInsets.left, right: contentViewEdgeInsets.right)
v.grid.reload()
v.divider.reload()
}
if let v = bottomBar {
format += "[bottomBar]"
metrics["bottomBarBottom"] = bottomBarEdgeInsets.bottom
if nil != contentView {
metrics["contentViewBottom"] = (metrics["contentViewBottom"] as! CGFloat) + bottomBarEdgeInsets.top
format += "-[bottomBar]-(bottomBarBottom)"
} else if nil != toolbar {
metrics["toolbarBottom"] = (metrics["toolbarBottom"] as! CGFloat) + bottomBarEdgeInsets.top
format += "-[bottomBar]-(bottomBarBottom)"
} else {
metrics["bottomBarTop"] = bottomBarEdgeInsets.top
format += "-(bottomBarTop)-[bottomBar]-(bottomBarBottom)"
}
views["bottomBar"] = v
layout(v).horizontally().height(v.height)
layout(v).horizontally(left: bottomBarEdgeInsets.left, right: bottomBarEdgeInsets.right).height(v.height)
v.grid.reload()
v.divider.reload()
}
guard 0 < views.count else {
return
}
var metrics = [String: Any]()
metrics["top"] = contentEdgeInsets.top
metrics["bottom"] = contentEdgeInsets.bottom
addConstraints(Layout.constraint(format: "\(format)|", options: [], metrics: metrics, views: views))
addConstraints(Layout.constraint(format: "\(format)-|", options: [], metrics: metrics, views: views))
}
/**
......
......@@ -146,7 +146,7 @@ open class CollectionReusableView: UICollectionReusableView {
}
}
/// A preset wrapper around contentInset.
/// A preset wrapper around contentEdgeInsets.
open var contentEdgeInsetsPreset: EdgeInsetsPreset {
get {
return grid.contentEdgeInsetsPreset
......@@ -156,7 +156,7 @@ open class CollectionReusableView: UICollectionReusableView {
}
}
/// A wrapper around grid.contentInset.
/// A reference to EdgeInsets.
@IBInspectable open var contentInset: UIEdgeInsets {
get {
return grid.contentEdgeInsets
......
......@@ -31,7 +31,7 @@
import UIKit
open class CollectionView: UICollectionView {
/// A preset wrapper around contentInset.
/// A preset wrapper around contentEdgeInsets.
open var contentEdgeInsetsPreset: EdgeInsets {
get {
return (collectionViewLayout as? CollectionViewLayout)!.contentEdgeInsets
......
......@@ -150,7 +150,7 @@ open class CollectionViewCell: UICollectionViewCell {
}
}
/// A preset wrapper around contentInset.
/// A preset wrapper around contentEdgeInsets.
public var contentEdgeInsetsPreset: EdgeInsetsPreset {
get {
return contentView.grid.contentEdgeInsetsPreset
......@@ -160,7 +160,7 @@ open class CollectionViewCell: UICollectionViewCell {
}
}
/// A wrapper around grid.contentInset.
/// A reference to EdgeInsets.
@IBInspectable
open var contentInset: EdgeInsets {
get {
......
......@@ -227,8 +227,6 @@ public class Grid {
canvas.addSubview(child)
}
canvas.layoutIfNeeded()
switch axis.direction {
case .horizontal:
let c = child.grid.columns
......
......@@ -37,6 +37,21 @@ public enum ToolbarAlignment: Int {
}
open class ImageCard: Card {
/// A preset wrapper around imageViewEdgeInsets.
open var imageViewEdgeInsetsPreset = EdgeInsetsPreset.none {
didSet {
imageViewEdgeInsets = EdgeInsetsPresetToValue(preset: imageViewEdgeInsetsPreset)
}
}
/// A reference to imageViewEdgeInsets.
@IBInspectable
open var imageViewEdgeInsets = EdgeInsets.zero {
didSet {
layoutSubviews()
}
}
/// A reference to the imageView.
@IBInspectable
open var imageView: UIImageView? {
......@@ -60,40 +75,60 @@ open class ImageCard: Card {
var format = "V:|"
var views = [String: Any]()
var metrics = [String: Any]()
metrics["imageViewTop"] = imageViewEdgeInsets.top
metrics["imageViewBottom"] = imageViewEdgeInsets.bottom
format += "[imageView]"
format += "-(imageViewTop)-[imageView]-(imageViewBottom)"
views["imageView"] = iv
layout(iv).horizontally()
layout(iv).horizontally(left: imageViewEdgeInsets.left, right: imageViewEdgeInsets.right)
iv.divider.reload()
if let v = toolbar {
iv.layout(v).horizontally().height(v.height)
iv.layout(v).horizontally(left: toolbarEdgeInsets.left, right: toolbarEdgeInsets.right).height(v.height)
if .top == toolbarAlignment {
iv.layout(v).top()
iv.layout(v).top(toolbarEdgeInsets.top)
} else {
iv.layout(v).bottom()
iv.layout(v).bottom(toolbarEdgeInsets.bottom)
}
v.grid.reload()
v.divider.reload()
}
if let v = contentView {
format += "-(top)-[contentView]-(bottom)-"
metrics["imageViewBottom"] = (metrics["imageViewBottom"] as! CGFloat) + contentViewEdgeInsets.top
metrics["contentViewBottom"] = contentViewEdgeInsets.bottom
format += "-[contentView]-(contentViewBottom)"
views["contentView"] = v
layout(v).horizontally(left: contentEdgeInsets.left, right: contentEdgeInsets.right)
layout(v).horizontally(left: contentViewEdgeInsets.left, right: contentViewEdgeInsets.right)
v.grid.reload()
v.divider.reload()
}
if let v = bottomBar {
format += "[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
layout(v).horizontally().height(v.height)
layout(v).horizontally(left: bottomBarEdgeInsets.left, right: bottomBarEdgeInsets.right).height(v.height)
v.grid.reload()
v.divider.reload()
}
guard 0 < views.count else {
return
}
var metrics = [String: Any]()
metrics["top"] = contentEdgeInsets.top
metrics["bottom"] = contentEdgeInsets.bottom
addConstraints(Layout.constraint(format: "\(format)|", options: [], metrics: metrics, views: views))
addConstraints(Layout.constraint(format: "\(format)-|", options: [], metrics: metrics, views: views))
}
}
......@@ -60,14 +60,14 @@ open class NavigationBar: UINavigationBar {
return 0 < width && 0 < height && nil != superview
}
/// A preset wrapper around contentInset.
/// A preset wrapper around contentEdgeInsets.
open var contentEdgeInsetsPreset = EdgeInsetsPreset.none {
didSet {
contentEdgeInsets = EdgeInsetsPresetToValue(preset: contentEdgeInsetsPreset)
}
}
/// A wrapper around grid.contentInset.
/// A reference to EdgeInsets.
@IBInspectable
open var contentEdgeInsets = EdgeInsets.zero {
didSet {
......
......@@ -31,6 +31,21 @@
import UIKit
open class PresenterCard: Card {
/// A preset wrapper around presenterViewEdgeInsets.
open var presenterViewEdgeInsetsPreset = EdgeInsetsPreset.none {
didSet {
presenterViewEdgeInsets = EdgeInsetsPresetToValue(preset: presenterViewEdgeInsetsPreset)
}
}
/// A reference to presenterViewEdgeInsets.
@IBInspectable
open var presenterViewEdgeInsets = EdgeInsets.zero {
didSet {
layoutSubviews()
}
}
/// A reference to the presenterView.
@IBInspectable
open var presenterView: UIView? {
......@@ -42,39 +57,85 @@ open class PresenterCard: Card {
open override func layout() {
var format = "V:|"
var views = [String: Any]()
var metrics = [String: Any]()
if let v = toolbar {
format += "[toolbar]"
metrics["toolbarTop"] = toolbarEdgeInsets.top
metrics["toolbarBottom"] = toolbarEdgeInsets.bottom
format += "-(toolbarTop)-[toolbar]-(toolbarBottom)"
views["toolbar"] = v
layout(v).horizontally().height(v.height)
layout(v).horizontally(left: toolbarEdgeInsets.left, right: toolbarEdgeInsets.right).height(v.height)
v.grid.reload()
v.divider.reload()
}
if let v = presenterView {
format += "[presenterView]"
metrics["presenterViewBottom"] = presenterViewEdgeInsets.bottom
if nil != toolbar {
metrics["toolbarBottom"] = (metrics["toolbarBottom"] as! CGFloat) + presenterViewEdgeInsets.top
format += "-[presenterView]-(presenterViewBottom)"
} else {
metrics["presenterViewTop"] = presenterViewEdgeInsets.top
format += "-(presenterViewTop)-[presenterView]-(presenterViewBottom)"
}
views["presenterView"] = v
layout(v).horizontally()
layout(v).horizontally(left: presenterViewEdgeInsets.left, right: presenterViewEdgeInsets.right)
v.grid.reload()
v.divider.reload()
}
if let v = contentView {
format += "-(top)-[contentView]-(bottom)-"
metrics["contentViewBottom"] = contentViewEdgeInsets.bottom
if nil != presenterView {
metrics["presenterViewBottom"] = (metrics["presenterViewBottom"] as! CGFloat) + contentViewEdgeInsets.top
format += "-[contentView]-(contentViewBottom)"
} else if nil != toolbar {
metrics["toolbarBottom"] = (metrics["toolbarBottom"] as! CGFloat) + contentViewEdgeInsets.top
format += "-[contentView]-(contentViewBottom)"
} else {
metrics["contentViewTop"] = contentViewEdgeInsets.top
format += "-(contentViewTop)-[contentView]-(contentViewBottom)"
}
views["contentView"] = v
layout(v).horizontally(left: contentEdgeInsets.left, right: contentEdgeInsets.right)
layout(v).horizontally(left: contentViewEdgeInsets.left, right: contentViewEdgeInsets.right)
v.grid.reload()
v.divider.reload()
}
if let v = bottomBar {
format += "[bottomBar]"
metrics["bottomBarBottom"] = bottomBarEdgeInsets.bottom
if nil != contentView {
metrics["contentViewBottom"] = (metrics["contentViewBottom"] as! CGFloat) + bottomBarEdgeInsets.top
format += "-[bottomBar]-(bottomBarBottom)"
} else if nil != presenterView {
metrics["presenterViewBottom"] = (metrics["presenterViewBottom"] as! CGFloat) + bottomBarEdgeInsets.top
format += "-[bottomBar]-(bottomBarBottom)"
} else if nil != toolbar {
metrics["toolbarBottom"] = (metrics["toolbarBottom"] as! CGFloat) + bottomBarEdgeInsets.top
format += "-[bottomBar]-(bottomBarBottom)"
} else {
metrics["bottomBarTop"] = bottomBarEdgeInsets.top
format += "-(bottomBarTop)-[bottomBar]-(bottomBarBottom)"
}
views["bottomBar"] = v
layout(v).horizontally().height(v.height)
layout(v).horizontally(left: bottomBarEdgeInsets.left, right: bottomBarEdgeInsets.right).height(v.height)
v.grid.reload()
v.divider.reload()
}
guard 0 < views.count else {
return
}
var metrics = [String: Any]()
metrics["top"] = contentEdgeInsets.top
metrics["bottom"] = contentEdgeInsets.bottom
print(format)
addConstraints(Layout.constraint(format: "\(format)|", options: [], metrics: metrics, views: views))
addConstraints(Layout.constraint(format: "\(format)-|", options: [], metrics: metrics, views: views))
}
}
......@@ -136,8 +136,6 @@ open class SearchBar: Bar {
*/
open override func prepare() {
super.prepare()
interimSpacePreset = .interimSpace3
contentEdgeInsetsPreset = .square1
prepareTextField()
prepareClearButton()
}
......
......@@ -482,7 +482,7 @@ open class TextField: UITextField {
/// The animation for the divider when editing begins.
open func dividerEditingDidBeginAnimation() {
dividerHeight = dividerActiveHeight
dividerColor = dividerActiveColor ?? placeholderActiveColor
dividerColor = dividerActiveColor
}
/// The animation for the divider when editing ends.
......
......@@ -150,8 +150,6 @@ open class Toolbar: Bar {
open override func prepare() {
super.prepare()
contentViewAlignment = .center
interimSpacePreset = .interimSpace3
contentEdgeInsetsPreset = .square1
prepareTitleLabel()
prepareDetailLabel()
}
......
......@@ -163,7 +163,7 @@ open class View: UIView {
open override func layoutSubviews() {
super.layoutSubviews()
layoutShadowPath()
layoutShadowPath()
}
/**
......
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