Commit 547b07de by Daniel Dahan

rework for release

parent e50b0c11
...@@ -68,7 +68,7 @@ class AppViewController: NavigationViewController { ...@@ -68,7 +68,7 @@ class AppViewController: NavigationViewController {
because any earlier may cause a race condition when instantiating because any earlier may cause a race condition when instantiating
the MainViewController and SideViewController. the MainViewController and SideViewController.
*/ */
sideNavigationViewController?.setLeftViewWidth(view.bounds.width - menuViewDiameter - 2 * menuViewInset, hidden: true, animated: false) // sideNavigationViewController?.setLeftViewWidth(view.bounds.width - menuViewDiameter - 2 * menuViewInset, hidden: true, animated: false)
sideNavigationViewController?.delegate = self sideNavigationViewController?.delegate = self
} }
......
...@@ -35,6 +35,7 @@ class FeedCollectionViewCell : MaterialCollectionViewCell { ...@@ -35,6 +35,7 @@ class FeedCollectionViewCell : MaterialCollectionViewCell {
let titleLabel: UILabel = UILabel() let titleLabel: UILabel = UILabel()
let detailLabel: UILabel = UILabel() let detailLabel: UILabel = UILabel()
let imageView: MaterialView = MaterialView() let imageView: MaterialView = MaterialView()
var images: Array<UIImage?>?
override init(frame: CGRect) { override init(frame: CGRect) {
super.init(frame: frame) super.init(frame: frame)
...@@ -51,77 +52,98 @@ class FeedCollectionViewCell : MaterialCollectionViewCell { ...@@ -51,77 +52,98 @@ class FeedCollectionViewCell : MaterialCollectionViewCell {
} }
override func prepareView() { override func prepareView() {
backgroundColor = MaterialColor.white
pulseScale = false pulseScale = false
pulseColor = MaterialColor.blue.lighten4 pulseColor = MaterialColor.blue.lighten4
var image: UIImage? // var image: UIImage?
imageView.contentsGravity = .ResizeAspectFill
addSubview(imageView)
let contentView: MaterialView = MaterialView() contentView.addSubview(imageView)
contentView.backgroundColor = MaterialColor.clear
addSubview(contentView)
titleLabel.textColor = MaterialColor.blueGrey.darken4 titleLabel.textColor = MaterialColor.blueGrey.darken4
titleLabel.backgroundColor = MaterialColor.clear titleLabel.backgroundColor = MaterialColor.clear
contentView.addSubview(titleLabel) contentView.addSubview(titleLabel)
image = UIImage(named: "ic_more_vert_white")?.imageWithRenderingMode(.AlwaysTemplate) // image = UIImage(named: "ic_more_vert_white")?.imageWithRenderingMode(.AlwaysTemplate)
let moreButton: FlatButton = FlatButton() // let moreButton: FlatButton = FlatButton()
moreButton.contentEdgeInsetsPreset = .None // moreButton.contentEdgeInsetsPreset = .None
moreButton.pulseColor = MaterialColor.blueGrey.darken4 // moreButton.pulseColor = MaterialColor.blueGrey.darken4
moreButton.tintColor = MaterialColor.blueGrey.darken4 // moreButton.tintColor = MaterialColor.blueGrey.darken4
moreButton.setImage(image, forState: .Normal) // moreButton.setImage(image, forState: .Normal)
moreButton.setImage(image, forState: .Highlighted) // moreButton.setImage(image, forState: .Highlighted)
contentView.addSubview(moreButton) // addSubview(moreButton)
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.blueGrey.darken4
detailLabel.backgroundColor = MaterialColor.clear // detailLabel.backgroundColor = MaterialColor.clear
contentView.addSubview(detailLabel) // addSubview(detailLabel)
let g: Int = Int(bounds.width / 48) let g: Int = Int(bounds.width / 48)
grid.axis.columns = g switch UIDevice.currentDevice().orientation {
case .LandscapeLeft, .LandscapeRight:
contentView.grid.axis.direction = .None
contentView.grid.columns = g
contentView.grid.views = [
imageView
]
imageView.grid.columns = 4 if let v: Array<UIImage?> = images {
let topImageView: MaterialView = MaterialView()
imageView.addSubview(topImageView)
contentView.grid.columns = g - 4 topImageView.image = v.first!
topImageView.grid.rows = 6
topImageView.grid.columns = 6
grid.contentInset.right = 8 let bottomImageView: MaterialView = MaterialView()
grid.axis.columns = g imageView.addSubview(bottomImageView)
grid.views = [
imageView, bottomImageView.image = v.last!
contentView bottomImageView.grid.rows = 6
bottomImageView.grid.columns = 6
imageView.grid.views = [
topImageView,
bottomImageView
] ]
}
default:
for v in imageView.subviews {
v.removeFromSuperview()
}
imageView.contentsGravity = .ResizeAspectFill
imageView.grid.columns = 2
titleLabel.grid.columns = g - 2
// moreButton.grid.rows = 4
// moreButton.grid.columns = 2
// moreButton.grid.offset.columns = 8
titleLabel.grid.rows = 4 detailLabel.grid.rows = 7
titleLabel.grid.columns = contentView.grid.columns detailLabel.grid.offset.rows = 4
// titleLabel.grid.offset.columns = 1 detailLabel.grid.columns = 7
// detailLabel.grid.offset.columns = 1
// moreButton.grid.rows = 4
// moreButton.grid.columns = 2 // grid.axis.columns = g
// moreButton.grid.offset.columns = 8 // grid.axis.inherited = false
// // grid.views = [
// detailLabel.grid.rows = 7 // imageView,
// detailLabel.grid.offset.rows = 4 // contentView
// detailLabel.grid.columns = 7 // ]
// detailLabel.grid.offset.columns = 1
// contentView.grid.columns = g
// contentView.grid.spacing = 8
// contentView.grid.axis.columns = 10
// contentView.grid.axis.direction = .None
// contentView.grid.axis.inherited = false
// contentView.grid.contentInsetPreset = .Square2
contentView.grid.views = [ contentView.grid.views = [
titleLabel, imageView,
// moreButton, titleLabel
// detailLabel
] ]
} }
}
} }
...@@ -33,17 +33,23 @@ import UIKit ...@@ -33,17 +33,23 @@ import UIKit
class FeedCollectionViewLayout : UICollectionViewLayout { class FeedCollectionViewLayout : UICollectionViewLayout {
private var contentSize: CGSize = CGSizeZero private var contentSize: CGSize = CGSizeZero
private var layoutItems: Array<(UICollectionViewLayoutAttributes, NSIndexPath)>? private var layoutItems: Array<(UICollectionViewLayoutAttributes, NSIndexPath)>?
internal var height: CGFloat = 128 internal var height: CGFloat = 96
internal var offset: CGFloat = 4 internal var offset: CGFloat = 4
override func layoutAttributesForItemAtIndexPath(indexPath: NSIndexPath) -> UICollectionViewLayoutAttributes? { override func layoutAttributesForItemAtIndexPath(indexPath: NSIndexPath) -> UICollectionViewLayoutAttributes? {
let attributes: UICollectionViewLayoutAttributes = UICollectionViewLayoutAttributes(forCellWithIndexPath: indexPath) let attributes: UICollectionViewLayoutAttributes = UICollectionViewLayoutAttributes(forCellWithIndexPath: indexPath)
switch UIDevice.currentDevice().orientation {
case .LandscapeLeft, .LandscapeRight:
height = UIScreen.mainScreen().bounds.height - 44
default:
height = 96
}
let w: CGFloat = collectionView!.bounds.width let w: CGFloat = collectionView!.bounds.width
let r: CGFloat = CGFloat(indexPath.row) let r: CGFloat = CGFloat(indexPath.row)
let h: CGFloat = CGFloat(height)
attributes.frame = CGRectMake(0, r * CGFloat(h + (0 < r ? offset : 0)), w, h) attributes.frame = CGRectMake(0, r * CGFloat(height + (0 < r ? offset : 0)), w, height)
return attributes return attributes
} }
......
...@@ -42,6 +42,7 @@ struct Item { ...@@ -42,6 +42,7 @@ struct Item {
var title: String var title: String
var detail: String var detail: String
var image: UIImage? var image: UIImage?
var images: Array<UIImage?>?
} }
class FeedViewController: UIViewController { class FeedViewController: UIViewController {
...@@ -73,43 +74,50 @@ class FeedViewController: UIViewController { ...@@ -73,43 +74,50 @@ class FeedViewController: UIViewController {
items.append(Item( items.append(Item(
title: "Raw Vegan Blackberry Tart!", title: "Raw Vegan Blackberry Tart!",
detail: "Treat yourself today and every day with this sweet nutritious cake!", detail: "Treat yourself today and every day with this sweet nutritious cake!",
image: UIImage(named: "VeganCakeFull") image: UIImage(named: "VeganCakeFull"),
images: [UIImage(named: "VeganCakeFull"), UIImage(named: "VeganCakeFull")]
)) ))
items.append(Item( items.append(Item(
title: "Raw Vegan Pumpkin Pie", title: "Raw Vegan Pumpkin Pie",
detail: "Pumpkin lovers, desert lovers, and anyone who likes simple healthy cooking and enjoys eating! Light up your day with a piece of happiness- raw vegan pumpkin pie :)", detail: "Pumpkin lovers, desert lovers, and anyone who likes simple healthy cooking and enjoys eating! Light up your day with a piece of happiness- raw vegan pumpkin pie :)",
image: UIImage(named: "VeganPieAbove") image: UIImage(named: "VeganPieAbove"),
images: [UIImage(named: "VeganCakeFull"), UIImage(named: "VeganCakeFull")]
)) ))
items.append(Item( items.append(Item(
title: "Raw Vegan Nutty Sweets!", title: "Raw Vegan Nutty Sweets!",
detail: "Since most of my readers have a sweet tooth, here is another simple recipe to boost your happiness :)", detail: "Since most of my readers have a sweet tooth, here is another simple recipe to boost your happiness :)",
image: UIImage(named: "VeganHempBalls") image: UIImage(named: "VeganHempBalls"),
images: [UIImage(named: "VeganCakeFull"), UIImage(named: "VeganCakeFull")]
)) ))
items.append(Item( items.append(Item(
title: "Avocado Chocolate Cake!", title: "Avocado Chocolate Cake!",
detail: "Do you know what are the two best things about vegan food besides that it's healthy and full of nutrition? It's absolutely delicious and easy to make!", detail: "Do you know what are the two best things about vegan food besides that it's healthy and full of nutrition? It's absolutely delicious and easy to make!",
image: UIImage(named: "AssortmentOfFood") image: UIImage(named: "AssortmentOfFood"),
images: [UIImage(named: "VeganCakeFull"), UIImage(named: "VeganCakeFull")]
)) ))
items.append(Item( items.append(Item(
title: "Homemade brunch: Crepe Indulgence", title: "Homemade brunch: Crepe Indulgence",
detail: "Looking for a perfect sunday brunch spot? How about staying in and making something to die for?:)", detail: "Looking for a perfect sunday brunch spot? How about staying in and making something to die for?:)",
image: UIImage(named: "AssortmentOfDessert") image: UIImage(named: "AssortmentOfDessert"),
images: [UIImage(named: "VeganCakeFull"), UIImage(named: "VeganCakeFull")]
)) ))
items.append(Item( items.append(Item(
title: "Raw Vegan Chocolate Cookies", title: "Raw Vegan Chocolate Cookies",
detail: "Once I start making sweets it's hard for me to stop! I've got another exciting recipe, which hopefully you will love! :D", detail: "Once I start making sweets it's hard for me to stop! I've got another exciting recipe, which hopefully you will love! :D",
image: UIImage(named: "HeartCookies") image: UIImage(named: "HeartCookies"),
images: [UIImage(named: "VeganCakeFull"), UIImage(named: "VeganCakeFull")]
)) ))
items.append(Item( items.append(Item(
title: "Homemade Avocado Ice Cream", title: "Homemade Avocado Ice Cream",
detail: "Avocado ice cream (and vegan!) might not sound so appealing to some of you, but the truth is- it's mind blowing!!!", detail: "Avocado ice cream (and vegan!) might not sound so appealing to some of you, but the truth is- it's mind blowing!!!",
image: UIImage(named: "AvocadoIceCream") image: UIImage(named: "AvocadoIceCream"),
images: [UIImage(named: "VeganCakeFull"), UIImage(named: "VeganCakeFull")]
)) ))
} }
...@@ -134,6 +142,7 @@ extension FeedViewController: UICollectionViewDelegate { ...@@ -134,6 +142,7 @@ extension FeedViewController: UICollectionViewDelegate {
c.titleLabel.text = item.title c.titleLabel.text = item.title
c.detailLabel.text = item.detail c.detailLabel.text = item.detail
c.imageView.image = item.image c.imageView.image = item.image
c.images = item.images
c.grid.reloadLayout() c.grid.reloadLayout()
return c return c
......
...@@ -421,6 +421,7 @@ public class MaterialCollectionViewCell : UICollectionViewCell { ...@@ -421,6 +421,7 @@ public class MaterialCollectionViewCell : UICollectionViewCell {
/// Manages the layout for the visualLayer property. /// Manages the layout for the visualLayer property.
internal func layoutVisualLayer() { internal func layoutVisualLayer() {
visualLayer.frame = bounds visualLayer.frame = bounds
visualLayer.backgroundColor = MaterialColor.green.base.CGColor
visualLayer.position = CGPointMake(width / 2, height / 2) visualLayer.position = CGPointMake(width / 2, height / 2)
visualLayer.cornerRadius = layer.cornerRadius visualLayer.cornerRadius = layer.cornerRadius
} }
......
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