Commit 547b07de by Daniel Dahan

rework for release

parent e50b0c11
......@@ -68,7 +68,7 @@ class AppViewController: NavigationViewController {
because any earlier may cause a race condition when instantiating
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
}
......
......@@ -35,6 +35,7 @@ class FeedCollectionViewCell : MaterialCollectionViewCell {
let titleLabel: UILabel = UILabel()
let detailLabel: UILabel = UILabel()
let imageView: MaterialView = MaterialView()
var images: Array<UIImage?>?
override init(frame: CGRect) {
super.init(frame: frame)
......@@ -51,77 +52,98 @@ class FeedCollectionViewCell : MaterialCollectionViewCell {
}
override func prepareView() {
backgroundColor = MaterialColor.white
pulseScale = false
pulseColor = MaterialColor.blue.lighten4
var image: UIImage?
imageView.contentsGravity = .ResizeAspectFill
addSubview(imageView)
// var image: UIImage?
let contentView: MaterialView = MaterialView()
contentView.backgroundColor = MaterialColor.clear
addSubview(contentView)
contentView.addSubview(imageView)
titleLabel.textColor = MaterialColor.blueGrey.darken4
titleLabel.backgroundColor = MaterialColor.clear
contentView.addSubview(titleLabel)
image = UIImage(named: "ic_more_vert_white")?.imageWithRenderingMode(.AlwaysTemplate)
let moreButton: FlatButton = FlatButton()
moreButton.contentEdgeInsetsPreset = .None
moreButton.pulseColor = MaterialColor.blueGrey.darken4
moreButton.tintColor = MaterialColor.blueGrey.darken4
moreButton.setImage(image, forState: .Normal)
moreButton.setImage(image, forState: .Highlighted)
contentView.addSubview(moreButton)
detailLabel.numberOfLines = 0
detailLabel.lineBreakMode = .ByTruncatingTail
detailLabel.font = RobotoFont.regularWithSize(12)
detailLabel.textColor = MaterialColor.blueGrey.darken4
detailLabel.backgroundColor = MaterialColor.clear
contentView.addSubview(detailLabel)
// image = UIImage(named: "ic_more_vert_white")?.imageWithRenderingMode(.AlwaysTemplate)
// let moreButton: FlatButton = FlatButton()
// moreButton.contentEdgeInsetsPreset = .None
// moreButton.pulseColor = MaterialColor.blueGrey.darken4
// moreButton.tintColor = MaterialColor.blueGrey.darken4
// moreButton.setImage(image, forState: .Normal)
// moreButton.setImage(image, forState: .Highlighted)
// addSubview(moreButton)
// detailLabel.numberOfLines = 0
// detailLabel.lineBreakMode = .ByTruncatingTail
// detailLabel.font = RobotoFont.regularWithSize(12)
// detailLabel.textColor = MaterialColor.blueGrey.darken4
// detailLabel.backgroundColor = MaterialColor.clear
// addSubview(detailLabel)
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
grid.axis.columns = g
grid.views = [
imageView,
contentView
let bottomImageView: MaterialView = MaterialView()
imageView.addSubview(bottomImageView)
bottomImageView.image = v.last!
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
titleLabel.grid.columns = contentView.grid.columns
// titleLabel.grid.offset.columns = 1
//
// moreButton.grid.rows = 4
// moreButton.grid.columns = 2
// moreButton.grid.offset.columns = 8
//
// detailLabel.grid.rows = 7
// detailLabel.grid.offset.rows = 4
// detailLabel.grid.columns = 7
// detailLabel.grid.offset.columns = 1
//
// contentView.grid.spacing = 8
// contentView.grid.axis.columns = 10
// contentView.grid.axis.direction = .None
// contentView.grid.axis.inherited = false
// contentView.grid.contentInsetPreset = .Square2
detailLabel.grid.rows = 7
detailLabel.grid.offset.rows = 4
detailLabel.grid.columns = 7
detailLabel.grid.offset.columns = 1
// grid.axis.columns = g
// grid.axis.inherited = false
// grid.views = [
// imageView,
// contentView
// ]
contentView.grid.columns = g
contentView.grid.views = [
titleLabel,
// moreButton,
// detailLabel
imageView,
titleLabel
]
}
}
}
......@@ -33,17 +33,23 @@ import UIKit
class FeedCollectionViewLayout : UICollectionViewLayout {
private var contentSize: CGSize = CGSizeZero
private var layoutItems: Array<(UICollectionViewLayoutAttributes, NSIndexPath)>?
internal var height: CGFloat = 128
internal var height: CGFloat = 96
internal var offset: CGFloat = 4
override func layoutAttributesForItemAtIndexPath(indexPath: NSIndexPath) -> UICollectionViewLayoutAttributes? {
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 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
}
......
......@@ -42,6 +42,7 @@ struct Item {
var title: String
var detail: String
var image: UIImage?
var images: Array<UIImage?>?
}
class FeedViewController: UIViewController {
......@@ -73,43 +74,50 @@ class FeedViewController: UIViewController {
items.append(Item(
title: "Raw Vegan Blackberry Tart!",
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(
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 :)",
image: UIImage(named: "VeganPieAbove")
image: UIImage(named: "VeganPieAbove"),
images: [UIImage(named: "VeganCakeFull"), UIImage(named: "VeganCakeFull")]
))
items.append(Item(
title: "Raw Vegan Nutty Sweets!",
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(
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!",
image: UIImage(named: "AssortmentOfFood")
image: UIImage(named: "AssortmentOfFood"),
images: [UIImage(named: "VeganCakeFull"), UIImage(named: "VeganCakeFull")]
))
items.append(Item(
title: "Homemade brunch: Crepe Indulgence",
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(
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",
image: UIImage(named: "HeartCookies")
image: UIImage(named: "HeartCookies"),
images: [UIImage(named: "VeganCakeFull"), UIImage(named: "VeganCakeFull")]
))
items.append(Item(
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!!!",
image: UIImage(named: "AvocadoIceCream")
image: UIImage(named: "AvocadoIceCream"),
images: [UIImage(named: "VeganCakeFull"), UIImage(named: "VeganCakeFull")]
))
}
......@@ -134,6 +142,7 @@ extension FeedViewController: UICollectionViewDelegate {
c.titleLabel.text = item.title
c.detailLabel.text = item.detail
c.imageView.image = item.image
c.images = item.images
c.grid.reloadLayout()
return c
......
......@@ -421,6 +421,7 @@ public class MaterialCollectionViewCell : UICollectionViewCell {
/// Manages the layout for the visualLayer property.
internal func layoutVisualLayer() {
visualLayer.frame = bounds
visualLayer.backgroundColor = MaterialColor.green.base.CGColor
visualLayer.position = CGPointMake(width / 2, height / 2)
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