Commit e50b0c11 by Daniel Dahan

finalized default NavigationBarView grid settings

parent 6e3438dc
......@@ -93,25 +93,12 @@ class AppViewController: NavigationViewController {
let image: UIImage?
if menuView.menu.opened {
// Enable the side nav.
sideNavigationViewController?.enabled = true
// Position the menuBackdropLayer for the animation when closing.
menuBackdropLayer.animate(MaterialAnimation.scale(1))
hideMenuBackdropLayer()
menuView.menu.close()
image = UIImage(named: "ic_add_white")
} else {
// Disable the side nav, so users can't swipe while viewing the menu.
sideNavigationViewController?.enabled = false
// Position the menuBackdropLayer for the animation when opening.
MaterialAnimation.animationDisabled { [unowned self] in
self.menuBackdropLayer.frame = self.menuView.frame
self.menuBackdropLayer.shape = .Circle
}
menuBackdropLayer.animate(MaterialAnimation.scale(30))
menuBackdropLayer.hidden = false
showMenuBackdropLayer()
menuView.menu.open() { (v: UIView) in
(v as? MaterialButton)?.pulse()
......@@ -138,7 +125,7 @@ class AppViewController: NavigationViewController {
titleLabel.text = "Recipes"
titleLabel.textAlignment = .Left
titleLabel.textColor = MaterialColor.white
titleLabel.font = RobotoFont.regularWithSize(20)
titleLabel.font = RobotoFont.regularWithSize(17)
// Detail label. Uncomment the code below to use a detail label.
// let detailLabel: UILabel = UILabel()
......@@ -232,6 +219,37 @@ class AppViewController: NavigationViewController {
MaterialLayout.size(view, child: menuView, width: menuViewDiameter, height: menuViewDiameter)
MaterialLayout.alignFromBottomRight(view, child: menuView, bottom: menuViewInset, right: menuViewInset)
}
/// Displays the menuBackdropLayer.
private func showMenuBackdropLayer() {
// Disable the side nav, so users can't swipe while viewing the menu.
sideNavigationViewController?.enabled = false
// Position the menuBackdropLayer for the animation when opening.
MaterialAnimation.animationDisabled { [unowned self] in
self.menuBackdropLayer.frame = self.menuView.frame
self.menuBackdropLayer.shape = .Circle
self.menuBackdropLayer.hidden = false
}
menuBackdropLayer.animate(MaterialAnimation.scale(30, duration: 0.25))
}
/// Hides the menuBackdropLayer.
private func hideMenuBackdropLayer() {
// Enable the side nav.
sideNavigationViewController?.enabled = true
// Position the menuBackdropLayer for the animation when closing.
menuBackdropLayer.animate(MaterialAnimation.animationGroup([
MaterialAnimation.scale(1),
MaterialAnimation.position(menuView.center)
], duration: 0.25))
MaterialAnimation.delay(0.25) { [weak self] in
self?.menuBackdropLayer.hidden = true
}
}
}
/// SideNavigationViewControllerDelegate methods.
......
......@@ -31,8 +31,7 @@
import UIKit
import Material
class FeedCollectionViewCell : UICollectionViewCell {
private var cardView: MaterialPulseView!
class FeedCollectionViewCell : MaterialCollectionViewCell {
let titleLabel: UILabel = UILabel()
let detailLabel: UILabel = UILabel()
let imageView: MaterialView = MaterialView()
......@@ -51,20 +50,18 @@ class FeedCollectionViewCell : UICollectionViewCell {
fatalError("init(coder:) has not been implemented")
}
private func prepareView() {
cardView = MaterialPulseView()
cardView.pulseScale = false
cardView.pulseColor = MaterialColor.blue.lighten4
addSubview(cardView)
override func prepareView() {
pulseScale = false
pulseColor = MaterialColor.blue.lighten4
var image: UIImage?
imageView.contentsGravity = .ResizeAspectFill
cardView.addSubview(imageView)
addSubview(imageView)
let contentView: MaterialView = MaterialView()
contentView.backgroundColor = MaterialColor.clear
cardView.addSubview(contentView)
addSubview(contentView)
titleLabel.textColor = MaterialColor.blueGrey.darken4
titleLabel.backgroundColor = MaterialColor.clear
......@@ -72,7 +69,7 @@ class FeedCollectionViewCell : UICollectionViewCell {
image = UIImage(named: "ic_more_vert_white")?.imageWithRenderingMode(.AlwaysTemplate)
let moreButton: FlatButton = FlatButton()
moreButton.contentInsetPreset = .None
moreButton.contentEdgeInsetsPreset = .None
moreButton.pulseColor = MaterialColor.blueGrey.darken4
moreButton.tintColor = MaterialColor.blueGrey.darken4
moreButton.setImage(image, forState: .Normal)
......@@ -89,15 +86,14 @@ class FeedCollectionViewCell : UICollectionViewCell {
let g: Int = Int(bounds.width / 48)
grid.axis.columns = g
grid.views = [cardView]
imageView.grid.columns = 4
contentView.grid.columns = g - 4
cardView.grid.contentInset.right = 8
cardView.grid.axis.columns = g
cardView.grid.views = [
grid.contentInset.right = 8
grid.axis.columns = g
grid.views = [
imageView,
contentView
]
......
......@@ -43,6 +43,6 @@ public class FlatButton : MaterialButton {
setTitleColor(MaterialColor.blue.accent3, forState: .Normal)
pulseColor = MaterialColor.blue.accent3
cornerRadiusPreset = .Radius1
contentInsetPreset = .WideRectangle3
contentEdgeInsetsPreset = .WideRectangle3
}
}
\ No newline at end of file
......@@ -257,12 +257,10 @@ public class MaterialButton : UIButton {
}
}
/**
:name: contentInsets
*/
public var contentInsetPreset: MaterialEdgeInset {
/// A preset property for updated contentEdgeInsets.
public var contentEdgeInsetsPreset: MaterialEdgeInset {
didSet {
let value: UIEdgeInsets = MaterialEdgeInsetToValue(contentInsetPreset)
let value: UIEdgeInsets = MaterialEdgeInsetToValue(contentEdgeInsetsPreset)
contentEdgeInsets = UIEdgeInsetsMake(value.top, value.left, value.bottom, value.right)
}
}
......@@ -276,7 +274,7 @@ public class MaterialButton : UIButton {
cornerRadiusPreset = .None
shape = .None
borderWidth = 0
contentInsetPreset = .None
contentEdgeInsetsPreset = .None
super.init(coder: aDecoder)
prepareView()
}
......@@ -292,7 +290,7 @@ public class MaterialButton : UIButton {
cornerRadiusPreset = .None
shape = .None
borderWidth = 0
contentInsetPreset = .None
contentEdgeInsetsPreset = .None
super.init(frame: frame)
prepareView()
}
......
......@@ -121,30 +121,39 @@ public class NavigationBarView : MaterialView {
// General alignment.
switch UIDevice.currentDevice().orientation {
case .LandscapeLeft, .LandscapeRight:
grid.contentInset.top = 0
grid.contentInset.bottom = 0
titleView.grid.spacing = 2
titleView.grid.contentInset.top = 4
titleView.grid.contentInset.bottom = 8
height = 44
default:
grid.contentInset.top = 20
grid.contentInset.bottom = 8
grid.contentInset.top = 8
// TitleView alignment.
if let v: UILabel = titleLabel {
if let d: UILabel = detailLabel {
v.grid.rows = 7
d.grid.rows = 5
titleView.grid.spacing = 4
titleView.grid.contentInset.top = -3
} else {
v.grid.rows = 12
titleView.grid.spacing = 0
titleView.grid.contentInset.top = 0
titleView.grid.contentInset.bottom = 0
height = 64
}
}
height = 44
default:
grid.contentInset.top = 28
// TitleView alignment.
titleView.grid.axis.rows = 6
if let v: UILabel = titleLabel {
titleView.grid.views?.append(v)
v.grid.rows = nil == detailLabel ? 6 : 4
if let d: UILabel = detailLabel {
v.grid.rows = 7
d.grid.rows = 5
titleView.grid.spacing = 4
titleView.grid.contentInset.top = -3
} else {
v.grid.rows = 12
titleView.grid.spacing = 0
titleView.grid.contentInset.top = 0
}
if let v: UILabel = detailLabel {
titleView.grid.views?.append(v)
v.grid.rows = 2
}
height = 64
}
// Column adjustment.
......@@ -241,7 +250,6 @@ public class NavigationBarView : MaterialView {
super.prepareView()
grid.spacing = 8
grid.axis.inherited = false
grid.contentInset.top = 20
grid.contentInset.left = 8
grid.contentInset.bottom = 8
grid.contentInset.right = 8
......@@ -252,7 +260,6 @@ public class NavigationBarView : MaterialView {
/// Prepares the titleView.
public func prepareTitleView() {
titleView.backgroundColor = nil
titleView.grid.axis.inherited = false
titleView.grid.axis.direction = .Vertical
addSubview(titleView)
}
......
......@@ -156,7 +156,8 @@ public class NavigationViewController: UIViewController {
/// Layout subviews.
private func layoutSubviews() {
let size: CGSize = UIScreen.mainScreen().bounds.size
mainViewController.view.frame = CGRectMake(0, navigationBarView.height, size.width, size.height - navigationBarView.height)
let h: CGFloat = UIApplication.sharedApplication().statusBarFrame.size.height
mainViewController.view.frame = CGRectMake(0, navigationBarView.height, size.width, size.height - navigationBarView.height - (20 >= h ? 0 : h - 20))
}
}
......
......@@ -44,6 +44,6 @@ public class RaisedButton : MaterialButton {
backgroundColor = MaterialColor.blue.accent3
depth = .Depth1
cornerRadiusPreset = .Radius1
contentInsetPreset = .WideRectangle3
contentEdgeInsetsPreset = .WideRectangle3
}
}
\ No newline at end of file
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