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
e50b0c11
Commit
e50b0c11
authored
Feb 16, 2016
by
Daniel Dahan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
finalized default NavigationBarView grid settings
parent
6e3438dc
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
85 additions
and
63 deletions
+85
-63
Examples/Programmatic/SideNavigationViewController/SideNavigationViewController/AppViewController.swift
+34
-16
Examples/Programmatic/SideNavigationViewController/SideNavigationViewController/FeedCollectionViewCell.swift
+10
-14
Sources/FlatButton.swift
+2
-1
Sources/MaterialButton.swift
+5
-7
Sources/MaterialCollectionViewCell.swift
+0
-0
Sources/NavigationBarView.swift
+30
-23
Sources/NavigationViewController.swift
+2
-1
Sources/RaisedButton.swift
+2
-1
No files found.
Examples/Programmatic/SideNavigationViewController/SideNavigationViewController/AppViewController.swift
View file @
e50b0c11
...
...
@@ -93,25 +93,12 @@ class AppViewController: NavigationViewController {
let
image
:
UIImage
?
if
menuView
.
menu
.
opened
{
// Enable the side nav.
sideNavigationViewController
?
.
enabled
=
true
// Position the menuBackdropLayer for the animation when closing.
menuBackdropLayer
.
animate
(
MaterialAnimation
.
scale
(
1
))
hideMenuBackdropLayer
()
menuView
.
menu
.
close
()
image
=
UIImage
(
named
:
"ic_add_white"
)
}
else
{
// Disable the side nav, so users can't swipe while viewing the menu.
sideNavigationViewController
?
.
enabled
=
false
// Position the menuBackdropLayer for the animation when opening.
MaterialAnimation
.
animationDisabled
{
[
unowned
self
]
in
self
.
menuBackdropLayer
.
frame
=
self
.
menuView
.
frame
self
.
menuBackdropLayer
.
shape
=
.
Circle
}
menuBackdropLayer
.
animate
(
MaterialAnimation
.
scale
(
30
))
menuBackdropLayer
.
hidden
=
false
showMenuBackdropLayer
()
menuView
.
menu
.
open
()
{
(
v
:
UIView
)
in
(
v
as?
MaterialButton
)?
.
pulse
()
...
...
@@ -138,7 +125,7 @@ class AppViewController: NavigationViewController {
titleLabel
.
text
=
"Recipes"
titleLabel
.
textAlignment
=
.
Left
titleLabel
.
textColor
=
MaterialColor
.
white
titleLabel
.
font
=
RobotoFont
.
regularWithSize
(
20
)
titleLabel
.
font
=
RobotoFont
.
regularWithSize
(
17
)
// Detail label. Uncomment the code below to use a detail label.
// let detailLabel: UILabel = UILabel()
...
...
@@ -232,6 +219,37 @@ class AppViewController: NavigationViewController {
MaterialLayout
.
size
(
view
,
child
:
menuView
,
width
:
menuViewDiameter
,
height
:
menuViewDiameter
)
MaterialLayout
.
alignFromBottomRight
(
view
,
child
:
menuView
,
bottom
:
menuViewInset
,
right
:
menuViewInset
)
}
/// Displays the menuBackdropLayer.
private
func
showMenuBackdropLayer
()
{
// Disable the side nav, so users can't swipe while viewing the menu.
sideNavigationViewController
?
.
enabled
=
false
// Position the menuBackdropLayer for the animation when opening.
MaterialAnimation
.
animationDisabled
{
[
unowned
self
]
in
self
.
menuBackdropLayer
.
frame
=
self
.
menuView
.
frame
self
.
menuBackdropLayer
.
shape
=
.
Circle
self
.
menuBackdropLayer
.
hidden
=
false
}
menuBackdropLayer
.
animate
(
MaterialAnimation
.
scale
(
30
,
duration
:
0.25
))
}
/// Hides the menuBackdropLayer.
private
func
hideMenuBackdropLayer
()
{
// Enable the side nav.
sideNavigationViewController
?
.
enabled
=
true
// Position the menuBackdropLayer for the animation when closing.
menuBackdropLayer
.
animate
(
MaterialAnimation
.
animationGroup
([
MaterialAnimation
.
scale
(
1
),
MaterialAnimation
.
position
(
menuView
.
center
)
],
duration
:
0.25
))
MaterialAnimation
.
delay
(
0.25
)
{
[
weak
self
]
in
self
?
.
menuBackdropLayer
.
hidden
=
true
}
}
}
/// SideNavigationViewControllerDelegate methods.
...
...
Examples/Programmatic/SideNavigationViewController/SideNavigationViewController/FeedCollectionViewCell.swift
View file @
e50b0c11
...
...
@@ -31,8 +31,7 @@
import
UIKit
import
Material
class
FeedCollectionViewCell
:
UICollectionViewCell
{
private
var
cardView
:
MaterialPulseView
!
class
FeedCollectionViewCell
:
MaterialCollectionViewCell
{
let
titleLabel
:
UILabel
=
UILabel
()
let
detailLabel
:
UILabel
=
UILabel
()
let
imageView
:
MaterialView
=
MaterialView
()
...
...
@@ -51,20 +50,18 @@ class FeedCollectionViewCell : UICollectionViewCell {
fatalError
(
"init(coder:) has not been implemented"
)
}
private
func
prepareView
()
{
cardView
=
MaterialPulseView
()
cardView
.
pulseScale
=
false
cardView
.
pulseColor
=
MaterialColor
.
blue
.
lighten4
addSubview
(
cardView
)
override
func
prepareView
()
{
pulseScale
=
false
pulseColor
=
MaterialColor
.
blue
.
lighten4
var
image
:
UIImage
?
imageView
.
contentsGravity
=
.
ResizeAspectFill
cardView
.
addSubview
(
imageView
)
addSubview
(
imageView
)
let
contentView
:
MaterialView
=
MaterialView
()
contentView
.
backgroundColor
=
MaterialColor
.
clear
cardView
.
addSubview
(
contentView
)
addSubview
(
contentView
)
titleLabel
.
textColor
=
MaterialColor
.
blueGrey
.
darken4
titleLabel
.
backgroundColor
=
MaterialColor
.
clear
...
...
@@ -72,7 +69,7 @@ class FeedCollectionViewCell : UICollectionViewCell {
image
=
UIImage
(
named
:
"ic_more_vert_white"
)?
.
imageWithRenderingMode
(
.
AlwaysTemplate
)
let
moreButton
:
FlatButton
=
FlatButton
()
moreButton
.
content
Inset
Preset
=
.
None
moreButton
.
content
EdgeInsets
Preset
=
.
None
moreButton
.
pulseColor
=
MaterialColor
.
blueGrey
.
darken4
moreButton
.
tintColor
=
MaterialColor
.
blueGrey
.
darken4
moreButton
.
setImage
(
image
,
forState
:
.
Normal
)
...
...
@@ -89,15 +86,14 @@ class FeedCollectionViewCell : UICollectionViewCell {
let
g
:
Int
=
Int
(
bounds
.
width
/
48
)
grid
.
axis
.
columns
=
g
grid
.
views
=
[
cardView
]
imageView
.
grid
.
columns
=
4
contentView
.
grid
.
columns
=
g
-
4
cardView
.
grid
.
contentInset
.
right
=
8
cardView
.
grid
.
axis
.
columns
=
g
cardView
.
grid
.
views
=
[
grid
.
contentInset
.
right
=
8
grid
.
axis
.
columns
=
g
grid
.
views
=
[
imageView
,
contentView
]
...
...
Sources/FlatButton.swift
View file @
e50b0c11
...
...
@@ -43,6 +43,6 @@ public class FlatButton : MaterialButton {
setTitleColor
(
MaterialColor
.
blue
.
accent3
,
forState
:
.
Normal
)
pulseColor
=
MaterialColor
.
blue
.
accent3
cornerRadiusPreset
=
.
Radius1
content
Inset
Preset
=
.
WideRectangle3
content
EdgeInsets
Preset
=
.
WideRectangle3
}
}
\ No newline at end of file
Sources/MaterialButton.swift
View file @
e50b0c11
...
...
@@ -257,12 +257,10 @@ public class MaterialButton : UIButton {
}
}
/**
:name: contentInsets
*/
public
var
contentInsetPreset
:
MaterialEdgeInset
{
/// A preset property for updated contentEdgeInsets.
public
var
contentEdgeInsetsPreset
:
MaterialEdgeInset
{
didSet
{
let
value
:
UIEdgeInsets
=
MaterialEdgeInsetToValue
(
content
Inset
Preset
)
let
value
:
UIEdgeInsets
=
MaterialEdgeInsetToValue
(
content
EdgeInsets
Preset
)
contentEdgeInsets
=
UIEdgeInsetsMake
(
value
.
top
,
value
.
left
,
value
.
bottom
,
value
.
right
)
}
}
...
...
@@ -276,7 +274,7 @@ public class MaterialButton : UIButton {
cornerRadiusPreset
=
.
None
shape
=
.
None
borderWidth
=
0
content
Inset
Preset
=
.
None
content
EdgeInsets
Preset
=
.
None
super
.
init
(
coder
:
aDecoder
)
prepareView
()
}
...
...
@@ -292,7 +290,7 @@ public class MaterialButton : UIButton {
cornerRadiusPreset
=
.
None
shape
=
.
None
borderWidth
=
0
content
Inset
Preset
=
.
None
content
EdgeInsets
Preset
=
.
None
super
.
init
(
frame
:
frame
)
prepareView
()
}
...
...
Sources/MaterialCollectionViewCell.swift
View file @
e50b0c11
This diff is collapsed.
Click to expand it.
Sources/NavigationBarView.swift
View file @
e50b0c11
...
...
@@ -121,32 +121,41 @@ public class NavigationBarView : MaterialView {
// General alignment.
switch
UIDevice
.
currentDevice
()
.
orientation
{
case
.
LandscapeLeft
,
.
LandscapeRight
:
grid
.
contentInset
.
top
=
0
grid
.
contentInset
.
bottom
=
0
titleView
.
grid
.
spacing
=
2
titleView
.
grid
.
contentInset
.
top
=
4
titleView
.
grid
.
contentInset
.
bottom
=
8
grid
.
contentInset
.
top
=
8
// TitleView alignment.
if
let
v
:
UILabel
=
titleLabel
{
if
let
d
:
UILabel
=
detailLabel
{
v
.
grid
.
rows
=
7
d
.
grid
.
rows
=
5
titleView
.
grid
.
spacing
=
4
titleView
.
grid
.
contentInset
.
top
=
-
3
}
else
{
v
.
grid
.
rows
=
12
titleView
.
grid
.
spacing
=
0
titleView
.
grid
.
contentInset
.
top
=
0
}
}
height
=
44
default
:
grid
.
contentInset
.
top
=
20
grid
.
contentInset
.
bottom
=
8
titleView
.
grid
.
spacing
=
0
titleView
.
grid
.
contentInset
.
top
=
0
titleView
.
grid
.
contentInset
.
bottom
=
0
grid
.
contentInset
.
top
=
28
// TitleView alignment.
if
let
v
:
UILabel
=
titleLabel
{
if
let
d
:
UILabel
=
detailLabel
{
v
.
grid
.
rows
=
7
d
.
grid
.
rows
=
5
titleView
.
grid
.
spacing
=
4
titleView
.
grid
.
contentInset
.
top
=
-
3
}
else
{
v
.
grid
.
rows
=
12
titleView
.
grid
.
spacing
=
0
titleView
.
grid
.
contentInset
.
top
=
0
}
}
height
=
64
}
// TitleView alignment.
titleView
.
grid
.
axis
.
rows
=
6
if
let
v
:
UILabel
=
titleLabel
{
titleView
.
grid
.
views
?
.
append
(
v
)
v
.
grid
.
rows
=
nil
==
detailLabel
?
6
:
4
}
if
let
v
:
UILabel
=
detailLabel
{
titleView
.
grid
.
views
?
.
append
(
v
)
v
.
grid
.
rows
=
2
}
// Column adjustment.
width
=
UIScreen
.
mainScreen
()
.
bounds
.
width
grid
.
axis
.
columns
=
Int
(
width
/
48
)
...
...
@@ -241,7 +250,6 @@ public class NavigationBarView : MaterialView {
super
.
prepareView
()
grid
.
spacing
=
8
grid
.
axis
.
inherited
=
false
grid
.
contentInset
.
top
=
20
grid
.
contentInset
.
left
=
8
grid
.
contentInset
.
bottom
=
8
grid
.
contentInset
.
right
=
8
...
...
@@ -252,7 +260,6 @@ public class NavigationBarView : MaterialView {
/// Prepares the titleView.
public
func
prepareTitleView
()
{
titleView
.
backgroundColor
=
nil
titleView
.
grid
.
axis
.
inherited
=
false
titleView
.
grid
.
axis
.
direction
=
.
Vertical
addSubview
(
titleView
)
}
...
...
Sources/NavigationViewController.swift
View file @
e50b0c11
...
...
@@ -156,7 +156,8 @@ public class NavigationViewController: UIViewController {
/// Layout subviews.
private
func
layoutSubviews
()
{
let
size
:
CGSize
=
UIScreen
.
mainScreen
()
.
bounds
.
size
mainViewController
.
view
.
frame
=
CGRectMake
(
0
,
navigationBarView
.
height
,
size
.
width
,
size
.
height
-
navigationBarView
.
height
)
let
h
:
CGFloat
=
UIApplication
.
sharedApplication
()
.
statusBarFrame
.
size
.
height
mainViewController
.
view
.
frame
=
CGRectMake
(
0
,
navigationBarView
.
height
,
size
.
width
,
size
.
height
-
navigationBarView
.
height
-
(
20
>=
h
?
0
:
h
-
20
))
}
}
...
...
Sources/RaisedButton.swift
View file @
e50b0c11
...
...
@@ -44,6 +44,6 @@ public class RaisedButton : MaterialButton {
backgroundColor
=
MaterialColor
.
blue
.
accent3
depth
=
.
Depth1
cornerRadiusPreset
=
.
Radius1
content
Inset
Preset
=
.
WideRectangle3
content
EdgeInsets
Preset
=
.
WideRectangle3
}
}
\ No newline at end of file
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