Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
M
Material
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Dmitriy Stepanets
Material
Commits
3f51240e
Commit
3f51240e
authored
Feb 21, 2016
by
Daniel Dahan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
updated App example
parent
dfd7d96e
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
73 additions
and
42 deletions
+73
-42
Examples/Programmatic/NavigationBarViewController/NavigationBarViewController/AppMenuViewController.swift
+33
-22
Examples/Programmatic/NavigationBarViewController/NavigationBarViewController/AppNavigationBarViewController.swift
+1
-0
Sources/MaterialTransitionAnimation.swift
+2
-2
Sources/MenuView.swift
+18
-0
Sources/NavigationBarViewController.swift
+19
-18
No files found.
Examples/Programmatic/NavigationBarViewController/NavigationBarViewController/AppMenuViewController.swift
View file @
3f51240e
...
@@ -52,59 +52,71 @@ class AppMenuViewController: MenuViewController {
...
@@ -52,59 +52,71 @@ class AppMenuViewController: MenuViewController {
/**
/**
*/
*/
func
handleBtn2
()
{
func
handleBtn2
()
{
if
navigationBar
ViewController
?
.
mainViewController
is
BlueViewController
{
if
menu
ViewController
?
.
mainViewController
is
BlueViewController
{
return
return
}
}
handleMenu
()
menuViewController
?
.
transitionFromMainViewController
(
BlueViewController
())
closeMenu
{
[
weak
self
]
in
navigationBarViewController
?
.
navigationBarView
.
titleLabel
?
.
text
=
"Blue"
self
?
.
menuViewController
?
.
transitionFromMainViewController
(
BlueViewController
(),
options
:
[
.
TransitionCrossDissolve
])
}
}
}
/**
/**
*/
*/
func
handleBtn3
()
{
func
handleBtn3
()
{
if
navigationBar
ViewController
?
.
mainViewController
is
GreenViewController
{
if
menu
ViewController
?
.
mainViewController
is
GreenViewController
{
return
return
}
}
handleMenu
()
closeMenu
{
[
weak
self
]
in
menuViewController
?
.
transitionFromMainViewController
(
GreenViewController
()
)
self
?
.
menuViewController
?
.
transitionFromMainViewController
(
GreenViewController
(),
options
:
[
.
TransitionCrossDissolve
]
)
navigationBarViewController
?
.
navigationBarView
.
titleLabel
?
.
text
=
"Green"
}
}
}
/**
/**
*/
*/
func
handleBtn4
()
{
func
handleBtn4
()
{
if
navigationBarViewController
?
.
mainViewController
is
FeedViewController
{
if
(
menuViewController
?
.
mainViewController
as?
NavigationBarViewController
)
?
.
mainViewController
is
FeedViewController
{
return
return
}
}
handleMenu
()
closeMenu
{
[
weak
self
]
in
menuViewController
?
.
transitionFromMainViewController
(
AppNavigationBarViewController
(
mainViewController
:
FeedViewController
()))
self
?
.
menuViewController
?
.
transitionFromMainViewController
(
AppNavigationBarViewController
(
mainViewController
:
FeedViewController
()),
options
:
[
.
TransitionCrossDissolve
])
navigationBarViewController
?
.
navigationBarView
.
titleLabel
?
.
text
=
"Feed"
}
}
/// Opens the menu with a callback.
func
openMenu
(
completion
:
(()
->
Void
)?
=
nil
)
{
(
menuView
.
menu
.
views
?
.
first
as?
MaterialButton
)?
.
animate
(
MaterialAnimation
.
rotate
(
0.125
))
menuView
.
menu
.
open
{
[
weak
self
]
(
v
:
UIView
)
in
(
v
as?
MaterialButton
)?
.
pulse
()
if
self
?
.
menuView
.
menu
.
views
?
.
last
==
v
{
completion
?()
}
}
}
/// Closes the menu with a callback.
func
closeMenu
(
completion
:
(()
->
Void
)?
=
nil
)
{
(
menuView
.
menu
.
views
?
.
first
as?
MaterialButton
)?
.
animate
(
MaterialAnimation
.
rotate
(
-
0.125
))
menuView
.
close
(
completion
)
}
}
/// Handle the menuView touch event.
/// Handle the menuView touch event.
func
handleMenu
()
{
func
handleMenu
()
{
var
rotate
:
Double
=
-
0.125
if
true
==
menuView
.
menu
.
opened
{
if
true
==
menuView
.
menu
.
opened
{
hideMenuBackdrop
()
hideMenuBackdrop
()
menuView
.
menu
.
close
()
closeMenu
()
}
else
{
}
else
{
showMenuBackdrop
()
showMenuBackdrop
()
rotate
=
0.125
openMenu
()
menuView
.
menu
.
open
()
{
(
v
:
UIView
)
in
(
v
as?
MaterialButton
)?
.
pulse
()
}
}
}
(
menuView
.
menu
.
views
?
.
first
as?
MaterialButton
)?
.
animate
(
MaterialAnimation
.
rotate
(
rotate
))
}
}
/// Prepares view.
/// Prepares view.
private
func
prepareView
()
{
private
func
prepareView
()
{
view
.
backgroundColor
=
MaterialColor
.
white
view
.
backgroundColor
=
MaterialColor
.
black
}
}
/// Prepares the add button.
/// Prepares the add button.
...
@@ -141,7 +153,6 @@ class AppMenuViewController: MenuViewController {
...
@@ -141,7 +153,6 @@ class AppMenuViewController: MenuViewController {
btn4
.
addTarget
(
self
,
action
:
"handleBtn4"
,
forControlEvents
:
.
TouchUpInside
)
btn4
.
addTarget
(
self
,
action
:
"handleBtn4"
,
forControlEvents
:
.
TouchUpInside
)
// Initialize the menu and setup the configuration options.
// Initialize the menu and setup the configuration options.
menuView
.
menu
.
direction
=
.
Up
menuView
.
menu
.
baseViewSize
=
baseViewSize
menuView
.
menu
.
baseViewSize
=
baseViewSize
menuView
.
menu
.
views
=
[
btn1
,
btn2
,
btn3
,
btn4
]
menuView
.
menu
.
views
=
[
btn1
,
btn2
,
btn3
,
btn4
]
...
...
Examples/Programmatic/NavigationBarViewController/NavigationBarViewController/AppNavigationBarViewController.swift
View file @
3f51240e
...
@@ -81,6 +81,7 @@ class AppNavigationBarViewController: NavigationBarViewController {
...
@@ -81,6 +81,7 @@ class AppNavigationBarViewController: NavigationBarViewController {
guard
let
v
:
AppSearchBarViewController
=
AppSearchBarViewController
(
mainViewController
:
SearchListViewController
())
else
{
guard
let
v
:
AppSearchBarViewController
=
AppSearchBarViewController
(
mainViewController
:
SearchListViewController
())
else
{
return
return
}
}
navigationBarViewController
?
.
floatingViewController
=
v
navigationBarViewController
?
.
floatingViewController
=
v
}
}
...
...
Sources/MaterialTransitionAnimation.swift
View file @
3f51240e
...
@@ -73,9 +73,9 @@ public func MaterialAnimationTransitionSubTypeToValue(direction: MaterialAnimati
...
@@ -73,9 +73,9 @@ public func MaterialAnimationTransitionSubTypeToValue(direction: MaterialAnimati
case
.
Left
:
case
.
Left
:
return
kCATransitionFromLeft
return
kCATransitionFromLeft
case
.
Top
:
case
.
Top
:
return
kCATransitionFromTop
case
.
Bottom
:
return
kCATransitionFromBottom
return
kCATransitionFromBottom
case
.
Bottom
:
return
kCATransitionFromTop
}
}
}
}
...
...
Sources/MenuView.swift
View file @
3f51240e
...
@@ -48,6 +48,24 @@ public class MenuView : MaterialPulseView {
...
@@ -48,6 +48,24 @@ public class MenuView : MaterialPulseView {
clipsToBounds
=
false
clipsToBounds
=
false
backgroundColor
=
nil
backgroundColor
=
nil
}
}
/// Opens the menu with a callback.
public
func
open
(
completion
:
(()
->
Void
)?
=
nil
)
{
menu
.
open
{
[
weak
self
]
(
v
:
UIView
)
in
if
self
?
.
menu
.
views
?
.
last
==
v
{
completion
?()
}
}
}
/// Closes the menu with a callback.
public
func
close
(
completion
:
(()
->
Void
)?
=
nil
)
{
menu
.
close
{
[
weak
self
]
(
v
:
UIView
)
in
if
self
?
.
menu
.
views
?
.
last
==
v
{
completion
?()
}
}
}
public
override
func
hitTest
(
point
:
CGPoint
,
withEvent
event
:
UIEvent
?)
->
UIView
?
{
public
override
func
hitTest
(
point
:
CGPoint
,
withEvent
event
:
UIEvent
?)
->
UIView
?
{
/**
/**
...
...
Sources/NavigationBarViewController.swift
View file @
3f51240e
...
@@ -49,18 +49,32 @@ public extension UIViewController {
...
@@ -49,18 +49,32 @@ public extension UIViewController {
}
}
public
class
NavigationBarViewController
:
UIViewController
{
public
class
NavigationBarViewController
:
UIViewController
{
/// Reference to the NavigationBarView.
public
private(set)
lazy
var
navigationBarView
:
NavigationBarView
=
NavigationBarView
()
/// Internal reference to the floatingViewController.
/// Internal reference to the floatingViewController.
private
var
internalFloatingViewController
:
UIViewController
?
private
var
internalFloatingViewController
:
UIViewController
?
/// Reference to the NavigationBarView.
public
private(set)
lazy
var
navigationBarView
:
NavigationBarView
=
NavigationBarView
()
/// A floating UIViewController.
/// A floating UIViewController.
public
var
floatingViewController
:
UIViewController
?
{
public
var
floatingViewController
:
UIViewController
?
{
get
{
get
{
return
internalFloatingViewController
return
internalFloatingViewController
}
}
set
(
value
)
{
set
(
value
)
{
if
let
v
:
UIViewController
=
internalFloatingViewController
{
sideNavigationViewController
?
.
enabled
=
true
UIView
.
animateWithDuration
(
0.5
,
animations
:
{
[
unowned
self
]
in
v
.
view
.
center
.
y
=
2
*
self
.
view
.
bounds
.
height
})
{
[
unowned
self
]
_
in
v
.
willMoveToParentViewController
(
nil
)
v
.
view
.
removeFromSuperview
()
v
.
removeFromParentViewController
()
self
.
internalFloatingViewController
=
nil
}
}
if
let
v
:
UIViewController
=
value
{
if
let
v
:
UIViewController
=
value
{
/**
/**
Disable the sideNavigationViewController from opening while in
Disable the sideNavigationViewController from opening while in
...
@@ -79,24 +93,11 @@ public class NavigationBarViewController: UIViewController {
...
@@ -79,24 +93,11 @@ public class NavigationBarViewController: UIViewController {
// Animate the noteButton out and the noteViewController! in.
// Animate the noteButton out and the noteViewController! in.
v
.
view
.
hidden
=
false
v
.
view
.
hidden
=
false
internalFloatingViewController
=
v
UIView
.
animateWithDuration
(
0.5
,
UIView
.
animateWithDuration
(
0.5
,
animations
:
{
[
unowned
self
]
in
animations
:
{
[
unowned
self
]
in
v
.
view
.
center
.
y
=
self
.
view
.
bounds
.
height
/
2
v
.
view
.
center
.
y
=
self
.
view
.
bounds
.
height
/
2
})
})
{
[
unowned
self
]
_
in
}
else
if
let
v
:
UIViewController
=
internalFloatingViewController
{
self
.
internalFloatingViewController
=
v
sideNavigationViewController
?
.
enabled
=
true
internalFloatingViewController
=
nil
UIView
.
animateWithDuration
(
0.5
,
animations
:
{
[
unowned
self
]
in
v
.
view
.
center
.
y
=
2
*
self
.
view
.
bounds
.
height
})
{
_
in
v
.
willMoveToParentViewController
(
nil
)
v
.
view
.
removeFromSuperview
()
v
.
removeFromParentViewController
()
}
}
}
}
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment