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
4dbaa51d
Commit
4dbaa51d
authored
May 10, 2016
by
Daniel Dahan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
adjusted sizing for NavigationBar
parent
beff5c45
Hide whitespace changes
Inline
Side-by-side
Showing
18 changed files
with
268 additions
and
288 deletions
+268
-288
Examples/Programmatic/App/App.xcodeproj/project.pbxproj
+6
-6
Examples/Programmatic/App/App/ItemViewController.swift
+10
-21
Examples/Programmatic/App/App/RecipesViewController.swift
+4
-10
Examples/Programmatic/CardView/CardView/ViewController.swift
+3
-3
Examples/Programmatic/ImageCardView/ImageCardView/ViewController.swift
+1
-1
Examples/Programmatic/MaterialIcon/MaterialIcon/ViewController.swift
+1
-1
Examples/Programmatic/TableCardView/TableCardView/ViewController.swift
+3
-3
Examples/Storyboards/CardView/CardView/ViewController.swift
+2
-2
Sources/iOS/CardView.swift
+23
-23
Sources/iOS/ControlView.swift
+6
-6
Sources/iOS/ImageCardView.swift
+26
-26
Sources/iOS/MaterialButton.swift
+4
-0
Sources/iOS/NavigationBar.swift
+133
-170
Sources/iOS/NavigationController.swift
+1
-1
Sources/iOS/NavigationItem.swift
+26
-8
Sources/iOS/SearchBar.swift
+9
-3
Sources/iOS/StatusBarView.swift
+1
-1
Sources/iOS/Toolbar.swift
+9
-3
No files found.
Examples/Programmatic/App/App.xcodeproj/project.pbxproj
View file @
4dbaa51d
...
@@ -9,8 +9,8 @@
...
@@ -9,8 +9,8 @@
/* Begin PBXBuildFile section */
/* Begin PBXBuildFile section */
96162C6C1CA71C8700E3A235
/* VideoViewController.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
96162C6B1CA71C8700E3A235
/* VideoViewController.swift */
;
};
96162C6C1CA71C8700E3A235
/* VideoViewController.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
96162C6B1CA71C8700E3A235
/* VideoViewController.swift */
;
};
96162C6E1CA7274E00E3A235
/* PhotoViewController.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
96162C6D1CA7274E00E3A235
/* PhotoViewController.swift */
;
};
96162C6E1CA7274E00E3A235
/* PhotoViewController.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
96162C6D1CA7274E00E3A235
/* PhotoViewController.swift */
;
};
961F19
2F1CE14C3E008927C5
/* Material.framework in Frameworks */
=
{
isa
=
PBXBuildFile
;
fileRef
=
961F192E1CE14C3E
008927C5
/* Material.framework */
;
};
961F19
321CE2579D008927C5
/* Material.framework in Frameworks */
=
{
isa
=
PBXBuildFile
;
fileRef
=
961F19311CE2579D
008927C5
/* Material.framework */
;
};
961F193
01CE14C3E008927C5
/* Material.framework in Embed Frameworks */
=
{
isa
=
PBXBuildFile
;
fileRef
=
961F192E1CE14C3E
008927C5
/* Material.framework */
;
settings
=
{
ATTRIBUTES
=
(
CodeSignOnCopy
,
RemoveHeadersOnCopy
,
);
};
};
961F193
31CE2579D008927C5
/* Material.framework in Embed Frameworks */
=
{
isa
=
PBXBuildFile
;
fileRef
=
961F19311CE2579D
008927C5
/* Material.framework */
;
settings
=
{
ATTRIBUTES
=
(
CodeSignOnCopy
,
RemoveHeadersOnCopy
,
);
};
};
9663F9321C7A744600AF0965
/* AppDelegate.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
9663F9311C7A744600AF0965
/* AppDelegate.swift */
;
};
9663F9321C7A744600AF0965
/* AppDelegate.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
9663F9311C7A744600AF0965
/* AppDelegate.swift */
;
};
9663F9341C7A744600AF0965
/* RecommendationViewController.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
9663F9331C7A744600AF0965
/* RecommendationViewController.swift */
;
};
9663F9341C7A744600AF0965
/* RecommendationViewController.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
9663F9331C7A744600AF0965
/* RecommendationViewController.swift */
;
};
9663F9391C7A744600AF0965
/* Assets.xcassets in Resources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
9663F9381C7A744600AF0965
/* Assets.xcassets */
;
};
9663F9391C7A744600AF0965
/* Assets.xcassets in Resources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
9663F9381C7A744600AF0965
/* Assets.xcassets */
;
};
...
@@ -30,7 +30,7 @@
...
@@ -30,7 +30,7 @@
dstPath
=
""
;
dstPath
=
""
;
dstSubfolderSpec
=
10
;
dstSubfolderSpec
=
10
;
files
=
(
files
=
(
961F193
01CE14C3E
008927C5
/* Material.framework in Embed Frameworks */
,
961F193
31CE2579D
008927C5
/* Material.framework in Embed Frameworks */
,
);
);
name
=
"Embed Frameworks"
;
name
=
"Embed Frameworks"
;
runOnlyForDeploymentPostprocessing
=
0
;
runOnlyForDeploymentPostprocessing
=
0
;
...
@@ -40,7 +40,7 @@
...
@@ -40,7 +40,7 @@
/* Begin PBXFileReference section */
/* Begin PBXFileReference section */
96162C6B1CA71C8700E3A235
/* VideoViewController.swift */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
sourcecode.swift
;
path
=
VideoViewController.swift
;
sourceTree
=
"<group>"
;
};
96162C6B1CA71C8700E3A235
/* VideoViewController.swift */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
sourcecode.swift
;
path
=
VideoViewController.swift
;
sourceTree
=
"<group>"
;
};
96162C6D1CA7274E00E3A235
/* PhotoViewController.swift */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
sourcecode.swift
;
path
=
PhotoViewController.swift
;
sourceTree
=
"<group>"
;
};
96162C6D1CA7274E00E3A235
/* PhotoViewController.swift */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
sourcecode.swift
;
path
=
PhotoViewController.swift
;
sourceTree
=
"<group>"
;
};
961F19
2E1CE14C3E008927C5
/* Material.framework */
=
{
isa
=
PBXFileReference
;
explicitFileType
=
wrapper.framework
;
name
=
Material.framework
;
path
=
"/Users/danieldahan/Library/Developer/Xcode/DerivedData/Material-bshwisidfobstlbomegqyybbrygh
/Build/Products/Debug-iphoneos/Material.framework"
;
sourceTree
=
"<absolute>"
;
};
961F19
311CE2579D008927C5
/* Material.framework */
=
{
isa
=
PBXFileReference
;
explicitFileType
=
wrapper.framework
;
name
=
Material.framework
;
path
=
"/Users/danieldahan/Library/Developer/Xcode/DerivedData/CosmicMind-hgvxkqfizbxkrsfcxbtlafgqkbve
/Build/Products/Debug-iphoneos/Material.framework"
;
sourceTree
=
"<absolute>"
;
};
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
/* RecommendationViewController.swift */
=
{
isa
=
PBXFileReference
;
lastKnownFileType
=
sourcecode.swift
;
path
=
RecommendationViewController.swift
;
sourceTree
=
"<group>"
;
};
9663F9331C7A744600AF0965
/* RecommendationViewController.swift */
=
{
isa
=
PBXFileReference
;
lastKnownFileType
=
sourcecode.swift
;
path
=
RecommendationViewController.swift
;
sourceTree
=
"<group>"
;
};
...
@@ -60,7 +60,7 @@
...
@@ -60,7 +60,7 @@
isa
=
PBXFrameworksBuildPhase
;
isa
=
PBXFrameworksBuildPhase
;
buildActionMask
=
2147483647
;
buildActionMask
=
2147483647
;
files
=
(
files
=
(
961F19
2F1CE14C3E
008927C5
/* Material.framework in Frameworks */
,
961F19
321CE2579D
008927C5
/* Material.framework in Frameworks */
,
);
);
runOnlyForDeploymentPostprocessing
=
0
;
runOnlyForDeploymentPostprocessing
=
0
;
};
};
...
@@ -70,7 +70,7 @@
...
@@ -70,7 +70,7 @@
9663F9251C7A744500AF0965
=
{
9663F9251C7A744500AF0965
=
{
isa
=
PBXGroup
;
isa
=
PBXGroup
;
children
=
(
children
=
(
961F19
2E1CE14C3E
008927C5
/* Material.framework */
,
961F19
311CE2579D
008927C5
/* Material.framework */
,
9663F9301C7A744600AF0965
/* App */
,
9663F9301C7A744600AF0965
/* App */
,
9663F92F1C7A744600AF0965
/* Products */
,
9663F92F1C7A744600AF0965
/* Products */
,
);
);
...
...
Examples/Programmatic/App/App/ItemViewController.swift
View file @
4dbaa51d
...
@@ -66,7 +66,6 @@ class ItemViewController: UIViewController {
...
@@ -66,7 +66,6 @@ class ItemViewController: UIViewController {
override
func
viewDidLoad
()
{
override
func
viewDidLoad
()
{
super
.
viewDidLoad
()
super
.
viewDidLoad
()
prepareView
()
prepareView
()
prepareTitleLabel
()
prepareShareButton
()
prepareShareButton
()
prepareNavigationItem
()
prepareNavigationItem
()
prepareScrollView
()
prepareScrollView
()
...
@@ -101,22 +100,6 @@ class ItemViewController: UIViewController {
...
@@ -101,22 +100,6 @@ class ItemViewController: UIViewController {
automaticallyAdjustsScrollViewInsets
=
false
automaticallyAdjustsScrollViewInsets
=
false
}
}
/// Prepares the titleLabel.
private
func
prepareTitleLabel
()
{
titleLabel
=
UILabel
()
titleLabel
.
text
=
"Item"
titleLabel
.
textAlignment
=
.
Left
titleLabel
.
textColor
=
MaterialColor
.
white
}
/// Prepares the detailLabel.
private
func
prepareDetailLabel
()
{
detailLabel
=
UILabel
()
detailLabel
.
text
=
"January 22, 2016"
detailLabel
.
textAlignment
=
.
Left
detailLabel
.
textColor
=
MaterialColor
.
white
}
/// Prepares the shareButton.
/// Prepares the shareButton.
private
func
prepareShareButton
()
{
private
func
prepareShareButton
()
{
let
image
:
UIImage
?
=
MaterialIcon
.
cm
.
share
let
image
:
UIImage
?
=
MaterialIcon
.
cm
.
share
...
@@ -128,8 +111,14 @@ class ItemViewController: UIViewController {
...
@@ -128,8 +111,14 @@ class ItemViewController: UIViewController {
/// Prepares the navigationItem.
/// Prepares the navigationItem.
private
func
prepareNavigationItem
()
{
private
func
prepareNavigationItem
()
{
navigationItem
.
titleLabel
=
titleLabel
navigationItem
.
title
=
"Item"
navigationItem
.
detailLabel
=
detailLabel
navigationItem
.
titleLabel
.
textAlignment
=
.
Left
navigationItem
.
titleLabel
.
textColor
=
MaterialColor
.
white
navigationItem
.
detail
=
"January 22, 2016"
navigationItem
.
detailLabel
.
textAlignment
=
.
Left
navigationItem
.
detailLabel
.
textColor
=
MaterialColor
.
white
navigationItem
.
rightControls
=
[
shareButton
]
navigationItem
.
rightControls
=
[
shareButton
]
}
}
...
@@ -163,8 +152,8 @@ class ItemViewController: UIViewController {
...
@@ -163,8 +152,8 @@ class ItemViewController: UIViewController {
detailLabel
.
font
=
RobotoFont
.
regular
detailLabel
.
font
=
RobotoFont
.
regular
detailLabel
.
numberOfLines
=
0
detailLabel
.
numberOfLines
=
0
imageCardView
.
detail
View
=
detailLabel
imageCardView
.
content
View
=
detailLabel
imageCardView
.
detail
ViewInset
.
top
=
52
imageCardView
.
content
ViewInset
.
top
=
52
let
image
:
UIImage
?
=
UIImage
(
named
:
data
[
"image"
]
as!
String
)
let
image
:
UIImage
?
=
UIImage
(
named
:
data
[
"image"
]
as!
String
)
imageCardView
.
image
=
image
imageCardView
.
image
=
image
...
...
Examples/Programmatic/App/App/RecipesViewController.swift
View file @
4dbaa51d
...
@@ -54,7 +54,6 @@ class RecipesViewController: UIViewController {
...
@@ -54,7 +54,6 @@ class RecipesViewController: UIViewController {
super
.
viewDidLoad
()
super
.
viewDidLoad
()
prepareView
()
prepareView
()
prepareItems
()
prepareItems
()
prepareTitleLabel
()
prepareMenuButton
()
prepareMenuButton
()
prepareSwitchControl
()
prepareSwitchControl
()
prepareSearchButton
()
prepareSearchButton
()
...
@@ -218,14 +217,6 @@ class RecipesViewController: UIViewController {
...
@@ -218,14 +217,6 @@ class RecipesViewController: UIViewController {
view
.
backgroundColor
=
MaterialColor
.
white
view
.
backgroundColor
=
MaterialColor
.
white
}
}
/// Prepares the titleLabel.
private
func
prepareTitleLabel
()
{
titleLabel
=
UILabel
()
titleLabel
.
text
=
"Recipes"
titleLabel
.
textAlignment
=
.
Left
titleLabel
.
textColor
=
MaterialColor
.
white
}
/// Prepares the menuButton.
/// Prepares the menuButton.
private
func
prepareMenuButton
()
{
private
func
prepareMenuButton
()
{
let
image
:
UIImage
?
=
MaterialIcon
.
cm
.
menu
let
image
:
UIImage
?
=
MaterialIcon
.
cm
.
menu
...
@@ -253,7 +244,10 @@ class RecipesViewController: UIViewController {
...
@@ -253,7 +244,10 @@ class RecipesViewController: UIViewController {
/// Prepares the navigationItem.
/// Prepares the navigationItem.
private
func
prepareNavigationItem
()
{
private
func
prepareNavigationItem
()
{
navigationItem
.
titleLabel
=
titleLabel
navigationItem
.
title
=
"Recipes"
navigationItem
.
titleLabel
.
textAlignment
=
.
Left
navigationItem
.
titleLabel
.
textColor
=
MaterialColor
.
white
navigationItem
.
leftControls
=
[
menuButton
]
navigationItem
.
leftControls
=
[
menuButton
]
navigationItem
.
rightControls
=
[
switchControl
,
searchButton
]
navigationItem
.
rightControls
=
[
switchControl
,
searchButton
]
}
}
...
...
Examples/Programmatic/CardView/CardView/ViewController.swift
View file @
4dbaa51d
...
@@ -61,7 +61,7 @@ class ViewController: UIViewController {
...
@@ -61,7 +61,7 @@ class ViewController: UIViewController {
let
detailLabel
:
UILabel
=
UILabel
()
let
detailLabel
:
UILabel
=
UILabel
()
detailLabel
.
text
=
"It’s been a while, have you read any new books lately?"
detailLabel
.
text
=
"It’s been a while, have you read any new books lately?"
detailLabel
.
numberOfLines
=
0
detailLabel
.
numberOfLines
=
0
cardView
.
detail
View
=
detailLabel
cardView
.
content
View
=
detailLabel
// Yes button.
// Yes button.
let
btn1
:
FlatButton
=
FlatButton
()
let
btn1
:
FlatButton
=
FlatButton
()
...
@@ -106,7 +106,7 @@ class ViewController: UIViewController {
...
@@ -106,7 +106,7 @@ class ViewController: UIViewController {
detailLabel
.
text
=
"Beautiful Material Design"
detailLabel
.
text
=
"Beautiful Material Design"
detailLabel
.
textColor
=
MaterialColor
.
white
detailLabel
.
textColor
=
MaterialColor
.
white
detailLabel
.
numberOfLines
=
0
detailLabel
.
numberOfLines
=
0
cardView
.
detail
View
=
detailLabel
cardView
.
content
View
=
detailLabel
// Share button.
// Share button.
let
img1
:
UIImage
?
=
MaterialIcon
.
cm
.
share
let
img1
:
UIImage
?
=
MaterialIcon
.
cm
.
share
...
@@ -147,7 +147,7 @@ class ViewController: UIViewController {
...
@@ -147,7 +147,7 @@ class ViewController: UIViewController {
detailLabel
.
text
=
"Data-Driven Framework"
detailLabel
.
text
=
"Data-Driven Framework"
detailLabel
.
textColor
=
MaterialColor
.
white
detailLabel
.
textColor
=
MaterialColor
.
white
detailLabel
.
numberOfLines
=
0
detailLabel
.
numberOfLines
=
0
cardView
.
detail
View
=
detailLabel
cardView
.
content
View
=
detailLabel
// Share button.
// Share button.
let
img1
:
UIImage
?
=
MaterialIcon
.
cm
.
share
let
img1
:
UIImage
?
=
MaterialIcon
.
cm
.
share
...
...
Examples/Programmatic/ImageCardView/ImageCardView/ViewController.swift
View file @
4dbaa51d
...
@@ -65,7 +65,7 @@ class ViewController: UIViewController {
...
@@ -65,7 +65,7 @@ class ViewController: UIViewController {
let
detailLabel
:
UILabel
=
UILabel
()
let
detailLabel
:
UILabel
=
UILabel
()
detailLabel
.
text
=
"It’s been a while, have you read any new books lately?"
detailLabel
.
text
=
"It’s been a while, have you read any new books lately?"
detailLabel
.
numberOfLines
=
0
detailLabel
.
numberOfLines
=
0
imageCardView
.
detail
View
=
detailLabel
imageCardView
.
content
View
=
detailLabel
// Yes button.
// Yes button.
let
btn1
:
FlatButton
=
FlatButton
()
let
btn1
:
FlatButton
=
FlatButton
()
...
...
Examples/Programmatic/MaterialIcon/MaterialIcon/ViewController.swift
View file @
4dbaa51d
...
@@ -29,7 +29,7 @@
...
@@ -29,7 +29,7 @@
*/
*/
/*
/*
The following is an example of setting a UITableView as the
detail
View for a
The following is an example of setting a UITableView as the
content
View for a
CardView.
CardView.
*/
*/
...
...
Examples/Programmatic/TableCardView/TableCardView/ViewController.swift
View file @
4dbaa51d
...
@@ -29,7 +29,7 @@
...
@@ -29,7 +29,7 @@
*/
*/
/*
/*
The following is an example of setting a UITableView as the
detail
View for a
The following is an example of setting a UITableView as the
content
View for a
CardView.
CardView.
*/
*/
...
@@ -91,7 +91,7 @@ class ViewController: UIViewController {
...
@@ -91,7 +91,7 @@ class ViewController: UIViewController {
cardView
.
contentInsetPreset
=
.
None
cardView
.
contentInsetPreset
=
.
None
cardView
.
leftButtonsInsetPreset
=
.
Square2
cardView
.
leftButtonsInsetPreset
=
.
Square2
cardView
.
rightButtonsInsetPreset
=
.
Square2
cardView
.
rightButtonsInsetPreset
=
.
Square2
cardView
.
detail
ViewInsetPreset
=
.
None
cardView
.
content
ViewInsetPreset
=
.
None
let
titleLabel
:
UILabel
=
UILabel
()
let
titleLabel
:
UILabel
=
UILabel
()
titleLabel
.
font
=
RobotoFont
.
mediumWithSize
(
20
)
titleLabel
.
font
=
RobotoFont
.
mediumWithSize
(
20
)
...
@@ -113,7 +113,7 @@ class ViewController: UIViewController {
...
@@ -113,7 +113,7 @@ class ViewController: UIViewController {
// Use MaterialLayout to easily align the tableView.
// Use MaterialLayout to easily align the tableView.
cardView
.
titleLabel
=
titleLabel
cardView
.
titleLabel
=
titleLabel
cardView
.
detail
View
=
tableView
cardView
.
content
View
=
tableView
cardView
.
leftButtons
=
[
closeButton
]
cardView
.
leftButtons
=
[
closeButton
]
cardView
.
rightButtons
=
[
settingButton
]
cardView
.
rightButtons
=
[
settingButton
]
...
...
Examples/Storyboards/CardView/CardView/ViewController.swift
View file @
4dbaa51d
...
@@ -60,7 +60,7 @@ class ViewController: UIViewController {
...
@@ -60,7 +60,7 @@ class ViewController: UIViewController {
let
detailLabel
:
UILabel
=
UILabel
()
let
detailLabel
:
UILabel
=
UILabel
()
detailLabel
.
text
=
"It’s been a while, have you read any new books lately?"
detailLabel
.
text
=
"It’s been a while, have you read any new books lately?"
detailLabel
.
numberOfLines
=
0
detailLabel
.
numberOfLines
=
0
topCardView
.
detail
View
=
detailLabel
topCardView
.
content
View
=
detailLabel
// Yes button.
// Yes button.
let
btn1
:
FlatButton
=
FlatButton
()
let
btn1
:
FlatButton
=
FlatButton
()
...
@@ -91,7 +91,7 @@ class ViewController: UIViewController {
...
@@ -91,7 +91,7 @@ class ViewController: UIViewController {
let
detailLabel
:
UILabel
=
UILabel
()
let
detailLabel
:
UILabel
=
UILabel
()
detailLabel
.
text
=
"It’s been a while, have you read any new books lately?"
detailLabel
.
text
=
"It’s been a while, have you read any new books lately?"
detailLabel
.
numberOfLines
=
0
detailLabel
.
numberOfLines
=
0
bottomCardView
.
detail
View
=
detailLabel
bottomCardView
.
content
View
=
detailLabel
// Yes button.
// Yes button.
let
btn1
:
FlatButton
=
FlatButton
()
let
btn1
:
FlatButton
=
FlatButton
()
...
...
Sources/iOS/CardView.swift
View file @
4dbaa51d
...
@@ -119,29 +119,29 @@ public class CardView : MaterialPulseView {
...
@@ -119,29 +119,29 @@ public class CardView : MaterialPulseView {
}
}
/**
/**
:name:
detail
ViewInsets
:name:
content
ViewInsets
*/
*/
public
var
detail
ViewInsetPreset
:
MaterialEdgeInset
=
.
Square2
{
public
var
content
ViewInsetPreset
:
MaterialEdgeInset
=
.
Square2
{
didSet
{
didSet
{
detailViewInset
=
MaterialEdgeInsetToValue
(
detail
ViewInsetPreset
)
contentViewInset
=
MaterialEdgeInsetToValue
(
content
ViewInsetPreset
)
}
}
}
}
/**
/**
:name:
detail
ViewInset
:name:
content
ViewInset
*/
*/
@IBInspectable
public
var
detail
ViewInset
:
UIEdgeInsets
=
MaterialEdgeInsetToValue
(
.
Square2
)
{
@IBInspectable
public
var
content
ViewInset
:
UIEdgeInsets
=
MaterialEdgeInsetToValue
(
.
Square2
)
{
didSet
{
didSet
{
reloadView
()
reloadView
()
}
}
}
}
/**
/**
:name:
detail
View
:name:
content
View
*/
*/
@IBInspectable
public
var
detail
View
:
UIView
?
{
@IBInspectable
public
var
content
View
:
UIView
?
{
didSet
{
didSet
{
detail
View
?
.
translatesAutoresizingMaskIntoConstraints
=
false
content
View
?
.
translatesAutoresizingMaskIntoConstraints
=
false
reloadView
()
reloadView
()
}
}
}
}
...
@@ -234,9 +234,9 @@ public class CardView : MaterialPulseView {
...
@@ -234,9 +234,9 @@ public class CardView : MaterialPulseView {
/**
/**
:name: init
:name: init
*/
*/
public
convenience
init
?(
image
:
UIImage
?
=
nil
,
titleLabel
:
UILabel
?
=
nil
,
detail
View
:
UIView
?
=
nil
,
leftButtons
:
Array
<
UIButton
>
?
=
nil
,
rightButtons
:
Array
<
UIButton
>
?
=
nil
)
{
public
convenience
init
?(
image
:
UIImage
?
=
nil
,
titleLabel
:
UILabel
?
=
nil
,
content
View
:
UIView
?
=
nil
,
leftButtons
:
Array
<
UIButton
>
?
=
nil
,
rightButtons
:
Array
<
UIButton
>
?
=
nil
)
{
self
.
init
(
frame
:
CGRectZero
)
self
.
init
(
frame
:
CGRectZero
)
prepareProperties
(
image
,
titleLabel
:
titleLabel
,
detailView
:
detail
View
,
leftButtons
:
leftButtons
,
rightButtons
:
rightButtons
)
prepareProperties
(
image
,
titleLabel
:
titleLabel
,
contentView
:
content
View
,
leftButtons
:
leftButtons
,
rightButtons
:
rightButtons
)
}
}
/**
/**
...
@@ -279,9 +279,9 @@ public class CardView : MaterialPulseView {
...
@@ -279,9 +279,9 @@ public class CardView : MaterialPulseView {
if
nil
!=
titleLabel
{
if
nil
!=
titleLabel
{
verticalFormat
+=
"-(insetTop)"
verticalFormat
+=
"-(insetTop)"
metrics
[
"insetTop"
]
=
contentInset
.
top
+
titleLabelInset
.
top
metrics
[
"insetTop"
]
=
contentInset
.
top
+
titleLabelInset
.
top
}
else
if
nil
!=
detail
View
{
}
else
if
nil
!=
content
View
{
verticalFormat
+=
"-(insetTop)"
verticalFormat
+=
"-(insetTop)"
metrics
[
"insetTop"
]
=
contentInset
.
top
+
detail
ViewInset
.
top
metrics
[
"insetTop"
]
=
contentInset
.
top
+
content
ViewInset
.
top
}
}
// title
// title
...
@@ -295,20 +295,20 @@ public class CardView : MaterialPulseView {
...
@@ -295,20 +295,20 @@ public class CardView : MaterialPulseView {
}
}
// detail
// detail
if
let
v
:
UIView
=
detail
View
{
if
let
v
:
UIView
=
content
View
{
addSubview
(
v
)
addSubview
(
v
)
if
nil
==
titleLabel
{
if
nil
==
titleLabel
{
metrics
[
"insetTop"
]
=
(
metrics
[
"insetTop"
]
as!
CGFloat
)
+
detail
ViewInset
.
top
metrics
[
"insetTop"
]
=
(
metrics
[
"insetTop"
]
as!
CGFloat
)
+
content
ViewInset
.
top
}
else
{
}
else
{
verticalFormat
+=
"-(insetB)"
verticalFormat
+=
"-(insetB)"
metrics
[
"insetB"
]
=
titleLabelInset
.
bottom
+
detail
ViewInset
.
top
metrics
[
"insetB"
]
=
titleLabelInset
.
bottom
+
content
ViewInset
.
top
}
}
verticalFormat
+=
"-[
detail
View]"
verticalFormat
+=
"-[
content
View]"
views
[
"
detail
View"
]
=
v
views
[
"
content
View"
]
=
v
MaterialLayout
.
alignToParentHorizontally
(
self
,
child
:
v
,
left
:
contentInset
.
left
+
detailViewInset
.
left
,
right
:
contentInset
.
right
+
detail
ViewInset
.
right
)
MaterialLayout
.
alignToParentHorizontally
(
self
,
child
:
v
,
left
:
contentInset
.
left
+
contentViewInset
.
left
,
right
:
contentInset
.
right
+
content
ViewInset
.
right
)
}
}
// leftButtons
// leftButtons
...
@@ -382,11 +382,11 @@ public class CardView : MaterialPulseView {
...
@@ -382,11 +382,11 @@ public class CardView : MaterialPulseView {
metrics
[
"insetBottom"
]
=
contentInset
.
bottom
+
rightButtonsInset
.
bottom
metrics
[
"insetBottom"
]
=
contentInset
.
bottom
+
rightButtonsInset
.
bottom
}
}
if
nil
!=
detail
View
{
if
nil
!=
content
View
{
if
nil
==
metrics
[
"insetC"
]
{
if
nil
==
metrics
[
"insetC"
]
{
metrics
[
"insetBottom"
]
=
contentInset
.
bottom
+
detail
ViewInset
.
bottom
+
(
divider
?
dividerInset
.
top
+
dividerInset
.
bottom
:
0
)
metrics
[
"insetBottom"
]
=
contentInset
.
bottom
+
content
ViewInset
.
bottom
+
(
divider
?
dividerInset
.
top
+
dividerInset
.
bottom
:
0
)
}
else
{
}
else
{
metrics
[
"insetC"
]
=
(
metrics
[
"insetC"
]
as!
CGFloat
)
+
detail
ViewInset
.
bottom
+
(
divider
?
dividerInset
.
top
+
dividerInset
.
bottom
:
0
)
metrics
[
"insetC"
]
=
(
metrics
[
"insetC"
]
as!
CGFloat
)
+
content
ViewInset
.
bottom
+
(
divider
?
dividerInset
.
top
+
dividerInset
.
bottom
:
0
)
}
}
}
else
if
nil
!=
titleLabel
{
}
else
if
nil
!=
titleLabel
{
if
nil
==
metrics
[
"insetC"
]
{
if
nil
==
metrics
[
"insetC"
]
{
...
@@ -430,10 +430,10 @@ public class CardView : MaterialPulseView {
...
@@ -430,10 +430,10 @@ public class CardView : MaterialPulseView {
/**
/**
:name: prepareProperties
:name: prepareProperties
*/
*/
internal
func
prepareProperties
(
image
:
UIImage
?,
titleLabel
:
UILabel
?,
detail
View
:
UIView
?,
leftButtons
:
Array
<
UIButton
>
?,
rightButtons
:
Array
<
UIButton
>
?)
{
internal
func
prepareProperties
(
image
:
UIImage
?,
titleLabel
:
UILabel
?,
content
View
:
UIView
?,
leftButtons
:
Array
<
UIButton
>
?,
rightButtons
:
Array
<
UIButton
>
?)
{
self
.
image
=
image
self
.
image
=
image
self
.
titleLabel
=
titleLabel
self
.
titleLabel
=
titleLabel
self
.
detailView
=
detail
View
self
.
contentView
=
content
View
self
.
leftButtons
=
leftButtons
self
.
leftButtons
=
leftButtons
self
.
rightButtons
=
rightButtons
self
.
rightButtons
=
rightButtons
}
}
...
...
Sources/iOS/ControlView.swift
View file @
4dbaa51d
...
@@ -196,12 +196,6 @@ public class ControlView : MaterialView {
...
@@ -196,12 +196,6 @@ public class ControlView : MaterialView {
prepareContentView
()
prepareContentView
()
}
}
/// Prepares the contentView.
public
func
prepareContentView
()
{
contentView
.
backgroundColor
=
nil
addSubview
(
contentView
)
}
/**
/**
Used to trigger property changes that initializers avoid.
Used to trigger property changes that initializers avoid.
- Parameter leftControls: An Array of UIControls that go on the left side.
- Parameter leftControls: An Array of UIControls that go on the left side.
...
@@ -211,4 +205,10 @@ public class ControlView : MaterialView {
...
@@ -211,4 +205,10 @@ public class ControlView : MaterialView {
self
.
leftControls
=
leftControls
self
.
leftControls
=
leftControls
self
.
rightControls
=
rightControls
self
.
rightControls
=
rightControls
}
}
/// Prepares the contentView.
private
func
prepareContentView
()
{
contentView
.
backgroundColor
=
nil
addSubview
(
contentView
)
}
}
}
Sources/iOS/ImageCardView.swift
View file @
4dbaa51d
...
@@ -212,29 +212,29 @@ public class ImageCardView : MaterialPulseView {
...
@@ -212,29 +212,29 @@ public class ImageCardView : MaterialPulseView {
}
}
/**
/**
:name:
detail
ViewInsets
:name:
content
ViewInsets
*/
*/
public
var
detail
ViewInsetPreset
:
MaterialEdgeInset
=
.
Square2
{
public
var
content
ViewInsetPreset
:
MaterialEdgeInset
=
.
Square2
{
didSet
{
didSet
{
detailViewInset
=
MaterialEdgeInsetToValue
(
detail
ViewInsetPreset
)
contentViewInset
=
MaterialEdgeInsetToValue
(
content
ViewInsetPreset
)
}
}
}
}
/**
/**
:name:
detail
ViewInset
:name:
content
ViewInset
*/
*/
@IBInspectable
public
var
detail
ViewInset
:
UIEdgeInsets
=
MaterialEdgeInsetToValue
(
.
Square2
)
{
@IBInspectable
public
var
content
ViewInset
:
UIEdgeInsets
=
MaterialEdgeInsetToValue
(
.
Square2
)
{
didSet
{
didSet
{
reloadView
()
reloadView
()
}
}
}
}
/**
/**
:name:
detail
View
:name:
content
View
*/
*/
@IBInspectable
public
var
detail
View
:
UIView
?
{
@IBInspectable
public
var
content
View
:
UIView
?
{
didSet
{
didSet
{
detail
View
?
.
translatesAutoresizingMaskIntoConstraints
=
false
content
View
?
.
translatesAutoresizingMaskIntoConstraints
=
false
reloadView
()
reloadView
()
}
}
}
}
...
@@ -327,9 +327,9 @@ public class ImageCardView : MaterialPulseView {
...
@@ -327,9 +327,9 @@ public class ImageCardView : MaterialPulseView {
/**
/**
:name: init
:name: init
*/
*/
public
convenience
init
?(
image
:
UIImage
?
=
nil
,
titleLabel
:
UILabel
?
=
nil
,
detail
View
:
UIView
?
=
nil
,
leftButtons
:
Array
<
UIButton
>
?
=
nil
,
rightButtons
:
Array
<
UIButton
>
?
=
nil
)
{
public
convenience
init
?(
image
:
UIImage
?
=
nil
,
titleLabel
:
UILabel
?
=
nil
,
content
View
:
UIView
?
=
nil
,
leftButtons
:
Array
<
UIButton
>
?
=
nil
,
rightButtons
:
Array
<
UIButton
>
?
=
nil
)
{
self
.
init
(
frame
:
CGRectZero
)
self
.
init
(
frame
:
CGRectZero
)
prepareProperties
(
image
,
titleLabel
:
titleLabel
,
detailView
:
detail
View
,
leftButtons
:
leftButtons
,
rightButtons
:
rightButtons
)
prepareProperties
(
image
,
titleLabel
:
titleLabel
,
contentView
:
content
View
,
leftButtons
:
leftButtons
,
rightButtons
:
rightButtons
)
}
}
/**
/**
...
@@ -379,9 +379,9 @@ public class ImageCardView : MaterialPulseView {
...
@@ -379,9 +379,9 @@ public class ImageCardView : MaterialPulseView {
}
else
if
nil
!=
titleLabel
{
}
else
if
nil
!=
titleLabel
{
verticalFormat
+=
"-(insetTop)"
verticalFormat
+=
"-(insetTop)"
metrics
[
"insetTop"
]
=
contentInset
.
top
+
titleLabelInset
.
top
metrics
[
"insetTop"
]
=
contentInset
.
top
+
titleLabelInset
.
top
}
else
if
nil
!=
detail
View
{
}
else
if
nil
!=
content
View
{
verticalFormat
+=
"-(insetTop)"
verticalFormat
+=
"-(insetTop)"
metrics
[
"insetTop"
]
=
contentInset
.
top
+
detail
ViewInset
.
top
metrics
[
"insetTop"
]
=
contentInset
.
top
+
content
ViewInset
.
top
}
}
// title
// title
...
@@ -398,20 +398,20 @@ public class ImageCardView : MaterialPulseView {
...
@@ -398,20 +398,20 @@ public class ImageCardView : MaterialPulseView {
}
}
// detail
// detail
if
let
v
:
UIView
=
detail
View
{
if
let
v
:
UIView
=
content
View
{
addSubview
(
v
)
addSubview
(
v
)
if
nil
==
imageLayer
?
.
contents
&&
nil
!=
titleLabel
{
if
nil
==
imageLayer
?
.
contents
&&
nil
!=
titleLabel
{
verticalFormat
+=
"-(insetB)"
verticalFormat
+=
"-(insetB)"
metrics
[
"insetB"
]
=
titleLabelInset
.
bottom
+
detail
ViewInset
.
top
metrics
[
"insetB"
]
=
titleLabelInset
.
bottom
+
content
ViewInset
.
top
}
else
{
}
else
{
metrics
[
"insetTop"
]
=
(
metrics
[
"insetTop"
]
as!
CGFloat
)
+
detail
ViewInset
.
top
metrics
[
"insetTop"
]
=
(
metrics
[
"insetTop"
]
as!
CGFloat
)
+
content
ViewInset
.
top
}
}
verticalFormat
+=
"-[
detail
View]"
verticalFormat
+=
"-[
content
View]"
views
[
"
detail
View"
]
=
v
views
[
"
content
View"
]
=
v
MaterialLayout
.
alignToParentHorizontally
(
self
,
child
:
v
,
left
:
contentInset
.
left
+
detailViewInset
.
left
,
right
:
contentInset
.
right
+
detail
ViewInset
.
right
)
MaterialLayout
.
alignToParentHorizontally
(
self
,
child
:
v
,
left
:
contentInset
.
left
+
contentViewInset
.
left
,
right
:
contentInset
.
right
+
content
ViewInset
.
right
)
}
}
// leftButtons
// leftButtons
...
@@ -486,11 +486,11 @@ public class ImageCardView : MaterialPulseView {
...
@@ -486,11 +486,11 @@ public class ImageCardView : MaterialPulseView {
metrics
[
"insetBottom"
]
=
contentInset
.
bottom
+
rightButtonsInset
.
bottom
metrics
[
"insetBottom"
]
=
contentInset
.
bottom
+
rightButtonsInset
.
bottom
}
}
if
nil
!=
detail
View
{
if
nil
!=
content
View
{
if
nil
==
metrics
[
"insetC"
]
{
if
nil
==
metrics
[
"insetC"
]
{
metrics
[
"insetBottom"
]
=
contentInset
.
bottom
+
detail
ViewInset
.
bottom
+
(
divider
?
dividerInset
.
top
+
dividerInset
.
bottom
:
0
)
metrics
[
"insetBottom"
]
=
contentInset
.
bottom
+
content
ViewInset
.
bottom
+
(
divider
?
dividerInset
.
top
+
dividerInset
.
bottom
:
0
)
}
else
{
}
else
{
metrics
[
"insetC"
]
=
(
metrics
[
"insetC"
]
as!
CGFloat
)
+
detail
ViewInset
.
bottom
+
(
divider
?
dividerInset
.
top
+
dividerInset
.
bottom
:
0
)
metrics
[
"insetC"
]
=
(
metrics
[
"insetC"
]
as!
CGFloat
)
+
content
ViewInset
.
bottom
+
(
divider
?
dividerInset
.
top
+
dividerInset
.
bottom
:
0
)
}
}
}
else
if
nil
!=
titleLabel
{
}
else
if
nil
!=
titleLabel
{
if
nil
==
metrics
[
"insetC"
]
{
if
nil
==
metrics
[
"insetC"
]
{
...
@@ -501,7 +501,7 @@ public class ImageCardView : MaterialPulseView {
...
@@ -501,7 +501,7 @@ public class ImageCardView : MaterialPulseView {
}
else
if
nil
!=
metrics
[
"insetC"
]
{
}
else
if
nil
!=
metrics
[
"insetC"
]
{
metrics
[
"insetC"
]
=
(
metrics
[
"insetC"
]
as!
CGFloat
)
+
contentInset
.
top
+
(
divider
?
dividerInset
.
top
+
dividerInset
.
bottom
:
0
)
metrics
[
"insetC"
]
=
(
metrics
[
"insetC"
]
as!
CGFloat
)
+
contentInset
.
top
+
(
divider
?
dividerInset
.
top
+
dividerInset
.
bottom
:
0
)
}
}
}
else
if
nil
!=
detail
View
{
}
else
if
nil
!=
content
View
{
if
0
<
leftButtons
?
.
count
{
if
0
<
leftButtons
?
.
count
{
verticalFormat
+=
"-(insetC)-[button]"
verticalFormat
+=
"-(insetC)-[button]"
views
[
"button"
]
=
leftButtons
!
[
0
]
views
[
"button"
]
=
leftButtons
!
[
0
]
...
@@ -515,9 +515,9 @@ public class ImageCardView : MaterialPulseView {
...
@@ -515,9 +515,9 @@ public class ImageCardView : MaterialPulseView {
}
}
if
nil
==
metrics
[
"insetC"
]
{
if
nil
==
metrics
[
"insetC"
]
{
metrics
[
"insetBottom"
]
=
contentInset
.
bottom
+
detail
ViewInset
.
bottom
+
(
divider
?
dividerInset
.
top
+
dividerInset
.
bottom
:
0
)
metrics
[
"insetBottom"
]
=
contentInset
.
bottom
+
content
ViewInset
.
bottom
+
(
divider
?
dividerInset
.
top
+
dividerInset
.
bottom
:
0
)
}
else
{
}
else
{
metrics
[
"insetC"
]
=
(
metrics
[
"insetC"
]
as!
CGFloat
)
+
detail
ViewInset
.
bottom
+
(
divider
?
dividerInset
.
top
+
dividerInset
.
bottom
:
0
)
metrics
[
"insetC"
]
=
(
metrics
[
"insetC"
]
as!
CGFloat
)
+
content
ViewInset
.
bottom
+
(
divider
?
dividerInset
.
top
+
dividerInset
.
bottom
:
0
)
}
}
}
else
{
}
else
{
if
0
<
leftButtons
?
.
count
{
if
0
<
leftButtons
?
.
count
{
...
@@ -583,10 +583,10 @@ public class ImageCardView : MaterialPulseView {
...
@@ -583,10 +583,10 @@ public class ImageCardView : MaterialPulseView {
/**
/**
:name: prepareProperties
:name: prepareProperties
*/
*/
internal
func
prepareProperties
(
image
:
UIImage
?,
titleLabel
:
UILabel
?,
detail
View
:
UIView
?,
leftButtons
:
Array
<
UIButton
>
?,
rightButtons
:
Array
<
UIButton
>
?)
{
internal
func
prepareProperties
(
image
:
UIImage
?,
titleLabel
:
UILabel
?,
content
View
:
UIView
?,
leftButtons
:
Array
<
UIButton
>
?,
rightButtons
:
Array
<
UIButton
>
?)
{
self
.
image
=
image
self
.
image
=
image
self
.
titleLabel
=
titleLabel
self
.
titleLabel
=
titleLabel
self
.
detailView
=
detail
View
self
.
contentView
=
content
View
self
.
leftButtons
=
leftButtons
self
.
leftButtons
=
leftButtons
self
.
rightButtons
=
rightButtons
self
.
rightButtons
=
rightButtons
}
}
...
...
Sources/iOS/MaterialButton.swift
View file @
4dbaa51d
...
@@ -349,6 +349,10 @@ public class MaterialButton : UIButton {
...
@@ -349,6 +349,10 @@ public class MaterialButton : UIButton {
}
}
}
}
public
override
func
alignmentRectInsets
()
->
UIEdgeInsets
{
return
UIEdgeInsetsZero
}
/**
/**
A method that accepts CAAnimation objects and executes them on the
A method that accepts CAAnimation objects and executes them on the
view's backing layer.
view's backing layer.
...
...
Sources/iOS/NavigationBar.swift
View file @
4dbaa51d
...
@@ -44,17 +44,38 @@ public extension UINavigationBar {
...
@@ -44,17 +44,38 @@ public extension UINavigationBar {
@IBDesignable
@IBDesignable
public
class
NavigationBar
:
UINavigationBar
{
public
class
NavigationBar
:
UINavigationBar
{
/// The current layout.
/// Will render the view.
private
var
isLandscape
:
Bool
=
false
public
var
willRenderView
:
Bool
{
return
0
<
width
}
/// the spacer inset value.
/// A preset wrapper around contentInset.
private
var
spacerInset
:
CGFloat
=
0
public
var
contentInsetPreset
:
MaterialEdgeInset
=
.
None
{
didSet
{
contentInset
=
MaterialEdgeInsetToValue
(
contentInsetPreset
)
}
}
/// Left spacer moves the items to the left edge of the NavigationBar.
/// A wrapper around grid.contentInset.
private
var
leftSpacer
:
UIBarButtonItem
=
UIBarButtonItem
(
barButtonSystemItem
:
.
FixedSpace
,
target
:
nil
,
action
:
nil
)
@IBInspectable
public
var
contentInset
:
UIEdgeInsets
=
UIEdgeInsetsZero
{
didSet
{
layoutSubviews
()
}
}
/// Right spacer moves the items to the right edge of the NavigationBar.
/// A preset wrapper around spacing.
private
var
rightSpacer
:
UIBarButtonItem
=
UIBarButtonItem
(
barButtonSystemItem
:
.
FixedSpace
,
target
:
nil
,
action
:
nil
)
public
var
spacingPreset
:
MaterialSpacing
=
.
None
{
didSet
{
spacing
=
MaterialSpacingToValue
(
spacingPreset
)
}
}
/// A wrapper around grid.spacing.
@IBInspectable
public
var
spacing
:
CGFloat
=
0
{
didSet
{
layoutSubviews
()
}
}
/// Reference to the backButton.
/// Reference to the backButton.
public
private(set)
lazy
var
backButton
:
IconButton
=
IconButton
()
public
private(set)
lazy
var
backButton
:
IconButton
=
IconButton
()
...
@@ -76,20 +97,6 @@ public class NavigationBar : UINavigationBar {
...
@@ -76,20 +97,6 @@ public class NavigationBar : UINavigationBar {
}
}
}
}
/// A preset for contentInset.
public
var
contentInsetPreset
:
MaterialEdgeInset
=
.
None
{
didSet
{
contentInset
=
MaterialEdgeInsetToValue
(
contentInsetPreset
)
}
}
/// A UIEdgeInsets value for insetting the content.
public
var
contentInset
:
UIEdgeInsets
=
MaterialEdgeInsetToValue
(
.
None
)
{
didSet
{
layoutSubviews
()
}
}
/**
/**
This property is the same as clipsToBounds. It crops any of the view's
This property is the same as clipsToBounds. It crops any of the view's
contents from bleeding past the view's frame. If an image is set using
contents from bleeding past the view's frame. If an image is set using
...
@@ -265,31 +272,22 @@ public class NavigationBar : UINavigationBar {
...
@@ -265,31 +272,22 @@ public class NavigationBar : UINavigationBar {
self
.
init
(
frame
:
CGRectZero
)
self
.
init
(
frame
:
CGRectZero
)
}
}
public
override
func
intrinsicContentSize
()
->
CGSize
{
return
CGSizeMake
(
MaterialDevice
.
width
,
44
)
}
public
override
func
sizeThatFits
(
size
:
CGSize
)
->
CGSize
{
return
intrinsicContentSize
()
}
public
override
func
layoutSubviews
()
{
public
override
func
layoutSubviews
()
{
super
.
layoutSubviews
()
super
.
layoutSubviews
()
if
!
isLandscape
&&
MaterialDevice
.
isLandscape
{
isLandscape
=
true
spacerInset
=
0
}
else
if
isLandscape
&&
MaterialDevice
.
isPortrait
{
isLandscape
=
false
spacerInset
=
0
}
if
let
v
:
UINavigationItem
=
topItem
{
if
let
v
:
UINavigationItem
=
topItem
{
if
0
==
spacerInset
{
layoutNavigationItem
(
v
)
layoutNavigationItem
(
v
)
}
else
{
sizeNavigationItem
(
v
)
}
}
}
if
let
v
:
UINavigationItem
=
backItem
{
if
let
v
:
UINavigationItem
=
backItem
{
if
0
==
spacerInset
{
layoutNavigationItem
(
v
)
layoutNavigationItem
(
v
)
}
else
{
sizeNavigationItem
(
v
)
}
}
}
}
}
...
@@ -303,133 +301,103 @@ public class NavigationBar : UINavigationBar {
...
@@ -303,133 +301,103 @@ public class NavigationBar : UINavigationBar {
- Parameter item: A UINavigationItem to layout.
- Parameter item: A UINavigationItem to layout.
*/
*/
internal
func
layoutNavigationItem
(
item
:
UINavigationItem
)
{
internal
func
layoutNavigationItem
(
item
:
UINavigationItem
)
{
prepareItem
(
item
)
if
willRenderView
{
// leftControls
if
let
v
:
Array
<
UIControl
>
=
item
.
leftControls
{
if
0
<
v
.
count
{
var
n
:
Array
<
UIBarButtonItem
>
=
Array
<
UIBarButtonItem
>
()
for
c
in
v
{
n
.
append
(
UIBarButtonItem
(
customView
:
c
))
}
n
.
append
(
leftSpacer
)
item
.
leftBarButtonItems
=
n
.
reverse
()
if
0
==
spacerInset
{
spacerInset
=
n
.
first
!.
customView
!.
frame
.
origin
.
x
}
}
}
// Set the titleView if title is empty.
if
""
==
item
.
title
{
if
nil
==
item
.
titleView
{
if
nil
==
item
.
titleView
{
item
.
titleView
=
UIView
(
frame
:
CGRectMake
(
0
,
contentInset
.
top
,
MaterialDevice
.
width
<
MaterialDevice
.
height
?
MaterialDevice
.
height
:
MaterialDevice
.
width
,
intrinsicContentSize
()
.
height
-
contentInset
.
top
-
contentInset
.
bottom
))
item
.
titleView
=
UIView
(
frame
:
CGRectZero
)
item
.
titleView
!.
grid
.
axis
.
direction
=
.
Vertical
}
}
// TitleView alignment.
if
let
titleView
:
UIView
=
item
.
titleView
{
if
let
t
:
UILabel
=
item
.
titleLabel
{
titleView
.
frame
.
origin
=
CGPointZero
t
.
grid
.
rows
=
1
titleView
.
frame
.
size
=
intrinsicContentSize
()
item
.
titleView
!.
addSubview
(
t
)
titleView
.
grid
.
axis
.
columns
=
Int
(
width
/
48
)
if
let
d
:
UILabel
=
item
.
detailLabel
{
d
.
grid
.
rows
=
1
item
.
titleView
!.
addSubview
(
d
)
item
.
titleView
!.
grid
.
views
=
[
t
,
d
]
}
else
{
item
.
titleView
!.
grid
.
views
=
[
t
]
}
}
else
if
let
d
:
UIView
=
item
.
detailView
{
d
.
grid
.
rows
=
1
item
.
titleView
!.
addSubview
(
d
)
item
.
titleView
!.
grid
.
views
=
[
d
]
}
}
// rightControls
if
let
v
:
Array
<
UIControl
>
=
item
.
rightControls
{
if
0
<
v
.
count
{
var
n
:
Array
<
UIBarButtonItem
>
=
Array
<
UIBarButtonItem
>
()
for
c
in
v
{
n
.
append
(
UIBarButtonItem
(
customView
:
c
))
}
n
.
append
(
rightSpacer
)
if
nil
==
item
.
contentView
{
item
.
rightBarButtonItems
=
n
.
reverse
()
item
.
contentView
=
UIView
()
if
0
==
spacerInset
{
spacerInset
=
width
-
n
[
n
.
count
-
2
]
.
customView
!.
frame
.
origin
.
x
-
n
[
n
.
count
-
2
]
.
customView
!.
frame
.
width
}
}
}
sizeNavigationItem
(
item
)
}
/**
Sizes the UINavigationItem.
- Parameter item: A UINavigationItem to size.
*/
internal
func
sizeNavigationItem
(
item
:
UINavigationItem
)
{
print
(
spacerInset
)
let
h
:
CGFloat
=
intrinsicContentSize
()
.
height
var
spaceLeft
:
CGFloat
=
0
var
spaceRight
:
CGFloat
=
0
var
capturedSpace
:
Bool
=
false
// leftControls
if
let
v
:
Array
<
UIControl
>
=
item
.
leftControls
{
for
c
in
v
{
if
let
b
:
UIButton
=
c
as?
UIButton
{
b
.
contentEdgeInsets
.
top
=
0
b
.
contentEdgeInsets
.
bottom
=
0
}
}
c
.
bounds
.
size
=
CGSizeMake
(
c
.
intrinsicContentSize
()
.
width
,
h
-
contentInset
.
top
-
contentInset
.
bottom
)
c
.
backgroundColor
=
MaterialColor
.
purple
.
base
spaceLeft
+=
c
.
bounds
.
size
.
width
+
contentInset
.
left
}
leftSpacer
.
width
=
contentInset
.
left
-
spacerInset
spaceLeft
+=
contentInset
.
left
}
item
.
titleView
?
.
frame
.
size
.
width
=
width
item
.
titleView
?
.
frame
.
size
.
height
=
height
-
contentInset
.
top
-
contentInset
.
bottom
if
let
t
:
UILabel
=
item
.
titleLabel
{
if
32
>=
height
||
nil
==
item
.
detailLabel
{
t
.
font
=
t
.
font
.
fontWithSize
(
20
)
item
.
detailLabel
?
.
hidden
=
true
item
.
titleView
?
.
grid
.
axis
.
rows
=
1
}
else
if
let
d
:
UILabel
=
item
.
detailLabel
{
t
.
font
=
t
.
font
.
fontWithSize
(
17
)
d
.
hidden
=
false
d
.
font
=
d
.
font
.
fontWithSize
(
12
)
item
.
titleView
?
.
grid
.
axis
.
rows
=
2
if
let
contentView
:
UIView
=
item
.
contentView
{
}
contentView
.
grid
.
columns
=
titleView
.
grid
.
axis
.
columns
}
else
if
let
_
:
UIView
=
item
.
detailView
{
item
.
titleView
?
.
grid
.
axis
.
rows
=
1
// Size of single grid column.
}
if
let
g
:
CGFloat
=
width
/
CGFloat
(
0
<
titleView
.
grid
.
axis
.
columns
?
titleView
.
grid
.
axis
.
columns
:
1
)
{
titleView
.
grid
.
views
=
[]
// rightControls
if
let
v
:
Array
<
UIControl
>
=
item
.
rightControls
{
// leftControls
for
c
in
v
{
if
let
v
:
Array
<
UIControl
>
=
item
.
leftControls
{
if
let
b
:
UIButton
=
c
as?
UIButton
{
for
c
in
v
{
b
.
contentEdgeInsets
.
top
=
0
let
w
:
CGFloat
=
c
.
intrinsicContentSize
()
.
width
b
.
contentEdgeInsets
.
bottom
=
0
if
let
b
:
UIButton
=
c
as?
UIButton
{
b
.
contentEdgeInsets
=
UIEdgeInsetsZero
}
c
.
frame
.
size
.
height
=
titleView
.
frame
.
size
.
height
-
contentInset
.
top
-
contentInset
.
bottom
c
.
grid
.
columns
=
0
==
g
?
1
:
Int
(
ceil
(
w
/
g
))
contentView
.
grid
.
columns
-=
c
.
grid
.
columns
titleView
.
addSubview
(
c
)
titleView
.
grid
.
views
?
.
append
(
c
)
}
}
titleView
.
addSubview
(
contentView
)
titleView
.
grid
.
views
?
.
append
(
contentView
)
// rightControls
if
let
v
:
Array
<
UIControl
>
=
item
.
rightControls
{
for
c
in
v
{
let
w
:
CGFloat
=
c
.
intrinsicContentSize
()
.
width
if
let
b
:
UIButton
=
c
as?
UIButton
{
b
.
contentEdgeInsets
=
UIEdgeInsetsZero
}
c
.
frame
.
size
.
height
=
titleView
.
frame
.
size
.
height
-
contentInset
.
top
-
contentInset
.
bottom
c
.
grid
.
columns
=
0
==
g
?
1
:
Int
(
ceil
(
w
/
g
))
contentView
.
grid
.
columns
-=
c
.
grid
.
columns
titleView
.
addSubview
(
c
)
titleView
.
grid
.
views
?
.
append
(
c
)
}
}
}
contentView
.
grid
.
views
=
[]
// contentView alignment.
if
let
title
:
String
=
item
.
title
{
if
let
t
:
UILabel
=
item
.
titleLabel
{
if
""
!=
title
{
t
.
text
=
title
}
item
.
title
=
""
if
""
!=
t
.
text
{
t
.
grid
.
rows
=
1
contentView
.
addSubview
(
t
)
contentView
.
grid
.
views
?
.
append
(
t
)
if
let
detail
:
String
=
item
.
detail
{
if
let
d
:
UILabel
=
item
.
detailLabel
{
t
.
font
=
t
.
font
.
fontWithSize
(
17
)
d
.
text
=
detail
d
.
grid
.
rows
=
1
d
.
font
=
d
.
font
.
fontWithSize
(
12
)
contentView
.
addSubview
(
d
)
contentView
.
grid
.
axis
.
rows
=
2
contentView
.
grid
.
views
?
.
append
(
d
)
}
}
else
{
t
.
font
=
t
.
font
?
.
fontWithSize
(
20
)
contentView
.
grid
.
axis
.
rows
=
1
}
}
}
}
titleView
.
grid
.
contentInset
=
contentInset
titleView
.
grid
.
spacing
=
spacing
titleView
.
grid
.
reloadLayout
()
contentView
.
grid
.
axis
.
direction
=
.
Vertical
contentView
.
grid
.
reloadLayout
()
}
}
c
.
bounds
.
size
=
CGSizeMake
(
c
.
intrinsicContentSize
()
.
width
,
h
-
contentInset
.
top
-
contentInset
.
bottom
)
c
.
backgroundColor
=
MaterialColor
.
purple
.
base
.
colorWithAlphaComponent
(
0.1
)
spaceRight
+=
c
.
bounds
.
size
.
width
+
contentInset
.
right
}
}
rightSpacer
.
width
=
contentInset
.
right
-
spacerInset
spaceRight
+=
contentInset
.
right
}
}
item
.
titleView
?
.
backgroundColor
=
MaterialColor
.
green
.
base
item
.
titleView
?
.
frame
.
size
.
width
=
width
-
spaceLeft
-
spaceRight
item
.
titleView
?
.
frame
.
origin
.
x
=
spaceLeft
item
.
titleView
?
.
grid
.
reloadLayout
()
}
}
/**
/**
...
@@ -440,28 +408,23 @@ public class NavigationBar : UINavigationBar {
...
@@ -440,28 +408,23 @@ public class NavigationBar : UINavigationBar {
when subclassing.
when subclassing.
*/
*/
public
func
prepareView
()
{
public
func
prepareView
()
{
isLandscape
=
MaterialDevice
.
isLandscape
barStyle
=
.
Default
barStyle
=
.
Default
translucent
=
false
translucent
=
false
backButtonImage
=
nil
backgroundColor
=
MaterialColor
.
white
depth
=
.
Depth1
depth
=
.
Depth1
spacingPreset
=
.
Spacing1
contentInsetPreset
=
.
Square1
contentInsetPreset
=
.
Square1
contentScaleFactor
=
MaterialDevice
.
scale
contentScaleFactor
=
MaterialDevice
.
scale
prepareBackButton
()
prepareBackButton
()
}
}
/// Prepares the backButton.
/// Prepares the backButton.
internal
func
prepareBackButton
()
{
private
func
prepareBackButton
()
{
backButton
.
pulseColor
=
MaterialColor
.
white
backButton
.
pulseColor
=
MaterialColor
.
white
backButton
.
setImage
(
backButtonImage
,
forState
:
.
Normal
)
backButton
.
setImage
(
backButtonImage
,
forState
:
.
Normal
)
backButton
.
setImage
(
backButtonImage
,
forState
:
.
Highlighted
)
backButton
.
setImage
(
backButtonImage
,
forState
:
.
Highlighted
)
}
backButtonImage
=
nil
let
image
:
UIImage
?
=
UIImage
.
imageWithColor
(
MaterialColor
.
clear
,
size
:
CGSizeMake
(
1
,
1
))
/// Prepares the UINavigationItem for layout and sizing.
shadowImage
=
image
internal
func
prepareItem
(
item
:
UINavigationItem
)
{
setBackgroundImage
(
image
,
forBarMetrics
:
.
Default
)
if
nil
==
item
.
title
{
item
.
title
=
""
}
}
}
}
}
Sources/iOS/NavigationController.swift
View file @
4dbaa51d
...
@@ -114,7 +114,7 @@ public class NavigationController : UINavigationController, UIGestureRecognizerD
...
@@ -114,7 +114,7 @@ public class NavigationController : UINavigationController, UIGestureRecognizerD
*/
*/
public
func
navigationBar
(
navigationBar
:
UINavigationBar
,
shouldPushItem
item
:
UINavigationItem
)
->
Bool
{
public
func
navigationBar
(
navigationBar
:
UINavigationBar
,
shouldPushItem
item
:
UINavigationItem
)
->
Bool
{
if
let
v
:
NavigationBar
=
navigationBar
as?
NavigationBar
{
if
let
v
:
NavigationBar
=
navigationBar
as?
NavigationBar
{
item
.
setHidesBackButton
(
true
,
animated
:
false
)
item
.
hidesBackButton
=
true
if
var
c
:
Array
<
UIControl
>
=
item
.
leftControls
{
if
var
c
:
Array
<
UIControl
>
=
item
.
leftControls
{
c
.
append
(
v
.
backButton
)
c
.
append
(
v
.
backButton
)
item
.
leftControls
=
c
item
.
leftControls
=
c
...
...
Sources/iOS/NavigationItem.swift
View file @
4dbaa51d
...
@@ -35,19 +35,27 @@ private var MaterialAssociatedObjectNavigationItemKey: UInt8 = 0
...
@@ -35,19 +35,27 @@ private var MaterialAssociatedObjectNavigationItemKey: UInt8 = 0
public
class
MaterialAssociatedObjectNavigationItem
{
public
class
MaterialAssociatedObjectNavigationItem
{
/// Detail View.
/// Detail View.
public
var
detail
View
:
UIView
?
public
var
content
View
:
UIView
?
/// Title label.
/// Title label.
public
var
titleLabel
:
UILabel
?
public
var
titleLabel
:
UILabel
/// Detail text.
public
var
detail
:
String
?
/// Detail label.
/// Detail label.
public
var
detailLabel
:
UILabel
?
public
var
detailLabel
:
UILabel
/// Left controls.
/// Left controls.
public
var
leftControls
:
Array
<
UIControl
>
?
public
var
leftControls
:
Array
<
UIControl
>
?
/// Right controls.
/// Right controls.
public
var
rightControls
:
Array
<
UIControl
>
?
public
var
rightControls
:
Array
<
UIControl
>
?
public
init
()
{
titleLabel
=
UILabel
()
detailLabel
=
UILabel
()
}
}
}
public
extension
UINavigationItem
{
public
extension
UINavigationItem
{
...
@@ -64,17 +72,17 @@ public extension UINavigationItem {
...
@@ -64,17 +72,17 @@ public extension UINavigationItem {
}
}
/// Detail View.
/// Detail View.
public
var
detail
View
:
UIView
?
{
public
internal(set)
var
content
View
:
UIView
?
{
get
{
get
{
return
item
.
detail
View
return
item
.
content
View
}
}
set
(
value
)
{
set
(
value
)
{
item
.
detail
View
=
value
item
.
content
View
=
value
}
}
}
}
/// Title Label.
/// Title Label.
public
var
titleLabel
:
UILabel
?
{
public
internal(set)
var
titleLabel
:
UILabel
{
get
{
get
{
return
item
.
titleLabel
return
item
.
titleLabel
}
}
...
@@ -83,8 +91,18 @@ public extension UINavigationItem {
...
@@ -83,8 +91,18 @@ public extension UINavigationItem {
}
}
}
}
/// Detail text.
public
var
detail
:
String
?
{
get
{
return
item
.
detail
}
set
(
value
)
{
item
.
detail
=
value
}
}
/// Detail Label.
/// Detail Label.
public
var
detailLabel
:
UILabel
?
{
public
internal(set)
var
detailLabel
:
UILabel
{
get
{
get
{
return
item
.
detailLabel
return
item
.
detailLabel
}
}
...
...
Sources/iOS/SearchBar.swift
View file @
4dbaa51d
...
@@ -99,9 +99,15 @@ public class SearchBar : StatusBarView {
...
@@ -99,9 +99,15 @@ public class SearchBar : StatusBarView {
}
}
}
}
/// Prepares the contentView.
/**
public
override
func
prepareContentView
()
{
Prepares the view instance when intialized. When subclassing,
super
.
prepareContentView
()
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
override
func
prepareView
()
{
super
.
prepareView
()
prepareTextField
()
prepareTextField
()
prepareClearButton
()
prepareClearButton
()
}
}
...
...
Sources/iOS/StatusBarView.swift
View file @
4dbaa51d
...
@@ -74,7 +74,7 @@ public class StatusBarView : ControlView {
...
@@ -74,7 +74,7 @@ public class StatusBarView : ControlView {
width
=
MaterialDevice
.
width
width
=
MaterialDevice
.
width
}
}
grid
.
axis
.
columns
=
Int
(
width
/
56
)
grid
.
axis
.
columns
=
Int
(
width
/
48
)
// General alignment.
// General alignment.
if
.
iPhone
==
MaterialDevice
.
type
&&
MaterialDevice
.
isLandscape
{
if
.
iPhone
==
MaterialDevice
.
type
&&
MaterialDevice
.
isLandscape
{
...
...
Sources/iOS/Toolbar.swift
View file @
4dbaa51d
...
@@ -101,9 +101,15 @@ public class Toolbar : StatusBarView {
...
@@ -101,9 +101,15 @@ public class Toolbar : StatusBarView {
}
}
}
}
/// Prepares the contentView.
/**
public
override
func
prepareContentView
()
{
Prepares the view instance when intialized. When subclassing,
super
.
prepareContentView
()
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
override
func
prepareView
()
{
super
.
prepareView
()
contentView
.
grid
.
axis
.
direction
=
.
Vertical
contentView
.
grid
.
axis
.
direction
=
.
Vertical
}
}
...
...
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