Commit bb852d76 by danieldahan

renamed MenuView to MenuLayout

parent fdf87ffa
......@@ -58,9 +58,9 @@
</Group>
<Group
location = "container:"
name = "MenuView">
name = "MenuLayout">
<FileRef
location = "group:Programmatic/MenuView/MenuView.xcodeproj">
location = "group:Programmatic/MenuLayout/MenuLayout.xcodeproj">
</FileRef>
</Group>
<Group
......
......@@ -2,6 +2,6 @@
<Workspace
version = "1.0">
<FileRef
location = "self:MenuView.xcodeproj">
location = "self:MenuLayout.xcodeproj">
</FileRef>
</Workspace>
......@@ -59,6 +59,7 @@ class ViewController: UIViewController {
if menuLayout.opened {
menuLayout.close()
} else {
// (menuLayout.items?.first?.button as? MaterialButton)?.animate(MaterialAnimation.rotate(1))
menuLayout.open() { (item: MenuLayoutItem) in
(item.button as? MaterialButton)?.pulse()
}
......@@ -78,36 +79,36 @@ class ViewController: UIViewController {
let image: UIImage? = UIImage(named: "ic_add_white")
let btn1: FabButton = FabButton()
btn1.depth = .None
btn1.depth = .Depth1
btn1.setImage(image, forState: .Normal)
btn1.setImage(image, forState: .Highlighted)
btn1.addTarget(self, action: "handleOpenMenuLayout", forControlEvents: .TouchUpInside)
view.addSubview(btn1)
let btn2: FabButton = FabButton()
btn2.depth = .None
btn2.depth = .Depth1
btn2.backgroundColor = MaterialColor.blue.base
btn2.setImage(image, forState: .Normal)
btn2.setImage(image, forState: .Highlighted)
view.addSubview(btn2)
let btn3: FabButton = FabButton()
btn3.depth = .None
btn3.depth = .Depth1
btn3.backgroundColor = MaterialColor.green.base
btn3.setImage(image, forState: .Normal)
btn3.setImage(image, forState: .Highlighted)
view.addSubview(btn3)
let btn4: FabButton = FabButton()
btn4.depth = .None
btn4.depth = .Depth1
btn4.backgroundColor = MaterialColor.yellow.base
btn4.setImage(image, forState: .Normal)
btn4.setImage(image, forState: .Highlighted)
view.addSubview(btn4)
menuLayout = MenuLayout()
menuLayout.baseSize = CGSizeMake(48, 48)
menuLayout.itemSize = CGSizeMake(36, 36)
menuLayout.baseSize = CGSizeMake(56, 56)
menuLayout.itemSize = CGSizeMake(48, 48)
menuLayout.items = [
MenuLayoutItem(button: btn1),
......
......@@ -391,9 +391,9 @@
96D88C541C132A7700B91418 /* Navigation */ = {
isa = PBXGroup;
children = (
65FDC2EA1C66858A00103AC2 /* MenuLayout.swift */,
96D88C151C1328D800B91418 /* NavigationBarView.swift */,
96D88C1D1C1328D800B91418 /* SideNavigationViewController.swift */,
65FDC2EA1C66858A00103AC2 /* MenuLayout.swift */,
);
name = Navigation;
sourceTree = "<group>";
......
......@@ -407,7 +407,7 @@ public class CardView : MaterialPulseView {
public override func prepareView() {
super.prepareView()
pulseColor = MaterialColor.blueGrey.lighten4
depth = .Depth2
depth = .Depth1
dividerColor = MaterialColor.blueGrey.lighten5
}
......
......@@ -41,7 +41,7 @@ public class FabButton : MaterialButton {
public override func prepareView() {
super.prepareView()
backgroundColor = MaterialColor.red.darken1
depth = .Depth2
depth = .Depth1
shape = .Circle
}
}
\ No newline at end of file
......@@ -544,7 +544,7 @@ public class ImageCardView : MaterialPulseView {
public override func prepareView() {
super.prepareView()
pulseColor = MaterialColor.blueGrey.lighten4
depth = .Depth2
depth = .Depth1
dividerColor = MaterialColor.blueGrey.lighten5
}
......
......@@ -64,6 +64,9 @@ public class MenuLayout {
/// A Boolean that indicates if the menu is open or not.
public private(set) var opened: Bool = false
/// Animation duration.
public var duration: Double = 0.07
/// The position of the menu.
public var position: MenuLayoutPosition = .BottomRight {
didSet {
......@@ -90,6 +93,7 @@ public class MenuLayout {
}
public func reloadLayout() {
opened = false
switch position {
case .TopLeft:
layoutTopLeft()
......@@ -137,7 +141,7 @@ public class MenuLayout {
}
let item: MenuLayoutItem = v[i]
item.button.hidden = false
UIView.animateWithDuration(Double(i) * 0.15,
UIView.animateWithDuration(Double(i) * duration,
animations: { [unowned self] in
item.button.alpha = 1
item.button.frame.origin.y = base!.button.frame.origin.y - CGFloat(i) * self.itemSize.height - CGFloat(i) * 16
......@@ -154,7 +158,7 @@ public class MenuLayout {
if let v: Array<MenuLayoutItem> = items {
for var i: Int = 1, l: Int = v.count; i < l; ++i {
let item: MenuLayoutItem = v[i]
UIView.animateWithDuration(0.15,
UIView.animateWithDuration(Double(i) * duration,
animations: { [unowned self] in
item.button.alpha = 0
item.button.frame.origin.y = self.height - item.button.bounds.height - 16
......@@ -177,7 +181,7 @@ public class MenuLayout {
}
let item: MenuLayoutItem = v[i]
item.button.hidden = false
UIView.animateWithDuration(Double(i) * 0.15,
UIView.animateWithDuration(Double(i) * duration,
animations: { [unowned self] in
item.button.alpha = 1
item.button.frame.origin.y = base!.button.frame.origin.y + self.baseSize.height + CGFloat(i - 1) * self.itemSize.height + CGFloat(i) * 16
......@@ -194,7 +198,7 @@ public class MenuLayout {
if let v: Array<MenuLayoutItem> = items {
for var i: Int = 1, l: Int = v.count; i < l; ++i {
let item: MenuLayoutItem = v[i]
UIView.animateWithDuration(0.15,
UIView.animateWithDuration(Double(i) * duration,
animations: {
item.button.alpha = 0
item.button.frame.origin.y = 16
......@@ -217,7 +221,7 @@ public class MenuLayout {
}
let item: MenuLayoutItem = v[i]
item.button.hidden = false
UIView.animateWithDuration(Double(i) * 0.15,
UIView.animateWithDuration(Double(i) * duration,
animations: { [unowned self] in
item.button.alpha = 1
item.button.frame.origin.x = base!.button.frame.origin.x - CGFloat(i) * self.itemSize.width - CGFloat(i) * 16
......@@ -234,7 +238,7 @@ public class MenuLayout {
if let v: Array<MenuLayoutItem> = items {
for var i: Int = 1, l: Int = v.count; i < l; ++i {
let item: MenuLayoutItem = v[i]
UIView.animateWithDuration(0.15,
UIView.animateWithDuration(Double(i) * duration,
animations: { [unowned self] in
item.button.alpha = 0
item.button.frame.origin.x = self.width - item.button.bounds.width - 16
......@@ -257,7 +261,7 @@ public class MenuLayout {
}
let item: MenuLayoutItem = v[i]
item.button.hidden = false
UIView.animateWithDuration(Double(i) * 0.15,
UIView.animateWithDuration(Double(i) * duration,
animations: { [unowned self] in
item.button.alpha = 1
item.button.frame.origin.x = base!.button.frame.origin.x + self.baseSize.width + CGFloat(i - 1) * self.itemSize.width + CGFloat(i) * 16
......@@ -274,7 +278,7 @@ public class MenuLayout {
if let v: Array<MenuLayoutItem> = items {
for var i: Int = 1, l: Int = v.count; i < l; ++i {
let item: MenuLayoutItem = v[i]
UIView.animateWithDuration(0.15,
UIView.animateWithDuration(Double(i) * duration,
animations: {
item.button.alpha = 0
item.button.frame.origin.x = 16
......
......@@ -332,7 +332,7 @@ public class NavigationBarView : MaterialView {
*/
public override func prepareView() {
super.prepareView()
depth = .Depth2
depth = .Depth1
}
/**
......
......@@ -42,7 +42,7 @@ public class RaisedButton : MaterialButton {
super.prepareView()
setTitleColor(MaterialColor.white, forState: .Normal)
backgroundColor = MaterialColor.blue.accent3
depth = .Depth2
depth = .Depth1
cornerRadius = .Radius1
contentInsetPreset = .WideRectangle3
}
......
......@@ -234,7 +234,7 @@ public class SideNavigationViewController: UIViewController, UIGestureRecognizer
A MaterialDepth property that is used to set the depth of the
leftView when opened.
*/
public var depth: MaterialDepth = .Depth2
public var depth: MaterialDepth = .Depth1
/**
A MaterialView property that is used to hide and reveal the
......
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