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