Commit eefc513b by Daniel Dahan

working version of BasicCollectionViewCell

parent b2e465a7
...@@ -71,7 +71,7 @@ class AppLeftViewController: UIViewController { ...@@ -71,7 +71,7 @@ class AppLeftViewController: UIViewController {
/// General preparation statements. /// General preparation statements.
private func prepareView() { private func prepareView() {
view.backgroundColor = MaterialColor.blueGrey.darken4 view.backgroundColor = MaterialColor.grey.darken4
} }
/// Prepares the items that are displayed within the tableView. /// Prepares the items that are displayed within the tableView.
...@@ -164,7 +164,7 @@ extension AppLeftViewController: UITableViewDelegate { ...@@ -164,7 +164,7 @@ extension AppLeftViewController: UITableViewDelegate {
let item: Item = items[indexPath.row] let item: Item = items[indexPath.row]
if let a: MenuViewController = sideNavigationViewController?.mainViewController as? MenuViewController { if let a: MenuViewController = sideNavigationViewController?.mainViewController as? MenuViewController {
if let b: NavigationBarViewController = a.mainViewController as? NavigationBarViewController { if let b: NavigationBarViewController = a.mainViewController as? NavigationBarViewController {
b.transitionFromMainViewController("Feed" == item.text ? FeedViewController() : InboxViewController(), duration: 0.75, options: [.TransitionCrossDissolve]) { [weak self] _ in b.transitionFromMainViewController("Feed" == item.text ? FeedViewController() : InboxViewController(), options: [.TransitionCrossDissolve]) { [weak self] _ in
self?.sideNavigationViewController?.closeLeftView() self?.sideNavigationViewController?.closeLeftView()
} }
} }
......
...@@ -58,7 +58,7 @@ class AppRightViewController: UIViewController { ...@@ -58,7 +58,7 @@ class AppRightViewController: UIViewController {
/// General preparation statements. /// General preparation statements.
private func prepareView() { private func prepareView() {
view.backgroundColor = MaterialColor.blueGrey.darken4 view.backgroundColor = MaterialColor.grey.darken4
} }
override func viewWillAppear(animated: Bool) { override func viewWillAppear(animated: Bool) {
......
...@@ -79,18 +79,18 @@ class AppSearchBarViewController: SearchBarViewController { ...@@ -79,18 +79,18 @@ class AppSearchBarViewController: SearchBarViewController {
var image = UIImage(named: "ic_close_white")?.imageWithRenderingMode(.AlwaysTemplate) var image = UIImage(named: "ic_close_white")?.imageWithRenderingMode(.AlwaysTemplate)
let clearButton: FlatButton = FlatButton() let clearButton: FlatButton = FlatButton()
clearButton.pulseColor = MaterialColor.blueGrey.darken4 clearButton.pulseColor = MaterialColor.grey.darken4
clearButton.pulseScale = false clearButton.pulseScale = false
clearButton.tintColor = MaterialColor.blueGrey.darken4 clearButton.tintColor = MaterialColor.grey.darken4
clearButton.setImage(image, forState: .Normal) clearButton.setImage(image, forState: .Normal)
clearButton.setImage(image, forState: .Highlighted) clearButton.setImage(image, forState: .Highlighted)
// Back button. // Back button.
image = UIImage(named: "ic_arrow_back_white")?.imageWithRenderingMode(.AlwaysTemplate) image = UIImage(named: "ic_arrow_back_white")?.imageWithRenderingMode(.AlwaysTemplate)
let backButton: FlatButton = FlatButton() let backButton: FlatButton = FlatButton()
backButton.pulseColor = MaterialColor.blueGrey.darken4 backButton.pulseColor = MaterialColor.grey.darken4
backButton.pulseScale = false backButton.pulseScale = false
backButton.tintColor = MaterialColor.blueGrey.darken4 backButton.tintColor = MaterialColor.grey.darken4
backButton.setImage(image, forState: .Normal) backButton.setImage(image, forState: .Normal)
backButton.setImage(image, forState: .Highlighted) backButton.setImage(image, forState: .Highlighted)
backButton.addTarget(self, action: "handleBackButton", forControlEvents: .TouchUpInside) backButton.addTarget(self, action: "handleBackButton", forControlEvents: .TouchUpInside)
...@@ -98,18 +98,18 @@ class AppSearchBarViewController: SearchBarViewController { ...@@ -98,18 +98,18 @@ class AppSearchBarViewController: SearchBarViewController {
// More button. // More button.
image = UIImage(named: "ic_more_horiz_white")?.imageWithRenderingMode(.AlwaysTemplate) image = UIImage(named: "ic_more_horiz_white")?.imageWithRenderingMode(.AlwaysTemplate)
let moreButton: FlatButton = FlatButton() let moreButton: FlatButton = FlatButton()
moreButton.pulseColor = MaterialColor.blueGrey.darken4 moreButton.pulseColor = MaterialColor.grey.darken4
moreButton.pulseScale = false moreButton.pulseScale = false
moreButton.tintColor = MaterialColor.blueGrey.darken4 moreButton.tintColor = MaterialColor.grey.darken4
moreButton.setImage(image, forState: .Normal) moreButton.setImage(image, forState: .Normal)
moreButton.setImage(image, forState: .Highlighted) moreButton.setImage(image, forState: .Highlighted)
moreButton.addTarget(self, action: "handleMoreButton", forControlEvents: .TouchUpInside) moreButton.addTarget(self, action: "handleMoreButton", forControlEvents: .TouchUpInside)
searchBarView.delegate = self searchBarView.delegate = self
searchBarView.placeholder = "Search" searchBarView.placeholder = "Search"
searchBarView.tintColor = MaterialColor.blueGrey.darken4 searchBarView.tintColor = MaterialColor.grey.darken4
searchBarView.textColor = MaterialColor.blueGrey.darken4 searchBarView.textColor = MaterialColor.grey.darken4
searchBarView.placeholderTextColor = MaterialColor.blueGrey.darken4 searchBarView.placeholderTextColor = MaterialColor.grey.darken4
searchBarView.textField.font = RobotoFont.regularWithSize(17) searchBarView.textField.font = RobotoFont.regularWithSize(17)
searchBarView.textField.delegate = self searchBarView.textField.delegate = self
......
{
"images" : [
{
"idiom" : "universal",
"filename" : "ic_share_white.png",
"scale" : "1x"
},
{
"idiom" : "universal",
"filename" : "ic_share_white_2x.png",
"scale" : "2x"
},
{
"idiom" : "universal",
"filename" : "ic_share_white_3x.png",
"scale" : "3x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
\ No newline at end of file
{
"images" : [
{
"idiom" : "universal",
"filename" : "ic_share_white_18pt.png",
"scale" : "1x"
},
{
"idiom" : "universal",
"filename" : "ic_share_white_18pt_2x.png",
"scale" : "2x"
},
{
"idiom" : "universal",
"filename" : "ic_share_white_18pt_3x.png",
"scale" : "3x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
\ No newline at end of file
...@@ -72,18 +72,12 @@ extension FeedViewController: MaterialCollectionViewDataSource { ...@@ -72,18 +72,12 @@ extension FeedViewController: MaterialCollectionViewDataSource {
/// Retrieves the items for the collectionView. /// Retrieves the items for the collectionView.
func items() -> Array<MaterialDataSourceItem> { func items() -> Array<MaterialDataSourceItem> {
return [ return [
MaterialDataSourceItem(data: ["title": "Material", "detail": "#Pumpkin #pie - Preheat oven to 425 degrees F. Whisk pumpkin, sweetened condensed milk, eggs...", "date": "February 26, 2016"], dataSourceItemSize: .Small), MaterialDataSourceItem(data: ["title": "MaterialColor", "detail": "MaterialColor is a complete Material Design color library. It uses base color values that expand to a range of lighter and darker shades, with the addition of accents.", "date": "February 26, 2016"], dataSourceItemSize: .Small),
MaterialDataSourceItem(data: ["title": "Material", "detail": "Wow!!! I really really need this fabulous pair. Action is ending tonight #sneakerhead", "date": "February 26, 2016"], dataSourceItemSize: .Default), MaterialDataSourceItem(data: ["title": "MaterialLayer", "detail": "MaterialLayer is a lightweight CAShapeLayer used throughout Material. It is designed to easily take shape, depth, and animations.", "date": "February 26, 2016"], dataSourceItemSize: .Default),
MaterialDataSourceItem(data: ["title": "Material", "detail": "Discovered an amazing #cofeeshop with the best #latte at Adelaide and Spadina #Toronto They also...", "date": "February 26, 2016"], dataSourceItemSize: .Large), MaterialDataSourceItem(data: ["title": "MaterialView", "detail": "MaterialView is the base UIView class used throughout Material. Like MaterialLayer, it is designed to easily take shape, depth, and animations. The major difference is that MaterialView has all the added features of the UIView class.", "date": "February 26, 2016"], dataSourceItemSize: .Large),
MaterialDataSourceItem(data: ["title": "Material", "detail": "Talk to that agency guy, a friend of #Jen, about renting...", "date": "February 26, 2016"], dataSourceItemSize: .Small), MaterialDataSourceItem(data: ["title": "MaterialPulseView", "detail": "MaterialPulseView is at the heart of all pulse animations. Any view that subclasses MaterialPulseView instantly inherits the pulse animation with full customizability.", "date": "February 26, 2016"], dataSourceItemSize: .Small),
MaterialDataSourceItem(data: ["title": "Material", "detail": "#Pumpkin #pie - Preheat oven to 425 degrees F. Whisk pumpkin, sweetened condensed milk, eggs...", "date": "February 26, 2016"], dataSourceItemSize: .Default), MaterialDataSourceItem(data: ["title": "TextField", "detail": "A TextField is an excellent way to improve UX. TextFields offer details that describe the usage and input results of text. For example, when a user enters an incorrect email, it is possible to display an error message under the TextField.", "date": "February 26, 2016"], dataSourceItemSize: .Default),
MaterialDataSourceItem(data: ["title": "Material", "detail": "Wow!!! I really really need this fabulous pair. Action is ending tonight #sneakerhead", "date": "February 26, 2016"], dataSourceItemSize: .Large), MaterialDataSourceItem(data: ["title": "TextView", "detail": "A TextView is an excellent way to improve UX. TextViews offer details that describe the usage of text. In addition, TextViews may easily match any regular expression pattern in a body of text. Below is an example of the default hashtag pattern matching.", "date": "February 26, 2016"], dataSourceItemSize: .Large)
MaterialDataSourceItem(data: ["title": "Material", "detail": "Discovered an amazing #cofeeshop with the best #latte at Adelaide and Spadina #Toronto They also...", "date": "February 26, 2016"], dataSourceItemSize: .Default),
MaterialDataSourceItem(data: ["title": "Material", "detail": "Talk to that agency guy, a friend of #Jen, about renting...", "date": "February 26, 2016"], dataSourceItemSize: .Default),
MaterialDataSourceItem(data: ["title": "Material", "detail": "#Pumpkin #pie - Preheat oven to 425 degrees F. Whisk pumpkin, sweetened condensed milk, eggs...", "date": "February 26, 2016"], dataSourceItemSize: .Default),
MaterialDataSourceItem(data: ["title": "Material", "detail": "Wow!!! I really really need this fabulous pair. Action is ending tonight #sneakerhead", "date": "February 26, 2016"], dataSourceItemSize: .Default),
MaterialDataSourceItem(data: ["title": "Material", "detail": "Discovered an amazing #cofeeshop with the best #latte at Adelaide and Spadina #Toronto They also...", "date": "February 26, 2016"], dataSourceItemSize: .Default),
MaterialDataSourceItem(data: ["title": "Material", "detail": "Talk to that agency guy, a friend of #Jen, about renting...", "date": "February 26, 2016"], dataSourceItemSize: .Default)
] ]
} }
...@@ -102,40 +96,42 @@ extension FeedViewController: MaterialCollectionViewDataSource { ...@@ -102,40 +96,42 @@ extension FeedViewController: MaterialCollectionViewDataSource {
let c: BasicCollectionViewCell = collectionView.dequeueReusableCellWithReuseIdentifier("Cell", forIndexPath: indexPath) as! BasicCollectionViewCell let c: BasicCollectionViewCell = collectionView.dequeueReusableCellWithReuseIdentifier("Cell", forIndexPath: indexPath) as! BasicCollectionViewCell
let item: MaterialDataSourceItem = items()[indexPath.item] let item: MaterialDataSourceItem = items()[indexPath.item]
c.backgroundColor = MaterialColor.blue.base
if let data: Dictionary<String, AnyObject> = item.data as? Dictionary<String, AnyObject> { if let data: Dictionary<String, AnyObject> = item.data as? Dictionary<String, AnyObject> {
if nil == data["title"] { if nil == data["title"] {
c.titleLabel = nil c.titleLabel = nil
} else if nil == c.titleLabel { } else if nil == c.titleLabel {
let titleLabel: UILabel = UILabel() let titleLabel: UILabel = UILabel()
titleLabel.textColor = MaterialColor.blueGrey.darken4 titleLabel.textColor = MaterialColor.grey.darken4
titleLabel.backgroundColor = MaterialColor.clear
c.titleLabel = titleLabel c.titleLabel = titleLabel
} }
// if nil == data["detail"] { if nil == data["detail"] {
// c.detailLabel = nil c.detailLabel = nil
// } else if nil == c.detailLabel { } else if nil == c.detailLabel {
// let detailLabel: UILabel = UILabel() let detailLabel: UILabel = UILabel()
// detailLabel.numberOfLines = 0 detailLabel.numberOfLines = 0
// detailLabel.lineBreakMode = .ByTruncatingTail detailLabel.lineBreakMode = .ByTruncatingTail
// detailLabel.font = RobotoFont.regularWithSize(12) detailLabel.font = RobotoFont.regularWithSize(12)
// detailLabel.textColor = MaterialColor.blueGrey.darken4 detailLabel.textColor = MaterialColor.grey.darken4
// detailLabel.backgroundColor = MaterialColor.clear c.detailLabel = detailLabel
// c.detailLabel = detailLabel }
// }
// if nil == c.controlView {
// if nil == c.controlView { c.controlView = ControlView()
// c.controlView = ControlView() c.controlView!.backgroundColor = nil
// c.controlView!.backgroundColor = nil
// let image = UIImage(named: "ic_share_white_18pt")?.imageWithRenderingMode(.AlwaysTemplate)
// let date: UILabel = UILabel()
// date.font = RobotoFont.regularWithSize(12) // Share button.
// date.textColor = MaterialColor.grey.lighten1 let shareButton: FlatButton = FlatButton()
// c.controlView?.contentView.addSubview(date) shareButton.pulseScale = false
// c.controlView?.grid.views = [date] shareButton.pulseColor = MaterialColor.grey.lighten1
// } shareButton.tintColor = MaterialColor.grey.base
shareButton.setImage(image, forState: .Normal)
shareButton.setImage(image, forState: .Highlighted)
c.controlView?.rightControls = [shareButton]
}
c.titleLabel?.text = data["title"] as? String c.titleLabel?.text = data["title"] as? String
c.detailLabel?.text = data["detail"] as? String c.detailLabel?.text = data["detail"] as? String
......
...@@ -290,7 +290,6 @@ class ViewController: UIViewController { ...@@ -290,7 +290,6 @@ class ViewController: UIViewController {
alarmButton.grid.offset.columns = 10 alarmButton.grid.offset.columns = 10
contentView.grid.spacing = 8 contentView.grid.spacing = 8
contentView.grid.axis.inherited = false
contentView.grid.axis.direction = .None contentView.grid.axis.direction = .None
contentView.grid.contentInsetPreset = .Square3 contentView.grid.contentInsetPreset = .Square3
contentView.grid.views = [ contentView.grid.views = [
...@@ -388,7 +387,6 @@ class ViewController: UIViewController { ...@@ -388,7 +387,6 @@ class ViewController: UIViewController {
alarmButton.grid.offset.columns = 9 alarmButton.grid.offset.columns = 9
contentView.grid.spacing = 8 contentView.grid.spacing = 8
contentView.grid.axis.inherited = false
contentView.grid.axis.direction = .None contentView.grid.axis.direction = .None
contentView.grid.contentInsetPreset = .Square3 contentView.grid.contentInsetPreset = .Square3
contentView.grid.views = [ contentView.grid.views = [
...@@ -513,7 +511,6 @@ class ViewController: UIViewController { ...@@ -513,7 +511,6 @@ class ViewController: UIViewController {
alarmButton.grid.offset.columns = 10 alarmButton.grid.offset.columns = 10
contentView.grid.spacing = 8 contentView.grid.spacing = 8
contentView.grid.axis.inherited = false
contentView.grid.axis.direction = .None contentView.grid.axis.direction = .None
contentView.grid.contentInsetPreset = .Square3 contentView.grid.contentInsetPreset = .Square3
contentView.grid.views = [ contentView.grid.views = [
......
...@@ -352,7 +352,9 @@ ...@@ -352,7 +352,9 @@
96CC08891C7FEBE10034FF84 /* CollectionView */ = { 96CC08891C7FEBE10034FF84 /* CollectionView */ = {
isa = PBXGroup; isa = PBXGroup;
children = ( children = (
96CC089E1C80BD550034FF84 /* Basic */, 96CC08981C80B74F0034FF84 /* BasicCollectionViewCell.swift */,
96CC089A1C80B82E0034FF84 /* BasicCollectionView.swift */,
96CC089C1C80B8F70034FF84 /* BasicCollectionViewLayout.swift */,
96CC088B1C7FEC170034FF84 /* MaterialCollectionView.swift */, 96CC088B1C7FEC170034FF84 /* MaterialCollectionView.swift */,
96CC088C1C7FEC170034FF84 /* MaterialCollectionViewCell.swift */, 96CC088C1C7FEC170034FF84 /* MaterialCollectionViewCell.swift */,
96CC088D1C7FEC170034FF84 /* MaterialCollectionViewDataSource.swift */, 96CC088D1C7FEC170034FF84 /* MaterialCollectionViewDataSource.swift */,
...@@ -363,16 +365,6 @@ ...@@ -363,16 +365,6 @@
name = CollectionView; name = CollectionView;
sourceTree = "<group>"; sourceTree = "<group>";
}; };
96CC089E1C80BD550034FF84 /* Basic */ = {
isa = PBXGroup;
children = (
96CC08981C80B74F0034FF84 /* BasicCollectionViewCell.swift */,
96CC089A1C80B82E0034FF84 /* BasicCollectionView.swift */,
96CC089C1C80B8F70034FF84 /* BasicCollectionViewLayout.swift */,
);
name = Basic;
sourceTree = "<group>";
};
96D88BF41C1328D800B91418 /* Sources */ = { 96D88BF41C1328D800B91418 /* Sources */ = {
isa = PBXGroup; isa = PBXGroup;
children = ( children = (
......
...@@ -67,188 +67,119 @@ public class BasicCollectionViewCell : MaterialCollectionViewCell { ...@@ -67,188 +67,119 @@ public class BasicCollectionViewCell : MaterialCollectionViewCell {
*/ */
public override func prepareView() { public override func prepareView() {
super.prepareView() super.prepareView()
spacingPreset = .Spacing2
contentInsetPreset = .Square3 contentInsetPreset = .Square3
backgroundColor = MaterialColor.white backgroundColor = MaterialColor.white
} }
/// Reloads the view. /// Reloads the view.
public func reloadView() { public func reloadView() {
for v in contentView.subviews {
v.removeFromSuperview()
}
grid.views = []
contentView.grid.views = [] contentView.grid.views = []
contentView.grid.axis.rows = 12
contentView.grid.axis.direction = .Vertical
controlView?.grid.axis.columns = 0 < width ? Int(width / 48) : 12
var a: Int = 0
var b: Int = 0
var c: Int = 0
switch height { switch height {
case 192: case 142:
let rows: Int = Int(height / 48)
contentView.grid.axis.direction = .Vertical
contentView.grid.axis.rows = rows
for v in contentView.subviews {
v.removeFromSuperview()
}
var a: Int = 0
var b: Int = 0
var c: Int = 0
if nil != titleLabel && nil == detailLabel && nil == controlView { if nil != titleLabel && nil == detailLabel && nil == controlView {
a = rows a = 12
} else if nil == titleLabel && nil != detailLabel && nil == controlView { } else if nil == titleLabel && nil != detailLabel && nil == controlView {
b = rows b = 12
} else if nil == titleLabel && nil == detailLabel && nil != controlView { } else if nil == titleLabel && nil == detailLabel && nil != controlView {
c = rows c = 12
} else if nil != titleLabel && nil != detailLabel && nil == controlView { } else if nil != titleLabel && nil != detailLabel && nil == controlView {
a = 1 a = 4
b = rows - 1 b = 8
} else if nil != titleLabel && nil == detailLabel && nil != controlView { } else if nil != titleLabel && nil == detailLabel && nil != controlView {
a = rows - 1 a = 8
c = 1 c = 4
} else if nil == titleLabel && nil != detailLabel && nil != controlView { } else if nil == titleLabel && nil != detailLabel && nil != controlView {
b = rows - 1 b = 8
c = 1 c = 4
} else if nil != titleLabel && nil != detailLabel && nil != controlView { } else if nil != titleLabel && nil != detailLabel && nil != controlView {
a = 1 a = 4
b = rows - 6 b = 4
c = 1 c = 4
}
if let v: UILabel = titleLabel {
v.grid.rows = a
contentView.addSubview(v)
contentView.grid.views?.append(v)
}
if let v: UILabel = detailLabel {
v.grid.rows = b
contentView.addSubview(v)
contentView.grid.views?.append(v)
} }
case 192:
if let v: ControlView = controlView {
v.grid.rows = c
contentView.addSubview(v)
contentView.grid.views?.append(v)
}
grid.views = [
contentView
]
contentView.grid.reloadLayout()
case 144:
let rows: Int = Int(height / 48)
contentView.grid.axis.direction = .Vertical
contentView.grid.axis.rows = rows
for v in contentView.subviews {
v.removeFromSuperview()
}
var a: Int = 0
var b: Int = 0
var c: Int = 0
if nil != titleLabel && nil == detailLabel && nil == controlView { if nil != titleLabel && nil == detailLabel && nil == controlView {
a = rows a = 12
} else if nil == titleLabel && nil != detailLabel && nil == controlView { } else if nil == titleLabel && nil != detailLabel && nil == controlView {
b = rows b = 12
} else if nil == titleLabel && nil == detailLabel && nil != controlView { } else if nil == titleLabel && nil == detailLabel && nil != controlView {
c = rows c = 12
} else if nil != titleLabel && nil != detailLabel && nil == controlView { } else if nil != titleLabel && nil != detailLabel && nil == controlView {
a = 1 a = 3
b = rows - 1 b = 9
} else if nil != titleLabel && nil == detailLabel && nil != controlView { } else if nil != titleLabel && nil == detailLabel && nil != controlView {
a = rows - 1 a = 9
c = 1 c = 3
} else if nil == titleLabel && nil != detailLabel && nil != controlView { } else if nil == titleLabel && nil != detailLabel && nil != controlView {
b = rows - 1 b = 9
c = 1 c = 3
} else if nil != titleLabel && nil != detailLabel && nil != controlView { } else if nil != titleLabel && nil != detailLabel && nil != controlView {
a = 1 a = 3
b = rows - 6 b = 6
c = 1 c = 3
}
if let v: UILabel = titleLabel {
v.grid.rows = a
contentView.addSubview(v)
contentView.grid.views?.append(v)
}
if let v: UILabel = detailLabel {
v.grid.rows = b
contentView.addSubview(v)
contentView.grid.views?.append(v)
} }
case 256:
if let v: ControlView = controlView {
v.grid.rows = c
contentView.addSubview(v)
contentView.grid.views?.append(v)
}
grid.views = [
contentView
]
contentView.grid.reloadLayout()
case 192:
let rows: Int = Int(height / 48)
contentView.grid.axis.direction = .Vertical
contentView.grid.axis.rows = rows
for v in contentView.subviews {
v.removeFromSuperview()
}
var a: Int = 0
var b: Int = 0
var c: Int = 0
if nil != titleLabel && nil == detailLabel && nil == controlView { if nil != titleLabel && nil == detailLabel && nil == controlView {
a = rows a = 12
} else if nil == titleLabel && nil != detailLabel && nil == controlView { } else if nil == titleLabel && nil != detailLabel && nil == controlView {
b = rows b = 12
} else if nil == titleLabel && nil == detailLabel && nil != controlView { } else if nil == titleLabel && nil == detailLabel && nil != controlView {
c = rows c = 12
} else if nil != titleLabel && nil != detailLabel && nil == controlView { } else if nil != titleLabel && nil != detailLabel && nil == controlView {
a = 1 a = 2
b = rows - 1 b = 10
} else if nil != titleLabel && nil == detailLabel && nil != controlView { } else if nil != titleLabel && nil == detailLabel && nil != controlView {
a = rows - 1 a = 10
c = 1 c = 2
} else if nil == titleLabel && nil != detailLabel && nil != controlView { } else if nil == titleLabel && nil != detailLabel && nil != controlView {
b = rows - 1 b = 10
c = 1 c = 2
} else if nil != titleLabel && nil != detailLabel && nil != controlView { } else if nil != titleLabel && nil != detailLabel && nil != controlView {
a = 1 a = 2
b = rows - 6 b = 8
c = 1 c = 2
}
if let v: UILabel = titleLabel {
v.grid.rows = a
contentView.addSubview(v)
contentView.grid.views?.append(v)
}
if let v: UILabel = detailLabel {
v.grid.rows = b
contentView.addSubview(v)
contentView.grid.views?.append(v)
} }
if let v: ControlView = controlView {
v.grid.rows = c
contentView.addSubview(v)
contentView.grid.views?.append(v)
}
grid.views = [
contentView
]
contentView.grid.reloadLayout()
default: default:
grid.views = [] return
contentView.grid.views = [] }
if let v: UILabel = titleLabel {
v.grid.rows = a
contentView.addSubview(v)
contentView.grid.views?.append(v)
}
if let v: UILabel = detailLabel {
v.grid.rows = b
contentView.addSubview(v)
contentView.grid.views?.append(v)
}
if let v: ControlView = controlView {
v.grid.rows = c
contentView.addSubview(v)
contentView.grid.views?.append(v)
} }
grid.views = [
contentView
]
contentView.grid.reloadLayout()
controlView?.reloadView()
} }
} }
...@@ -40,11 +40,11 @@ public class BasicCollectionViewLayout : MaterialCollectionViewLayout { ...@@ -40,11 +40,11 @@ public class BasicCollectionViewLayout : MaterialCollectionViewLayout {
if let q: MaterialDataSourceItemSize = v.dataSourceItemSize { if let q: MaterialDataSourceItemSize = v.dataSourceItemSize {
switch q { switch q {
case .Small: case .Small:
v.height = 96 v.height = 142
case .Large: case .Default:
v.height = 192 v.height = 192
default: case .Large:
v.height = 144 v.height = 256
} }
} }
items[i] = v items[i] = v
......
...@@ -125,7 +125,6 @@ public class ControlView : MaterialView { ...@@ -125,7 +125,6 @@ public class ControlView : MaterialView {
/// Reloads the view. /// Reloads the view.
public func reloadView() { public func reloadView() {
layoutIfNeeded()
// clear constraints so new ones do not conflict // clear constraints so new ones do not conflict
removeConstraints(constraints) removeConstraints(constraints)
...@@ -177,6 +176,7 @@ public class ControlView : MaterialView { ...@@ -177,6 +176,7 @@ public class ControlView : MaterialView {
contentView.grid.columns -= contentView.grid.offset.columns contentView.grid.columns -= contentView.grid.offset.columns
grid.reloadLayout() grid.reloadLayout()
contentView.grid.reloadLayout()
} }
} }
......
...@@ -41,7 +41,7 @@ public class GridAxis { ...@@ -41,7 +41,7 @@ public class GridAxis {
unowned var grid: Grid unowned var grid: Grid
/// Inherit grid rows and columns. /// Inherit grid rows and columns.
public var inherited: Bool = true public var inherited: Bool = false
/// The direction the grid layouts its views out. /// The direction the grid layouts its views out.
public var direction: GridAxisDirection = .Horizontal public var direction: GridAxisDirection = .Horizontal
......
...@@ -71,10 +71,6 @@ public class NavigationBarView : StatusBarView { ...@@ -71,10 +71,6 @@ public class NavigationBarView : StatusBarView {
public override func layoutSubviews() { public override func layoutSubviews() {
super.layoutSubviews() super.layoutSubviews()
width = UIScreen.mainScreen().bounds.width
grid.axis.columns = Int(width / 48)
// TitleView alignment. // TitleView alignment.
if let v: UILabel = titleLabel { if let v: UILabel = titleLabel {
if let d: UILabel = detailLabel { if let d: UILabel = detailLabel {
...@@ -119,7 +115,6 @@ public class NavigationBarView : StatusBarView { ...@@ -119,7 +115,6 @@ public class NavigationBarView : StatusBarView {
*/ */
public override func prepareView() { public override func prepareView() {
super.prepareView() super.prepareView()
contentView.grid.axis.inherited = false
contentView.grid.axis.direction = .Vertical contentView.grid.axis.direction = .Vertical
} }
......
...@@ -85,14 +85,6 @@ public class SearchBarView : StatusBarView { ...@@ -85,14 +85,6 @@ public class SearchBarView : StatusBarView {
self.init(frame: CGRectMake(0, 0, UIScreen.mainScreen().bounds.width, 64)) self.init(frame: CGRectMake(0, 0, UIScreen.mainScreen().bounds.width, 64))
} }
public override func layoutSubviews() {
super.layoutSubviews()
grid.axis.columns = Int(width / 48)
reloadView()
}
public override func didMoveToSuperview() { public override func didMoveToSuperview() {
super.didMoveToSuperview() super.didMoveToSuperview()
reloadView() reloadView()
...@@ -103,9 +95,8 @@ public class SearchBarView : StatusBarView { ...@@ -103,9 +95,8 @@ public class SearchBarView : StatusBarView {
super.reloadView() super.reloadView()
textField.grid.columns = contentView.grid.columns textField.grid.columns = contentView.grid.columns
textField.reloadView()
grid.reloadLayout() grid.reloadLayout()
textField.reloadView()
} }
/** /**
......
...@@ -60,6 +60,7 @@ public class StatusBarView : ControlView { ...@@ -60,6 +60,7 @@ public class StatusBarView : ControlView {
super.layoutSubviews() super.layoutSubviews()
width = UIScreen.mainScreen().bounds.width width = UIScreen.mainScreen().bounds.width
grid.axis.columns = Int(width / 48)
// General alignment. // General alignment.
if UIApplication.sharedApplication().statusBarOrientation.isLandscape { if UIApplication.sharedApplication().statusBarOrientation.isLandscape {
...@@ -101,7 +102,6 @@ public class StatusBarView : ControlView { ...@@ -101,7 +102,6 @@ public class StatusBarView : ControlView {
grid.contentInset.left = 8 grid.contentInset.left = 8
grid.contentInset.bottom = 8 grid.contentInset.bottom = 8
grid.contentInset.right = 8 grid.contentInset.right = 8
grid.axis.inherited = false
} }
/// Chaining method for subclasses to offer delegation or other useful features. /// Chaining method for subclasses to offer delegation or other useful features.
......
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