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
ae33ab43
Commit
ae33ab43
authored
Jun 13, 2016
by
Daniel Dahan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
updated StatusBarController and updated App and NavigationDrawerController example
parent
7c7c0462
Hide whitespace changes
Inline
Side-by-side
Showing
13 changed files
with
474 additions
and
14 deletions
+474
-14
Examples/Programmatic/App/App.xcodeproj/project.pbxproj
+8
-0
Examples/Programmatic/App/App/AppDelegate.swift
+4
-5
Examples/Programmatic/App/App/AppNavigationDrawerController.swift
+69
-0
Examples/Programmatic/App/App/AppStatusBarController.swift
+39
-0
Examples/Programmatic/NavigationDrawerController/NavigationDrawerController.xcodeproj/project.pbxproj
+8
-0
Examples/Programmatic/NavigationDrawerController/NavigationDrawerController/AppDelegate.swift
+4
-2
Examples/Programmatic/NavigationDrawerController/NavigationDrawerController/AppNavigationDrawerController.swift
+71
-0
Examples/Programmatic/NavigationDrawerController/NavigationDrawerController/AppStatusBarController.swift
+40
-0
Examples/Programmatic/NavigationDrawerController/NavigationDrawerController/Info.plist
+2
-0
Material.xcodeproj/project.pbxproj
+12
-0
Sources/iOS/MaterialSwitch.swift
+5
-5
Sources/iOS/NavigationDrawerController.swift
+2
-2
Sources/iOS/StatusBarController.swift
+210
-0
No files found.
Examples/Programmatic/App/App.xcodeproj/project.pbxproj
View file @
ae33ab43
...
...
@@ -19,6 +19,8 @@
9663F94C1C7A74C700AF0965
/* AppMenuController.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
9663F94B1C7A74C700AF0965
/* AppMenuController.swift */
;
};
9663F94E1C7A74EA00AF0965
/* AppLeftViewController.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
9663F94D1C7A74EA00AF0965
/* AppLeftViewController.swift */
;
};
9663F9521C7A751D00AF0965
/* ItemViewController.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
9663F9511C7A751D00AF0965
/* ItemViewController.swift */
;
};
967A481B1D0F58F800B8CEB7
/* AppNavigationDrawerController.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
967A481A1D0F58F800B8CEB7
/* AppNavigationDrawerController.swift */
;
};
967A481D1D0F5AFC00B8CEB7
/* AppStatusBarController.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
967A481C1D0F5AFC00B8CEB7
/* AppStatusBarController.swift */
;
};
96CC08881C7FEBD60034FF84
/* RecipesViewController.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
96CC08871C7FEBD60034FF84
/* RecipesViewController.swift */
;
};
/* End PBXBuildFile section */
...
...
@@ -50,6 +52,8 @@
9663F94B1C7A74C700AF0965
/* AppMenuController.swift */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
sourcecode.swift
;
path
=
AppMenuController.swift
;
sourceTree
=
"<group>"
;
};
9663F94D1C7A74EA00AF0965
/* AppLeftViewController.swift */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
sourcecode.swift
;
path
=
AppLeftViewController.swift
;
sourceTree
=
"<group>"
;
};
9663F9511C7A751D00AF0965
/* ItemViewController.swift */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
sourcecode.swift
;
path
=
ItemViewController.swift
;
sourceTree
=
"<group>"
;
};
967A481A1D0F58F800B8CEB7
/* AppNavigationDrawerController.swift */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
sourcecode.swift
;
path
=
AppNavigationDrawerController.swift
;
sourceTree
=
"<group>"
;
};
967A481C1D0F5AFC00B8CEB7
/* AppStatusBarController.swift */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
sourcecode.swift
;
path
=
AppStatusBarController.swift
;
sourceTree
=
"<group>"
;
};
96CC08871C7FEBD60034FF84
/* RecipesViewController.swift */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
sourcecode.swift
;
path
=
RecipesViewController.swift
;
sourceTree
=
"<group>"
;
};
/* End PBXFileReference section */
...
...
@@ -84,7 +88,9 @@
isa
=
PBXGroup
;
children
=
(
9663F9311C7A744600AF0965
/* AppDelegate.swift */
,
967A481C1D0F5AFC00B8CEB7
/* AppStatusBarController.swift */
,
9663F9471C7A749400AF0965
/* AppNavigationController.swift */
,
967A481A1D0F58F800B8CEB7
/* AppNavigationDrawerController.swift */
,
960CDA481D09FF3E00387CE8
/* AppBottomNavigationController.swift */
,
9663F9491C7A74B500AF0965
/* AppSearchBarViewController.swift */
,
9663F94B1C7A74C700AF0965
/* AppMenuController.swift */
,
...
...
@@ -172,6 +178,8 @@
isa
=
PBXSourcesBuildPhase
;
buildActionMask
=
2147483647
;
files
=
(
967A481D1D0F5AFC00B8CEB7
/* AppStatusBarController.swift in Sources */
,
967A481B1D0F58F800B8CEB7
/* AppNavigationDrawerController.swift in Sources */
,
9663F94A1C7A74B500AF0965
/* AppSearchBarViewController.swift in Sources */
,
96CC08881C7FEBD60034FF84
/* RecipesViewController.swift in Sources */
,
9663F9481C7A749400AF0965
/* AppNavigationController.swift in Sources */
,
...
...
Examples/Programmatic/App/App/AppDelegate.swift
View file @
ae33ab43
...
...
@@ -37,14 +37,13 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
var
window
:
UIWindow
?
func
application
(
application
:
UIApplication
,
didFinishLaunchingWithOptions
launchOptions
:
[
NSObject
:
AnyObject
]?)
->
Bool
{
let
bottomNavigationController
:
AppBottomNavigationController
=
AppBottomNavigationController
()
let
bottomNavigationController
:
AppBottomNavigationController
=
AppBottomNavigationController
()
let
navigationController
:
AppNavigationController
=
AppNavigationController
(
rootViewController
:
bottomNavigationController
)
let
navigationDrawerController
:
NavigationDrawerController
=
NavigationDrawerController
(
rootViewController
:
navigationController
,
leftViewController
:
AppLeftViewController
())
navigationDrawerController
.
statusBarStyle
=
.
LightContent
let
navigationDrawerController
:
AppNavigationDrawerController
=
App
NavigationDrawerController
(
rootViewController
:
navigationController
,
leftViewController
:
AppLeftViewController
())
let
statusBarController
:
AppStatusBarController
=
AppStatusBarController
(
rootViewController
:
navigationDrawerController
)
window
=
UIWindow
(
frame
:
UIScreen
.
mainScreen
()
.
bounds
)
window
!.
rootViewController
=
navigationDrawe
rController
window
!.
rootViewController
=
statusBa
rController
window
!.
makeKeyAndVisible
()
return
true
}
...
...
Examples/Programmatic/App/App/AppNavigationDrawerController.swift
0 → 100644
View file @
ae33ab43
/*
* Copyright (C) 2015 - 2016, Daniel Dahan and CosmicMind, Inc. <http://cosmicmind.io>.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
*
* * Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* * Neither the name of Material nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
import
UIKit
import
Material
class
AppNavigationDrawerController
:
NavigationDrawerController
,
NavigationDrawerControllerDelegate
{
override
func
prepareView
()
{
super
.
prepareView
()
delegate
=
self
}
func
navigationDrawerPanDidBegin
(
navigationDrawerController
:
NavigationDrawerController
,
point
:
CGPoint
,
position
:
SideNavigationPosition
)
{
showStatusBarView
()
}
func
navigationDrawerPanDidEnd
(
navigationDrawerController
:
NavigationDrawerController
,
point
:
CGPoint
,
position
:
SideNavigationPosition
)
{
hideStatusBarView
()
}
func
navigationDrawerWillOpen
(
navigationDrawerController
:
NavigationDrawerController
,
position
:
SideNavigationPosition
)
{
showStatusBarView
()
}
func
navigationDrawerWillClose
(
navigationDrawerController
:
NavigationDrawerController
,
position
:
SideNavigationPosition
)
{
hideStatusBarView
()
}
/// Shows the transparent statusBarView.
private
func
showStatusBarView
()
{
UIView
.
animateWithDuration
(
0.25
,
animations
:
{
[
weak
self
]
in
self
?
.
statusBarController
?
.
statusBarView
.
alpha
=
1
})
}
/// Hides the transparent statusBarView.
private
func
hideStatusBarView
()
{
UIView
.
animateWithDuration
(
0.25
,
animations
:
{
[
weak
self
]
in
self
?
.
statusBarController
?
.
statusBarView
.
alpha
=
0
})
}
}
Examples/Programmatic/App/App/AppStatusBarController.swift
0 → 100644
View file @
ae33ab43
/*
* Copyright (C) 2015 - 2016, Daniel Dahan and CosmicMind, Inc. <http://cosmicmind.io>.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
*
* * Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* * Neither the name of Material nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
import
UIKit
import
Material
class
AppStatusBarController
:
StatusBarController
{
override
func
prepareView
()
{
super
.
prepareView
()
statusBarView
.
alpha
=
0
}
}
Examples/Programmatic/NavigationDrawerController/NavigationDrawerController.xcodeproj/project.pbxproj
View file @
ae33ab43
...
...
@@ -8,6 +8,8 @@
/* Begin PBXBuildFile section */
967A48071D0E0EA300B8CEB7
/* AppRightViewController.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
967A48061D0E0EA300B8CEB7
/* AppRightViewController.swift */
;
};
967A48221D0F601B00B8CEB7
/* AppNavigationDrawerController.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
967A48211D0F601B00B8CEB7
/* AppNavigationDrawerController.swift */
;
};
967A48241D0F603200B8CEB7
/* AppStatusBarController.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
967A48231D0F603200B8CEB7
/* AppStatusBarController.swift */
;
};
96CB75011D0DFDBB0012D9F2
/* AppDelegate.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
96CB75001D0DFDBB0012D9F2
/* AppDelegate.swift */
;
};
96CB75031D0DFDBB0012D9F2
/* AppLeftViewController.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
96CB75021D0DFDBB0012D9F2
/* AppLeftViewController.swift */
;
};
96CB75081D0DFDBB0012D9F2
/* Assets.xcassets in Resources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
96CB75071D0DFDBB0012D9F2
/* Assets.xcassets */
;
};
...
...
@@ -34,6 +36,8 @@
/* Begin PBXFileReference section */
967A48061D0E0EA300B8CEB7
/* AppRightViewController.swift */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
sourcecode.swift
;
path
=
AppRightViewController.swift
;
sourceTree
=
"<group>"
;
};
967A48211D0F601B00B8CEB7
/* AppNavigationDrawerController.swift */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
sourcecode.swift
;
path
=
AppNavigationDrawerController.swift
;
sourceTree
=
"<group>"
;
};
967A48231D0F603200B8CEB7
/* AppStatusBarController.swift */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
sourcecode.swift
;
path
=
AppStatusBarController.swift
;
sourceTree
=
"<group>"
;
};
96CB74FD1D0DFDBB0012D9F2
/* NavigationDrawerController.app */
=
{
isa
=
PBXFileReference
;
explicitFileType
=
wrapper.application
;
includeInIndex
=
0
;
path
=
NavigationDrawerController.app
;
sourceTree
=
BUILT_PRODUCTS_DIR
;
};
96CB75001D0DFDBB0012D9F2
/* AppDelegate.swift */
=
{
isa
=
PBXFileReference
;
lastKnownFileType
=
sourcecode.swift
;
path
=
AppDelegate.swift
;
sourceTree
=
"<group>"
;
};
96CB75021D0DFDBB0012D9F2
/* AppLeftViewController.swift */
=
{
isa
=
PBXFileReference
;
lastKnownFileType
=
sourcecode.swift
;
path
=
AppLeftViewController.swift
;
sourceTree
=
"<group>"
;
};
...
...
@@ -78,6 +82,8 @@
isa
=
PBXGroup
;
children
=
(
96CB75001D0DFDBB0012D9F2
/* AppDelegate.swift */
,
967A48231D0F603200B8CEB7
/* AppStatusBarController.swift */
,
967A48211D0F601B00B8CEB7
/* AppNavigationDrawerController.swift */
,
96CB75021D0DFDBB0012D9F2
/* AppLeftViewController.swift */
,
967A48061D0E0EA300B8CEB7
/* AppRightViewController.swift */
,
96CB75121D0DFF6F0012D9F2
/* YellowViewController.swift */
,
...
...
@@ -163,10 +169,12 @@
isa
=
PBXSourcesBuildPhase
;
buildActionMask
=
2147483647
;
files
=
(
967A48221D0F601B00B8CEB7
/* AppNavigationDrawerController.swift in Sources */
,
96CB75031D0DFDBB0012D9F2
/* AppLeftViewController.swift in Sources */
,
96CB75131D0DFF6F0012D9F2
/* YellowViewController.swift in Sources */
,
96CB75191D0DFFAE0012D9F2
/* PurpleViewController.swift in Sources */
,
96CB75151D0DFF840012D9F2
/* BlueViewController.swift in Sources */
,
967A48241D0F603200B8CEB7
/* AppStatusBarController.swift in Sources */
,
96CB75011D0DFDBB0012D9F2
/* AppDelegate.swift in Sources */
,
967A48071D0E0EA300B8CEB7
/* AppRightViewController.swift in Sources */
,
96CB751B1D0DFFC10012D9F2
/* OrangeViewController.swift in Sources */
,
...
...
Examples/Programmatic/NavigationDrawerController/NavigationDrawerController/AppDelegate.swift
View file @
ae33ab43
...
...
@@ -38,7 +38,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
func
application
(
application
:
UIApplication
,
didFinishLaunchingWithOptions
launchOptions
:
[
NSObject
:
AnyObject
]?)
->
Bool
{
let
navigationController
:
NavigationController
=
NavigationController
(
rootViewController
:
YellowViewController
())
let
navigationDrawerController
:
NavigationDrawerController
=
NavigationDrawerController
(
rootViewController
:
navigationController
,
leftViewController
:
AppLeftViewController
(),
rightViewController
:
AppRightViewController
())
let
navigationDrawerController
:
AppNavigationDrawerController
=
App
NavigationDrawerController
(
rootViewController
:
navigationController
,
leftViewController
:
AppLeftViewController
(),
rightViewController
:
AppRightViewController
())
// navigationDrawerController.enabled = true
//
...
...
@@ -50,8 +50,10 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
// navigationDrawerController.enabledRightTapGesture = true
// navigationDrawerController.enabledRightPanGesture = true
let
statusBarController
:
AppStatusBarController
=
AppStatusBarController
(
rootViewController
:
navigationDrawerController
)
window
=
UIWindow
(
frame
:
UIScreen
.
mainScreen
()
.
bounds
)
window
!.
rootViewController
=
navigationDrawe
rController
window
!.
rootViewController
=
statusBa
rController
window
!.
makeKeyAndVisible
()
return
true
}
...
...
Examples/Programmatic/NavigationDrawerController/NavigationDrawerController/AppNavigationDrawerController.swift
0 → 100644
View file @
ae33ab43
/*
* Copyright (C) 2015 - 2016, Daniel Dahan and CosmicMind, Inc. <http://cosmicmind.io>.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
*
* * Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* * Neither the name of Material nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
import
UIKit
import
Material
class
AppNavigationDrawerController
:
NavigationDrawerController
,
NavigationDrawerControllerDelegate
{
override
func
prepareView
()
{
super
.
prepareView
()
delegate
=
self
}
func
navigationDrawerPanDidBegin
(
navigationDrawerController
:
NavigationDrawerController
,
point
:
CGPoint
,
position
:
SideNavigationPosition
)
{
showStatusBarView
()
}
func
navigationDrawerPanDidEnd
(
navigationDrawerController
:
NavigationDrawerController
,
point
:
CGPoint
,
position
:
SideNavigationPosition
)
{
hideStatusBarView
()
}
func
navigationDrawerWillOpen
(
navigationDrawerController
:
NavigationDrawerController
,
position
:
SideNavigationPosition
)
{
showStatusBarView
()
}
func
navigationDrawerWillClose
(
navigationDrawerController
:
NavigationDrawerController
,
position
:
SideNavigationPosition
)
{
hideStatusBarView
()
}
/// Shows the transparent statusBarView.
private
func
showStatusBarView
()
{
statusBarController
?
.
statusBarStyle
=
.
LightContent
UIView
.
animateWithDuration
(
0.25
,
animations
:
{
[
weak
self
]
in
self
?
.
statusBarController
?
.
statusBarView
.
alpha
=
1
})
}
/// Hides the transparent statusBarView.
private
func
hideStatusBarView
()
{
statusBarController
?
.
statusBarStyle
=
.
Default
UIView
.
animateWithDuration
(
0.25
,
animations
:
{
[
weak
self
]
in
self
?
.
statusBarController
?
.
statusBarView
.
alpha
=
0
})
}
}
Examples/Programmatic/NavigationDrawerController/NavigationDrawerController/AppStatusBarController.swift
0 → 100644
View file @
ae33ab43
/*
* Copyright (C) 2015 - 2016, Daniel Dahan and CosmicMind, Inc. <http://cosmicmind.io>.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
*
* * Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* * Neither the name of Material nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
import
UIKit
import
Material
class
AppStatusBarController
:
StatusBarController
{
override
func
prepareView
()
{
super
.
prepareView
()
statusBarView
.
alpha
=
0
statusBarStyle
=
.
LightContent
}
}
Examples/Programmatic/NavigationDrawerController/NavigationDrawerController/Info.plist
View file @
ae33ab43
...
...
@@ -2,6 +2,8 @@
<
!
D
O
C
TYP
E
plist
PU
B
LI
C
"-//
A
ppl
e
//
D
T
D
PLIST
1
.
0
//
E
N"
"http://www.
a
ppl
e
.
c
om/
D
T
D
s/Prop
e
rtyList-
1
.
0
.
d
t
d
"
>
<
plist
v
e
rsion="
1
.
0
"
>
<
d
i
c
t
>
<
k
e
y
>
UIViewControllerBasedStatusBarAppearance
<
/k
e
y
>
<
fa
ls
e
/
>
<
k
e
y
>
CFBundleDevelopmentRegion
<
/k
e
y
>
<
string
>
en
<
/string
>
<
k
e
y
>
CFBundleExecutable
<
/k
e
y
>
...
...
Material.xcodeproj/project.pbxproj
View file @
ae33ab43
...
...
@@ -15,6 +15,7 @@
9660162A1CB2F04E00AAB661
/* Material.h in Headers */
=
{
isa
=
PBXBuildFile
;
fileRef
=
96D88C091C1328D800B91418
/* Material.h */
;
settings
=
{
ATTRIBUTES
=
(
Public
,
);
};
};
966ECF2A1CF4C20100BB0BDF
/* MaterialCollectionReusableView.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
966ECF291CF4C20100BB0BDF
/* MaterialCollectionReusableView.swift */
;
};
9679CEAB1CC69E080021685B
/* Material+UIImage+TintColor.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
9679CEAA1CC69E080021685B
/* Material+UIImage+TintColor.swift */
;
};
967A48191D0F425A00B8CEB7
/* StatusBarController.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
967A48181D0F425A00B8CEB7
/* StatusBarController.swift */
;
};
96815B381CA07BA20006CBE2
/* MaterialViewTests.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
967887881C9777CB0037F6C9
/* MaterialViewTests.swift */
;
};
96977DA61CBB2E49000BEFC4
/* Material+UIImage+FilterBlur.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
96977DA51CBB2E49000BEFC4
/* Material+UIImage+FilterBlur.swift */
;
};
96BCB7A11CB40DC500C806FE
/* BottomNavigationController.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
96BCB7581CB40DC500C806FE
/* BottomNavigationController.swift */
;
};
...
...
@@ -206,6 +207,7 @@
966ECF291CF4C20100BB0BDF
/* MaterialCollectionReusableView.swift */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
sourcecode.swift
;
path
=
MaterialCollectionReusableView.swift
;
sourceTree
=
"<group>"
;
};
967887881C9777CB0037F6C9
/* MaterialViewTests.swift */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
sourcecode.swift
;
path
=
MaterialViewTests.swift
;
sourceTree
=
"<group>"
;
};
9679CEAA1CC69E080021685B
/* Material+UIImage+TintColor.swift */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
sourcecode.swift
;
path
=
"Material+UIImage+TintColor.swift"
;
sourceTree
=
"<group>"
;
};
967A48181D0F425A00B8CEB7
/* StatusBarController.swift */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
sourcecode.swift
;
path
=
StatusBarController.swift
;
sourceTree
=
"<group>"
;
};
96977DA51CBB2E49000BEFC4
/* Material+UIImage+FilterBlur.swift */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
sourcecode.swift
;
path
=
"Material+UIImage+FilterBlur.swift"
;
sourceTree
=
"<group>"
;
};
96BCB7581CB40DC500C806FE
/* BottomNavigationController.swift */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
sourcecode.swift
;
path
=
BottomNavigationController.swift
;
sourceTree
=
"<group>"
;
};
96BCB7591CB40DC500C806FE
/* BottomTabBar.swift */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
sourcecode.swift
;
path
=
BottomTabBar.swift
;
sourceTree
=
"<group>"
;
};
...
...
@@ -361,6 +363,14 @@
name
=
Table
;
sourceTree
=
"<group>"
;
};
967A48171D0F424B00B8CEB7
/* StatusBar */
=
{
isa
=
PBXGroup
;
children
=
(
967A48181D0F425A00B8CEB7
/* StatusBarController.swift */
,
);
name
=
StatusBar
;
sourceTree
=
"<group>"
;
};
96BCB7571CB40DC500C806FE
/* iOS */
=
{
isa
=
PBXGroup
;
children
=
(
...
...
@@ -377,6 +387,7 @@
96BCB80D1CB410FD00C806FE
/* Layer */
,
96BCB8041CB40F6C00C806FE
/* Layout */
,
96BCB8011CB40F1700C806FE
/* Navigation */
,
967A48171D0F424B00B8CEB7
/* StatusBar */
,
966ECF2B1CF4C21B00BB0BDF
/* Table */
,
96BCB80E1CB4110E00C806FE
/* Text */
,
96BCB8061CB40FD000C806FE
/* Type */
,
...
...
@@ -924,6 +935,7 @@
96BCB7A11CB40DC500C806FE
/* BottomNavigationController.swift in Sources */
,
96BCB7D81CB40DC500C806FE
/* MenuController.swift in Sources */
,
96BCB7D41CB40DC500C806FE
/* MaterialTransitionAnimation.swift in Sources */
,
967A48191D0F425A00B8CEB7
/* StatusBarController.swift in Sources */
,
96BCB7C21CB40DC500C806FE
/* MaterialDevice.swift in Sources */
,
96BCB7A41CB40DC500C806FE
/* CaptureSession.swift in Sources */
,
96BCB7C51CB40DC500C806FE
/* MaterialGravity.swift in Sources */
,
...
...
Sources/iOS/MaterialSwitch.swift
View file @
ae33ab43
...
...
@@ -181,7 +181,7 @@ public class MaterialSwitch : UIControl {
}
/// Track view reference.
public
private(set)
var
trackLayer
:
Material
Layer
{
public
private(set)
var
trackLayer
:
CAShape
Layer
{
didSet
{
prepareTrack
()
}
...
...
@@ -285,7 +285,7 @@ public class MaterialSwitch : UIControl {
- Parameter aDecoder: A NSCoder instance.
*/
public
required
init
?(
coder
aDecoder
:
NSCoder
)
{
trackLayer
=
Material
Layer
()
trackLayer
=
CAShape
Layer
()
button
=
FabButton
()
super
.
init
(
coder
:
aDecoder
)
prepareTrack
()
...
...
@@ -303,7 +303,7 @@ public class MaterialSwitch : UIControl {
- Parameter frame: A CGRect instance.
*/
public
override
init
(
frame
:
CGRect
)
{
trackLayer
=
Material
Layer
()
trackLayer
=
CAShape
Layer
()
button
=
FabButton
()
super
.
init
(
frame
:
frame
)
prepareTrack
()
...
...
@@ -320,7 +320,7 @@ public class MaterialSwitch : UIControl {
- Parameter size: A MaterialSwitchSize value.
*/
public
init
(
state
:
MaterialSwitchState
=
.
Off
,
style
:
MaterialSwitchStyle
=
.
Default
,
size
:
MaterialSwitchSize
=
.
Default
)
{
trackLayer
=
Material
Layer
()
trackLayer
=
CAShape
Layer
()
button
=
FabButton
()
super
.
init
(
frame
:
CGRectNull
)
prepareTrack
()
...
...
@@ -526,7 +526,7 @@ public class MaterialSwitch : UIControl {
let
px
:
CGFloat
=
(
width
-
w
)
/
2
trackLayer
.
frame
=
CGRectMake
(
px
,
(
height
-
trackThickness
)
/
2
,
w
,
trackThickness
)
trackLayer
.
cornerRadius
=
min
(
trackLayer
.
height
,
trackLayer
.
width
)
/
2
trackLayer
.
cornerRadius
=
min
(
trackLayer
.
frame
.
height
,
trackLayer
.
frame
.
width
)
/
2
button
.
frame
=
CGRectMake
(
px
,
(
height
-
buttonDiameter
)
/
2
,
buttonDiameter
,
buttonDiameter
)
onPosition
=
width
-
px
-
buttonDiameter
...
...
Sources/iOS/NavigationDrawerController.swift
View file @
ae33ab43
...
...
@@ -304,7 +304,7 @@ public class NavigationDrawerController : UIViewController, UIGestureRecognizerD
A Boolean property that triggers the status bar to be hidden
when the leftView is opened. Defaults to true.
*/
@IBInspectable
public
var
enableHideStatusbar
:
Bool
=
tru
e
@IBInspectable
public
var
enableHideStatusbar
:
Bool
=
fals
e
/**
A MaterialDepth property that is used to set the depth of the
...
...
@@ -400,7 +400,7 @@ public class NavigationDrawerController : UIViewController, UIGestureRecognizerD
public
override
func
viewWillTransitionToSize
(
size
:
CGSize
,
withTransitionCoordinator
coordinator
:
UIViewControllerTransitionCoordinator
)
{
super
.
viewWillTransitionToSize
(
size
,
withTransitionCoordinator
:
coordinator
)
closeLeftView
()
closeLeftView
()
closeRightView
()
// Ensures the view is hidden.
...
...
Sources/iOS/StatusBarController.swift
0 → 100644
View file @
ae33ab43
/*
* Copyright (C) 2015 - 2016, Daniel Dahan and CosmicMind, Inc. <http://cosmicmind.io>.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
*
* * Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* * Neither the name of Material nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
import
UIKit
public
extension
UIViewController
{
/**
A convenience property that provides access to the StatusBarController.
This is the recommended method of accessing the StatusBarController
through child UIViewControllers.
*/
public
var
statusBarController
:
StatusBarController
?
{
var
viewController
:
UIViewController
?
=
self
while
nil
!=
viewController
{
if
viewController
is
StatusBarController
{
return
viewController
as?
StatusBarController
}
viewController
=
viewController
?
.
parentViewController
}
return
nil
}
}
@IBDesignable
public
class
StatusBarController
:
UIViewController
{
/// Device status bar style.
public
var
statusBarStyle
:
UIStatusBarStyle
{
get
{
return
MaterialDevice
.
statusBarStyle
}
set
(
value
)
{
MaterialDevice
.
statusBarStyle
=
value
}
}
/// A reference to the statusBarView.
public
private(set)
var
statusBarView
:
MaterialView
!
/**
A Boolean property used to enable and disable interactivity
with the rootViewController.
*/
@IBInspectable
public
var
userInteractionEnabled
:
Bool
{
get
{
return
rootViewController
.
view
.
userInteractionEnabled
}
set
(
value
)
{
rootViewController
.
view
.
userInteractionEnabled
=
value
}
}
/**
A UIViewController property that references the active
main UIViewController. To swap the rootViewController, it
is recommended to use the transitionFromRootViewController
helper method.
*/
public
private(set)
var
rootViewController
:
UIViewController
!
/**
An initializer that initializes the object with a NSCoder object.
- Parameter aDecoder: A NSCoder instance.
*/
public
required
init
?(
coder
aDecoder
:
NSCoder
)
{
super
.
init
(
coder
:
aDecoder
)
prepareView
()
}
/**
An initializer that initializes the object with an Optional nib and bundle.
- Parameter nibNameOrNil: An Optional String for the nib.
- Parameter bundle: An Optional NSBundle where the nib is located.
*/
public
override
init
(
nibName
nibNameOrNil
:
String
?,
bundle
nibBundleOrNil
:
NSBundle
?)
{
super
.
init
(
nibName
:
nibNameOrNil
,
bundle
:
nibBundleOrNil
)
prepareView
()
}
/**
An initializer for the BarController.
- Parameter rootViewController: The main UIViewController.
*/
public
init
(
rootViewController
:
UIViewController
)
{
super
.
init
(
nibName
:
nil
,
bundle
:
nil
)
self
.
rootViewController
=
rootViewController
prepareView
()
}
public
override
func
viewWillLayoutSubviews
()
{
super
.
viewWillLayoutSubviews
()
layoutSubviews
()
}
/**
A method to swap rootViewController objects.
- Parameter toViewController: The UIViewController to swap
with the active rootViewController.
- 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 rootViewController
to the toViewController.
- Parameter animations: An animation block that is executed during
the transition from the active rootViewController
to the toViewController.
- Parameter completion: A completion block that is execited after
the transition animation from the active rootViewController
to the toViewController has completed.
*/
public
func
transitionFromRootViewController
(
toViewController
:
UIViewController
,
duration
:
NSTimeInterval
=
0.5
,
options
:
UIViewAnimationOptions
=
[],
animations
:
(()
->
Void
)?
=
nil
,
completion
:
((
Bool
)
->
Void
)?
=
nil
)
{
rootViewController
.
willMoveToParentViewController
(
nil
)
addChildViewController
(
toViewController
)
toViewController
.
view
.
frame
=
rootViewController
.
view
.
frame
transitionFromViewController
(
rootViewController
,
toViewController
:
toViewController
,
duration
:
duration
,
options
:
options
,
animations
:
animations
,
completion
:
{
[
weak
self
]
(
result
:
Bool
)
in
if
let
s
:
StatusBarController
=
self
{
toViewController
.
didMoveToParentViewController
(
s
)
s
.
rootViewController
.
removeFromParentViewController
()
s
.
rootViewController
=
toViewController
s
.
rootViewController
.
view
.
clipsToBounds
=
true
s
.
rootViewController
.
view
.
autoresizingMask
=
[
.
FlexibleWidth
,
.
FlexibleHeight
]
s
.
view
.
sendSubviewToBack
(
s
.
rootViewController
.
view
)
completion
?(
result
)
}
})
}
/**
Prepares the view instance when intialized. When subclassing,
it is recommended to override the prepareView method
to initialize property values and other setup operations.
The super.prepareView method should always be called immediately
when subclassing.
*/
public
func
prepareView
()
{
view
.
clipsToBounds
=
true
view
.
contentScaleFactor
=
MaterialDevice
.
scale
prepareStatusBarView
()
prepareRootViewController
()
}
/// Prepares the statusBarView.
private
func
prepareStatusBarView
()
{
statusBarView
=
MaterialView
()
statusBarView
.
zPosition
=
3000
statusBarView
.
backgroundColor
=
MaterialColor
.
black
.
colorWithAlphaComponent
(
0.12
)
view
.
layout
(
statusBarView
)
.
top
(
0
)
.
horizontally
()
.
height
(
20
)
}
/// A method that prepares the rootViewController.
private
func
prepareRootViewController
()
{
prepareViewControllerWithinContainer
(
rootViewController
,
container
:
view
)
}
/**
A method that adds the passed in controller as a child of
the StatusBarController within the passed in
container view.
- Parameter viewController: A UIViewController to add as a child.
- Parameter container: A UIView that is the parent of the
passed in controller view within the view hierarchy.
*/
private
func
prepareViewControllerWithinContainer
(
viewController
:
UIViewController
?,
container
:
UIView
)
{
if
let
v
:
UIViewController
=
viewController
{
addChildViewController
(
v
)
v
.
didMoveToParentViewController
(
self
)
v
.
view
.
clipsToBounds
=
true
v
.
view
.
autoresizingMask
=
[
.
FlexibleWidth
,
.
FlexibleHeight
]
container
.
addSubview
(
v
.
view
)
container
.
sendSubviewToBack
(
v
.
view
)
}
}
/// Layout subviews.
private
func
layoutSubviews
()
{
statusBarView
.
hidden
=
MaterialDevice
.
isLandscape
&&
.
iPhone
==
MaterialDevice
.
type
rootViewController
.
view
.
frame
=
view
.
bounds
}
}
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