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
7d7e0975
Commit
7d7e0975
authored
Mar 06, 2016
by
Daniel Dahan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
working NavigationController -> NavigationBar Back Button
parent
0ff4ab03
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
283 additions
and
264 deletions
+283
-264
Examples/Programmatic/App/App.xcodeproj/project.pbxproj
+0
-4
Examples/Programmatic/App/App/AppDelegate.swift
+1
-1
Examples/Programmatic/App/App/FeedViewController.swift
+12
-8
Examples/Programmatic/App/App/InboxViewController.swift
+5
-2
Examples/Programmatic/App/App/Info.plist
+4
-2
Examples/Programmatic/App/App/ViewController.swift
+0
-58
Sources/Grid.swift
+1
-1
Sources/MaterialEdgeInset.swift
+28
-30
Sources/NavigationBar.swift
+214
-144
Sources/NavigationController.swift
+10
-8
Sources/SideNavigationViewController.swift
+8
-6
No files found.
Examples/Programmatic/App/App.xcodeproj/project.pbxproj
View file @
7d7e0975
...
@@ -9,7 +9,6 @@
...
@@ -9,7 +9,6 @@
/* Begin PBXBuildFile section */
/* Begin PBXBuildFile section */
96334EFC1C8B85F40083986B
/* Material.framework in Frameworks */
=
{
isa
=
PBXBuildFile
;
fileRef
=
96334EFB1C8B85F40083986B
/* Material.framework */
;
};
96334EFC1C8B85F40083986B
/* Material.framework in Frameworks */
=
{
isa
=
PBXBuildFile
;
fileRef
=
96334EFB1C8B85F40083986B
/* Material.framework */
;
};
96334EFD1C8B85F40083986B
/* Material.framework in Embed Frameworks */
=
{
isa
=
PBXBuildFile
;
fileRef
=
96334EFB1C8B85F40083986B
/* Material.framework */
;
settings
=
{
ATTRIBUTES
=
(
CodeSignOnCopy
,
RemoveHeadersOnCopy
,
);
};
};
96334EFD1C8B85F40083986B
/* Material.framework in Embed Frameworks */
=
{
isa
=
PBXBuildFile
;
fileRef
=
96334EFB1C8B85F40083986B
/* Material.framework */
;
settings
=
{
ATTRIBUTES
=
(
CodeSignOnCopy
,
RemoveHeadersOnCopy
,
);
};
};
96334EFF1C8B876E0083986B
/* ViewController.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
96334EFE1C8B876E0083986B
/* ViewController.swift */
;
};
9663F9321C7A744600AF0965
/* AppDelegate.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
9663F9311C7A744600AF0965
/* AppDelegate.swift */
;
};
9663F9321C7A744600AF0965
/* AppDelegate.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
9663F9311C7A744600AF0965
/* AppDelegate.swift */
;
};
9663F9341C7A744600AF0965
/* SearchListViewController.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
9663F9331C7A744600AF0965
/* SearchListViewController.swift */
;
};
9663F9341C7A744600AF0965
/* SearchListViewController.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
9663F9331C7A744600AF0965
/* SearchListViewController.swift */
;
};
9663F9391C7A744600AF0965
/* Assets.xcassets in Resources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
9663F9381C7A744600AF0965
/* Assets.xcassets */
;
};
9663F9391C7A744600AF0965
/* Assets.xcassets in Resources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
9663F9381C7A744600AF0965
/* Assets.xcassets */
;
};
...
@@ -39,7 +38,6 @@
...
@@ -39,7 +38,6 @@
/* Begin PBXFileReference section */
/* Begin PBXFileReference section */
96334EFB1C8B85F40083986B
/* Material.framework */
=
{
isa
=
PBXFileReference
;
explicitFileType
=
wrapper.framework
;
name
=
Material.framework
;
path
=
"/Users/danieldahan/Library/Developer/Xcode/DerivedData/Material-hbpnflxhoouqxebjcyhbbhqyesjd/Build/Products/Debug-iphoneos/Material.framework"
;
sourceTree
=
"<absolute>"
;
};
96334EFB1C8B85F40083986B
/* Material.framework */
=
{
isa
=
PBXFileReference
;
explicitFileType
=
wrapper.framework
;
name
=
Material.framework
;
path
=
"/Users/danieldahan/Library/Developer/Xcode/DerivedData/Material-hbpnflxhoouqxebjcyhbbhqyesjd/Build/Products/Debug-iphoneos/Material.framework"
;
sourceTree
=
"<absolute>"
;
};
96334EFE1C8B876E0083986B
/* ViewController.swift */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
sourcecode.swift
;
path
=
ViewController.swift
;
sourceTree
=
"<group>"
;
};
9663F92E1C7A744600AF0965
/* App.app */
=
{
isa
=
PBXFileReference
;
explicitFileType
=
wrapper.application
;
includeInIndex
=
0
;
path
=
App.app
;
sourceTree
=
BUILT_PRODUCTS_DIR
;
};
9663F92E1C7A744600AF0965
/* App.app */
=
{
isa
=
PBXFileReference
;
explicitFileType
=
wrapper.application
;
includeInIndex
=
0
;
path
=
App.app
;
sourceTree
=
BUILT_PRODUCTS_DIR
;
};
9663F9311C7A744600AF0965
/* AppDelegate.swift */
=
{
isa
=
PBXFileReference
;
lastKnownFileType
=
sourcecode.swift
;
path
=
AppDelegate.swift
;
sourceTree
=
"<group>"
;
};
9663F9311C7A744600AF0965
/* AppDelegate.swift */
=
{
isa
=
PBXFileReference
;
lastKnownFileType
=
sourcecode.swift
;
path
=
AppDelegate.swift
;
sourceTree
=
"<group>"
;
};
9663F9331C7A744600AF0965
/* SearchListViewController.swift */
=
{
isa
=
PBXFileReference
;
lastKnownFileType
=
sourcecode.swift
;
path
=
SearchListViewController.swift
;
sourceTree
=
"<group>"
;
};
9663F9331C7A744600AF0965
/* SearchListViewController.swift */
=
{
isa
=
PBXFileReference
;
lastKnownFileType
=
sourcecode.swift
;
path
=
SearchListViewController.swift
;
sourceTree
=
"<group>"
;
};
...
@@ -99,7 +97,6 @@
...
@@ -99,7 +97,6 @@
9663F9381C7A744600AF0965
/* Assets.xcassets */
,
9663F9381C7A744600AF0965
/* Assets.xcassets */
,
9663F93A1C7A744600AF0965
/* LaunchScreen.storyboard */
,
9663F93A1C7A744600AF0965
/* LaunchScreen.storyboard */
,
9663F93D1C7A744600AF0965
/* Info.plist */
,
9663F93D1C7A744600AF0965
/* Info.plist */
,
96334EFE1C8B876E0083986B
/* ViewController.swift */
,
);
);
path
=
App
;
path
=
App
;
sourceTree
=
"<group>"
;
sourceTree
=
"<group>"
;
...
@@ -175,7 +172,6 @@
...
@@ -175,7 +172,6 @@
isa
=
PBXSourcesBuildPhase
;
isa
=
PBXSourcesBuildPhase
;
buildActionMask
=
2147483647
;
buildActionMask
=
2147483647
;
files
=
(
files
=
(
96334EFF1C8B876E0083986B
/* ViewController.swift in Sources */
,
9663F94A1C7A74B500AF0965
/* AppSearchBarViewController.swift in Sources */
,
9663F94A1C7A74B500AF0965
/* AppSearchBarViewController.swift in Sources */
,
96CC08881C7FEBD60034FF84
/* InboxViewController.swift in Sources */
,
96CC08881C7FEBD60034FF84
/* InboxViewController.swift in Sources */
,
9663F9501C7A74FC00AF0965
/* AppRightViewController.swift in Sources */
,
9663F9501C7A74FC00AF0965
/* AppRightViewController.swift in Sources */
,
...
...
Examples/Programmatic/App/App/AppDelegate.swift
View file @
7d7e0975
...
@@ -40,7 +40,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
...
@@ -40,7 +40,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
// Override point for customization after application launch.
// Override point for customization after application launch.
window
=
UIWindow
(
frame
:
UIScreen
.
mainScreen
()
.
bounds
)
window
=
UIWindow
(
frame
:
UIScreen
.
mainScreen
()
.
bounds
)
// window!.rootViewController = SideNavigationViewController(mainViewController: AppMenuViewController(mainViewController: AppNavigationBarViewController(mainViewController: InboxViewController())), leftViewController: AppLeftViewController(), rightViewController: AppRightViewController())
// window!.rootViewController = SideNavigationViewController(mainViewController: AppMenuViewController(mainViewController: AppNavigationBarViewController(mainViewController: InboxViewController())), leftViewController: AppLeftViewController(), rightViewController: AppRightViewController())
window
!.
rootViewController
=
NavigationController
(
rootViewController
:
Feed
ViewController
())
window
!.
rootViewController
=
SideNavigationViewController
(
mainViewController
:
NavigationController
(
rootViewController
:
FeedViewController
()),
leftViewController
:
AppLeft
ViewController
())
window
!.
makeKeyAndVisible
()
window
!.
makeKeyAndVisible
()
return
true
return
true
}
}
...
...
Examples/Programmatic/App/App/FeedViewController.swift
View file @
7d7e0975
...
@@ -46,7 +46,6 @@ class FeedViewController: UIViewController {
...
@@ -46,7 +46,6 @@ class FeedViewController: UIViewController {
override
func
viewWillLayoutSubviews
()
{
override
func
viewWillLayoutSubviews
()
{
super
.
viewWillLayoutSubviews
()
super
.
viewWillLayoutSubviews
()
collectionView
.
frame
=
view
.
bounds
collectionView
.
reloadData
()
collectionView
.
reloadData
()
}
}
...
@@ -59,11 +58,11 @@ class FeedViewController: UIViewController {
...
@@ -59,11 +58,11 @@ class FeedViewController: UIViewController {
// Menu button.
// Menu button.
let
menuButton
:
FlatButton
=
FlatButton
()
let
menuButton
:
FlatButton
=
FlatButton
()
menuButton
.
pulseColor
=
MaterialColor
.
white
menuButton
.
pulseScale
=
false
menuButton
.
pulseScale
=
false
menuButton
.
pulseColor
=
MaterialColor
.
white
menuButton
.
setImage
(
image
,
forState
:
.
Normal
)
menuButton
.
setImage
(
image
,
forState
:
.
Normal
)
menuButton
.
setImage
(
image
,
forState
:
.
Highlighted
)
menuButton
.
setImage
(
image
,
forState
:
.
Highlighted
)
//
menuButton.addTarget(self, action: "handleMenuButton", forControlEvents: .TouchUpInside)
menuButton
.
addTarget
(
self
,
action
:
"handleMenuButton"
,
forControlEvents
:
.
TouchUpInside
)
// Switch control.
// Switch control.
let
switchControl
:
MaterialSwitch
=
MaterialSwitch
(
state
:
.
Off
,
style
:
.
LightContent
,
size
:
.
Small
)
let
switchControl
:
MaterialSwitch
=
MaterialSwitch
(
state
:
.
Off
,
style
:
.
LightContent
,
size
:
.
Small
)
...
@@ -71,18 +70,18 @@ class FeedViewController: UIViewController {
...
@@ -71,18 +70,18 @@ class FeedViewController: UIViewController {
// Search button.
// Search button.
image
=
UIImage
(
named
:
"ic_search_white"
)
image
=
UIImage
(
named
:
"ic_search_white"
)
let
searchButton
:
FlatButton
=
FlatButton
()
let
searchButton
:
FlatButton
=
FlatButton
()
searchButton
.
pulseColor
=
MaterialColor
.
white
searchButton
.
pulseScale
=
false
searchButton
.
pulseScale
=
false
searchButton
.
pulseColor
=
MaterialColor
.
white
searchButton
.
setImage
(
image
,
forState
:
.
Normal
)
searchButton
.
setImage
(
image
,
forState
:
.
Normal
)
searchButton
.
setImage
(
image
,
forState
:
.
Highlighted
)
searchButton
.
setImage
(
image
,
forState
:
.
Highlighted
)
//
searchButton.addTarget(self, action: "handleSearchButton", forControlEvents: .TouchUpInside)
searchButton
.
addTarget
(
self
,
action
:
"handleSearchButton"
,
forControlEvents
:
.
TouchUpInside
)
navigationController
?
.
navigationBar
.
leftControls
=
[
menuButton
]
navigationController
?
.
navigationBar
.
leftControls
=
[
menuButton
]
navigationController
?
.
navigationBar
.
rightControls
=
[
switchControl
,
searchButton
]
navigationController
?
.
navigationBar
.
rightControls
=
[
switchControl
,
searchButton
]
}
}
internal
func
handleMenuButton
()
{
internal
func
handleMenuButton
()
{
print
(
"handled"
)
sideNavigationViewController
?
.
toggleLeftView
(
)
}
}
internal
func
handleSearchButton
()
{
internal
func
handleSearchButton
()
{
...
@@ -94,7 +93,9 @@ class FeedViewController: UIViewController {
...
@@ -94,7 +93,9 @@ class FeedViewController: UIViewController {
view
.
backgroundColor
=
MaterialColor
.
grey
.
lighten4
view
.
backgroundColor
=
MaterialColor
.
grey
.
lighten4
navigationController
?
.
navigationBar
.
statusBarStyle
=
.
LightContent
navigationController
?
.
navigationBar
.
statusBarStyle
=
.
LightContent
navigationController
?
.
navigationBar
.
tintColor
=
MaterialColor
.
white
navigationController
?
.
navigationBar
.
backgroundColor
=
MaterialColor
.
blue
.
base
navigationController
?
.
navigationBar
.
backgroundColor
=
MaterialColor
.
blue
.
base
navigationController
?
.
navigationBar
.
backButton
.
pulseColor
=
MaterialColor
.
white
}
}
/// Prepares the collectionView
/// Prepares the collectionView
...
@@ -102,11 +103,12 @@ class FeedViewController: UIViewController {
...
@@ -102,11 +103,12 @@ class FeedViewController: UIViewController {
collectionView
.
dataSource
=
self
collectionView
.
dataSource
=
self
collectionView
.
delegate
=
self
collectionView
.
delegate
=
self
collectionView
.
spacingPreset
=
.
Spacing1
collectionView
.
spacingPreset
=
.
Spacing1
collectionView
.
contentInsetPreset
=
.
Square1
collectionView
.
registerClass
(
MaterialCollectionViewCell
.
self
,
forCellWithReuseIdentifier
:
"MaterialCollectionViewCell"
)
collectionView
.
registerClass
(
MaterialCollectionViewCell
.
self
,
forCellWithReuseIdentifier
:
"MaterialCollectionViewCell"
)
// To avoid being hidden under the hovering MenuView.
// To avoid being hidden under the hovering MenuView.
view
.
addSubview
(
collectionView
)
view
.
addSubview
(
collectionView
)
collectionView
.
translatesAutoresizingMaskIntoConstraints
=
false
MaterialLayout
.
alignToParent
(
view
,
child
:
collectionView
)
// collectionView.scrollDirection = .Horizontal // Uncomment to see the horizontal scroll direction.
// collectionView.scrollDirection = .Horizontal // Uncomment to see the horizontal scroll direction.
}
}
...
@@ -204,6 +206,7 @@ extension FeedViewController: MaterialCollectionViewDataSource {
...
@@ -204,6 +206,7 @@ extension FeedViewController: MaterialCollectionViewDataSource {
cardView
!.
pulseScale
=
false
cardView
!.
pulseScale
=
false
cardView
!.
divider
=
false
cardView
!.
divider
=
false
cardView
!.
depth
=
.
None
cardView
!.
depth
=
.
None
cardView
!.
cornerRadiusPreset
=
.
None
let
titleLabel
:
UILabel
=
UILabel
()
let
titleLabel
:
UILabel
=
UILabel
()
titleLabel
.
textColor
=
MaterialColor
.
grey
.
darken4
titleLabel
.
textColor
=
MaterialColor
.
grey
.
darken4
...
@@ -246,6 +249,6 @@ extension FeedViewController: MaterialCollectionViewDelegate {
...
@@ -246,6 +249,6 @@ extension FeedViewController: MaterialCollectionViewDelegate {
/// Executed when an item is selected.
/// Executed when an item is selected.
func
collectionView
(
collectionView
:
UICollectionView
,
didSelectItemAtIndexPath
indexPath
:
NSIndexPath
)
{
func
collectionView
(
collectionView
:
UICollectionView
,
didSelectItemAtIndexPath
indexPath
:
NSIndexPath
)
{
// print(indexPath)
// print(indexPath)
navigationController
?
.
pushViewController
(
ViewController
(),
animated
:
true
)
navigationController
?
.
pushViewController
(
Inbox
ViewController
(),
animated
:
true
)
}
}
}
}
\ No newline at end of file
Examples/Programmatic/App/App/InboxViewController.swift
View file @
7d7e0975
...
@@ -53,7 +53,10 @@ class InboxViewController: UIViewController {
...
@@ -53,7 +53,10 @@ class InboxViewController: UIViewController {
override
func
viewWillAppear
(
animated
:
Bool
)
{
override
func
viewWillAppear
(
animated
:
Bool
)
{
super
.
viewWillAppear
(
animated
)
super
.
viewWillAppear
(
animated
)
navigationBarViewController
?
.
navigationBarView
.
titleLabel
?
.
text
=
"Inbox"
navigationItem
.
title
=
"Messages"
navigationController
?
.
navigationBar
.
topItem
?
.
title
=
""
navigationController
?
.
navigationBar
.
leftControls
=
[]
}
}
/**
/**
...
@@ -135,7 +138,7 @@ extension InboxViewController: UITableViewDataSource {
...
@@ -135,7 +138,7 @@ extension InboxViewController: UITableViewDataSource {
header
.
addSubview
(
label
)
header
.
addSubview
(
label
)
label
.
translatesAutoresizingMaskIntoConstraints
=
false
label
.
translatesAutoresizingMaskIntoConstraints
=
false
MaterialLayout
.
alignToParent
(
header
,
child
:
label
,
left
:
navigation
BarViewController
!.
navigationBarView
.
contentInset
.
left
+
navigationBarViewController
!.
navigationBarView
.
spacing
)
MaterialLayout
.
alignToParent
(
header
,
child
:
label
,
left
:
navigation
Controller
!.
navigationBar
.
contentInset
.
left
)
return
header
return
header
}
}
...
...
Examples/Programmatic/App/App/Info.plist
View file @
7d7e0975
...
@@ -2,8 +2,6 @@
...
@@ -2,8 +2,6 @@
<
!
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
"
>
<
!
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
"
>
<
plist
v
e
rsion="
1
.
0
"
>
<
d
i
c
t
>
<
d
i
c
t
>
<
k
e
y
>
UIViewControllerBasedStatusBarAppearance
<
/k
e
y
>
<
fa
ls
e
/
>
<
k
e
y
>
CFBundleDevelopmentRegion
<
/k
e
y
>
<
k
e
y
>
CFBundleDevelopmentRegion
<
/k
e
y
>
<
string
>
en
<
/string
>
<
string
>
en
<
/string
>
<
k
e
y
>
CFBundleExecutable
<
/k
e
y
>
<
k
e
y
>
CFBundleExecutable
<
/k
e
y
>
...
@@ -30,6 +28,8 @@
...
@@ -30,6 +28,8 @@
<
a
rr
a
y
>
<
a
rr
a
y
>
<
string
>
armv7
<
/string
>
<
string
>
armv7
<
/string
>
<
/
a
rr
a
y
>
<
/
a
rr
a
y
>
<
k
e
y
>
UIStatusBarHidden
<
/k
e
y
>
<
fa
ls
e
/
>
<
k
e
y
>
UISupportedInterfaceOrientations
<
/k
e
y
>
<
k
e
y
>
UISupportedInterfaceOrientations
<
/k
e
y
>
<
a
rr
a
y
>
<
a
rr
a
y
>
<
string
>
UIInterfaceOrientationPortrait
<
/string
>
<
string
>
UIInterfaceOrientationPortrait
<
/string
>
...
@@ -44,5 +44,7 @@
...
@@ -44,5 +44,7 @@
<
string
>
UIInterfaceOrientationLandscapeLeft
<
/string
>
<
string
>
UIInterfaceOrientationLandscapeLeft
<
/string
>
<
string
>
UIInterfaceOrientationLandscapeRight
<
/string
>
<
string
>
UIInterfaceOrientationLandscapeRight
<
/string
>
<
/
a
rr
a
y
>
<
/
a
rr
a
y
>
<
k
e
y
>
UIViewControllerBasedStatusBarAppearance
<
/k
e
y
>
<
fa
ls
e
/
>
<
/
d
i
c
t
>
<
/
d
i
c
t
>
<
/plist
>
<
/plist
>
Examples/Programmatic/App/App/ViewController.swift
deleted
100644 → 0
View file @
0ff4ab03
/*
* 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.
*/
/*
The following example shows how to dynamically size MaterialCollectionViewCells.
*/
import
UIKit
import
Material
class
ViewController
:
UIViewController
{
override
func
viewDidLoad
()
{
super
.
viewDidLoad
()
prepareView
()
}
override
func
viewWillAppear
(
animated
:
Bool
)
{
super
.
viewWillAppear
(
animated
)
navigationItem
.
title
=
"Material"
navigationController
?
.
navigationBar
.
leftControls
=
[]
navigationController
?
.
navigationBar
.
rightControls
=
[]
}
/// Prepares view.
private
func
prepareView
()
{
view
.
backgroundColor
=
MaterialColor
.
grey
.
lighten4
}
}
\ No newline at end of file
Sources/Grid.swift
View file @
7d7e0975
...
@@ -228,7 +228,7 @@ private var GridKey: UInt8 = 0
...
@@ -228,7 +228,7 @@ private var GridKey: UInt8 = 0
/// Grid extension for UIView.
/// Grid extension for UIView.
public
extension
UIView
{
public
extension
UIView
{
/// Grid reference.
/// Grid reference.
public
var
grid
:
Grid
{
public
internal(set)
var
grid
:
Grid
{
get
{
get
{
return
MaterialObjectAssociatedObject
(
self
,
key
:
&
GridKey
)
{
return
MaterialObjectAssociatedObject
(
self
,
key
:
&
GridKey
)
{
return
Grid
()
return
Grid
()
...
...
Sources/MaterialEdgeInset.swift
View file @
7d7e0975
...
@@ -67,9 +67,7 @@ public enum MaterialEdgeInset {
...
@@ -67,9 +67,7 @@ public enum MaterialEdgeInset {
case
TallRectangle9
case
TallRectangle9
}
}
/**
/// Converts the MaterialEdgeInset to a UIEdgeInsets value.
:name: MaterialEdgeInsetToValue
*/
public
func
MaterialEdgeInsetToValue
(
inset
:
MaterialEdgeInset
)
->
UIEdgeInsets
{
public
func
MaterialEdgeInsetToValue
(
inset
:
MaterialEdgeInset
)
->
UIEdgeInsets
{
switch
inset
{
switch
inset
{
case
.
None
:
case
.
None
:
...
@@ -77,62 +75,62 @@ public func MaterialEdgeInsetToValue(inset: MaterialEdgeInset) -> UIEdgeInsets {
...
@@ -77,62 +75,62 @@ public func MaterialEdgeInsetToValue(inset: MaterialEdgeInset) -> UIEdgeInsets {
// square
// square
case
.
Square1
:
case
.
Square1
:
return
UIEdgeInsets
(
top
:
4
,
left
:
4
,
bottom
:
4
,
right
:
4
)
return
UIEdgeInsets
Make
(
4
,
4
,
4
,
4
)
case
.
Square2
:
case
.
Square2
:
return
UIEdgeInsets
(
top
:
8
,
left
:
8
,
bottom
:
8
,
right
:
8
)
return
UIEdgeInsets
Make
(
8
,
8
,
8
,
8
)
case
.
Square3
:
case
.
Square3
:
return
UIEdgeInsets
(
top
:
16
,
left
:
16
,
bottom
:
16
,
right
:
16
)
return
UIEdgeInsets
Make
(
16
,
16
,
16
,
16
)
case
.
Square4
:
case
.
Square4
:
return
UIEdgeInsets
(
top
:
24
,
left
:
24
,
bottom
:
24
,
right
:
24
)
return
UIEdgeInsets
Make
(
24
,
24
,
24
,
24
)
case
.
Square5
:
case
.
Square5
:
return
UIEdgeInsets
(
top
:
32
,
left
:
32
,
bottom
:
32
,
right
:
32
)
return
UIEdgeInsets
Make
(
32
,
32
,
32
,
32
)
case
.
Square6
:
case
.
Square6
:
return
UIEdgeInsets
(
top
:
40
,
left
:
40
,
bottom
:
40
,
right
:
40
)
return
UIEdgeInsets
Make
(
40
,
40
,
40
,
40
)
case
.
Square7
:
case
.
Square7
:
return
UIEdgeInsets
(
top
:
48
,
left
:
48
,
bottom
:
48
,
right
:
48
)
return
UIEdgeInsets
Make
(
48
,
48
,
48
,
48
)
case
.
Square8
:
case
.
Square8
:
return
UIEdgeInsets
(
top
:
56
,
left
:
56
,
bottom
:
56
,
right
:
56
)
return
UIEdgeInsets
Make
(
56
,
56
,
56
,
56
)
case
.
Square9
:
case
.
Square9
:
return
UIEdgeInsets
(
top
:
64
,
left
:
64
,
bottom
:
64
,
right
:
64
)
return
UIEdgeInsets
Make
(
64
,
64
,
64
,
64
)
// rectangle
// rectangle
case
.
WideRectangle1
:
case
.
WideRectangle1
:
return
UIEdgeInsets
(
top
:
2
,
left
:
4
,
bottom
:
2
,
right
:
4
)
return
UIEdgeInsets
Make
(
2
,
4
,
2
,
4
)
case
.
WideRectangle2
:
case
.
WideRectangle2
:
return
UIEdgeInsets
(
top
:
4
,
left
:
8
,
bottom
:
4
,
right
:
8
)
return
UIEdgeInsets
Make
(
4
,
8
,
4
,
8
)
case
.
WideRectangle3
:
case
.
WideRectangle3
:
return
UIEdgeInsets
(
top
:
8
,
left
:
16
,
bottom
:
8
,
right
:
16
)
return
UIEdgeInsets
Make
(
8
,
16
,
8
,
16
)
case
.
WideRectangle4
:
case
.
WideRectangle4
:
return
UIEdgeInsets
(
top
:
12
,
left
:
24
,
bottom
:
12
,
right
:
24
)
return
UIEdgeInsets
Make
(
12
,
24
,
12
,
24
)
case
.
WideRectangle5
:
case
.
WideRectangle5
:
return
UIEdgeInsets
(
top
:
16
,
left
:
32
,
bottom
:
16
,
right
:
32
)
return
UIEdgeInsets
Make
(
16
,
32
,
16
,
32
)
case
.
WideRectangle6
:
case
.
WideRectangle6
:
return
UIEdgeInsets
(
top
:
20
,
left
:
40
,
bottom
:
20
,
right
:
40
)
return
UIEdgeInsets
Make
(
20
,
40
,
20
,
40
)
case
.
WideRectangle7
:
case
.
WideRectangle7
:
return
UIEdgeInsets
(
top
:
24
,
left
:
48
,
bottom
:
24
,
right
:
48
)
return
UIEdgeInsets
Make
(
24
,
48
,
24
,
48
)
case
.
WideRectangle8
:
case
.
WideRectangle8
:
return
UIEdgeInsets
(
top
:
28
,
left
:
56
,
bottom
:
28
,
right
:
56
)
return
UIEdgeInsets
Make
(
28
,
56
,
28
,
56
)
case
.
WideRectangle9
:
case
.
WideRectangle9
:
return
UIEdgeInsets
(
top
:
32
,
left
:
64
,
bottom
:
32
,
right
:
64
)
return
UIEdgeInsets
Make
(
32
,
64
,
32
,
64
)
// flipped rectangle
// flipped rectangle
case
.
TallRectangle1
:
case
.
TallRectangle1
:
return
UIEdgeInsets
(
top
:
4
,
left
:
2
,
bottom
:
4
,
right
:
2
)
return
UIEdgeInsets
Make
(
4
,
2
,
4
,
2
)
case
.
TallRectangle2
:
case
.
TallRectangle2
:
return
UIEdgeInsets
(
top
:
8
,
left
:
4
,
bottom
:
8
,
right
:
4
)
return
UIEdgeInsets
Make
(
8
,
4
,
8
,
4
)
case
.
TallRectangle3
:
case
.
TallRectangle3
:
return
UIEdgeInsets
(
top
:
16
,
left
:
8
,
bottom
:
16
,
right
:
8
)
return
UIEdgeInsets
Make
(
16
,
8
,
16
,
8
)
case
.
TallRectangle4
:
case
.
TallRectangle4
:
return
UIEdgeInsets
(
top
:
24
,
left
:
12
,
bottom
:
24
,
right
:
12
)
return
UIEdgeInsets
Make
(
24
,
12
,
24
,
12
)
case
.
TallRectangle5
:
case
.
TallRectangle5
:
return
UIEdgeInsets
(
top
:
32
,
left
:
16
,
bottom
:
32
,
right
:
16
)
return
UIEdgeInsets
Make
(
32
,
16
,
32
,
16
)
case
.
TallRectangle6
:
case
.
TallRectangle6
:
return
UIEdgeInsets
(
top
:
40
,
left
:
20
,
bottom
:
40
,
right
:
20
)
return
UIEdgeInsets
Make
(
40
,
20
,
40
,
20
)
case
.
TallRectangle7
:
case
.
TallRectangle7
:
return
UIEdgeInsets
(
top
:
48
,
left
:
24
,
bottom
:
48
,
right
:
24
)
return
UIEdgeInsets
Make
(
48
,
24
,
48
,
24
)
case
.
TallRectangle8
:
case
.
TallRectangle8
:
return
UIEdgeInsets
(
top
:
56
,
left
:
28
,
bottom
:
56
,
right
:
28
)
return
UIEdgeInsets
Make
(
56
,
28
,
56
,
28
)
case
.
TallRectangle9
:
case
.
TallRectangle9
:
return
UIEdgeInsets
(
top
:
64
,
left
:
32
,
bottom
:
64
,
right
:
32
)
return
UIEdgeInsets
Make
(
64
,
32
,
64
,
32
)
}
}
}
}
Sources/NavigationBar.swift
View file @
7d7e0975
This diff is collapsed.
Click to expand it.
Sources/NavigationController.swift
View file @
7d7e0975
...
@@ -34,26 +34,28 @@ public class NavigationController : UINavigationController {
...
@@ -34,26 +34,28 @@ public class NavigationController : UINavigationController {
public
required
init
?(
coder
aDecoder
:
NSCoder
)
{
public
required
init
?(
coder
aDecoder
:
NSCoder
)
{
super
.
init
(
coder
:
aDecoder
)
super
.
init
(
coder
:
aDecoder
)
prepareView
()
}
}
public
override
init
(
nibName
nibNameOrNil
:
String
?,
bundle
nibBundleOrNil
:
NSBundle
?)
{
public
override
init
(
nibName
nibNameOrNil
:
String
?,
bundle
nibBundleOrNil
:
NSBundle
?)
{
super
.
init
(
nibName
:
nibNameOrNil
,
bundle
:
nibBundleOrNil
)
super
.
init
(
nibName
:
nibNameOrNil
,
bundle
:
nibBundleOrNil
)
prepareView
()
}
}
public
override
init
(
rootViewController
:
UIViewController
)
{
public
override
init
(
rootViewController
:
UIViewController
)
{
super
.
init
(
navigationBarClass
:
NavigationBar
.
self
,
toolbarClass
:
nil
)
super
.
init
(
navigationBarClass
:
NavigationBar
.
self
,
toolbarClass
:
nil
)
setViewControllers
([
rootViewController
],
animated
:
false
)
setViewControllers
([
rootViewController
],
animated
:
false
)
prepareView
()
}
}
public
override
func
viewDidLoad
()
{
public
override
func
viewWillLayoutSubviews
()
{
super
.
viewDidLoad
()
super
.
viewWillLayoutSubviews
()
prepareView
()
if
let
v
:
NavigationBar
=
navigationBar
as?
NavigationBar
{
v
.
layoutSubviews
()
v
.
backButton
.
removeTarget
(
self
,
action
:
"handleBackButton"
,
forControlEvents
:
.
TouchUpInside
)
v
.
backButton
.
addTarget
(
self
,
action
:
"handleBackButton"
,
forControlEvents
:
.
TouchUpInside
)
}
}
}
public
func
prepareView
()
{
/// Handles the backButton.
navigationItem
.
title
=
"Title"
internal
func
handleBackButton
()
{
popViewControllerAnimated
(
true
)
}
}
}
}
Sources/SideNavigationViewController.swift
View file @
7d7e0975
...
@@ -843,12 +843,14 @@ public class SideNavigationViewController: UIViewController, UIGestureRecognizer
...
@@ -843,12 +843,14 @@ public class SideNavigationViewController: UIViewController, UIGestureRecognizer
*/
*/
private
func
toggleStatusBar
(
hide
:
Bool
=
false
)
{
private
func
toggleStatusBar
(
hide
:
Bool
=
false
)
{
if
hideStatusBar
{
if
hideStatusBar
{
// General alignment.
UIView
.
animateWithDuration
(
0.25
,
animations
:
{
[
weak
self
]
in
if
.
iPhone
==
MaterialDevice
.
type
&&
MaterialDevice
.
landscape
{
// General alignment.
UIApplication
.
sharedApplication
()
.
statusBarHidden
=
true
if
.
iPhone
==
MaterialDevice
.
type
&&
MaterialDevice
.
landscape
{
}
else
{
UIApplication
.
sharedApplication
()
.
statusBarHidden
=
true
UIApplication
.
sharedApplication
()
.
statusBarHidden
=
opened
?
true
:
hide
}
else
{
}
UIApplication
.
sharedApplication
()
.
statusBarHidden
=
true
==
self
?
.
opened
?
true
:
hide
}
})
}
}
}
}
...
...
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