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
657394ba
Commit
657394ba
authored
May 01, 2016
by
Daniel Dahan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
added IconButton
parent
1e131e83
Show whitespace changes
Inline
Side-by-side
Showing
43 changed files
with
282 additions
and
206 deletions
+282
-206
Examples/Programmatic/App/App/AppNavigationController.swift
+14
-9
Examples/Programmatic/App/App/AppSearchBarViewController.swift
+2
-2
Examples/Programmatic/App/App/ItemViewController.swift
+3
-3
Examples/Programmatic/App/App/RecipesViewController.swift
+4
-4
Examples/Programmatic/CaptureView/CaptureView/ViewController.swift
+4
-4
Examples/Programmatic/CardView/CardView/ViewController.swift
+3
-3
Examples/Programmatic/Grid/Grid/ViewController.swift
+12
-12
Examples/Programmatic/ImageCardView/ImageCardView/ViewController.swift
+3
-3
Examples/Programmatic/MaterialPulseView/MaterialPulseView/ViewController.swift
+6
-6
Examples/Programmatic/SearchBar/SearchBar/ViewController.swift
+2
-2
Examples/Programmatic/SearchBarController/SearchBarController/AppSearchBarController.swift
+2
-4
Examples/Programmatic/TableCardView/TableCardView/ViewController.swift
+2
-2
Examples/Programmatic/TextField/TextField/ViewController.swift
+3
-4
Examples/Programmatic/Toolbar/Toolbar/ViewController.swift
+2
-2
Examples/Programmatic/ToolbarController/ToolbarController/AppToolbarController.swift
+2
-4
Examples/Storyboards/ImageCardView/ImageCardView/ViewController.swift
+3
-3
Examples/Storyboards/Toolbar/Toolbar/ViewController.swift
+3
-3
Material.xcodeproj/project.pbxproj
+4
-0
Sources/iOS/BottomNavigationController.swift
+1
-0
Sources/iOS/BottomTabBar.swift
+1
-0
Sources/iOS/CardView.swift
+0
-1
Sources/iOS/FabButton.swift
+3
-1
Sources/iOS/IconButton.swift
+48
-0
Sources/iOS/ImageCardView.swift
+0
-1
Sources/iOS/MaterialButton.swift
+10
-7
Sources/iOS/MaterialCollectionView.swift
+1
-0
Sources/iOS/MaterialCollectionViewCell.swift
+10
-7
Sources/iOS/MaterialLabel.swift
+2
-0
Sources/iOS/MaterialPulseAnimation.swift
+16
-22
Sources/iOS/MaterialPulseView.swift
+10
-19
Sources/iOS/MaterialSwitch.swift
+1
-1
Sources/iOS/MaterialTableViewCell.swift
+11
-8
Sources/iOS/MaterialView.swift
+2
-1
Sources/iOS/MenuView.swift
+1
-1
Sources/iOS/MenuViewController.swift
+9
-2
Sources/iOS/NavigationBar.swift
+2
-1
Sources/iOS/NavigationController.swift
+9
-2
Sources/iOS/SearchBar.swift
+2
-4
Sources/iOS/SideNavigationController.swift
+9
-2
Sources/iOS/StatusBarViewController.swift
+1
-0
Sources/iOS/TabBar.swift
+1
-0
Sources/iOS/TextField.swift
+57
-56
Sources/iOS/TextView.swift
+1
-0
No files found.
Examples/Programmatic/App/App/AppNavigationController.swift
View file @
657394ba
...
...
@@ -41,22 +41,27 @@ class AppNavigationController: NavigationController {
prepareNavigationBar
()
}
/**
Uncomment the code to set a statusBar that is colored, different
from the NavigationBar. Note, if using the .CenterRadialBeyondBounds
pulseAnimation value, it will cover the animation radial effect.
*/
override
func
viewWillLayoutSubviews
()
{
super
.
viewWillLayoutSubviews
()
statusBarView
?
.
hidden
=
MaterialDevice
.
statusBarHidden
//
statusBarView?.hidden = MaterialDevice.statusBarHidden
}
/// Prepares the statusBarView
private
func
prepareStatusBarView
()
{
statusBarView
=
MaterialView
()
statusBarView
!.
backgroundColor
=
MaterialColor
.
blue
.
darken2
view
.
addSubview
(
statusBarView
!
)
statusBarView
!.
translatesAutoresizingMaskIntoConstraints
=
false
MaterialLayout
.
alignFromTop
(
view
,
child
:
statusBarView
!
)
MaterialLayout
.
alignToParentHorizontally
(
view
,
child
:
statusBarView
!
)
MaterialLayout
.
height
(
view
,
child
:
statusBarView
!
,
height
:
20
)
// statusBarView = MaterialView()
// statusBarView!.backgroundColor = MaterialColor.blue.darken2
// view.addSubview(statusBarView!)
// statusBarView!.translatesAutoresizingMaskIntoConstraints = false
// MaterialLayout.alignFromTop(view, child: statusBarView!)
// MaterialLayout.alignToParentHorizontally(view, child: statusBarView!)
// MaterialLayout.height(view, child: statusBarView!, height: 20)
}
/// Prepares the navigationBar
...
...
Examples/Programmatic/App/App/AppSearchBarViewController.swift
View file @
657394ba
...
...
@@ -77,7 +77,7 @@ class AppSearchBarController: SearchBarController {
var
image
:
UIImage
?
=
MaterialIcon
.
cm
.
arrowBack
// Back button.
let
backButton
:
FlatButton
=
Flat
Button
()
let
backButton
:
IconButton
=
Icon
Button
()
backButton
.
pulseColor
=
MaterialColor
.
grey
.
base
backButton
.
tintColor
=
MaterialColor
.
grey
.
darken4
backButton
.
setImage
(
image
,
forState
:
.
Normal
)
...
...
@@ -86,7 +86,7 @@ class AppSearchBarController: SearchBarController {
// More button.
image
=
MaterialIcon
.
cm
.
moreHorizontal
let
moreButton
:
FlatButton
=
Flat
Button
()
let
moreButton
:
IconButton
=
Icon
Button
()
moreButton
.
pulseColor
=
MaterialColor
.
grey
.
base
moreButton
.
tintColor
=
MaterialColor
.
grey
.
darken4
moreButton
.
setImage
(
image
,
forState
:
.
Normal
)
...
...
Examples/Programmatic/App/App/ItemViewController.swift
View file @
657394ba
...
...
@@ -45,7 +45,7 @@ class ItemViewController: UIViewController {
private
var
detailLabel
:
UILabel
!
/// NavigationBar share button.
private
var
shareButton
:
Flat
Button
!
private
var
shareButton
:
Icon
Button
!
/// MaterialScrollView.
private
var
scrollView
:
UIScrollView
!
...
...
@@ -120,7 +120,7 @@ class ItemViewController: UIViewController {
/// Prepares the shareButton.
private
func
prepareShareButton
()
{
let
image
:
UIImage
?
=
MaterialIcon
.
cm
.
share
shareButton
=
Flat
Button
()
shareButton
=
Icon
Button
()
shareButton
.
pulseColor
=
MaterialColor
.
white
shareButton
.
setImage
(
image
,
forState
:
.
Normal
)
shareButton
.
setImage
(
image
,
forState
:
.
Highlighted
)
...
...
@@ -145,7 +145,7 @@ class ItemViewController: UIViewController {
imageCardView
=
ImageCardView
()
imageCardView
.
pulse
Color
=
nil
imageCardView
.
pulse
Animation
=
.
None
imageCardView
.
divider
=
false
imageCardView
.
depth
=
.
None
imageCardView
.
contentInsetPreset
=
.
Square3
...
...
Examples/Programmatic/App/App/RecipesViewController.swift
View file @
657394ba
...
...
@@ -39,13 +39,13 @@ class RecipesViewController: UIViewController {
private
var
titleLabel
:
UILabel
!
/// NavigationBar menu button.
private
var
menuButton
:
Flat
Button
!
private
var
menuButton
:
Icon
Button
!
/// NavigationBar switch control.
private
var
switchControl
:
MaterialSwitch
!
/// NavigationBar search button.
private
var
searchButton
:
Flat
Button
!
private
var
searchButton
:
Icon
Button
!
/// A tableView used to display items.
private
var
tableView
:
UITableView
!
...
...
@@ -229,7 +229,7 @@ class RecipesViewController: UIViewController {
/// Prepares the menuButton.
private
func
prepareMenuButton
()
{
let
image
:
UIImage
?
=
MaterialIcon
.
cm
.
menu
menuButton
=
Flat
Button
()
menuButton
=
Icon
Button
()
menuButton
.
pulseColor
=
MaterialColor
.
white
menuButton
.
setImage
(
image
,
forState
:
.
Normal
)
menuButton
.
setImage
(
image
,
forState
:
.
Highlighted
)
...
...
@@ -244,7 +244,7 @@ class RecipesViewController: UIViewController {
/// Prepares the searchButton.
private
func
prepareSearchButton
()
{
let
image
:
UIImage
?
=
MaterialIcon
.
cm
.
search
searchButton
=
Flat
Button
()
searchButton
=
Icon
Button
()
searchButton
.
pulseColor
=
MaterialColor
.
white
searchButton
.
setImage
(
image
,
forState
:
.
Normal
)
searchButton
.
setImage
(
image
,
forState
:
.
Highlighted
)
...
...
Examples/Programmatic/CaptureView/CaptureView/ViewController.swift
View file @
657394ba
...
...
@@ -35,10 +35,10 @@ import AVFoundation
class
ViewController
:
UIViewController
,
CaptureViewDelegate
,
CaptureSessionDelegate
{
lazy
var
captureView
:
CaptureView
=
CaptureView
()
lazy
var
toolbar
:
Toolbar
=
Toolbar
()
lazy
var
cameraButton
:
FlatButton
=
Flat
Button
()
lazy
var
videoButton
:
FlatButton
=
Flat
Button
()
lazy
var
switchCamerasButton
:
FlatButton
=
Flat
Button
()
lazy
var
flashButton
:
FlatButton
=
Flat
Button
()
lazy
var
cameraButton
:
IconButton
=
Icon
Button
()
lazy
var
videoButton
:
IconButton
=
Icon
Button
()
lazy
var
switchCamerasButton
:
IconButton
=
Icon
Button
()
lazy
var
flashButton
:
IconButton
=
Icon
Button
()
lazy
var
captureButton
:
FabButton
=
FabButton
()
override
func
viewDidLoad
()
{
...
...
Examples/Programmatic/CardView/CardView/ViewController.swift
View file @
657394ba
...
...
@@ -110,7 +110,7 @@ class ViewController: UIViewController {
// Share button.
let
img1
:
UIImage
?
=
MaterialIcon
.
cm
.
share
let
btn1
:
FlatButton
=
Flat
Button
()
let
btn1
:
IconButton
=
Icon
Button
()
btn1
.
pulseColor
=
MaterialColor
.
white
btn1
.
tintColor
=
MaterialColor
.
white
btn1
.
setImage
(
img1
,
forState
:
.
Normal
)
...
...
@@ -151,7 +151,7 @@ class ViewController: UIViewController {
// Share button.
let
img1
:
UIImage
?
=
MaterialIcon
.
cm
.
share
let
btn1
:
FlatButton
=
Flat
Button
()
let
btn1
:
IconButton
=
Icon
Button
()
btn1
.
pulseColor
=
MaterialColor
.
white
btn1
.
tintColor
=
MaterialColor
.
white
btn1
.
setImage
(
img1
,
forState
:
.
Normal
)
...
...
@@ -175,7 +175,7 @@ class ViewController: UIViewController {
// Search button.
let
img1
:
UIImage
?
=
MaterialIcon
.
cm
.
search
let
btn1
:
FlatButton
=
Flat
Button
()
let
btn1
:
IconButton
=
Icon
Button
()
btn1
.
pulseColor
=
MaterialColor
.
white
btn1
.
tintColor
=
MaterialColor
.
white
btn1
.
setImage
(
img1
,
forState
:
.
Normal
)
...
...
Examples/Programmatic/Grid/Grid/ViewController.swift
View file @
657394ba
...
...
@@ -57,7 +57,7 @@ class ViewController: UIViewController {
/// Prepares the Horizontal GridView example.
private
func
prepareHorizontalGridViewExample
()
{
var
image
:
UIImage
?
=
UIImage
(
named
:
"ic_flash_auto_white"
)?
.
imageWithRenderingMode
(
.
AlwaysTemplate
)
let
btn1
:
FlatButton
=
Flat
Button
()
let
btn1
:
IconButton
=
Icon
Button
()
btn1
.
pulseColor
=
MaterialColor
.
blueGrey
.
darken4
btn1
.
tintColor
=
MaterialColor
.
blueGrey
.
darken4
btn1
.
backgroundColor
=
MaterialColor
.
grey
.
lighten3
...
...
@@ -66,7 +66,7 @@ class ViewController: UIViewController {
view
.
addSubview
(
btn1
)
image
=
UIImage
(
named
:
"ic_flash_off_white"
)?
.
imageWithRenderingMode
(
.
AlwaysTemplate
)
let
btn2
:
FlatButton
=
Flat
Button
()
let
btn2
:
IconButton
=
Icon
Button
()
btn2
.
pulseColor
=
MaterialColor
.
blueGrey
.
darken4
btn2
.
tintColor
=
MaterialColor
.
blueGrey
.
darken4
btn2
.
backgroundColor
=
MaterialColor
.
grey
.
lighten3
...
...
@@ -75,7 +75,7 @@ class ViewController: UIViewController {
view
.
addSubview
(
btn2
)
image
=
UIImage
(
named
:
"ic_flash_on_white"
)?
.
imageWithRenderingMode
(
.
AlwaysTemplate
)
let
btn3
:
FlatButton
=
Flat
Button
()
let
btn3
:
IconButton
=
Icon
Button
()
btn3
.
pulseColor
=
MaterialColor
.
blueGrey
.
darken4
btn3
.
tintColor
=
MaterialColor
.
blueGrey
.
darken4
btn3
.
backgroundColor
=
MaterialColor
.
grey
.
lighten3
...
...
@@ -106,7 +106,7 @@ class ViewController: UIViewController {
/// Prepares the Vertical GridView example.
private
func
prepareVerticalGridViewExample
()
{
var
image
:
UIImage
?
=
UIImage
(
named
:
"ic_flash_auto_white"
)?
.
imageWithRenderingMode
(
.
AlwaysTemplate
)
let
btn1
:
FlatButton
=
Flat
Button
()
let
btn1
:
IconButton
=
Icon
Button
()
btn1
.
pulseColor
=
MaterialColor
.
blueGrey
.
darken4
btn1
.
tintColor
=
MaterialColor
.
blueGrey
.
darken4
btn1
.
backgroundColor
=
MaterialColor
.
grey
.
lighten3
...
...
@@ -115,7 +115,7 @@ class ViewController: UIViewController {
view
.
addSubview
(
btn1
)
image
=
UIImage
(
named
:
"ic_flash_off_white"
)?
.
imageWithRenderingMode
(
.
AlwaysTemplate
)
let
btn2
:
FlatButton
=
Flat
Button
()
let
btn2
:
IconButton
=
Icon
Button
()
btn2
.
pulseColor
=
MaterialColor
.
blueGrey
.
darken4
btn2
.
tintColor
=
MaterialColor
.
blueGrey
.
darken4
btn2
.
backgroundColor
=
MaterialColor
.
grey
.
lighten3
...
...
@@ -124,7 +124,7 @@ class ViewController: UIViewController {
view
.
addSubview
(
btn2
)
image
=
UIImage
(
named
:
"ic_flash_on_white"
)?
.
imageWithRenderingMode
(
.
AlwaysTemplate
)
let
btn3
:
FlatButton
=
Flat
Button
()
let
btn3
:
IconButton
=
Icon
Button
()
btn3
.
pulseColor
=
MaterialColor
.
blueGrey
.
darken4
btn3
.
tintColor
=
MaterialColor
.
blueGrey
.
darken4
btn3
.
backgroundColor
=
MaterialColor
.
grey
.
lighten3
...
...
@@ -203,7 +203,7 @@ class ViewController: UIViewController {
contentView
.
addSubview
(
titleLabel
)
image
=
MaterialIcon
.
cm
.
moreVertical
let
moreButton
:
FlatButton
=
Flat
Button
()
let
moreButton
:
IconButton
=
Icon
Button
()
moreButton
.
contentEdgeInsetsPreset
=
.
None
moreButton
.
pulseColor
=
MaterialColor
.
blueGrey
.
darken4
moreButton
.
tintColor
=
MaterialColor
.
blueGrey
.
darken4
...
...
@@ -228,7 +228,7 @@ class ViewController: UIViewController {
contentView
.
addSubview
(
alarmLabel
)
image
=
UIImage
(
named
:
"ic_alarm_white"
)?
.
imageWithRenderingMode
(
.
AlwaysTemplate
)
let
alarmButton
:
FlatButton
=
Flat
Button
()
let
alarmButton
:
IconButton
=
Icon
Button
()
alarmButton
.
contentEdgeInsetsPreset
=
.
None
alarmButton
.
pulseColor
=
MaterialColor
.
blueGrey
.
darken4
alarmButton
.
tintColor
=
MaterialColor
.
red
.
base
...
...
@@ -300,7 +300,7 @@ class ViewController: UIViewController {
contentView
.
addSubview
(
titleLabel
)
image
=
MaterialIcon
.
cm
.
moreVertical
let
moreButton
:
FlatButton
=
Flat
Button
()
let
moreButton
:
IconButton
=
Icon
Button
()
moreButton
.
contentEdgeInsetsPreset
=
.
None
moreButton
.
pulseColor
=
MaterialColor
.
blueGrey
.
darken4
moreButton
.
tintColor
=
MaterialColor
.
blueGrey
.
darken4
...
...
@@ -325,7 +325,7 @@ class ViewController: UIViewController {
contentView
.
addSubview
(
alarmLabel
)
image
=
UIImage
(
named
:
"ic_alarm_white"
)?
.
imageWithRenderingMode
(
.
AlwaysTemplate
)
let
alarmButton
:
FlatButton
=
Flat
Button
()
let
alarmButton
:
IconButton
=
Icon
Button
()
alarmButton
.
contentEdgeInsetsPreset
=
.
None
alarmButton
.
pulseColor
=
MaterialColor
.
blueGrey
.
darken4
alarmButton
.
tintColor
=
MaterialColor
.
red
.
base
...
...
@@ -409,7 +409,7 @@ class ViewController: UIViewController {
contentView
.
addSubview
(
titleLabel
)
image
=
MaterialIcon
.
cm
.
moreHorizontal
let
moreButton
:
FlatButton
=
Flat
Button
()
let
moreButton
:
IconButton
=
Icon
Button
()
moreButton
.
contentEdgeInsetsPreset
=
.
None
moreButton
.
pulseColor
=
MaterialColor
.
blueGrey
.
darken4
moreButton
.
tintColor
=
MaterialColor
.
blueGrey
.
darken4
...
...
@@ -434,7 +434,7 @@ class ViewController: UIViewController {
contentView
.
addSubview
(
alarmLabel
)
image
=
UIImage
(
named
:
"ic_alarm_white"
)?
.
imageWithRenderingMode
(
.
AlwaysTemplate
)
let
alarmButton
:
FlatButton
=
Flat
Button
()
let
alarmButton
:
IconButton
=
Icon
Button
()
alarmButton
.
contentEdgeInsetsPreset
=
.
None
alarmButton
.
pulseColor
=
MaterialColor
.
blueGrey
.
darken4
alarmButton
.
tintColor
=
MaterialColor
.
red
.
base
...
...
Examples/Programmatic/ImageCardView/ImageCardView/ViewController.swift
View file @
657394ba
...
...
@@ -107,7 +107,7 @@ class ViewController: UIViewController {
// Star button.
let
img1
:
UIImage
?
=
MaterialIcon
.
cm
.
star
let
btn1
:
FlatButton
=
Flat
Button
()
let
btn1
:
IconButton
=
Icon
Button
()
btn1
.
pulseColor
=
MaterialColor
.
blueGrey
.
lighten1
btn1
.
tintColor
=
MaterialColor
.
blueGrey
.
darken3
btn1
.
setImage
(
img1
,
forState
:
.
Normal
)
...
...
@@ -115,7 +115,7 @@ class ViewController: UIViewController {
// Library button.
let
img2
:
UIImage
?
=
MaterialIcon
.
cm
.
audioLibrary
let
btn2
:
FlatButton
=
Flat
Button
()
let
btn2
:
IconButton
=
Icon
Button
()
btn2
.
pulseColor
=
MaterialColor
.
blueGrey
.
lighten1
btn2
.
tintColor
=
MaterialColor
.
blueGrey
.
darken3
btn2
.
setImage
(
img2
,
forState
:
.
Normal
)
...
...
@@ -123,7 +123,7 @@ class ViewController: UIViewController {
// Share button.
let
img3
:
UIImage
?
=
MaterialIcon
.
share
let
btn3
:
FlatButton
=
Flat
Button
()
let
btn3
:
IconButton
=
Icon
Button
()
btn3
.
pulseColor
=
MaterialColor
.
blueGrey
.
lighten1
btn3
.
tintColor
=
MaterialColor
.
blueGrey
.
darken3
btn3
.
setImage
(
img3
,
forState
:
.
Normal
)
...
...
Examples/Programmatic/MaterialPulseView/MaterialPulseView/ViewController.swift
View file @
657394ba
...
...
@@ -59,7 +59,7 @@ class ViewController: UIViewController {
pulseView
.
shape
=
.
Square
pulseView
.
depth
=
.
Depth1
pulseView
.
cornerRadiusPreset
=
.
Radius3
// pulseView.pulseAnimation = .CenterWithBacking // Set a different type of pulse animation.
pulseView
.
pulseAnimation
=
.
CenterRadialBeyondBounds
// Add pulseView to UIViewController.
view
.
addSubview
(
pulseView
)
...
...
@@ -69,11 +69,11 @@ class ViewController: UIViewController {
// pulseView.pulse(CGPointMake(30, 30))
// }
pulseView
.
animate
(
MaterialAnimation
.
animationGroup
([
MaterialAnimation
.
rotate
(
rotation
:
0.5
),
MaterialAnimation
.
rotateX
(
rotation
:
2
),
MaterialAnimation
.
translateY
(
200
)
],
duration
:
4
))
//
pulseView.animate(MaterialAnimation.animationGroup([
//
MaterialAnimation.rotate(rotation: 0.5),
//
MaterialAnimation.rotateX(rotation: 2),
//
MaterialAnimation.translateY(200)
//
], duration: 4))
}
}
Examples/Programmatic/SearchBar/SearchBar/ViewController.swift
View file @
657394ba
...
...
@@ -57,7 +57,7 @@ class ViewController: UIViewController {
var
image
:
UIImage
?
=
MaterialIcon
.
cm
.
arrowBack
// Back button.
let
backButton
:
FlatButton
=
Flat
Button
()
let
backButton
:
IconButton
=
Icon
Button
()
backButton
.
pulseColor
=
MaterialColor
.
grey
.
base
backButton
.
tintColor
=
MaterialColor
.
grey
.
darken4
backButton
.
setImage
(
image
,
forState
:
.
Normal
)
...
...
@@ -68,7 +68,7 @@ class ViewController: UIViewController {
// More button.
image
=
MaterialIcon
.
cm
.
moreHorizontal
let
moreButton
:
FlatButton
=
Flat
Button
()
let
moreButton
:
IconButton
=
Icon
Button
()
moreButton
.
pulseColor
=
MaterialColor
.
grey
.
base
moreButton
.
tintColor
=
MaterialColor
.
grey
.
darken4
moreButton
.
setImage
(
image
,
forState
:
.
Normal
)
...
...
Examples/Programmatic/SearchBarController/SearchBarController/AppSearchBarController.swift
View file @
657394ba
...
...
@@ -79,8 +79,7 @@ class AppSearchBarController: SearchBarController {
var
image
:
UIImage
?
=
MaterialIcon
.
cm
.
arrowBack
// Back button.
let
backButton
:
FlatButton
=
FlatButton
()
backButton
.
pulseColor
=
nil
let
backButton
:
IconButton
=
IconButton
()
backButton
.
tintColor
=
MaterialColor
.
blueGrey
.
darken4
backButton
.
setImage
(
image
,
forState
:
.
Normal
)
backButton
.
setImage
(
image
,
forState
:
.
Highlighted
)
...
...
@@ -88,8 +87,7 @@ class AppSearchBarController: SearchBarController {
// More button.
image
=
MaterialIcon
.
cm
.
moreHorizontal
let
moreButton
:
FlatButton
=
FlatButton
()
moreButton
.
pulseColor
=
nil
let
moreButton
:
IconButton
=
IconButton
()
moreButton
.
tintColor
=
MaterialColor
.
blueGrey
.
darken4
moreButton
.
setImage
(
image
,
forState
:
.
Normal
)
moreButton
.
setImage
(
image
,
forState
:
.
Highlighted
)
...
...
Examples/Programmatic/TableCardView/TableCardView/ViewController.swift
View file @
657394ba
...
...
@@ -105,8 +105,8 @@ class ViewController: UIViewController {
let
closeButton
:
FlatButton
=
FlatButton
()
closeButton
.
setTitle
(
"Close"
,
forState
:
.
Normal
)
let
image
:
UIImage
?
=
UIImage
(
named
:
"ic_settings"
)?
.
imageWithRenderingMode
(
.
AlwaysTemplate
)
let
settingButton
:
FlatButton
=
Flat
Button
()
let
image
:
UIImage
?
=
MaterialIcon
.
cm
.
settings
let
settingButton
:
IconButton
=
Icon
Button
()
settingButton
.
tintColor
=
MaterialColor
.
blue
.
accent3
settingButton
.
setImage
(
image
,
forState
:
.
Normal
)
settingButton
.
setImage
(
image
,
forState
:
.
Highlighted
)
...
...
Examples/Programmatic/TextField/TextField/ViewController.swift
View file @
657394ba
...
...
@@ -92,7 +92,6 @@ class ViewController: UIViewController, TextFieldDelegate {
nameField
.
detail
=
"Your given name"
nameField
.
textAlignment
=
.
Center
nameField
.
clearButtonMode
=
.
WhileEditing
nameField
.
dividerActiveColor
=
MaterialColor
.
green
.
base
nameField
.
delegate
=
self
// The translatesAutoresizingMaskIntoConstraints property must be set to enable AutoLayout correctly.
...
...
@@ -110,7 +109,7 @@ class ViewController: UIViewController, TextFieldDelegate {
emailField
=
TextField
(
frame
:
CGRectMake
(
40
,
120
,
view
.
bounds
.
width
-
80
,
32
))
emailField
.
placeholder
=
"Email"
emailField
.
detail
=
"Error, incorrect email"
emailField
.
enableClear
Flat
Button
=
true
emailField
.
enableClear
Icon
Button
=
true
emailField
.
delegate
=
self
emailField
.
placeholderColor
=
MaterialColor
.
amber
.
darken4
...
...
@@ -127,11 +126,11 @@ class ViewController: UIViewController, TextFieldDelegate {
passwordField
.
placeholder
=
"Password"
passwordField
.
detail
=
"At least 8 characters"
passwordField
.
clearButtonMode
=
.
WhileEditing
passwordField
.
enableVisibility
Flat
Button
=
true
passwordField
.
enableVisibility
Icon
Button
=
true
passwordField
.
delegate
=
self
// Setting the visibilityFlatButton color.
passwordField
.
visibility
Flat
Button
?
.
tintColor
=
MaterialColor
.
green
.
base
.
colorWithAlphaComponent
(
passwordField
.
secureTextEntry
?
0.38
:
0.54
)
passwordField
.
visibility
Icon
Button
?
.
tintColor
=
MaterialColor
.
green
.
base
.
colorWithAlphaComponent
(
passwordField
.
secureTextEntry
?
0.38
:
0.54
)
// The translatesAutoresizingMaskIntoConstraints property must be set to enable AutoLayout correctly.
passwordField
.
translatesAutoresizingMaskIntoConstraints
=
false
...
...
Examples/Programmatic/Toolbar/Toolbar/ViewController.swift
View file @
657394ba
...
...
@@ -71,7 +71,7 @@ class ViewController: UIViewController {
var
image
:
UIImage
?
=
MaterialIcon
.
cm
.
menu
// Menu button.
let
menuButton
:
FlatButton
=
Flat
Button
()
let
menuButton
:
IconButton
=
Icon
Button
()
menuButton
.
pulseColor
=
MaterialColor
.
white
menuButton
.
tintColor
=
MaterialColor
.
white
menuButton
.
setImage
(
image
,
forState
:
.
Normal
)
...
...
@@ -82,7 +82,7 @@ class ViewController: UIViewController {
// Search button.
image
=
MaterialIcon
.
cm
.
search
let
searchButton
:
FlatButton
=
Flat
Button
()
let
searchButton
:
IconButton
=
Icon
Button
()
searchButton
.
pulseColor
=
MaterialColor
.
white
searchButton
.
tintColor
=
MaterialColor
.
white
searchButton
.
setImage
(
image
,
forState
:
.
Normal
)
...
...
Examples/Programmatic/ToolbarController/ToolbarController/AppToolbarController.swift
View file @
657394ba
...
...
@@ -94,8 +94,7 @@ class AppToolbarController: ToolbarController {
var
image
:
UIImage
?
=
MaterialIcon
.
cm
.
menu
// Menu button.
let
menuButton
:
FlatButton
=
FlatButton
()
menuButton
.
pulseColor
=
nil
let
menuButton
:
IconButton
=
IconButton
()
menuButton
.
tintColor
=
MaterialColor
.
white
menuButton
.
setImage
(
image
,
forState
:
.
Normal
)
menuButton
.
setImage
(
image
,
forState
:
.
Highlighted
)
...
...
@@ -107,8 +106,7 @@ class AppToolbarController: ToolbarController {
// Search button.
image
=
MaterialIcon
.
cm
.
search
let
searchButton
:
FlatButton
=
FlatButton
()
searchButton
.
pulseColor
=
nil
let
searchButton
:
IconButton
=
IconButton
()
searchButton
.
tintColor
=
MaterialColor
.
white
searchButton
.
setImage
(
image
,
forState
:
.
Normal
)
searchButton
.
setImage
(
image
,
forState
:
.
Highlighted
)
...
...
Examples/Storyboards/ImageCardView/ImageCardView/ViewController.swift
View file @
657394ba
...
...
@@ -61,7 +61,7 @@ class ViewController: UIViewController {
// Star button.
let
img1
:
UIImage
?
=
MaterialIcon
.
cm
.
star
let
btn1
:
FlatButton
=
Flat
Button
()
let
btn1
:
IconButton
=
Icon
Button
()
btn1
.
pulseColor
=
MaterialColor
.
blueGrey
.
lighten1
btn1
.
tintColor
=
MaterialColor
.
blueGrey
.
lighten1
btn1
.
setImage
(
img1
,
forState
:
.
Normal
)
...
...
@@ -69,7 +69,7 @@ class ViewController: UIViewController {
// Bell button.
let
img2
:
UIImage
?
=
MaterialIcon
.
cm
.
bell
let
btn2
:
FlatButton
=
Flat
Button
()
let
btn2
:
IconButton
=
Icon
Button
()
btn2
.
pulseColor
=
MaterialColor
.
blueGrey
.
lighten1
btn2
.
tintColor
=
MaterialColor
.
blueGrey
.
lighten1
btn2
.
setImage
(
img2
,
forState
:
.
Normal
)
...
...
@@ -77,7 +77,7 @@ class ViewController: UIViewController {
// Share button.
let
img3
:
UIImage
?
=
MaterialIcon
.
cm
.
share
let
btn3
:
FlatButton
=
Flat
Button
()
let
btn3
:
IconButton
=
Icon
Button
()
btn3
.
pulseColor
=
MaterialColor
.
blueGrey
.
lighten1
btn3
.
tintColor
=
MaterialColor
.
blueGrey
.
lighten1
btn3
.
setImage
(
img3
,
forState
:
.
Normal
)
...
...
Examples/Storyboards/Toolbar/Toolbar/ViewController.swift
View file @
657394ba
...
...
@@ -95,7 +95,7 @@ class ViewController: UIViewController {
// Menu button.
let
img1
:
UIImage
?
=
MaterialIcon
.
cm
.
menu
let
btn1
:
FlatButton
=
Flat
Button
()
let
btn1
:
IconButton
=
Icon
Button
()
btn1
.
pulseColor
=
MaterialColor
.
white
btn1
.
tintColor
=
MaterialColor
.
white
btn1
.
setImage
(
img1
,
forState
:
.
Normal
)
...
...
@@ -103,7 +103,7 @@ class ViewController: UIViewController {
// Star button.
let
img2
:
UIImage
?
=
MaterialIcon
.
cm
.
star
let
btn2
:
FlatButton
=
Flat
Button
()
let
btn2
:
IconButton
=
Icon
Button
()
btn2
.
pulseColor
=
MaterialColor
.
white
btn2
.
tintColor
=
MaterialColor
.
white
btn2
.
setImage
(
img2
,
forState
:
.
Normal
)
...
...
@@ -111,7 +111,7 @@ class ViewController: UIViewController {
// Search button.
let
img3
:
UIImage
?
=
MaterialIcon
.
cm
.
search
let
btn3
:
FlatButton
=
Flat
Button
()
let
btn3
:
IconButton
=
Icon
Button
()
btn3
.
pulseColor
=
MaterialColor
.
white
btn3
.
tintColor
=
MaterialColor
.
white
btn3
.
setImage
(
img3
,
forState
:
.
Normal
)
...
...
Material.xcodeproj/project.pbxproj
View file @
657394ba
...
...
@@ -9,6 +9,7 @@
/* Begin PBXBuildFile section */
96334EF61C8B84660083986B
/* Assets.xcassets in Resources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
96334EF51C8B84660083986B
/* Assets.xcassets */
;
};
963832421B88DFD80015F710
/* Material.framework in Frameworks */
=
{
isa
=
PBXBuildFile
;
fileRef
=
963832361B88DFD80015F710
/* Material.framework */
;
};
9658F2171CD6FA4700B902C1
/* IconButton.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
9658F2161CD6FA4700B902C1
/* IconButton.swift */
;
};
9660161D1CB2ED6C00AAB661
/* Material.framework in Frameworks */
=
{
isa
=
PBXBuildFile
;
fileRef
=
966016131CB2ED6C00AAB661
/* Material.framework */
;
};
9660162A1CB2F04E00AAB661
/* Material.h in Headers */
=
{
isa
=
PBXBuildFile
;
fileRef
=
96D88C091C1328D800B91418
/* Material.h */
;
settings
=
{
ATTRIBUTES
=
(
Public
,
);
};
};
9679CEAB1CC69E080021685B
/* Material+UIImage+TintColor.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
9679CEAA1CC69E080021685B
/* Material+UIImage+TintColor.swift */
;
};
...
...
@@ -196,6 +197,7 @@
963832361B88DFD80015F710
/* Material.framework */
=
{
isa
=
PBXFileReference
;
explicitFileType
=
wrapper.framework
;
includeInIndex
=
0
;
path
=
Material.framework
;
sourceTree
=
BUILT_PRODUCTS_DIR
;
};
963832411B88DFD80015F710
/* Material.xctest */
=
{
isa
=
PBXFileReference
;
explicitFileType
=
wrapper.cfbundle
;
includeInIndex
=
0
;
path
=
Material.xctest
;
sourceTree
=
BUILT_PRODUCTS_DIR
;
};
963832591B88E31A0015F710
/* Info.plist */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
text.plist.xml
;
path
=
Info.plist
;
sourceTree
=
"<group>"
;
};
9658F2161CD6FA4700B902C1
/* IconButton.swift */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
sourcecode.swift
;
path
=
IconButton.swift
;
sourceTree
=
"<group>"
;
};
966016131CB2ED6C00AAB661
/* Material.framework */
=
{
isa
=
PBXFileReference
;
explicitFileType
=
wrapper.framework
;
includeInIndex
=
0
;
path
=
Material.framework
;
sourceTree
=
BUILT_PRODUCTS_DIR
;
};
9660161C1CB2ED6C00AAB661
/* Material OSX Tests.xctest */
=
{
isa
=
PBXFileReference
;
explicitFileType
=
wrapper.cfbundle
;
includeInIndex
=
0
;
path
=
"Material OSX Tests.xctest"
;
sourceTree
=
BUILT_PRODUCTS_DIR
;
};
967887881C9777CB0037F6C9
/* MaterialViewTests.swift */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
sourcecode.swift
;
path
=
MaterialViewTests.swift
;
sourceTree
=
"<group>"
;
};
...
...
@@ -456,6 +458,7 @@
96BCB75F1CB40DC500C806FE
/* FabButton.swift */
,
96BCB7601CB40DC500C806FE
/* FlatButton.swift */
,
96BCB7931CB40DC500C806FE
/* RaisedButton.swift */
,
9658F2161CD6FA4700B902C1
/* IconButton.swift */
,
);
name
=
Button
;
sourceTree
=
"<group>"
;
...
...
@@ -869,6 +872,7 @@
96BCB7C01CB40DC500C806FE
/* MaterialDataSourceItem.swift in Sources */
,
96BCB7AC1CB40DC500C806FE
/* Material+Obj-C.swift in Sources */
,
9679CEAB1CC69E080021685B
/* Material+UIImage+TintColor.swift in Sources */
,
9658F2171CD6FA4700B902C1
/* IconButton.swift in Sources */
,
96BCB7BB1CB40DC500C806FE
/* MaterialCollectionViewCell.swift in Sources */
,
96BCB7CF1CB40DC500C806FE
/* MaterialShape.swift in Sources */
,
96BCB7DF1CB40DC500C806FE
/* SearchBarController.swift in Sources */
,
...
...
Sources/iOS/BottomNavigationController.swift
View file @
657394ba
...
...
@@ -126,6 +126,7 @@ public class BottomNavigationController : UITabBarController, UITabBarController
*/
public
func
prepareView
()
{
view
.
clipsToBounds
=
true
view
.
contentScaleFactor
=
MaterialDevice
.
scale
delegate
=
self
prepareTabBar
()
}
...
...
Sources/iOS/BottomTabBar.swift
View file @
657394ba
...
...
@@ -249,6 +249,7 @@ public class BottomTabBar : UITabBar {
*/
public
func
prepareView
()
{
depth
=
.
Depth1
contentScaleFactor
=
MaterialDevice
.
scale
backgroundColor
=
MaterialColor
.
white
let
image
:
UIImage
?
=
UIImage
.
imageWithColor
(
MaterialColor
.
clear
,
size
:
CGSizeMake
(
1
,
1
))
shadowImage
=
image
...
...
Sources/iOS/CardView.swift
View file @
657394ba
...
...
@@ -409,7 +409,6 @@ public class CardView : MaterialPulseView {
*/
public
override
func
prepareView
()
{
super
.
prepareView
()
pulseColor
=
MaterialColor
.
grey
.
lighten1
depth
=
.
Depth1
dividerColor
=
MaterialColor
.
grey
.
lighten3
cornerRadiusPreset
=
.
Radius1
...
...
Sources/iOS/FabButton.swift
View file @
657394ba
...
...
@@ -42,8 +42,9 @@ public class FabButton : MaterialButton {
super
.
prepareView
()
depth
=
.
Depth1
shape
=
.
Circle
backgroundColor
=
MaterialColor
.
blue
.
base
pulseAnimation
=
.
Center
pulseColor
=
MaterialColor
.
white
tintColor
=
MaterialColor
.
white
backgroundColor
=
MaterialColor
.
blue
.
base
}
}
\ No newline at end of file
Sources/iOS/IconButton.swift
0 → 100644
View file @
657394ba
/*
* Copyright (C) 2015 - 2016, Daniel Dahan and CosmicMind, Inc. <http://cosmicmind.io>.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
*
* * Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* * Neither the name of Material nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
import
UIKit
public
class
IconButton
:
MaterialButton
{
/**
Prepares the view instance when intialized. When subclassing,
it is recommended to override the prepareView method
to initialize property values and other setup operations.
The super.prepareView method should always be called immediately
when subclassing.
*/
public
override
func
prepareView
()
{
super
.
prepareView
()
cornerRadiusPreset
=
.
Radius1
contentEdgeInsetsPreset
=
.
WideRectangle3
pulseAnimation
=
.
Center
}
}
\ No newline at end of file
Sources/iOS/ImageCardView.swift
View file @
657394ba
...
...
@@ -550,7 +550,6 @@ public class ImageCardView : MaterialPulseView {
*/
public
override
func
prepareView
()
{
super
.
prepareView
()
pulseColor
=
MaterialColor
.
grey
.
lighten1
depth
=
.
Depth1
dividerColor
=
MaterialColor
.
grey
.
lighten3
cornerRadiusPreset
=
.
Radius1
...
...
Sources/iOS/MaterialButton.swift
View file @
657394ba
...
...
@@ -50,13 +50,17 @@ public class MaterialButton : UIButton {
public
private(set)
lazy
var
pulseLayers
:
Array
<
CAShapeLayer
>
=
Array
<
CAShapeLayer
>
()
/// The opacity value for the pulse animation.
@IBInspectable
public
var
pulseOpacity
:
CGFloat
=
0.
12
@IBInspectable
public
var
pulseOpacity
:
CGFloat
=
0.
25
/// The color of the pulse effect.
@IBInspectable
public
var
pulseColor
:
UIColor
?
@IBInspectable
public
var
pulseColor
:
UIColor
=
MaterialColor
.
grey
.
base
/// The type of PulseAnimation.
public
var
pulseAnimation
:
PulseAnimation
=
.
AtPointWithBacking
public
var
pulseAnimation
:
PulseAnimation
=
.
AtPointWithBacking
{
didSet
{
visualLayer
.
masksToBounds
=
.
CenterRadialBeyondBounds
!=
pulseAnimation
}
}
/**
This property is the same as clipsToBounds. It crops any of the view's
...
...
@@ -411,7 +415,7 @@ public class MaterialButton : UIButton {
}
MaterialAnimation
.
delay
(
0.35
)
{
[
weak
self
]
in
if
let
s
:
MaterialButton
=
self
{
MaterialAnimation
.
pulseContractAnimation
(
s
.
layer
,
pulseColor
:
s
.
pulseColor
,
pulseLayers
:
&
s
.
pulseLayers
,
pulseAnimation
:
s
.
pulseAnimation
)
MaterialAnimation
.
pulseContractAnimation
(
s
.
layer
,
visualLayer
:
s
.
visualLayer
,
pulseColor
:
s
.
pulseColor
,
pulseLayers
:
&
s
.
pulseLayers
,
pulseAnimation
:
s
.
pulseAnimation
)
}
}
}
...
...
@@ -435,7 +439,7 @@ public class MaterialButton : UIButton {
*/
public
override
func
touchesEnded
(
touches
:
Set
<
UITouch
>
,
withEvent
event
:
UIEvent
?)
{
super
.
touchesEnded
(
touches
,
withEvent
:
event
)
MaterialAnimation
.
pulseContractAnimation
(
layer
,
pulseColor
:
pulseColor
,
pulseLayers
:
&
pulseLayers
,
pulseAnimation
:
pulseAnimation
)
MaterialAnimation
.
pulseContractAnimation
(
layer
,
visualLayer
:
visualLayer
,
pulseColor
:
pulseColor
,
pulseLayers
:
&
pulseLayers
,
pulseAnimation
:
pulseAnimation
)
}
/**
...
...
@@ -446,7 +450,7 @@ public class MaterialButton : UIButton {
*/
public
override
func
touchesCancelled
(
touches
:
Set
<
UITouch
>
?,
withEvent
event
:
UIEvent
?)
{
super
.
touchesCancelled
(
touches
,
withEvent
:
event
)
MaterialAnimation
.
pulseContractAnimation
(
layer
,
pulseColor
:
pulseColor
,
pulseLayers
:
&
pulseLayers
,
pulseAnimation
:
pulseAnimation
)
MaterialAnimation
.
pulseContractAnimation
(
layer
,
visualLayer
:
visualLayer
,
pulseColor
:
pulseColor
,
pulseLayers
:
&
pulseLayers
,
pulseAnimation
:
pulseAnimation
)
}
/**
...
...
@@ -457,7 +461,6 @@ public class MaterialButton : UIButton {
when subclassing.
*/
public
func
prepareView
()
{
pulseColor
=
MaterialColor
.
black
contentScaleFactor
=
MaterialDevice
.
scale
prepareVisualLayer
()
}
...
...
Sources/iOS/MaterialCollectionView.swift
View file @
657394ba
...
...
@@ -118,6 +118,7 @@ public class MaterialCollectionView : UICollectionView {
when subclassing.
*/
public
func
prepareView
()
{
contentScaleFactor
=
MaterialDevice
.
scale
backgroundColor
=
MaterialColor
.
clear
contentInset
=
UIEdgeInsetsZero
}
...
...
Sources/iOS/MaterialCollectionViewCell.swift
View file @
657394ba
...
...
@@ -50,13 +50,17 @@ public class MaterialCollectionViewCell : UICollectionViewCell {
public
private(set)
lazy
var
pulseLayers
:
Array
<
CAShapeLayer
>
=
Array
<
CAShapeLayer
>
()
/// The opcaity value for the pulse animation.
@IBInspectable
public
var
pulseOpacity
:
CGFloat
=
0.
12
@IBInspectable
public
var
pulseOpacity
:
CGFloat
=
0.
25
/// The color of the pulse effect.
@IBInspectable
public
var
pulseColor
:
UIColor
?
@IBInspectable
public
var
pulseColor
:
UIColor
=
MaterialColor
.
grey
.
base
/// The type of PulseAnimation.
public
var
pulseAnimation
:
PulseAnimation
=
.
AtPointWithBacking
public
var
pulseAnimation
:
PulseAnimation
=
.
AtPointWithBacking
{
didSet
{
visualLayer
.
masksToBounds
=
.
CenterRadialBeyondBounds
!=
pulseAnimation
}
}
/**
A property that manages an image for the visualLayer's contents
...
...
@@ -516,7 +520,7 @@ public class MaterialCollectionViewCell : UICollectionViewCell {
}
MaterialAnimation
.
delay
(
0.35
)
{
[
weak
self
]
in
if
let
s
:
MaterialCollectionViewCell
=
self
{
MaterialAnimation
.
pulseContractAnimation
(
s
.
layer
,
pulseColor
:
s
.
pulseColor
,
pulseLayers
:
&
s
.
pulseLayers
,
pulseAnimation
:
s
.
pulseAnimation
)
MaterialAnimation
.
pulseContractAnimation
(
s
.
layer
,
visualLayer
:
s
.
visualLayer
,
pulseColor
:
s
.
pulseColor
,
pulseLayers
:
&
s
.
pulseLayers
,
pulseAnimation
:
s
.
pulseAnimation
)
}
}
}
...
...
@@ -540,7 +544,7 @@ public class MaterialCollectionViewCell : UICollectionViewCell {
*/
public
override
func
touchesEnded
(
touches
:
Set
<
UITouch
>
,
withEvent
event
:
UIEvent
?)
{
super
.
touchesEnded
(
touches
,
withEvent
:
event
)
MaterialAnimation
.
pulseContractAnimation
(
layer
,
pulseColor
:
pulseColor
,
pulseLayers
:
&
pulseLayers
,
pulseAnimation
:
pulseAnimation
)
MaterialAnimation
.
pulseContractAnimation
(
layer
,
visualLayer
:
visualLayer
,
pulseColor
:
pulseColor
,
pulseLayers
:
&
pulseLayers
,
pulseAnimation
:
pulseAnimation
)
}
/**
...
...
@@ -551,7 +555,7 @@ public class MaterialCollectionViewCell : UICollectionViewCell {
*/
public
override
func
touchesCancelled
(
touches
:
Set
<
UITouch
>
?,
withEvent
event
:
UIEvent
?)
{
super
.
touchesCancelled
(
touches
,
withEvent
:
event
)
MaterialAnimation
.
pulseContractAnimation
(
layer
,
pulseColor
:
pulseColor
,
pulseLayers
:
&
pulseLayers
,
pulseAnimation
:
pulseAnimation
)
MaterialAnimation
.
pulseContractAnimation
(
layer
,
visualLayer
:
visualLayer
,
pulseColor
:
pulseColor
,
pulseLayers
:
&
pulseLayers
,
pulseAnimation
:
pulseAnimation
)
}
/**
...
...
@@ -562,7 +566,6 @@ public class MaterialCollectionViewCell : UICollectionViewCell {
when subclassing.
*/
public
func
prepareView
()
{
pulseColor
=
MaterialColor
.
black
contentScaleFactor
=
MaterialDevice
.
scale
prepareVisualLayer
()
}
...
...
Sources/iOS/MaterialLabel.swift
View file @
657394ba
...
...
@@ -147,6 +147,7 @@ public class MaterialLabel : UILabel {
:name: prepareView
*/
public
func
prepareView
()
{
contentScaleFactor
=
MaterialDevice
.
scale
textAlignment
=
.
Left
}
}
\ No newline at end of file
Sources/iOS/MaterialPulseAnimation.swift
View file @
657394ba
...
...
@@ -34,6 +34,7 @@ public enum PulseAnimation {
case
None
case
Center
case
CenterWithBacking
case
CenterRadialBeyondBounds
case
Backing
case
AtPoint
case
AtPointWithBacking
...
...
@@ -51,11 +52,9 @@ internal extension MaterialAnimation {
- Parameter duration: Animation duration.
- Parameter pulseLayers: An Array of CAShapeLayers used in the animation.
*/
internal
static
func
pulseExpandAnimation
(
layer
:
CALayer
,
visualLayer
:
CALayer
,
pulseColor
:
UIColor
?
,
pulseOpacity
:
CGFloat
,
point
:
CGPoint
,
width
:
CGFloat
,
height
:
CGFloat
,
inout
pulseLayers
:
Array
<
CAShapeLayer
>
,
pulseAnimation
:
PulseAnimation
)
{
internal
static
func
pulseExpandAnimation
(
layer
:
CALayer
,
visualLayer
:
CALayer
,
pulseColor
:
UIColor
,
pulseOpacity
:
CGFloat
,
point
:
CGPoint
,
width
:
CGFloat
,
height
:
CGFloat
,
inout
pulseLayers
:
Array
<
CAShapeLayer
>
,
pulseAnimation
:
PulseAnimation
)
{
if
.
None
!=
pulseAnimation
{
if
let
color
:
UIColor
=
pulseColor
{
if
let
n
:
CGFloat
=
width
<
height
?
height
:
width
{
if
let
pOpacity
:
CGFloat
=
pulseOpacity
{
if
let
n
:
CGFloat
=
.
Center
==
pulseAnimation
?
width
<
height
?
width
:
height
:
width
<
height
?
height
:
width
{
let
bLayer
:
CAShapeLayer
=
CAShapeLayer
()
let
pLayer
:
CAShapeLayer
=
CAShapeLayer
()
bLayer
.
addSublayer
(
pLayer
)
...
...
@@ -65,34 +64,32 @@ internal extension MaterialAnimation {
bLayer
.
frame
=
visualLayer
.
bounds
pLayer
.
bounds
=
CGRectMake
(
0
,
0
,
n
,
n
)
switch
pulseAnimation
{
case
.
Center
,
.
CenterWithBacking
:
case
.
Center
,
.
CenterWithBacking
,
.
CenterRadialBeyondBounds
:
pLayer
.
position
=
CGPointMake
(
width
/
2
,
height
/
2
)
default
:
pLayer
.
position
=
point
}
pLayer
.
cornerRadius
=
n
/
2
pLayer
.
backgroundColor
=
color
.
colorWithAlphaComponent
(
p
Opacity
)
.
CGColor
pLayer
.
backgroundColor
=
pulseColor
.
colorWithAlphaComponent
(
pulse
Opacity
)
.
CGColor
pLayer
.
transform
=
CATransform3DMakeAffineTransform
(
CGAffineTransformMakeScale
(
0
,
0
))
})
bLayer
.
setValue
(
false
,
forKey
:
"animated"
)
switch
pulseAnimation
{
case
.
CenterWithBacking
,
.
Backing
,
.
AtPointWithBacking
:
bLayer
.
addAnimation
(
MaterialAnimation
.
backgroundColor
(
color
.
colorWithAlphaComponent
(
pOpacity
/
2
),
duration
:
0.3
5
),
forKey
:
nil
)
bLayer
.
addAnimation
(
MaterialAnimation
.
backgroundColor
(
pulseColor
.
colorWithAlphaComponent
(
pulseOpacity
/
2
),
duration
:
0.32
5
),
forKey
:
nil
)
default
:
break
}
switch
pulseAnimation
{
case
.
Center
,
.
CenterWithBacking
,
.
AtPoint
,
.
AtPointWithBacking
:
pLayer
.
addAnimation
(
MaterialAnimation
.
scale
(
1
,
duration
:
0.3
5
),
forKey
:
nil
)
case
.
Center
,
.
CenterWithBacking
,
.
CenterRadialBeyondBounds
,
.
AtPoint
,
.
AtPointWithBacking
:
pLayer
.
addAnimation
(
MaterialAnimation
.
scale
(
1
,
duration
:
0.32
5
),
forKey
:
nil
)
default
:
break
}
MaterialAnimation
.
delay
(
0.3
5
,
completion
:
{
MaterialAnimation
.
delay
(
0.32
5
,
completion
:
{
bLayer
.
setValue
(
true
,
forKey
:
"animated"
)
})
}
}
}
}
}
/**
Triggers the contracting animation.
...
...
@@ -100,26 +97,25 @@ internal extension MaterialAnimation {
- Parameter pulseColor: The UIColor for the pulse.
- Parameter pulseLayers: An Array of CAShapeLayers used in the animation.
*/
internal
static
func
pulseContractAnimation
(
layer
:
CALayer
,
pulseColor
:
UIColor
?,
inout
pulseLayers
:
Array
<
CAShapeLayer
>
,
pulseAnimation
:
PulseAnimation
)
{
if
let
color
:
UIColor
=
pulseColor
{
internal
static
func
pulseContractAnimation
(
layer
:
CALayer
,
visualLayer
:
CALayer
,
pulseColor
:
UIColor
,
inout
pulseLayers
:
Array
<
CAShapeLayer
>
,
pulseAnimation
:
PulseAnimation
)
{
if
let
bLayer
:
CAShapeLayer
=
pulseLayers
.
popLast
()
{
let
animated
:
Bool
?
=
bLayer
.
valueForKey
(
"animated"
)
as?
Bool
MaterialAnimation
.
delay
(
true
==
animated
?
0
:
0.15
)
{
if
let
pLayer
:
CAShapeLayer
=
bLayer
.
sublayers
?
.
first
as?
CAShapeLayer
{
switch
pulseAnimation
{
case
.
CenterWithBacking
,
.
Backing
,
.
AtPointWithBacking
:
bLayer
.
addAnimation
(
MaterialAnimation
.
backgroundColor
(
color
.
colorWithAlphaComponent
(
0
),
duration
:
0.3
5
),
forKey
:
nil
)
bLayer
.
addAnimation
(
MaterialAnimation
.
backgroundColor
(
pulseColor
.
colorWithAlphaComponent
(
0
),
duration
:
0.32
5
),
forKey
:
nil
)
default
:
break
}
switch
pulseAnimation
{
case
.
Center
,
.
CenterWithBacking
,
.
AtPoint
,
.
AtPointWithBacking
:
case
.
Center
,
.
CenterWithBacking
,
.
CenterRadialBeyondBounds
,
.
AtPoint
,
.
AtPointWithBacking
:
pLayer
.
addAnimation
(
MaterialAnimation
.
animationGroup
([
MaterialAnimation
.
scale
(
1.3
5
),
MaterialAnimation
.
backgroundColor
(
c
olor
.
colorWithAlphaComponent
(
0
))
],
duration
:
0.3
5
),
forKey
:
nil
)
MaterialAnimation
.
scale
(
.
Center
==
pulseAnimation
?
1
:
1.32
5
),
MaterialAnimation
.
backgroundColor
(
pulseC
olor
.
colorWithAlphaComponent
(
0
))
],
duration
:
0.32
5
),
forKey
:
nil
)
default
:
break
}
MaterialAnimation
.
delay
(
0.3
5
)
{
MaterialAnimation
.
delay
(
0.32
5
)
{
pLayer
.
removeFromSuperlayer
()
bLayer
.
removeFromSuperlayer
()
}
...
...
@@ -127,5 +123,4 @@ internal extension MaterialAnimation {
}
}
}
}
}
\ No newline at end of file
Sources/iOS/MaterialPulseView.swift
View file @
657394ba
...
...
@@ -38,13 +38,17 @@ public class MaterialPulseView : MaterialView {
public
private(set)
lazy
var
pulseLayers
:
Array
<
CAShapeLayer
>
=
Array
<
CAShapeLayer
>
()
/// The opcaity value for the pulse animation.
@IBInspectable
public
var
pulseOpacity
:
CGFloat
=
0.
12
@IBInspectable
public
var
pulseOpacity
:
CGFloat
=
0.
25
/// The color of the pulse effect.
@IBInspectable
public
var
pulseColor
:
UIColor
?
@IBInspectable
public
var
pulseColor
:
UIColor
=
MaterialColor
.
grey
.
base
/// The type of PulseAnimation.
public
var
pulseAnimation
:
PulseAnimation
=
.
AtPointWithBacking
public
var
pulseAnimation
:
PulseAnimation
=
.
AtPointWithBacking
{
didSet
{
visualLayer
.
masksToBounds
=
.
CenterRadialBeyondBounds
!=
pulseAnimation
}
}
/**
Triggers the pulse animation.
...
...
@@ -58,7 +62,7 @@ public class MaterialPulseView : MaterialView {
}
MaterialAnimation
.
delay
(
0.35
)
{
[
weak
self
]
in
if
let
s
:
MaterialPulseView
=
self
{
MaterialAnimation
.
pulseContractAnimation
(
s
.
layer
,
pulseColor
:
s
.
pulseColor
,
pulseLayers
:
&
s
.
pulseLayers
,
pulseAnimation
:
s
.
pulseAnimation
)
MaterialAnimation
.
pulseContractAnimation
(
s
.
layer
,
visualLayer
:
s
.
visualLayer
,
pulseColor
:
s
.
pulseColor
,
pulseLayers
:
&
s
.
pulseLayers
,
pulseAnimation
:
s
.
pulseAnimation
)
}
}
}
...
...
@@ -82,7 +86,7 @@ public class MaterialPulseView : MaterialView {
*/
public
override
func
touchesEnded
(
touches
:
Set
<
UITouch
>
,
withEvent
event
:
UIEvent
?)
{
super
.
touchesEnded
(
touches
,
withEvent
:
event
)
MaterialAnimation
.
pulseContractAnimation
(
layer
,
pulseColor
:
pulseColor
,
pulseLayers
:
&
pulseLayers
,
pulseAnimation
:
pulseAnimation
)
MaterialAnimation
.
pulseContractAnimation
(
layer
,
visualLayer
:
visualLayer
,
pulseColor
:
pulseColor
,
pulseLayers
:
&
pulseLayers
,
pulseAnimation
:
pulseAnimation
)
}
/**
...
...
@@ -93,19 +97,6 @@ public class MaterialPulseView : MaterialView {
*/
public
override
func
touchesCancelled
(
touches
:
Set
<
UITouch
>
?,
withEvent
event
:
UIEvent
?)
{
super
.
touchesCancelled
(
touches
,
withEvent
:
event
)
MaterialAnimation
.
pulseContractAnimation
(
layer
,
pulseColor
:
pulseColor
,
pulseLayers
:
&
pulseLayers
,
pulseAnimation
:
pulseAnimation
)
}
/**
Prepares the view instance when intialized. When subclassing,
it is recommended to override the prepareView method
to initialize property values and other setup operations.
The super.prepareView method should always be called immediately
when subclassing.
*/
public
override
func
prepareView
()
{
super
.
prepareView
()
pulseColor
=
MaterialColor
.
black
contentScaleFactor
=
MaterialDevice
.
scale
MaterialAnimation
.
pulseContractAnimation
(
layer
,
visualLayer
:
visualLayer
,
pulseColor
:
pulseColor
,
pulseLayers
:
&
pulseLayers
,
pulseAnimation
:
pulseAnimation
)
}
}
Sources/iOS/MaterialSwitch.swift
View file @
657394ba
...
...
@@ -434,7 +434,7 @@ public class MaterialSwitch : UIControl {
/// Prepares the button.
private
func
prepareButton
()
{
button
.
pulse
Color
=
nil
button
.
pulse
Animation
=
.
None
button
.
addTarget
(
self
,
action
:
#selector(
handleTouchUpInside
)
,
forControlEvents
:
.
TouchUpInside
)
button
.
addTarget
(
self
,
action
:
#selector(
handleTouchDragInside
)
,
forControlEvents
:
.
TouchDragInside
)
button
.
addTarget
(
self
,
action
:
#selector(
handleTouchUpOutsideOrCanceled
)
,
forControlEvents
:
.
TouchCancel
)
...
...
Sources/iOS/MaterialTableViewCell.swift
View file @
657394ba
...
...
@@ -49,13 +49,17 @@ public class MaterialTableViewCell : UITableViewCell {
public
private(set)
lazy
var
pulseLayers
:
Array
<
CAShapeLayer
>
=
Array
<
CAShapeLayer
>
()
/// The opcaity value for the pulse animation.
@IBInspectable
public
var
pulseOpacity
:
CGFloat
=
0.
12
@IBInspectable
public
var
pulseOpacity
:
CGFloat
=
0.
25
/// The color of the pulse effect.
@IBInspectable
public
var
pulseColor
:
UIColor
?
@IBInspectable
public
var
pulseColor
:
UIColor
=
MaterialColor
.
grey
.
base
/// The type of PulseAnimation.
public
var
pulseAnimation
:
PulseAnimation
=
.
AtPointWithBacking
public
var
pulseAnimation
:
PulseAnimation
=
.
AtPointWithBacking
{
didSet
{
visualLayer
.
masksToBounds
=
.
CenterRadialBeyondBounds
!=
pulseAnimation
}
}
/**
This property is the same as clipsToBounds. It crops any of the view's
...
...
@@ -366,7 +370,7 @@ public class MaterialTableViewCell : UITableViewCell {
}
MaterialAnimation
.
delay
(
0.35
)
{
[
weak
self
]
in
if
let
s
:
MaterialTableViewCell
=
self
{
MaterialAnimation
.
pulseContractAnimation
(
s
.
layer
,
pulseColor
:
s
.
pulseColor
,
pulseLayers
:
&
s
.
pulseLayers
,
pulseAnimation
:
s
.
pulseAnimation
)
MaterialAnimation
.
pulseContractAnimation
(
s
.
layer
,
visualLayer
:
s
.
visualLayer
,
pulseColor
:
s
.
pulseColor
,
pulseLayers
:
&
s
.
pulseLayers
,
pulseAnimation
:
s
.
pulseAnimation
)
}
}
}
...
...
@@ -390,7 +394,7 @@ public class MaterialTableViewCell : UITableViewCell {
*/
public
override
func
touchesEnded
(
touches
:
Set
<
UITouch
>
,
withEvent
event
:
UIEvent
?)
{
super
.
touchesEnded
(
touches
,
withEvent
:
event
)
MaterialAnimation
.
pulseContractAnimation
(
layer
,
pulseColor
:
pulseColor
,
pulseLayers
:
&
pulseLayers
,
pulseAnimation
:
pulseAnimation
)
MaterialAnimation
.
pulseContractAnimation
(
layer
,
visualLayer
:
visualLayer
,
pulseColor
:
pulseColor
,
pulseLayers
:
&
pulseLayers
,
pulseAnimation
:
pulseAnimation
)
}
/**
...
...
@@ -401,7 +405,7 @@ public class MaterialTableViewCell : UITableViewCell {
*/
public
override
func
touchesCancelled
(
touches
:
Set
<
UITouch
>
?,
withEvent
event
:
UIEvent
?)
{
super
.
touchesCancelled
(
touches
,
withEvent
:
event
)
MaterialAnimation
.
pulseContractAnimation
(
layer
,
pulseColor
:
pulseColor
,
pulseLayers
:
&
pulseLayers
,
pulseAnimation
:
pulseAnimation
)
MaterialAnimation
.
pulseContractAnimation
(
layer
,
visualLayer
:
visualLayer
,
pulseColor
:
pulseColor
,
pulseLayers
:
&
pulseLayers
,
pulseAnimation
:
pulseAnimation
)
}
/**
...
...
@@ -412,13 +416,12 @@ public class MaterialTableViewCell : UITableViewCell {
when subclassing.
*/
public
func
prepareView
()
{
prepareVisualLayer
()
selectionStyle
=
.
None
pulseColor
=
MaterialColor
.
black
contentScaleFactor
=
MaterialDevice
.
scale
imageView
?
.
userInteractionEnabled
=
false
textLabel
?
.
userInteractionEnabled
=
false
detailTextLabel
?
.
userInteractionEnabled
=
false
prepareVisualLayer
()
}
/// Prepares the visualLayer property.
...
...
Sources/iOS/MaterialView.swift
View file @
657394ba
...
...
@@ -457,8 +457,9 @@ public class MaterialView : UIView {
when subclassing.
*/
public
func
prepareView
()
{
prepareVisualLayer
()
contentScaleFactor
=
MaterialDevice
.
scale
backgroundColor
=
MaterialColor
.
white
prepareVisualLayer
()
}
/// Prepares the visualLayer property.
...
...
Sources/iOS/MenuView.swift
View file @
657394ba
...
...
@@ -43,7 +43,7 @@ public class MenuView : MaterialPulseView {
*/
public
override
func
prepareView
()
{
super
.
prepareView
()
pulse
Color
=
nil
pulse
Animation
=
.
None
clipsToBounds
=
false
backgroundColor
=
nil
}
...
...
Sources/iOS/MenuViewController.swift
View file @
657394ba
...
...
@@ -172,9 +172,16 @@ public class MenuViewController : UIViewController {
}
}
/// A method that generally prepares the MenuViewController.
private
func
prepareView
()
{
/**
Prepares the view instance when intialized. When subclassing,
it is recommended to override the prepareView method
to initialize property values and other setup operations.
The super.prepareView method should always be called immediately
when subclassing.
*/
public
func
prepareView
()
{
view
.
clipsToBounds
=
true
view
.
contentScaleFactor
=
MaterialDevice
.
scale
prepareMenuView
()
prepareRootViewController
()
}
...
...
Sources/iOS/NavigationBar.swift
View file @
657394ba
...
...
@@ -51,7 +51,7 @@ public class NavigationBar : UINavigationBar {
private
var
rightSpacer
:
UIBarButtonItem
=
UIBarButtonItem
(
barButtonSystemItem
:
.
FixedSpace
,
target
:
nil
,
action
:
nil
)
/// Reference to the backButton.
public
private(set)
lazy
var
backButton
:
FlatButton
=
Flat
Button
()
public
private(set)
lazy
var
backButton
:
IconButton
=
Icon
Button
()
/**
The back button image writes to the backIndicatorImage property and
...
...
@@ -402,6 +402,7 @@ public class NavigationBar : UINavigationBar {
backgroundColor
=
MaterialColor
.
white
depth
=
.
Depth1
contentInsetPreset
=
.
Square1
contentScaleFactor
=
MaterialDevice
.
scale
prepareBackButton
()
}
...
...
Sources/iOS/NavigationController.swift
View file @
657394ba
...
...
@@ -130,8 +130,15 @@ public class NavigationController : UINavigationController, UIGestureRecognizerD
popViewControllerAnimated
(
true
)
}
/// Prepares the view.
private
func
prepareView
()
{
/**
Prepares the view instance when intialized. When subclassing,
it is recommended to override the prepareView method
to initialize property values and other setup operations.
The super.prepareView method should always be called immediately
when subclassing.
*/
public
func
prepareView
()
{
view
.
clipsToBounds
=
true
view
.
contentScaleFactor
=
MaterialDevice
.
scale
}
}
Sources/iOS/SearchBar.swift
View file @
657394ba
...
...
@@ -35,7 +35,7 @@ public class SearchBar : StatusBarView {
public
private(set)
var
textField
:
UITextField
!
/// Reference to the clearButton.
public
private(set)
var
clearButton
:
Flat
Button
!
public
private(set)
var
clearButton
:
Icon
Button
!
/// Handle the clearButton manually.
@IBInspectable
public
var
clearButtonAutoHandleEnabled
:
Bool
=
true
{
...
...
@@ -126,10 +126,8 @@ public class SearchBar : StatusBarView {
/// Prepares the clearButton.
private
func
prepareClearButton
()
{
let
image
:
UIImage
?
=
MaterialIcon
.
cm
.
close
clearButton
=
Flat
Button
()
clearButton
=
Icon
Button
()
clearButton
.
contentEdgeInsets
=
UIEdgeInsetsZero
clearButton
.
pulseColor
=
MaterialColor
.
black
clearButton
.
pulseOpacity
=
0.12
clearButton
.
tintColor
=
placeholderTextColor
clearButton
.
setImage
(
image
,
forState
:
.
Normal
)
clearButton
.
setImage
(
image
,
forState
:
.
Highlighted
)
...
...
Sources/iOS/SideNavigationController.swift
View file @
657394ba
...
...
@@ -748,9 +748,16 @@ public class SideNavigationController : UIViewController, UIGestureRecognizerDel
}
}
/// A method that generally prepares the SideNavigationController.
private
func
prepareView
()
{
/**
Prepares the view instance when intialized. When subclassing,
it is recommended to override the prepareView method
to initialize property values and other setup operations.
The super.prepareView method should always be called immediately
when subclassing.
*/
public
func
prepareView
()
{
view
.
clipsToBounds
=
true
view
.
contentScaleFactor
=
MaterialDevice
.
scale
prepareRootViewController
()
prepareLeftView
()
prepareRightView
()
...
...
Sources/iOS/StatusBarViewController.swift
View file @
657394ba
...
...
@@ -136,6 +136,7 @@ public class StatusBarViewController : UIViewController {
*/
public
func
prepareView
()
{
view
.
clipsToBounds
=
true
view
.
contentScaleFactor
=
MaterialDevice
.
scale
prepareRootViewController
()
}
...
...
Sources/iOS/TabBar.swift
View file @
657394ba
...
...
@@ -107,6 +107,7 @@ public class TabBar : MaterialView {
public
override
func
prepareView
()
{
super
.
prepareView
()
autoresizingMask
=
.
FlexibleWidth
contentScaleFactor
=
MaterialDevice
.
scale
prepareBottomLayer
()
}
...
...
Sources/iOS/TextField.swift
View file @
657394ba
...
...
@@ -148,7 +148,7 @@ public class TextField : UITextField {
/// The placeholderLabel font value.
@IBInspectable
public
override
var
font
:
UIFont
?
{
didSet
{
placeholderLabel
.
font
=
self
.
font
placeholderLabel
.
font
=
font
}
}
...
...
@@ -243,87 +243,87 @@ public class TextField : UITextField {
}
}
/// Enables the clear
Flat
Button.
@IBInspectable
public
var
enableClear
Flat
Button
:
Bool
{
/// Enables the clear
Icon
Button.
@IBInspectable
public
var
enableClear
Icon
Button
:
Bool
{
get
{
return
nil
!=
clear
Flat
Button
return
nil
!=
clear
Icon
Button
}
set
(
value
)
{
if
value
{
if
nil
==
clear
Flat
Button
{
if
nil
==
clear
Icon
Button
{
let
image
:
UIImage
?
=
MaterialIcon
.
cm
.
clear
clear
FlatButton
=
Flat
Button
(
frame
:
CGRectZero
)
clear
Flat
Button
!.
contentEdgeInsets
=
UIEdgeInsetsZero
clear
FlatButton
!.
pulseColor
=
nil
clear
Flat
Button
!.
tintColor
=
placeholderColor
clear
Flat
Button
!.
setImage
(
image
,
forState
:
.
Normal
)
clear
Flat
Button
!.
setImage
(
image
,
forState
:
.
Highlighted
)
clear
IconButton
=
Icon
Button
(
frame
:
CGRectZero
)
clear
Icon
Button
!.
contentEdgeInsets
=
UIEdgeInsetsZero
clear
IconButton
!.
pulseAnimation
=
.
Center
clear
Icon
Button
!.
tintColor
=
placeholderColor
clear
Icon
Button
!.
setImage
(
image
,
forState
:
.
Normal
)
clear
Icon
Button
!.
setImage
(
image
,
forState
:
.
Highlighted
)
clearButtonMode
=
.
Never
rightViewMode
=
.
WhileEditing
rightView
=
clear
Flat
Button
clear
FlatButtonAutoHandle
=
clearFlat
ButtonAutoHandle
?
true
:
false
rightView
=
clear
Icon
Button
clear
IconButtonAutoHandle
=
clearIcon
ButtonAutoHandle
?
true
:
false
}
}
else
{
clear
Flat
Button
?
.
removeTarget
(
self
,
action
:
#selector(
handleClearButton
)
,
forControlEvents
:
.
TouchUpInside
)
clear
Flat
Button
=
nil
clear
Icon
Button
?
.
removeTarget
(
self
,
action
:
#selector(
handleClearButton
)
,
forControlEvents
:
.
TouchUpInside
)
clear
Icon
Button
=
nil
}
}
}
/// Enables the automatic handling of the clear
Flat
Button.
@IBInspectable
public
var
clear
Flat
ButtonAutoHandle
:
Bool
=
true
{
/// Enables the automatic handling of the clear
Icon
Button.
@IBInspectable
public
var
clear
Icon
ButtonAutoHandle
:
Bool
=
true
{
didSet
{
clear
Flat
Button
?
.
removeTarget
(
self
,
action
:
#selector(
handleClearButton
)
,
forControlEvents
:
.
TouchUpInside
)
if
clear
Flat
ButtonAutoHandle
{
clear
Flat
Button
?
.
addTarget
(
self
,
action
:
#selector(
handleClearButton
)
,
forControlEvents
:
.
TouchUpInside
)
clear
Icon
Button
?
.
removeTarget
(
self
,
action
:
#selector(
handleClearButton
)
,
forControlEvents
:
.
TouchUpInside
)
if
clear
Icon
ButtonAutoHandle
{
clear
Icon
Button
?
.
addTarget
(
self
,
action
:
#selector(
handleClearButton
)
,
forControlEvents
:
.
TouchUpInside
)
}
}
}
/// Enables the visibility
Flat
Button.
@IBInspectable
public
var
enableVisibility
Flat
Button
:
Bool
{
/// Enables the visibility
Icon
Button.
@IBInspectable
public
var
enableVisibility
Icon
Button
:
Bool
{
get
{
return
nil
!=
visibility
Flat
Button
return
nil
!=
visibility
Icon
Button
}
set
(
value
)
{
if
value
{
if
nil
==
visibility
Flat
Button
{
if
nil
==
visibility
Icon
Button
{
let
image
:
UIImage
?
=
MaterialIcon
.
visibility
visibility
FlatButton
=
Flat
Button
(
frame
:
CGRectZero
)
visibility
Flat
Button
!.
contentEdgeInsets
=
UIEdgeInsetsZero
visibility
FlatButton
!.
pulseColor
=
nil
visibility
Flat
Button
!.
tintColor
=
placeholderColor
visibility
Flat
Button
!.
setImage
(
image
,
forState
:
.
Normal
)
visibility
Flat
Button
!.
setImage
(
image
,
forState
:
.
Highlighted
)
visibility
Flat
Button
!.
tintColor
=
placeholderColor
.
colorWithAlphaComponent
(
secureTextEntry
?
0.38
:
0.54
)
visibility
IconButton
=
Icon
Button
(
frame
:
CGRectZero
)
visibility
Icon
Button
!.
contentEdgeInsets
=
UIEdgeInsetsZero
visibility
IconButton
!.
pulseAnimation
=
.
Center
visibility
Icon
Button
!.
tintColor
=
placeholderColor
visibility
Icon
Button
!.
setImage
(
image
,
forState
:
.
Normal
)
visibility
Icon
Button
!.
setImage
(
image
,
forState
:
.
Highlighted
)
visibility
Icon
Button
!.
tintColor
=
placeholderColor
.
colorWithAlphaComponent
(
secureTextEntry
?
0.38
:
0.54
)
secureTextEntry
=
true
clearButtonMode
=
.
Never
rightViewMode
=
.
WhileEditing
rightView
=
visibility
Flat
Button
visibility
FlatButtonAutoHandle
=
visibilityFlat
ButtonAutoHandle
?
true
:
false
rightView
=
visibility
Icon
Button
visibility
IconButtonAutoHandle
=
visibilityIcon
ButtonAutoHandle
?
true
:
false
}
}
else
{
visibility
Flat
Button
?
.
removeTarget
(
self
,
action
:
#selector(
handleClearButton
)
,
forControlEvents
:
.
TouchUpInside
)
visibility
Flat
Button
=
nil
visibility
Icon
Button
?
.
removeTarget
(
self
,
action
:
#selector(
handleClearButton
)
,
forControlEvents
:
.
TouchUpInside
)
visibility
Icon
Button
=
nil
}
}
}
/// Enables the automatic handling of the visibility
Flat
Button.
@IBInspectable
public
var
visibility
Flat
ButtonAutoHandle
:
Bool
=
true
{
/// Enables the automatic handling of the visibility
Icon
Button.
@IBInspectable
public
var
visibility
Icon
ButtonAutoHandle
:
Bool
=
true
{
didSet
{
visibility
Flat
Button
?
.
removeTarget
(
self
,
action
:
#selector(
handleVisibilityButton
)
,
forControlEvents
:
.
TouchUpInside
)
if
visibility
Flat
ButtonAutoHandle
{
visibility
Flat
Button
?
.
addTarget
(
self
,
action
:
#selector(
handleVisibilityButton
)
,
forControlEvents
:
.
TouchUpInside
)
visibility
Icon
Button
?
.
removeTarget
(
self
,
action
:
#selector(
handleVisibilityButton
)
,
forControlEvents
:
.
TouchUpInside
)
if
visibility
Icon
ButtonAutoHandle
{
visibility
Icon
Button
?
.
addTarget
(
self
,
action
:
#selector(
handleVisibilityButton
)
,
forControlEvents
:
.
TouchUpInside
)
}
}
}
/// A reference to the clear
Flat
Button.
public
private(set)
var
clear
FlatButton
:
Flat
Button
?
/// A reference to the clear
Icon
Button.
public
private(set)
var
clear
IconButton
:
Icon
Button
?
/// A reference to the visibility
Flat
Button.
public
private(set)
var
visibility
FlatButton
:
Flat
Button
?
/// A reference to the visibility
Icon
Button.
public
private(set)
var
visibility
IconButton
:
Icon
Button
?
/**
An initializer that initializes the object with a NSCoder object.
...
...
@@ -433,7 +433,7 @@ public class TextField : UITextField {
placeholderEditingDidEndAnimation
()
}
/// Handles the clear
Flat
Button TouchUpInside event.
/// Handles the clear
Icon
Button TouchUpInside event.
public
func
handleClearButton
()
{
if
false
==
delegate
?
.
textFieldShouldClear
?(
self
)
{
return
...
...
@@ -441,10 +441,10 @@ public class TextField : UITextField {
text
=
nil
}
/// Handles the visibility
Flat
Button TouchUpInside event.
/// Handles the visibility
Icon
Button TouchUpInside event.
public
func
handleVisibilityButton
()
{
secureTextEntry
=
!
secureTextEntry
visibility
FlatButton
?
.
tintColor
=
visibilityFlat
Button
?
.
tintColor
.
colorWithAlphaComponent
(
secureTextEntry
?
0.38
:
0.54
)
visibility
IconButton
?
.
tintColor
=
visibilityIcon
Button
?
.
tintColor
.
colorWithAlphaComponent
(
secureTextEntry
?
0.38
:
0.54
)
}
/**
...
...
@@ -455,12 +455,13 @@ public class TextField : UITextField {
when subclassing.
*/
public
func
prepareView
()
{
super
.
placeholder
=
nil
masksToBounds
=
false
borderStyle
=
.
None
backgroundColor
=
nil
super
.
placeholder
=
nil
textColor
=
MaterialColor
.
darkText
.
primary
font
=
RobotoFont
.
regularWithSize
(
16
)
contentScaleFactor
=
MaterialDevice
.
scale
prepareDivider
()
preparePlaceholderLabel
()
prepareDetailLabel
()
...
...
@@ -472,8 +473,8 @@ public class TextField : UITextField {
if
!
animating
{
layoutPlaceholderLabel
()
layoutDetailLabel
()
layoutClear
Flat
Button
()
layoutVisibility
Flat
Button
()
layoutClear
Icon
Button
()
layoutVisibility
Icon
Button
()
}
}
...
...
@@ -518,18 +519,18 @@ public class TextField : UITextField {
detailLabel
.
frame
=
CGRectMake
(
0
,
divider
.
frame
.
origin
.
y
+
8
,
width
,
h
)
}
/// Layout the clear
Flat
Button.
public
func
layoutClear
Flat
Button
()
{
if
let
v
:
FlatButton
=
clearFlat
Button
{
/// Layout the clear
Icon
Button.
public
func
layoutClear
Icon
Button
()
{
if
let
v
:
IconButton
=
clearIcon
Button
{
if
0
<
width
&&
0
<
height
{
v
.
frame
=
CGRectMake
(
width
-
height
,
0
,
height
,
height
)
}
}
}
/// Layout the visibility
Flat
Button.
public
func
layoutVisibility
Flat
Button
()
{
if
let
v
:
FlatButton
=
visibilityFlat
Button
{
/// Layout the visibility
Icon
Button.
public
func
layoutVisibility
Icon
Button
()
{
if
let
v
:
IconButton
=
visibilityIcon
Button
{
if
0
<
width
&&
0
<
height
{
v
.
frame
=
CGRectMake
(
width
-
height
,
0
,
height
,
height
)
}
...
...
Sources/iOS/TextView.swift
View file @
657394ba
...
...
@@ -467,6 +467,7 @@ public class TextView: UITextView {
when subclassing.
*/
public
func
prepareView
()
{
contentScaleFactor
=
MaterialDevice
.
scale
textContainerInset
=
MaterialEdgeInsetToValue
(
.
None
)
backgroundColor
=
MaterialColor
.
white
masksToBounds
=
false
...
...
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