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
cb15b04c
Unverified
Commit
cb15b04c
authored
Jun 09, 2016
by
M. Porooshani
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Reverted changes to NavBar and SideNav to stable
parent
11f9e26e
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
81 additions
and
76 deletions
+81
-76
Examples/Programmatic/App/App/AppDelegate.swift
+6
-5
Examples/Programmatic/App/App/AppMenuController.swift
+26
-18
Examples/Programmatic/App/App/AppNavigationController.swift
+0
-8
Examples/Programmatic/App/App/ItemViewController.swift
+13
-6
Examples/Programmatic/App/App/RecipesViewController.swift
+21
-0
Sources/iOS/NavigationBar.swift
+3
-17
Sources/iOS/SideNavigationController.swift
+12
-22
No files found.
Examples/Programmatic/App/App/AppDelegate.swift
View file @
cb15b04c
...
@@ -38,16 +38,17 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
...
@@ -38,16 +38,17 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
func
application
(
application
:
UIApplication
,
didFinishLaunchingWithOptions
launchOptions
:
[
NSObject
:
AnyObject
]?)
->
Bool
{
func
application
(
application
:
UIApplication
,
didFinishLaunchingWithOptions
launchOptions
:
[
NSObject
:
AnyObject
]?)
->
Bool
{
let
navigationController
:
AppNavigationController
=
AppNavigationController
(
rootViewController
:
RecipesViewController
())
let
navigationController
:
AppNavigationController
=
AppNavigationController
(
rootViewController
:
RecipesViewController
())
let
menuController
:
AppMenuController
=
AppMenuController
(
rootViewController
:
navigationController
)
menuController
.
edgesForExtendedLayout
=
.
None
let
bottomNavigationController
:
BottomNavigationController
=
BottomNavigationController
()
let
bottomNavigationController
:
BottomNavigationController
=
BottomNavigationController
()
bottomNavigationController
.
viewControllers
=
[
navigation
Controller
,
VideoViewController
(),
PhotoViewController
()]
bottomNavigationController
.
viewControllers
=
[
menu
Controller
,
VideoViewController
(),
PhotoViewController
()]
bottomNavigationController
.
selectedIndex
=
0
bottomNavigationController
.
selectedIndex
=
0
bottomNavigationController
.
tabBar
.
tintColor
=
MaterialColor
.
white
bottomNavigationController
.
tabBar
.
tintColor
=
MaterialColor
.
white
bottomNavigationController
.
tabBar
.
backgroundColor
=
MaterialColor
.
grey
.
darken4
bottomNavigationController
.
tabBar
.
backgroundColor
=
MaterialColor
.
grey
.
darken4
let
menuController
:
AppMenuController
=
AppMenuController
(
rootViewController
:
bottomNavigationController
)
let
sideNavigationController
:
SideNavigationController
=
SideNavigationController
(
rootViewController
:
bottomNavigationController
,
leftViewController
:
AppLeftViewController
())
let
sideNavigationController
:
SideNavigationController
=
SideNavigationController
(
rootViewController
:
menuController
,
leftViewController
:
AppLeftViewController
())
sideNavigationController
.
statusBarStyle
=
.
LightContent
sideNavigationController
.
statusBarStyle
=
.
LightContent
window
=
UIWindow
(
frame
:
UIScreen
.
mainScreen
()
.
bounds
)
window
=
UIWindow
(
frame
:
UIScreen
.
mainScreen
()
.
bounds
)
...
...
Examples/Programmatic/App/App/AppMenuController.swift
View file @
cb15b04c
...
@@ -40,11 +40,28 @@ class AppMenuController: MenuController {
...
@@ -40,11 +40,28 @@ class AppMenuController: MenuController {
/// MenuView diameter.
/// MenuView diameter.
private
let
baseSize
:
CGSize
=
CGSizeMake
(
56
,
56
)
private
let
baseSize
:
CGSize
=
CGSizeMake
(
56
,
56
)
/// MenuView inset.
private
let
menuViewInset
:
CGFloat
=
16
required
init
?(
coder
aDecoder
:
NSCoder
)
{
super
.
init
(
coder
:
aDecoder
)
}
override
init
(
rootViewController
:
UIViewController
)
{
super
.
init
(
rootViewController
:
rootViewController
)
prepareTabBarItem
()
}
override
func
viewDidLoad
()
{
override
func
viewDidLoad
()
{
super
.
viewDidLoad
()
super
.
viewDidLoad
()
prepareMenuView
()
prepareMenuView
()
}
}
override
func
viewWillDisappear
(
animated
:
Bool
)
{
super
.
viewWillDisappear
(
animated
)
closeMenu
()
}
override
func
openMenu
(
completion
:
(()
->
Void
)?
=
nil
)
{
override
func
openMenu
(
completion
:
(()
->
Void
)?
=
nil
)
{
super
.
openMenu
(
completion
)
super
.
openMenu
(
completion
)
sideNavigationController
?
.
enabled
=
false
sideNavigationController
?
.
enabled
=
false
...
@@ -81,22 +98,6 @@ class AppMenuController: MenuController {
...
@@ -81,22 +98,6 @@ class AppMenuController: MenuController {
}
}
}
}
/// Shows the menuView.
func
showMenu
()
{
menuView
.
animate
(
MaterialAnimation
.
animationGroup
([
MaterialAnimation
.
rotate
(
rotation
:
3
),
MaterialAnimation
.
translateY
(
0
)
]))
}
/// Hides the menuView.
func
hideMenu
()
{
menuView
.
animate
(
MaterialAnimation
.
animationGroup
([
MaterialAnimation
.
rotate
(
rotation
:
3
),
MaterialAnimation
.
translateY
(
150
)
]))
}
/// Prepares the menuView.
/// Prepares the menuView.
private
func
prepareMenuView
()
{
private
func
prepareMenuView
()
{
var
image
:
UIImage
?
=
MaterialIcon
.
cm
.
add
var
image
:
UIImage
?
=
MaterialIcon
.
cm
.
add
...
@@ -138,10 +139,17 @@ class AppMenuController: MenuController {
...
@@ -138,10 +139,17 @@ class AppMenuController: MenuController {
menuView
.
menu
.
baseSize
=
baseSize
menuView
.
menu
.
baseSize
=
baseSize
menuView
.
menu
.
views
=
[
menuButton
,
blueButton
,
greenButton
,
yellowButton
]
menuView
.
menu
.
views
=
[
menuButton
,
blueButton
,
greenButton
,
yellowButton
]
menuView
.
delegate
=
self
menuView
.
delegate
=
self
view
.
layout
.
size
(
menuView
,
width
:
baseSize
.
width
,
height
:
baseSize
.
height
)
view
.
layout
.
size
(
menuView
,
width
:
baseSize
.
width
,
height
:
baseSize
.
height
)
view
.
layout
.
align
.
bottomRight
(
menuView
,
bottom
:
65
,
right
:
16
)
view
.
layout
.
align
.
bottomRight
(
menuView
,
bottom
:
menuViewInset
,
right
:
menuViewInset
)
}
}
/// Prepare tabBarItem.
private
func
prepareTabBarItem
()
{
tabBarItem
.
image
=
MaterialIcon
.
cm
.
photoLibrary
tabBarItem
.
setTitleColor
(
MaterialColor
.
grey
.
base
,
forState
:
.
Normal
)
tabBarItem
.
setTitleColor
(
MaterialColor
.
white
,
forState
:
.
Selected
)
}
}
}
/// MenuViewDelegate.
/// MenuViewDelegate.
...
...
Examples/Programmatic/App/App/AppNavigationController.swift
View file @
cb15b04c
...
@@ -35,7 +35,6 @@ class AppNavigationController: NavigationController {
...
@@ -35,7 +35,6 @@ class AppNavigationController: NavigationController {
override
func
viewDidLoad
()
{
override
func
viewDidLoad
()
{
super
.
viewDidLoad
()
super
.
viewDidLoad
()
prepareNavigationBar
()
prepareNavigationBar
()
prepareTabBarItem
()
}
}
/// Prepares the navigationBar
/// Prepares the navigationBar
...
@@ -43,11 +42,4 @@ class AppNavigationController: NavigationController {
...
@@ -43,11 +42,4 @@ class AppNavigationController: NavigationController {
navigationBar
.
tintColor
=
MaterialColor
.
white
navigationBar
.
tintColor
=
MaterialColor
.
white
navigationBar
.
backgroundColor
=
MaterialColor
.
blue
.
base
navigationBar
.
backgroundColor
=
MaterialColor
.
blue
.
base
}
}
/// Prepare tabBarItem.
private
func
prepareTabBarItem
()
{
tabBarItem
.
image
=
MaterialIcon
.
cm
.
photoLibrary
tabBarItem
.
setTitleColor
(
MaterialColor
.
grey
.
base
,
forState
:
.
Normal
)
tabBarItem
.
setTitleColor
(
MaterialColor
.
white
,
forState
:
.
Selected
)
}
}
}
Examples/Programmatic/App/App/ItemViewController.swift
View file @
cb15b04c
...
@@ -57,7 +57,6 @@ class ItemViewController: UIViewController {
...
@@ -57,7 +57,6 @@ class ItemViewController: UIViewController {
convenience
init
(
dataSource
:
MaterialDataSourceItem
)
{
convenience
init
(
dataSource
:
MaterialDataSourceItem
)
{
self
.
init
(
nibName
:
nil
,
bundle
:
nil
)
self
.
init
(
nibName
:
nil
,
bundle
:
nil
)
self
.
dataSource
=
dataSource
self
.
dataSource
=
dataSource
hidesBottomBarWhenPushed
=
true
}
}
required
init
?(
coder
aDecoder
:
NSCoder
)
{
required
init
?(
coder
aDecoder
:
NSCoder
)
{
...
@@ -75,14 +74,19 @@ class ItemViewController: UIViewController {
...
@@ -75,14 +74,19 @@ class ItemViewController: UIViewController {
override
func
viewWillAppear
(
animated
:
Bool
)
{
override
func
viewWillAppear
(
animated
:
Bool
)
{
super
.
viewWillAppear
(
animated
)
super
.
viewWillAppear
(
animated
)
(
menuController
as?
AppMenuController
)?
.
hideMenu
()
sideNavigationController
?
.
enabled
=
false
sideNavigationController
?
.
enabled
=
false
// Stops the scrollView contentInsets from being automatically adjusted.
automaticallyAdjustsScrollViewInsets
=
false
}
}
override
func
viewWillDisappear
(
animated
:
Bool
)
{
override
func
viewDidAppear
(
animated
:
Bool
)
{
super
.
viewWillDisappear
(
animated
)
super
.
viewDidAppear
(
animated
)
(
menuController
as?
AppMenuController
)?
.
showMenu
()
}
// Access the navigationItem.backButton here.
// navigationItem.backButton
}
override
func
viewWillLayoutSubviews
()
{
override
func
viewWillLayoutSubviews
()
{
super
.
viewWillLayoutSubviews
()
super
.
viewWillLayoutSubviews
()
...
@@ -161,6 +165,9 @@ class ItemViewController: UIViewController {
...
@@ -161,6 +165,9 @@ class ItemViewController: UIViewController {
let
image
:
UIImage
?
=
UIImage
(
named
:
data
[
"image"
]
as!
String
)
let
image
:
UIImage
?
=
UIImage
(
named
:
data
[
"image"
]
as!
String
)
imageCardView
.
image
=
image
imageCardView
.
image
=
image
scrollView
.
addSubview
(
imageCardView
)
imageCardView
.
translatesAutoresizingMaskIntoConstraints
=
false
}
}
}
}
}
}
Examples/Programmatic/App/App/RecipesViewController.swift
View file @
cb15b04c
...
@@ -70,6 +70,27 @@ class RecipesViewController: UIViewController {
...
@@ -70,6 +70,27 @@ class RecipesViewController: UIViewController {
sideNavigationController
?
.
enabled
=
true
sideNavigationController
?
.
enabled
=
true
}
}
override
func
viewDidAppear
(
animated
:
Bool
)
{
super
.
viewDidAppear
(
animated
)
// Show the menuView.
menuController
?
.
menuView
.
animate
(
MaterialAnimation
.
animationGroup
([
MaterialAnimation
.
rotate
(
rotation
:
3
),
MaterialAnimation
.
translateY
(
0
)
]))
}
override
func
viewWillDisappear
(
animated
:
Bool
)
{
super
.
viewWillDisappear
(
animated
)
// Disable the SideNavigation.
// Hide the menuView.
menuController
?
.
menuView
.
animate
(
MaterialAnimation
.
animationGroup
([
MaterialAnimation
.
rotate
(
rotation
:
3
),
MaterialAnimation
.
translateY
(
150
)
]))
}
/// Handles the menuButton.
/// Handles the menuButton.
internal
func
handleMenuButton
()
{
internal
func
handleMenuButton
()
{
sideNavigationController
?
.
openLeftView
()
sideNavigationController
?
.
openLeftView
()
...
...
Sources/iOS/NavigationBar.swift
View file @
cb15b04c
...
@@ -287,18 +287,6 @@ public class NavigationBar : UINavigationBar {
...
@@ -287,18 +287,6 @@ public class NavigationBar : UINavigationBar {
self
.
init
(
frame
:
CGRectZero
)
self
.
init
(
frame
:
CGRectZero
)
}
}
/// Calculates the offset for the statusbar.
private
func
statusbarOffset
()
->
CGFloat
{
switch
MaterialDevice
.
type
{
case
.
iPad
:
return
MaterialDevice
.
statusBarHidden
?
20
:
0
case
.
iPhone
:
return
MaterialDevice
.
isPortrait
&&
MaterialDevice
.
statusBarHidden
?
20
:
0
default
:
return
0
}
}
public
override
func
intrinsicContentSize
()
->
CGSize
{
public
override
func
intrinsicContentSize
()
->
CGSize
{
switch
navigationBarStyle
{
switch
navigationBarStyle
{
case
.
Tiny
:
case
.
Tiny
:
...
@@ -311,9 +299,7 @@ public class NavigationBar : UINavigationBar {
...
@@ -311,9 +299,7 @@ public class NavigationBar : UINavigationBar {
}
}
public
override
func
sizeThatFits
(
size
:
CGSize
)
->
CGSize
{
public
override
func
sizeThatFits
(
size
:
CGSize
)
->
CGSize
{
var
result
:
CGSize
=
intrinsicContentSize
()
return
intrinsicContentSize
()
result
.
height
+=
statusbarOffset
()
return
result
}
}
public
override
func
layoutSubviews
()
{
public
override
func
layoutSubviews
()
{
...
@@ -337,7 +323,7 @@ public class NavigationBar : UINavigationBar {
...
@@ -337,7 +323,7 @@ public class NavigationBar : UINavigationBar {
- Parameter item: A UINavigationItem to layout.
- Parameter item: A UINavigationItem to layout.
*/
*/
internal
func
layoutNavigationItem
(
item
:
UINavigationItem
)
{
internal
func
layoutNavigationItem
(
item
:
UINavigationItem
)
{
if
willRenderView
&&
!
animating
{
if
willRenderView
{
prepareItem
(
item
)
prepareItem
(
item
)
if
let
titleView
:
UIView
=
prepareTitleView
(
item
)
{
if
let
titleView
:
UIView
=
prepareTitleView
(
item
)
{
...
@@ -345,7 +331,7 @@ public class NavigationBar : UINavigationBar {
...
@@ -345,7 +331,7 @@ public class NavigationBar : UINavigationBar {
if
let
g
:
Int
=
Int
(
width
/
gridFactor
)
{
if
let
g
:
Int
=
Int
(
width
/
gridFactor
)
{
let
columns
:
Int
=
g
+
1
let
columns
:
Int
=
g
+
1
titleView
.
frame
.
origin
=
CGPoint
(
x
:
0
,
y
:
statusbarOffset
())
titleView
.
frame
.
origin
=
CGPoint
.
zero
titleView
.
frame
.
size
=
intrinsicContentSize
()
titleView
.
frame
.
size
=
intrinsicContentSize
()
titleView
.
grid
.
views
=
[]
titleView
.
grid
.
views
=
[]
titleView
.
grid
.
axis
.
columns
=
columns
titleView
.
grid
.
axis
.
columns
=
columns
...
...
Sources/iOS/SideNavigationController.swift
View file @
cb15b04c
...
@@ -400,6 +400,12 @@ public class SideNavigationController : UIViewController, UIGestureRecognizerDel
...
@@ -400,6 +400,12 @@ public class SideNavigationController : UIViewController, UIGestureRecognizerDel
public
override
func
viewWillTransitionToSize
(
size
:
CGSize
,
withTransitionCoordinator
coordinator
:
UIViewControllerTransitionCoordinator
)
{
public
override
func
viewWillTransitionToSize
(
size
:
CGSize
,
withTransitionCoordinator
coordinator
:
UIViewControllerTransitionCoordinator
)
{
super
.
viewWillTransitionToSize
(
size
,
withTransitionCoordinator
:
coordinator
)
super
.
viewWillTransitionToSize
(
size
,
withTransitionCoordinator
:
coordinator
)
// Portrait will be Lanscape when this method is done.
if
MaterialDevice
.
isPortrait
&&
.
iPhone
==
MaterialDevice
.
type
{
hideStatusBar
()
}
else
{
showStatusBar
()
}
closeLeftView
()
closeLeftView
()
closeRightView
()
closeRightView
()
...
@@ -1092,17 +1098,9 @@ public class SideNavigationController : UIViewController, UIGestureRecognizerDel
...
@@ -1092,17 +1098,9 @@ public class SideNavigationController : UIViewController, UIGestureRecognizerDel
willHideStatusBar
=
false
willHideStatusBar
=
false
UIView
.
animateWithDuration
(
NSTimeInterval
(
UINavigationControllerHideShowBarDuration
),
UIView
.
animateWithDuration
(
NSTimeInterval
(
UINavigationControllerHideShowBarDuration
),
animations
:
{
[
weak
self
]
in
animations
:
{
[
weak
self
]
in
if
let
v
:
NavigationBar
=
(
self
?
.
rootViewController
as?
NavigationController
)?
.
navigationBar
as?
NavigationBar
{
self
?
.
setNeedsStatusBarAppearanceUpdate
()
v
.
animating
=
true
self
?
.
statusBarHidden
=
false
}
})
self
?
.
statusBarHidden
=
false
})
{
[
weak
self
]
_
in
if
let
v
:
NavigationBar
=
(
self
?
.
rootViewController
as?
NavigationController
)?
.
navigationBar
as?
NavigationBar
{
v
.
animating
=
false
}
}
self
.
setNeedsStatusBarAppearanceUpdate
()
delegate
?
.
sideNavigationStatusBarHiddenState
?(
self
,
hidden
:
false
)
delegate
?
.
sideNavigationStatusBarHiddenState
?(
self
,
hidden
:
false
)
}
}
}
}
...
@@ -1114,17 +1112,9 @@ public class SideNavigationController : UIViewController, UIGestureRecognizerDel
...
@@ -1114,17 +1112,9 @@ public class SideNavigationController : UIViewController, UIGestureRecognizerDel
if
!
statusBarHidden
{
if
!
statusBarHidden
{
UIView
.
animateWithDuration
(
NSTimeInterval
(
UINavigationControllerHideShowBarDuration
),
UIView
.
animateWithDuration
(
NSTimeInterval
(
UINavigationControllerHideShowBarDuration
),
animations
:
{
[
weak
self
]
in
animations
:
{
[
weak
self
]
in
if
let
v
:
NavigationBar
=
(
self
?
.
rootViewController
as?
NavigationController
)?
.
navigationBar
as?
NavigationBar
{
self
?
.
setNeedsStatusBarAppearanceUpdate
()
v
.
animating
=
true
self
?
.
statusBarHidden
=
true
}
})
self
?
.
statusBarHidden
=
true
})
{
[
weak
self
]
_
in
if
let
v
:
NavigationBar
=
(
self
?
.
rootViewController
as?
NavigationController
)?
.
navigationBar
as?
NavigationBar
{
v
.
animating
=
false
}
}
self
.
setNeedsStatusBarAppearanceUpdate
()
delegate
?
.
sideNavigationStatusBarHiddenState
?(
self
,
hidden
:
true
)
delegate
?
.
sideNavigationStatusBarHiddenState
?(
self
,
hidden
:
true
)
}
}
}
}
...
...
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