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
5c193224
Commit
5c193224
authored
Mar 27, 2016
by
Daniel Dahan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
updated mainViewController references to rootViewController
parent
30004d7d
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
20 changed files
with
134 additions
and
117 deletions
+134
-117
Examples/Programmatic/App/App/AppDelegate.swift
+2
-2
Examples/Programmatic/App/App/AppNavigationController.swift
+5
-1
Examples/Programmatic/App/App/RecipesViewController.swift
+3
-3
Examples/Programmatic/MenuViewController/MenuViewController/AppDelegate.swift
+1
-1
Examples/Programmatic/MenuViewController/MenuViewController/AppMenuViewController.swift
+11
-11
Examples/Programmatic/SearchBarController/SearchBarController/AppDelegate.swift
+1
-1
Examples/Programmatic/SearchBarController/SearchBarController/AppSearchBarController.swift
+13
-13
Examples/Programmatic/SideNavigationController/SideNavigationController/AppDelegate.swift
+1
-1
Examples/Programmatic/ToolbarController/ToolbarController/AppDelegate.swift
+1
-1
Examples/Programmatic/ToolbarController/ToolbarController/AppToolbarController.swift
+2
-2
Examples/Storyboards/SideNavigationController/SideNavigationController/AppDelegate.swift
+2
-2
Examples/Storyboards/SideNavigationController/SideNavigationController/Base.lproj/Main.storyboard
+4
-7
Examples/Storyboards/SideNavigationController/SideNavigationController/MainViewController.swift
+1
-1
Sources/BottomNavigationController.swift
+9
-4
Sources/Info.plist
+1
-1
Sources/MenuViewController.swift
+34
-30
Sources/NavigationController.swift
+6
-2
Sources/SideNavigationController.swift
+0
-0
Sources/StatusBarViewController.swift
+35
-32
Sources/ToolbarController.swift
+2
-2
No files found.
Examples/Programmatic/App/App/AppDelegate.swift
View file @
5c193224
...
...
@@ -39,14 +39,14 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
func
application
(
application
:
UIApplication
,
didFinishLaunchingWithOptions
launchOptions
:
[
NSObject
:
AnyObject
]?)
->
Bool
{
let
bottomNavigationController
:
BottomNavigationController
=
BottomNavigationController
()
bottomNavigationController
.
viewControllers
=
[
AppMenuViewController
(
main
ViewController
:
AppNavigationController
(
rootViewController
:
RecipesViewController
())),
VideoViewController
(),
PhotoViewController
()]
bottomNavigationController
.
viewControllers
=
[
AppMenuViewController
(
root
ViewController
:
AppNavigationController
(
rootViewController
:
RecipesViewController
())),
VideoViewController
(),
PhotoViewController
()]
bottomNavigationController
.
selectedIndex
=
0
bottomNavigationController
.
tabBar
.
tintColor
=
MaterialColor
.
lightBlue
.
base
bottomNavigationController
.
tabBar
.
backgroundColor
=
MaterialColor
.
grey
.
darken4
// Override point for customization after application launch.
window
=
UIWindow
(
frame
:
UIScreen
.
mainScreen
()
.
bounds
)
window
!.
rootViewController
=
SideNavigationController
(
main
ViewController
:
bottomNavigationController
,
leftViewController
:
AppLeftViewController
(),
rightViewController
:
AppRightViewController
())
window
!.
rootViewController
=
SideNavigationController
(
root
ViewController
:
bottomNavigationController
,
leftViewController
:
AppLeftViewController
(),
rightViewController
:
AppRightViewController
())
window
!.
makeKeyAndVisible
()
return
true
}
...
...
Examples/Programmatic/App/App/AppNavigationController.swift
View file @
5c193224
...
...
@@ -34,7 +34,11 @@ import Material
class
AppNavigationController
:
NavigationController
{
override
func
viewDidLoad
()
{
super
.
viewDidLoad
()
prepareNavigationBar
()
}
/// Prepares the navigationBar
private
func
prepareNavigationBar
()
{
navigationBar
.
statusBarStyle
=
.
LightContent
navigationBar
.
tintColor
=
MaterialColor
.
white
navigationBar
.
backgroundColor
=
MaterialColor
.
blue
.
base
...
...
Examples/Programmatic/App/App/RecipesViewController.swift
View file @
5c193224
...
...
@@ -75,7 +75,7 @@ class RecipesViewController: UIViewController {
// Show the menuView.
menuViewController
?
.
menuView
.
animate
(
MaterialAnimation
.
animationGroup
([
MaterialAnimation
.
rotate
(
rotation
:
3
),
MaterialAnimation
.
translateY
(
0
)
MaterialAnimation
.
translateY
(
0
-
tabBarController
!.
tabBar
.
frame
.
height
)
]))
}
...
...
@@ -87,7 +87,7 @@ class RecipesViewController: UIViewController {
// Hide the menuView.
menuViewController
?
.
menuView
.
animate
(
MaterialAnimation
.
animationGroup
([
MaterialAnimation
.
rotate
(
rotation
:
3
),
MaterialAnimation
.
translateY
(
150
)
MaterialAnimation
.
translateY
(
150
+
tabBarController
!.
tabBar
.
frame
.
height
)
]))
}
...
...
@@ -103,7 +103,7 @@ class RecipesViewController: UIViewController {
recommended
.
append
(
dataSourceItems
[
3
])
recommended
.
append
(
dataSourceItems
[
5
])
let
vc
:
AppSearchBarController
=
AppSearchBarController
(
main
ViewController
:
RecommendationViewController
(
dataSourceItems
:
recommended
))
let
vc
:
AppSearchBarController
=
AppSearchBarController
(
root
ViewController
:
RecommendationViewController
(
dataSourceItems
:
recommended
))
vc
.
modalTransitionStyle
=
.
CrossDissolve
navigationController
?
.
presentViewController
(
vc
,
animated
:
true
,
completion
:
nil
)
}
...
...
Examples/Programmatic/MenuViewController/MenuViewController/AppDelegate.swift
View file @
5c193224
...
...
@@ -39,7 +39,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
func
application
(
application
:
UIApplication
,
didFinishLaunchingWithOptions
launchOptions
:
[
NSObject
:
AnyObject
]?)
->
Bool
{
// Override point for customization after application launch.
window
=
UIWindow
(
frame
:
UIScreen
.
mainScreen
()
.
bounds
)
window
!.
rootViewController
=
AppMenuViewController
(
main
ViewController
:
YellowViewController
())
window
!.
rootViewController
=
AppMenuViewController
(
root
ViewController
:
YellowViewController
())
window
!.
makeKeyAndVisible
()
return
true
}
...
...
Examples/Programmatic/MenuViewController/MenuViewController/AppMenuViewController.swift
View file @
5c193224
...
...
@@ -49,46 +49,46 @@ class AppMenuViewController: MenuViewController {
prepareMenuView
()
}
/// Loads the BlueViewController into the menuViewControllers
main
ViewController.
/// Loads the BlueViewController into the menuViewControllers
root
ViewController.
func
handleBlueButton
()
{
if
main
ViewController
is
BlueViewController
{
if
root
ViewController
is
BlueViewController
{
return
}
closeMenu
{
[
weak
self
]
in
self
?
.
transitionFrom
Main
ViewController
(
BlueViewController
(),
options
:
[
.
TransitionCrossDissolve
])
self
?
.
transitionFrom
Root
ViewController
(
BlueViewController
(),
options
:
[
.
TransitionCrossDissolve
])
}
}
/// Loads the GreenViewController into the menuViewControllers
main
ViewController.
/// Loads the GreenViewController into the menuViewControllers
root
ViewController.
func
handleGreenButton
()
{
if
main
ViewController
is
GreenViewController
{
if
root
ViewController
is
GreenViewController
{
return
}
closeMenu
{
[
weak
self
]
in
self
?
.
transitionFrom
Main
ViewController
(
GreenViewController
(),
options
:
[
.
TransitionCrossDissolve
])
self
?
.
transitionFrom
Root
ViewController
(
GreenViewController
(),
options
:
[
.
TransitionCrossDissolve
])
}
}
/// Loads the YellowViewController into the menuViewControllers
main
ViewController.
/// Loads the YellowViewController into the menuViewControllers
root
ViewController.
func
handleYellowButton
()
{
// if (
mainViewController as? ToolbarController)?.main
ViewController is YellowViewController {
// if (
rootViewController as? ToolbarController)?.root
ViewController is YellowViewController {
// return
// }
closeMenu
{
[
weak
self
]
in
self
?
.
transitionFrom
Main
ViewController
(
YellowViewController
(),
options
:
[
.
TransitionCrossDissolve
])
self
?
.
transitionFrom
Root
ViewController
(
YellowViewController
(),
options
:
[
.
TransitionCrossDissolve
])
}
}
/// Handle the menuView touch event.
func
handleMenu
()
{
if
menuView
.
menu
.
opened
{
menuViewController
?
.
main
ViewController
.
view
.
alpha
=
1
menuViewController
?
.
root
ViewController
.
view
.
alpha
=
1
closeMenu
()
}
else
{
menuViewController
?
.
main
ViewController
.
view
.
alpha
=
0.5
menuViewController
?
.
root
ViewController
.
view
.
alpha
=
0.5
openMenu
()
}
}
...
...
Examples/Programmatic/SearchBarController/SearchBarController/AppDelegate.swift
View file @
5c193224
...
...
@@ -39,7 +39,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
func
application
(
application
:
UIApplication
,
didFinishLaunchingWithOptions
launchOptions
:
[
NSObject
:
AnyObject
]?)
->
Bool
{
// Override point for customization after application launch.
window
=
UIWindow
(
frame
:
UIScreen
.
mainScreen
()
.
bounds
)
window
!.
rootViewController
=
AppSearchBarController
(
main
ViewController
:
YellowViewController
())
window
!.
rootViewController
=
AppSearchBarController
(
root
ViewController
:
YellowViewController
())
window
!.
makeKeyAndVisible
()
return
true
}
...
...
Examples/Programmatic/SearchBarController/SearchBarController/AppSearchBarController.swift
View file @
5c193224
...
...
@@ -43,28 +43,28 @@ class AppSearchBarController: SearchBarController {
prepareSearchBar
()
}
/// Loads the BlueViewController into the searchBarControllers
main
ViewController.
/// Loads the BlueViewController into the searchBarControllers
root
ViewController.
func
handleBlueButton
()
{
if
main
ViewController
is
BlueViewController
{
if
root
ViewController
is
BlueViewController
{
return
}
transitionFrom
Main
ViewController
(
BlueViewController
(),
options
:
[
.
TransitionCrossDissolve
])
transitionFrom
Root
ViewController
(
BlueViewController
(),
options
:
[
.
TransitionCrossDissolve
])
}
/// Loads the GreenViewController into the searchBarControllers
main
ViewController.
/// Loads the GreenViewController into the searchBarControllers
root
ViewController.
func
handleGreenButton
()
{
if
main
ViewController
is
GreenViewController
{
if
root
ViewController
is
GreenViewController
{
return
}
transitionFrom
Main
ViewController
(
GreenViewController
(),
options
:
[
.
TransitionCrossDissolve
])
transitionFrom
Root
ViewController
(
GreenViewController
(),
options
:
[
.
TransitionCrossDissolve
])
}
/// Loads the YellowViewController into the searchBarControllers
main
ViewController.
/// Loads the YellowViewController into the searchBarControllers
root
ViewController.
func
handleYellowButton
()
{
if
(
mainViewController
as?
ToolbarController
)?
.
main
ViewController
is
YellowViewController
{
if
(
rootViewController
as?
ToolbarController
)?
.
root
ViewController
is
YellowViewController
{
return
}
transitionFrom
Main
ViewController
(
YellowViewController
(),
options
:
[
.
TransitionCrossDissolve
])
transitionFrom
Root
ViewController
(
YellowViewController
(),
options
:
[
.
TransitionCrossDissolve
])
searchBar
.
textField
.
resignFirstResponder
()
}
...
...
@@ -128,12 +128,12 @@ class AppSearchBarController: SearchBarController {
extension
AppSearchBarController
:
TextFieldDelegate
{
func
textFieldDidBeginEditing
(
textField
:
UITextField
)
{
main
ViewController
.
view
.
alpha
=
0.5
main
ViewController
.
view
.
userInteractionEnabled
=
false
root
ViewController
.
view
.
alpha
=
0.5
root
ViewController
.
view
.
userInteractionEnabled
=
false
}
func
textFieldDidEndEditing
(
textField
:
UITextField
)
{
main
ViewController
.
view
.
alpha
=
1
main
ViewController
.
view
.
userInteractionEnabled
=
true
root
ViewController
.
view
.
alpha
=
1
root
ViewController
.
view
.
userInteractionEnabled
=
true
}
}
Examples/Programmatic/SideNavigationController/SideNavigationController/AppDelegate.swift
View file @
5c193224
...
...
@@ -39,7 +39,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
func
application
(
application
:
UIApplication
,
didFinishLaunchingWithOptions
launchOptions
:
[
NSObject
:
AnyObject
]?)
->
Bool
{
// Override point for customization after application launch.
window
=
UIWindow
(
frame
:
UIScreen
.
mainScreen
()
.
bounds
)
window
!.
rootViewController
=
SideNavigationController
(
main
ViewController
:
YellowViewController
(),
leftViewController
:
GreenViewController
(),
rightViewController
:
BlueViewController
())
window
!.
rootViewController
=
SideNavigationController
(
root
ViewController
:
YellowViewController
(),
leftViewController
:
GreenViewController
(),
rightViewController
:
BlueViewController
())
window
!.
makeKeyAndVisible
()
return
true
}
...
...
Examples/Programmatic/ToolbarController/ToolbarController/AppDelegate.swift
View file @
5c193224
...
...
@@ -39,7 +39,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
func
application
(
application
:
UIApplication
,
didFinishLaunchingWithOptions
launchOptions
:
[
NSObject
:
AnyObject
]?)
->
Bool
{
// Override point for customization after application launch.
window
=
UIWindow
(
frame
:
UIScreen
.
mainScreen
()
.
bounds
)
window
!.
rootViewController
=
AppToolbarController
(
main
ViewController
:
YellowViewController
())
window
!.
rootViewController
=
AppToolbarController
(
root
ViewController
:
YellowViewController
())
window
!.
makeKeyAndVisible
()
return
true
}
...
...
Examples/Programmatic/ToolbarController/ToolbarController/AppToolbarController.swift
View file @
5c193224
...
...
@@ -61,7 +61,7 @@ class AppToolbarController: ToolbarController {
/// Toggle SideNavigationController left UIViewController.
internal
func
handleMenuButton
()
{
transitionFrom
Main
ViewController
(
GreenViewController
(),
options
:
[
.
TransitionCrossDissolve
])
transitionFrom
Root
ViewController
(
GreenViewController
(),
options
:
[
.
TransitionCrossDissolve
])
}
/// Toggle SideNavigationController right UIViewController.
...
...
@@ -125,7 +125,7 @@ class AppToolbarController: ToolbarController {
extension
AppToolbarController
:
MaterialSwitchDelegate
{
func
materialSwitchStateChanged
(
control
:
MaterialSwitch
)
{
transitionFrom
Main
ViewController
(
YellowViewController
(),
options
:
[
.
TransitionCrossDissolve
])
transitionFrom
Root
ViewController
(
YellowViewController
(),
options
:
[
.
TransitionCrossDissolve
])
}
}
Examples/Storyboards/SideNavigationController/SideNavigationController/AppDelegate.swift
View file @
5c193224
...
...
@@ -40,12 +40,12 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
func
application
(
application
:
UIApplication
,
didFinishLaunchingWithOptions
launchOptions
:
[
NSObject
:
AnyObject
]?)
->
Bool
{
// Get view controllers from storyboard
let
storyboard
=
UIStoryboard
(
name
:
"Main"
,
bundle
:
nil
)
let
mainViewController
=
storyboard
.
instantiateViewControllerWithIdentifier
(
"MainViewController"
)
as!
Main
ViewController
let
rootViewController
=
storyboard
.
instantiateViewControllerWithIdentifier
(
"RootViewController"
)
as!
Root
ViewController
let
sideViewController
=
storyboard
.
instantiateViewControllerWithIdentifier
(
"SideViewController"
)
as!
SideViewController
// Configure the window with the SideNavigationController as the root view controller
window
=
UIWindow
(
frame
:
UIScreen
.
mainScreen
()
.
bounds
)
window
?
.
rootViewController
=
SideNavigationController
(
mainViewController
:
main
ViewController
,
leftViewController
:
sideViewController
)
window
?
.
rootViewController
=
SideNavigationController
(
rootViewController
:
root
ViewController
,
leftViewController
:
sideViewController
)
window
?
.
makeKeyAndVisible
()
return
true
}
...
...
Examples/Storyboards/SideNavigationController/SideNavigationController/Base.lproj/Main.storyboard
View file @
5c193224
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document
type=
"com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB"
version=
"3.0"
toolsVersion=
"
9060"
systemVersion=
"15B42
"
targetRuntime=
"iOS.CocoaTouch"
propertyAccessControl=
"none"
useAutolayout=
"YES"
useTraitCollections=
"YES"
>
<document
type=
"com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB"
version=
"3.0"
toolsVersion=
"
10116"
systemVersion=
"15D21
"
targetRuntime=
"iOS.CocoaTouch"
propertyAccessControl=
"none"
useAutolayout=
"YES"
useTraitCollections=
"YES"
>
<dependencies>
<deployment
identifier=
"iOS"
/>
<plugIn
identifier=
"com.apple.InterfaceBuilder.IBCocoaTouchPlugin"
version=
"9051"
/>
<plugIn
identifier=
"com.apple.InterfaceBuilder.IBCocoaTouchPlugin"
version=
"10085"
/>
</dependencies>
<scenes>
<!--
Main
View Controller-->
<!--
Root
View Controller-->
<scene
sceneID=
"S32-pp-djU"
>
<objects>
<viewController
storyboardIdentifier=
"
MainViewController"
useStoryboardIdentifierAsRestorationIdentifier=
"YES"
id=
"huh-WT-4zU"
customClass=
"Main
ViewController"
customModule=
"SideNavigationViewController"
customModuleProvider=
"target"
sceneMemberID=
"viewController"
>
<viewController
storyboardIdentifier=
"
RootViewController"
useStoryboardIdentifierAsRestorationIdentifier=
"YES"
id=
"huh-WT-4zU"
customClass=
"Root
ViewController"
customModule=
"SideNavigationViewController"
customModuleProvider=
"target"
sceneMemberID=
"viewController"
>
<layoutGuides>
<viewControllerLayoutGuide
type=
"top"
id=
"778-lO-FMj"
/>
<viewControllerLayoutGuide
type=
"bottom"
id=
"hvu-kv-aLI"
/>
...
...
@@ -16,7 +15,6 @@
<view
key=
"view"
contentMode=
"scaleToFill"
id=
"I6q-Is-0pO"
>
<rect
key=
"frame"
x=
"0.0"
y=
"0.0"
width=
"600"
height=
"600"
/>
<autoresizingMask
key=
"autoresizingMask"
widthSizable=
"YES"
heightSizable=
"YES"
/>
<animations/>
<color
key=
"backgroundColor"
red=
"0.3590823447"
green=
"0.30467909450000003"
blue=
"0.81552683250000002"
alpha=
"1"
colorSpace=
"calibratedRGB"
/>
</view>
</viewController>
...
...
@@ -35,7 +33,6 @@
<view
key=
"view"
contentMode=
"scaleToFill"
id=
"8bC-Xf-vdC"
>
<rect
key=
"frame"
x=
"0.0"
y=
"0.0"
width=
"600"
height=
"600"
/>
<autoresizingMask
key=
"autoresizingMask"
widthSizable=
"YES"
heightSizable=
"YES"
/>
<animations/>
<color
key=
"backgroundColor"
red=
"0.93725490199999995"
green=
"0.93725490199999995"
blue=
"0.95686274510000002"
alpha=
"1"
colorSpace=
"calibratedRGB"
/>
</view>
</viewController>
...
...
Examples/Storyboards/SideNavigationController/SideNavigationController/MainViewController.swift
View file @
5c193224
...
...
@@ -31,7 +31,7 @@
import
UIKit
import
Material
class
Main
ViewController
:
UIViewController
{
class
Root
ViewController
:
UIViewController
{
override
func
viewDidLoad
()
{
super
.
viewDidLoad
()
// Do any additional setup after loading the view, typically from a nib.
...
...
Sources/BottomNavigationController.swift
View file @
5c193224
...
...
@@ -112,14 +112,19 @@ public class BottomNavigationController : UITabBarController, UITabBarController
public
func
prepareView
()
{
view
.
clipsToBounds
=
true
delegate
=
self
tabBar
.
depth
=
.
Depth1
tabBar
.
backgroundColor
=
MaterialColor
.
white
tabBar
.
shadowImage
=
UIImage
.
imageWithColor
(
MaterialColor
.
clear
,
size
:
CGSizeMake
(
1
,
1
))
tabBar
.
backgroundImage
=
UIImage
()
prepareTabBar
()
}
/// Handles transitions when tabBarItems are pressed.
public
func
tabBarController
(
tabBarController
:
UITabBarController
,
animationControllerForTransitionFromViewController
fromVC
:
UIViewController
,
toViewController
toVC
:
UIViewController
)
->
UIViewControllerAnimatedTransitioning
?
{
return
.
Fade
==
transitionAnimation
?
BottomNavigationFadeAnimatedTransitioning
()
:
nil
}
/// Prepares the tabBar.
private
func
prepareTabBar
()
{
tabBar
.
depth
=
.
Depth1
tabBar
.
backgroundColor
=
MaterialColor
.
white
tabBar
.
shadowImage
=
UIImage
.
imageWithColor
(
MaterialColor
.
clear
,
size
:
CGSizeMake
(
1
,
1
))
tabBar
.
backgroundImage
=
UIImage
()
}
}
Sources/Info.plist
View file @
5c193224
...
...
@@ -15,7 +15,7 @@
<
k
e
y
>
CFBundlePackageType
<
/k
e
y
>
<
string
>
FMWK
<
/string
>
<
k
e
y
>
CFBundleShortVersionString
<
/k
e
y
>
<
string
>
1.3
7.3
<
/string
>
<
string
>
1.3
8.0
<
/string
>
<
k
e
y
>
CFBundleSignature
<
/k
e
y
>
<
string
>
????
<
/string
>
<
k
e
y
>
CFBundleVersion
<
/k
e
y
>
...
...
Sources/MenuViewController.swift
View file @
5c193224
...
...
@@ -55,32 +55,32 @@ public class MenuViewController : UIViewController {
/**
A Boolean property used to enable and disable interactivity
with the
main
ViewController.
with the
root
ViewController.
*/
@IBInspectable
public
var
userInteractionEnabled
:
Bool
{
get
{
return
main
ViewController
.
view
.
userInteractionEnabled
return
root
ViewController
.
view
.
userInteractionEnabled
}
set
(
value
)
{
main
ViewController
.
view
.
userInteractionEnabled
=
value
root
ViewController
.
view
.
userInteractionEnabled
=
value
}
}
/**
A UIViewController property that references the active
main UIViewController. To swap the
main
ViewController, it
is recommended to use the transitionFrom
Main
ViewController
main UIViewController. To swap the
root
ViewController, it
is recommended to use the transitionFrom
Root
ViewController
helper method.
*/
public
private(set)
var
main
ViewController
:
UIViewController
!
public
private(set)
var
root
ViewController
:
UIViewController
!
/**
An initializer for the MenuViewController.
- Parameter
main
ViewController: The main UIViewController.
- Parameter
root
ViewController: The main UIViewController.
*/
public
convenience
init
(
main
ViewController
:
UIViewController
)
{
public
convenience
init
(
root
ViewController
:
UIViewController
)
{
self
.
init
()
self
.
mainViewController
=
main
ViewController
self
.
rootViewController
=
root
ViewController
prepareView
()
}
...
...
@@ -90,35 +90,37 @@ public class MenuViewController : UIViewController {
}
/**
A method to swap
main
ViewController objects.
A method to swap
root
ViewController objects.
- Parameter toViewController: The UIViewController to swap
with the active
main
ViewController.
with the active
root
ViewController.
- Parameter duration: A NSTimeInterval that sets the
animation duration of the transition.
- Parameter options: UIViewAnimationOptions thst are used
when animating the transition from the active
main
ViewController
when animating the transition from the active
root
ViewController
to the toViewController.
- Parameter animations: An animation block that is executed during
the transition from the active
main
ViewController
the transition from the active
root
ViewController
to the toViewController.
- Parameter completion: A completion block that is execited after
the transition animation from the active
main
ViewController
the transition animation from the active
root
ViewController
to the toViewController has completed.
*/
public
func
transitionFrom
Main
ViewController
(
toViewController
:
UIViewController
,
duration
:
NSTimeInterval
=
0.5
,
options
:
UIViewAnimationOptions
=
[],
animations
:
(()
->
Void
)?
=
nil
,
completion
:
((
Bool
)
->
Void
)?
=
nil
)
{
main
ViewController
.
willMoveToParentViewController
(
nil
)
public
func
transitionFrom
Root
ViewController
(
toViewController
:
UIViewController
,
duration
:
NSTimeInterval
=
0.5
,
options
:
UIViewAnimationOptions
=
[],
animations
:
(()
->
Void
)?
=
nil
,
completion
:
((
Bool
)
->
Void
)?
=
nil
)
{
root
ViewController
.
willMoveToParentViewController
(
nil
)
addChildViewController
(
toViewController
)
toViewController
.
view
.
frame
=
main
ViewController
.
view
.
frame
transitionFromViewController
(
main
ViewController
,
toViewController
.
view
.
frame
=
root
ViewController
.
view
.
frame
transitionFromViewController
(
root
ViewController
,
toViewController
:
toViewController
,
duration
:
duration
,
options
:
options
,
animations
:
animations
,
completion
:
{
[
unowned
self
]
(
result
:
Bool
)
in
toViewController
.
didMoveToParentViewController
(
self
)
self
.
mainViewController
.
removeFromParentViewController
()
self
.
mainViewController
=
toViewController
self
.
view
.
sendSubviewToBack
(
self
.
mainViewController
.
view
)
self
.
rootViewController
.
removeFromParentViewController
()
self
.
rootViewController
=
toViewController
self
.
rootViewController
.
view
.
clipsToBounds
=
true
self
.
rootViewController
.
view
.
autoresizingMask
=
.
FlexibleWidth
self
.
view
.
sendSubviewToBack
(
self
.
rootViewController
.
view
)
completion
?(
result
)
})
}
...
...
@@ -131,7 +133,7 @@ public class MenuViewController : UIViewController {
public
func
openMenu
(
completion
:
(()
->
Void
)?
=
nil
)
{
if
true
==
userInteractionEnabled
{
userInteractionEnabled
=
false
main
ViewController
.
view
.
alpha
=
0.5
root
ViewController
.
view
.
alpha
=
0.5
menuView
.
open
(
completion
)
}
}
...
...
@@ -143,7 +145,7 @@ public class MenuViewController : UIViewController {
*/
public
func
closeMenu
(
completion
:
(()
->
Void
)?
=
nil
)
{
if
false
==
userInteractionEnabled
{
main
ViewController
.
view
.
alpha
=
1
root
ViewController
.
view
.
alpha
=
1
menuView
.
close
({
[
weak
self
]
in
self
?
.
userInteractionEnabled
=
true
completion
?()
...
...
@@ -153,10 +155,9 @@ public class MenuViewController : UIViewController {
/// A method that generally prepares the MenuViewController.
private
func
prepareView
()
{
edgesForExtendedLayout
=
.
None
view
.
clipsToBounds
=
true
prepareMenuView
()
prepare
Main
ViewController
()
prepare
Root
ViewController
()
}
/// Prepares the MenuView.
...
...
@@ -165,9 +166,11 @@ public class MenuViewController : UIViewController {
view
.
addSubview
(
menuView
)
}
/// A method that prepares the mainViewController.
private
func
prepareMainViewController
()
{
prepareViewControllerWithinContainer
(
mainViewController
,
container
:
view
)
/// A method that prepares the rootViewController.
private
func
prepareRootViewController
()
{
rootViewController
.
view
.
clipsToBounds
=
true
rootViewController
.
view
.
autoresizingMask
=
.
FlexibleWidth
prepareViewControllerWithinContainer
(
rootViewController
,
container
:
view
)
}
/**
...
...
@@ -181,13 +184,14 @@ public class MenuViewController : UIViewController {
private
func
prepareViewControllerWithinContainer
(
viewController
:
UIViewController
?,
container
:
UIView
)
{
if
let
v
:
UIViewController
=
viewController
{
addChildViewController
(
v
)
container
.
insertSubview
(
v
.
view
,
atIndex
:
0
)
container
.
addSubview
(
v
.
view
)
container
.
sendSubviewToBack
(
v
.
view
)
v
.
didMoveToParentViewController
(
self
)
}
}
/// Layout subviews.
private
func
layoutSubviews
()
{
main
ViewController
.
view
.
frame
=
view
.
bounds
root
ViewController
.
view
.
frame
=
view
.
bounds
}
}
Sources/NavigationController.swift
View file @
5c193224
...
...
@@ -60,8 +60,7 @@ public class NavigationController : UINavigationController, UIGestureRecognizerD
public
override
func
viewDidLoad
()
{
super
.
viewDidLoad
()
edgesForExtendedLayout
=
.
None
view
.
clipsToBounds
=
true
prepareView
()
// This ensures the panning gesture is available when going back between views.
if
let
v
:
UIGestureRecognizer
=
interactivePopGestureRecognizer
{
...
...
@@ -128,4 +127,9 @@ public class NavigationController : UINavigationController, UIGestureRecognizerD
internal
func
handleBackButton
()
{
popViewControllerAnimated
(
true
)
}
/// Prepares the view.
private
func
prepareView
()
{
view
.
clipsToBounds
=
true
}
}
Sources/SideNavigationController.swift
View file @
5c193224
This diff is collapsed.
Click to expand it.
Sources/StatusBarViewController.swift
View file @
5c193224
...
...
@@ -43,65 +43,67 @@ public class StatusBarViewController : UIViewController {
/**
A Boolean property used to enable and disable interactivity
with the
main
ViewController.
with the
root
ViewController.
*/
@IBInspectable
public
var
userInteractionEnabled
:
Bool
{
get
{
return
main
ViewController
.
view
.
userInteractionEnabled
return
root
ViewController
.
view
.
userInteractionEnabled
}
set
(
value
)
{
main
ViewController
.
view
.
userInteractionEnabled
=
value
root
ViewController
.
view
.
userInteractionEnabled
=
value
}
}
/**
A UIViewController property that references the active
main UIViewController. To swap the
main
ViewController, it
is recommended to use the transitionFrom
Main
ViewController
main UIViewController. To swap the
root
ViewController, it
is recommended to use the transitionFrom
Root
ViewController
helper method.
*/
public
private(set)
var
main
ViewController
:
UIViewController
!
public
private(set)
var
root
ViewController
:
UIViewController
!
/**
An initializer for the StatusBarViewController.
- Parameter
main
ViewController: The main UIViewController.
- Parameter
root
ViewController: The main UIViewController.
*/
public
convenience
init
(
main
ViewController
:
UIViewController
)
{
public
convenience
init
(
root
ViewController
:
UIViewController
)
{
self
.
init
()
self
.
mainViewController
=
main
ViewController
self
.
rootViewController
=
root
ViewController
prepareView
()
}
/**
A method to swap
main
ViewController objects.
A method to swap
root
ViewController objects.
- Parameter toViewController: The UIViewController to swap
with the active
main
ViewController.
with the active
root
ViewController.
- Parameter duration: A NSTimeInterval that sets the
animation duration of the transition.
- Parameter options: UIViewAnimationOptions thst are used
when animating the transition from the active
main
ViewController
when animating the transition from the active
root
ViewController
to the toViewController.
- Parameter animations: An animation block that is executed during
the transition from the active
main
ViewController
the transition from the active
root
ViewController
to the toViewController.
- Parameter completion: A completion block that is execited after
the transition animation from the active
main
ViewController
the transition animation from the active
root
ViewController
to the toViewController has completed.
*/
public
func
transitionFrom
Main
ViewController
(
toViewController
:
UIViewController
,
duration
:
NSTimeInterval
=
0.5
,
options
:
UIViewAnimationOptions
=
[],
animations
:
(()
->
Void
)?
=
nil
,
completion
:
((
Bool
)
->
Void
)?
=
nil
)
{
main
ViewController
.
willMoveToParentViewController
(
nil
)
public
func
transitionFrom
Root
ViewController
(
toViewController
:
UIViewController
,
duration
:
NSTimeInterval
=
0.5
,
options
:
UIViewAnimationOptions
=
[],
animations
:
(()
->
Void
)?
=
nil
,
completion
:
((
Bool
)
->
Void
)?
=
nil
)
{
root
ViewController
.
willMoveToParentViewController
(
nil
)
addChildViewController
(
toViewController
)
toViewController
.
view
.
frame
=
main
ViewController
.
view
.
frame
transitionFromViewController
(
main
ViewController
,
toViewController
.
view
.
frame
=
root
ViewController
.
view
.
frame
transitionFromViewController
(
root
ViewController
,
toViewController
:
toViewController
,
duration
:
duration
,
options
:
options
,
animations
:
animations
,
completion
:
{
[
unowned
self
]
(
result
:
Bool
)
in
toViewController
.
didMoveToParentViewController
(
self
)
self
.
mainViewController
.
removeFromParentViewController
()
self
.
mainViewController
=
toViewController
self
.
view
.
sendSubviewToBack
(
self
.
mainViewController
.
view
)
self
.
rootViewController
.
removeFromParentViewController
()
self
.
rootViewController
=
toViewController
self
.
rootViewController
.
view
.
clipsToBounds
=
true
self
.
rootViewController
.
view
.
autoresizingMask
=
.
FlexibleWidth
self
.
view
.
sendSubviewToBack
(
self
.
rootViewController
.
view
)
completion
?(
result
)
})
}
...
...
@@ -114,9 +116,8 @@ public class StatusBarViewController : UIViewController {
when subclassing.
*/
public
func
prepareView
()
{
edgesForExtendedLayout
=
.
None
view
.
clipsToBounds
=
true
prepare
Main
ViewController
()
prepare
Root
ViewController
()
}
public
override
func
viewWillLayoutSubviews
()
{
...
...
@@ -130,18 +131,19 @@ public class StatusBarViewController : UIViewController {
let
q
:
CGFloat
=
UIApplication
.
sharedApplication
()
.
statusBarFrame
.
size
.
height
if
.
iPhone
==
MaterialDevice
.
type
&&
MaterialDevice
.
landscape
{
main
ViewController
.
view
.
frame
.
origin
.
y
=
heightForLandscapeOrientation
main
ViewController
.
view
.
frame
.
size
.
height
=
h
-
(
heightForStatusBar
>=
q
?
heightForLandscapeOrientation
:
q
-
heightForStatusBar
-
heightForLandscapeOrientation
)
root
ViewController
.
view
.
frame
.
origin
.
y
=
heightForLandscapeOrientation
root
ViewController
.
view
.
frame
.
size
.
height
=
h
-
(
heightForStatusBar
>=
q
?
heightForLandscapeOrientation
:
q
-
heightForStatusBar
-
heightForLandscapeOrientation
)
}
else
{
main
ViewController
.
view
.
frame
.
origin
.
y
=
heightForPortraitOrientation
main
ViewController
.
view
.
frame
.
size
.
height
=
h
-
(
heightForStatusBar
>=
q
?
heightForPortraitOrientation
:
q
-
heightForStatusBar
-
heightForPortraitOrientation
)
root
ViewController
.
view
.
frame
.
origin
.
y
=
heightForPortraitOrientation
root
ViewController
.
view
.
frame
.
size
.
height
=
h
-
(
heightForStatusBar
>=
q
?
heightForPortraitOrientation
:
q
-
heightForStatusBar
-
heightForPortraitOrientation
)
}
}
/// A method that prepares the mainViewController.
private
func
prepareMainViewController
()
{
mainViewController
.
view
.
autoresizingMask
=
.
FlexibleWidth
prepareViewControllerWithinContainer
(
mainViewController
,
container
:
view
)
/// A method that prepares the rootViewController.
private
func
prepareRootViewController
()
{
rootViewController
.
view
.
clipsToBounds
=
true
rootViewController
.
view
.
autoresizingMask
=
.
FlexibleWidth
prepareViewControllerWithinContainer
(
rootViewController
,
container
:
view
)
}
/**
...
...
@@ -155,7 +157,8 @@ public class StatusBarViewController : UIViewController {
private
func
prepareViewControllerWithinContainer
(
viewController
:
UIViewController
?,
container
:
UIView
)
{
if
let
v
:
UIViewController
=
viewController
{
addChildViewController
(
v
)
container
.
insertSubview
(
v
.
view
,
atIndex
:
0
)
container
.
addSubview
(
v
.
view
)
container
.
sendSubviewToBack
(
v
.
view
)
v
.
didMoveToParentViewController
(
self
)
}
}
...
...
Sources/ToolbarController.swift
View file @
5c193224
...
...
@@ -119,7 +119,7 @@ public class ToolbarController : StatusBarViewController {
animations
:
{
[
unowned
self
]
in
v
.
view
.
center
.
y
=
2
*
self
.
view
.
bounds
.
height
self
.
toolbar
.
alpha
=
1
self
.
main
ViewController
.
view
.
alpha
=
1
self
.
root
ViewController
.
view
.
alpha
=
1
})
{
[
unowned
self
]
_
in
v
.
willMoveToParentViewController
(
nil
)
v
.
view
.
removeFromSuperview
()
...
...
@@ -157,7 +157,7 @@ public class ToolbarController : StatusBarViewController {
animations
:
{
[
unowned
self
]
in
v
.
view
.
center
.
y
=
self
.
view
.
bounds
.
height
/
2
self
.
toolbar
.
alpha
=
0.5
self
.
main
ViewController
.
view
.
alpha
=
0.5
self
.
root
ViewController
.
view
.
alpha
=
0.5
})
{
[
unowned
self
]
_
in
v
.
view
.
layer
.
shouldRasterize
=
false
self
.
view
.
layer
.
shouldRasterize
=
false
...
...
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