Commit 657394ba by Daniel Dahan

added IconButton

parent 1e131e83
...@@ -41,22 +41,27 @@ class AppNavigationController: NavigationController { ...@@ -41,22 +41,27 @@ class AppNavigationController: NavigationController {
prepareNavigationBar() 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() { override func viewWillLayoutSubviews() {
super.viewWillLayoutSubviews() super.viewWillLayoutSubviews()
statusBarView?.hidden = MaterialDevice.statusBarHidden // statusBarView?.hidden = MaterialDevice.statusBarHidden
} }
/// Prepares the statusBarView /// Prepares the statusBarView
private func prepareStatusBarView() { private func prepareStatusBarView() {
statusBarView = MaterialView() // statusBarView = MaterialView()
statusBarView!.backgroundColor = MaterialColor.blue.darken2 // 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)
// 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 /// Prepares the navigationBar
......
...@@ -77,7 +77,7 @@ class AppSearchBarController: SearchBarController { ...@@ -77,7 +77,7 @@ class AppSearchBarController: SearchBarController {
var image: UIImage? = MaterialIcon.cm.arrowBack var image: UIImage? = MaterialIcon.cm.arrowBack
// Back button. // Back button.
let backButton: FlatButton = FlatButton() let backButton: IconButton = IconButton()
backButton.pulseColor = MaterialColor.grey.base backButton.pulseColor = MaterialColor.grey.base
backButton.tintColor = MaterialColor.grey.darken4 backButton.tintColor = MaterialColor.grey.darken4
backButton.setImage(image, forState: .Normal) backButton.setImage(image, forState: .Normal)
...@@ -86,7 +86,7 @@ class AppSearchBarController: SearchBarController { ...@@ -86,7 +86,7 @@ class AppSearchBarController: SearchBarController {
// More button. // More button.
image = MaterialIcon.cm.moreHorizontal image = MaterialIcon.cm.moreHorizontal
let moreButton: FlatButton = FlatButton() let moreButton: IconButton = IconButton()
moreButton.pulseColor = MaterialColor.grey.base moreButton.pulseColor = MaterialColor.grey.base
moreButton.tintColor = MaterialColor.grey.darken4 moreButton.tintColor = MaterialColor.grey.darken4
moreButton.setImage(image, forState: .Normal) moreButton.setImage(image, forState: .Normal)
......
...@@ -45,7 +45,7 @@ class ItemViewController: UIViewController { ...@@ -45,7 +45,7 @@ class ItemViewController: UIViewController {
private var detailLabel: UILabel! private var detailLabel: UILabel!
/// NavigationBar share button. /// NavigationBar share button.
private var shareButton: FlatButton! private var shareButton: IconButton!
/// MaterialScrollView. /// MaterialScrollView.
private var scrollView: UIScrollView! private var scrollView: UIScrollView!
...@@ -120,7 +120,7 @@ class ItemViewController: UIViewController { ...@@ -120,7 +120,7 @@ class ItemViewController: UIViewController {
/// Prepares the shareButton. /// Prepares the shareButton.
private func prepareShareButton() { private func prepareShareButton() {
let image: UIImage? = MaterialIcon.cm.share let image: UIImage? = MaterialIcon.cm.share
shareButton = FlatButton() shareButton = IconButton()
shareButton.pulseColor = MaterialColor.white shareButton.pulseColor = MaterialColor.white
shareButton.setImage(image, forState: .Normal) shareButton.setImage(image, forState: .Normal)
shareButton.setImage(image, forState: .Highlighted) shareButton.setImage(image, forState: .Highlighted)
...@@ -145,7 +145,7 @@ class ItemViewController: UIViewController { ...@@ -145,7 +145,7 @@ class ItemViewController: UIViewController {
imageCardView = ImageCardView() imageCardView = ImageCardView()
imageCardView.pulseColor = nil imageCardView.pulseAnimation = .None
imageCardView.divider = false imageCardView.divider = false
imageCardView.depth = .None imageCardView.depth = .None
imageCardView.contentInsetPreset = .Square3 imageCardView.contentInsetPreset = .Square3
......
...@@ -39,13 +39,13 @@ class RecipesViewController: UIViewController { ...@@ -39,13 +39,13 @@ class RecipesViewController: UIViewController {
private var titleLabel: UILabel! private var titleLabel: UILabel!
/// NavigationBar menu button. /// NavigationBar menu button.
private var menuButton: FlatButton! private var menuButton: IconButton!
/// NavigationBar switch control. /// NavigationBar switch control.
private var switchControl: MaterialSwitch! private var switchControl: MaterialSwitch!
/// NavigationBar search button. /// NavigationBar search button.
private var searchButton: FlatButton! private var searchButton: IconButton!
/// A tableView used to display items. /// A tableView used to display items.
private var tableView: UITableView! private var tableView: UITableView!
...@@ -229,7 +229,7 @@ class RecipesViewController: UIViewController { ...@@ -229,7 +229,7 @@ class RecipesViewController: UIViewController {
/// Prepares the menuButton. /// Prepares the menuButton.
private func prepareMenuButton() { private func prepareMenuButton() {
let image: UIImage? = MaterialIcon.cm.menu let image: UIImage? = MaterialIcon.cm.menu
menuButton = FlatButton() menuButton = IconButton()
menuButton.pulseColor = MaterialColor.white menuButton.pulseColor = MaterialColor.white
menuButton.setImage(image, forState: .Normal) menuButton.setImage(image, forState: .Normal)
menuButton.setImage(image, forState: .Highlighted) menuButton.setImage(image, forState: .Highlighted)
...@@ -244,7 +244,7 @@ class RecipesViewController: UIViewController { ...@@ -244,7 +244,7 @@ class RecipesViewController: UIViewController {
/// Prepares the searchButton. /// Prepares the searchButton.
private func prepareSearchButton() { private func prepareSearchButton() {
let image: UIImage? = MaterialIcon.cm.search let image: UIImage? = MaterialIcon.cm.search
searchButton = FlatButton() searchButton = IconButton()
searchButton.pulseColor = MaterialColor.white searchButton.pulseColor = MaterialColor.white
searchButton.setImage(image, forState: .Normal) searchButton.setImage(image, forState: .Normal)
searchButton.setImage(image, forState: .Highlighted) searchButton.setImage(image, forState: .Highlighted)
......
...@@ -35,10 +35,10 @@ import AVFoundation ...@@ -35,10 +35,10 @@ import AVFoundation
class ViewController: UIViewController, CaptureViewDelegate, CaptureSessionDelegate { class ViewController: UIViewController, CaptureViewDelegate, CaptureSessionDelegate {
lazy var captureView: CaptureView = CaptureView() lazy var captureView: CaptureView = CaptureView()
lazy var toolbar: Toolbar = Toolbar() lazy var toolbar: Toolbar = Toolbar()
lazy var cameraButton: FlatButton = FlatButton() lazy var cameraButton: IconButton = IconButton()
lazy var videoButton: FlatButton = FlatButton() lazy var videoButton: IconButton = IconButton()
lazy var switchCamerasButton: FlatButton = FlatButton() lazy var switchCamerasButton: IconButton = IconButton()
lazy var flashButton: FlatButton = FlatButton() lazy var flashButton: IconButton = IconButton()
lazy var captureButton: FabButton = FabButton() lazy var captureButton: FabButton = FabButton()
override func viewDidLoad() { override func viewDidLoad() {
......
...@@ -110,7 +110,7 @@ class ViewController: UIViewController { ...@@ -110,7 +110,7 @@ class ViewController: UIViewController {
// Share button. // Share button.
let img1: UIImage? = MaterialIcon.cm.share let img1: UIImage? = MaterialIcon.cm.share
let btn1: FlatButton = FlatButton() let btn1: IconButton = IconButton()
btn1.pulseColor = MaterialColor.white btn1.pulseColor = MaterialColor.white
btn1.tintColor = MaterialColor.white btn1.tintColor = MaterialColor.white
btn1.setImage(img1, forState: .Normal) btn1.setImage(img1, forState: .Normal)
...@@ -151,7 +151,7 @@ class ViewController: UIViewController { ...@@ -151,7 +151,7 @@ class ViewController: UIViewController {
// Share button. // Share button.
let img1: UIImage? = MaterialIcon.cm.share let img1: UIImage? = MaterialIcon.cm.share
let btn1: FlatButton = FlatButton() let btn1: IconButton = IconButton()
btn1.pulseColor = MaterialColor.white btn1.pulseColor = MaterialColor.white
btn1.tintColor = MaterialColor.white btn1.tintColor = MaterialColor.white
btn1.setImage(img1, forState: .Normal) btn1.setImage(img1, forState: .Normal)
...@@ -175,7 +175,7 @@ class ViewController: UIViewController { ...@@ -175,7 +175,7 @@ class ViewController: UIViewController {
// Search button. // Search button.
let img1: UIImage? = MaterialIcon.cm.search let img1: UIImage? = MaterialIcon.cm.search
let btn1: FlatButton = FlatButton() let btn1: IconButton = IconButton()
btn1.pulseColor = MaterialColor.white btn1.pulseColor = MaterialColor.white
btn1.tintColor = MaterialColor.white btn1.tintColor = MaterialColor.white
btn1.setImage(img1, forState: .Normal) btn1.setImage(img1, forState: .Normal)
......
...@@ -57,7 +57,7 @@ class ViewController: UIViewController { ...@@ -57,7 +57,7 @@ class ViewController: UIViewController {
/// Prepares the Horizontal GridView example. /// Prepares the Horizontal GridView example.
private func prepareHorizontalGridViewExample() { private func prepareHorizontalGridViewExample() {
var image: UIImage? = UIImage(named: "ic_flash_auto_white")?.imageWithRenderingMode(.AlwaysTemplate) var image: UIImage? = UIImage(named: "ic_flash_auto_white")?.imageWithRenderingMode(.AlwaysTemplate)
let btn1: FlatButton = FlatButton() let btn1: IconButton = IconButton()
btn1.pulseColor = MaterialColor.blueGrey.darken4 btn1.pulseColor = MaterialColor.blueGrey.darken4
btn1.tintColor = MaterialColor.blueGrey.darken4 btn1.tintColor = MaterialColor.blueGrey.darken4
btn1.backgroundColor = MaterialColor.grey.lighten3 btn1.backgroundColor = MaterialColor.grey.lighten3
...@@ -66,7 +66,7 @@ class ViewController: UIViewController { ...@@ -66,7 +66,7 @@ class ViewController: UIViewController {
view.addSubview(btn1) view.addSubview(btn1)
image = UIImage(named: "ic_flash_off_white")?.imageWithRenderingMode(.AlwaysTemplate) image = UIImage(named: "ic_flash_off_white")?.imageWithRenderingMode(.AlwaysTemplate)
let btn2: FlatButton = FlatButton() let btn2: IconButton = IconButton()
btn2.pulseColor = MaterialColor.blueGrey.darken4 btn2.pulseColor = MaterialColor.blueGrey.darken4
btn2.tintColor = MaterialColor.blueGrey.darken4 btn2.tintColor = MaterialColor.blueGrey.darken4
btn2.backgroundColor = MaterialColor.grey.lighten3 btn2.backgroundColor = MaterialColor.grey.lighten3
...@@ -75,7 +75,7 @@ class ViewController: UIViewController { ...@@ -75,7 +75,7 @@ class ViewController: UIViewController {
view.addSubview(btn2) view.addSubview(btn2)
image = UIImage(named: "ic_flash_on_white")?.imageWithRenderingMode(.AlwaysTemplate) image = UIImage(named: "ic_flash_on_white")?.imageWithRenderingMode(.AlwaysTemplate)
let btn3: FlatButton = FlatButton() let btn3: IconButton = IconButton()
btn3.pulseColor = MaterialColor.blueGrey.darken4 btn3.pulseColor = MaterialColor.blueGrey.darken4
btn3.tintColor = MaterialColor.blueGrey.darken4 btn3.tintColor = MaterialColor.blueGrey.darken4
btn3.backgroundColor = MaterialColor.grey.lighten3 btn3.backgroundColor = MaterialColor.grey.lighten3
...@@ -106,7 +106,7 @@ class ViewController: UIViewController { ...@@ -106,7 +106,7 @@ class ViewController: UIViewController {
/// Prepares the Vertical GridView example. /// Prepares the Vertical GridView example.
private func prepareVerticalGridViewExample() { private func prepareVerticalGridViewExample() {
var image: UIImage? = UIImage(named: "ic_flash_auto_white")?.imageWithRenderingMode(.AlwaysTemplate) var image: UIImage? = UIImage(named: "ic_flash_auto_white")?.imageWithRenderingMode(.AlwaysTemplate)
let btn1: FlatButton = FlatButton() let btn1: IconButton = IconButton()
btn1.pulseColor = MaterialColor.blueGrey.darken4 btn1.pulseColor = MaterialColor.blueGrey.darken4
btn1.tintColor = MaterialColor.blueGrey.darken4 btn1.tintColor = MaterialColor.blueGrey.darken4
btn1.backgroundColor = MaterialColor.grey.lighten3 btn1.backgroundColor = MaterialColor.grey.lighten3
...@@ -115,7 +115,7 @@ class ViewController: UIViewController { ...@@ -115,7 +115,7 @@ class ViewController: UIViewController {
view.addSubview(btn1) view.addSubview(btn1)
image = UIImage(named: "ic_flash_off_white")?.imageWithRenderingMode(.AlwaysTemplate) image = UIImage(named: "ic_flash_off_white")?.imageWithRenderingMode(.AlwaysTemplate)
let btn2: FlatButton = FlatButton() let btn2: IconButton = IconButton()
btn2.pulseColor = MaterialColor.blueGrey.darken4 btn2.pulseColor = MaterialColor.blueGrey.darken4
btn2.tintColor = MaterialColor.blueGrey.darken4 btn2.tintColor = MaterialColor.blueGrey.darken4
btn2.backgroundColor = MaterialColor.grey.lighten3 btn2.backgroundColor = MaterialColor.grey.lighten3
...@@ -124,7 +124,7 @@ class ViewController: UIViewController { ...@@ -124,7 +124,7 @@ class ViewController: UIViewController {
view.addSubview(btn2) view.addSubview(btn2)
image = UIImage(named: "ic_flash_on_white")?.imageWithRenderingMode(.AlwaysTemplate) image = UIImage(named: "ic_flash_on_white")?.imageWithRenderingMode(.AlwaysTemplate)
let btn3: FlatButton = FlatButton() let btn3: IconButton = IconButton()
btn3.pulseColor = MaterialColor.blueGrey.darken4 btn3.pulseColor = MaterialColor.blueGrey.darken4
btn3.tintColor = MaterialColor.blueGrey.darken4 btn3.tintColor = MaterialColor.blueGrey.darken4
btn3.backgroundColor = MaterialColor.grey.lighten3 btn3.backgroundColor = MaterialColor.grey.lighten3
...@@ -203,7 +203,7 @@ class ViewController: UIViewController { ...@@ -203,7 +203,7 @@ class ViewController: UIViewController {
contentView.addSubview(titleLabel) contentView.addSubview(titleLabel)
image = MaterialIcon.cm.moreVertical image = MaterialIcon.cm.moreVertical
let moreButton: FlatButton = FlatButton() let moreButton: IconButton = IconButton()
moreButton.contentEdgeInsetsPreset = .None moreButton.contentEdgeInsetsPreset = .None
moreButton.pulseColor = MaterialColor.blueGrey.darken4 moreButton.pulseColor = MaterialColor.blueGrey.darken4
moreButton.tintColor = MaterialColor.blueGrey.darken4 moreButton.tintColor = MaterialColor.blueGrey.darken4
...@@ -228,7 +228,7 @@ class ViewController: UIViewController { ...@@ -228,7 +228,7 @@ class ViewController: UIViewController {
contentView.addSubview(alarmLabel) contentView.addSubview(alarmLabel)
image = UIImage(named: "ic_alarm_white")?.imageWithRenderingMode(.AlwaysTemplate) image = UIImage(named: "ic_alarm_white")?.imageWithRenderingMode(.AlwaysTemplate)
let alarmButton: FlatButton = FlatButton() let alarmButton: IconButton = IconButton()
alarmButton.contentEdgeInsetsPreset = .None alarmButton.contentEdgeInsetsPreset = .None
alarmButton.pulseColor = MaterialColor.blueGrey.darken4 alarmButton.pulseColor = MaterialColor.blueGrey.darken4
alarmButton.tintColor = MaterialColor.red.base alarmButton.tintColor = MaterialColor.red.base
...@@ -300,7 +300,7 @@ class ViewController: UIViewController { ...@@ -300,7 +300,7 @@ class ViewController: UIViewController {
contentView.addSubview(titleLabel) contentView.addSubview(titleLabel)
image = MaterialIcon.cm.moreVertical image = MaterialIcon.cm.moreVertical
let moreButton: FlatButton = FlatButton() let moreButton: IconButton = IconButton()
moreButton.contentEdgeInsetsPreset = .None moreButton.contentEdgeInsetsPreset = .None
moreButton.pulseColor = MaterialColor.blueGrey.darken4 moreButton.pulseColor = MaterialColor.blueGrey.darken4
moreButton.tintColor = MaterialColor.blueGrey.darken4 moreButton.tintColor = MaterialColor.blueGrey.darken4
...@@ -325,7 +325,7 @@ class ViewController: UIViewController { ...@@ -325,7 +325,7 @@ class ViewController: UIViewController {
contentView.addSubview(alarmLabel) contentView.addSubview(alarmLabel)
image = UIImage(named: "ic_alarm_white")?.imageWithRenderingMode(.AlwaysTemplate) image = UIImage(named: "ic_alarm_white")?.imageWithRenderingMode(.AlwaysTemplate)
let alarmButton: FlatButton = FlatButton() let alarmButton: IconButton = IconButton()
alarmButton.contentEdgeInsetsPreset = .None alarmButton.contentEdgeInsetsPreset = .None
alarmButton.pulseColor = MaterialColor.blueGrey.darken4 alarmButton.pulseColor = MaterialColor.blueGrey.darken4
alarmButton.tintColor = MaterialColor.red.base alarmButton.tintColor = MaterialColor.red.base
...@@ -409,7 +409,7 @@ class ViewController: UIViewController { ...@@ -409,7 +409,7 @@ class ViewController: UIViewController {
contentView.addSubview(titleLabel) contentView.addSubview(titleLabel)
image = MaterialIcon.cm.moreHorizontal image = MaterialIcon.cm.moreHorizontal
let moreButton: FlatButton = FlatButton() let moreButton: IconButton = IconButton()
moreButton.contentEdgeInsetsPreset = .None moreButton.contentEdgeInsetsPreset = .None
moreButton.pulseColor = MaterialColor.blueGrey.darken4 moreButton.pulseColor = MaterialColor.blueGrey.darken4
moreButton.tintColor = MaterialColor.blueGrey.darken4 moreButton.tintColor = MaterialColor.blueGrey.darken4
...@@ -434,7 +434,7 @@ class ViewController: UIViewController { ...@@ -434,7 +434,7 @@ class ViewController: UIViewController {
contentView.addSubview(alarmLabel) contentView.addSubview(alarmLabel)
image = UIImage(named: "ic_alarm_white")?.imageWithRenderingMode(.AlwaysTemplate) image = UIImage(named: "ic_alarm_white")?.imageWithRenderingMode(.AlwaysTemplate)
let alarmButton: FlatButton = FlatButton() let alarmButton: IconButton = IconButton()
alarmButton.contentEdgeInsetsPreset = .None alarmButton.contentEdgeInsetsPreset = .None
alarmButton.pulseColor = MaterialColor.blueGrey.darken4 alarmButton.pulseColor = MaterialColor.blueGrey.darken4
alarmButton.tintColor = MaterialColor.red.base alarmButton.tintColor = MaterialColor.red.base
......
...@@ -107,7 +107,7 @@ class ViewController: UIViewController { ...@@ -107,7 +107,7 @@ class ViewController: UIViewController {
// Star button. // Star button.
let img1: UIImage? = MaterialIcon.cm.star let img1: UIImage? = MaterialIcon.cm.star
let btn1: FlatButton = FlatButton() let btn1: IconButton = IconButton()
btn1.pulseColor = MaterialColor.blueGrey.lighten1 btn1.pulseColor = MaterialColor.blueGrey.lighten1
btn1.tintColor = MaterialColor.blueGrey.darken3 btn1.tintColor = MaterialColor.blueGrey.darken3
btn1.setImage(img1, forState: .Normal) btn1.setImage(img1, forState: .Normal)
...@@ -115,7 +115,7 @@ class ViewController: UIViewController { ...@@ -115,7 +115,7 @@ class ViewController: UIViewController {
// Library button. // Library button.
let img2: UIImage? = MaterialIcon.cm.audioLibrary let img2: UIImage? = MaterialIcon.cm.audioLibrary
let btn2: FlatButton = FlatButton() let btn2: IconButton = IconButton()
btn2.pulseColor = MaterialColor.blueGrey.lighten1 btn2.pulseColor = MaterialColor.blueGrey.lighten1
btn2.tintColor = MaterialColor.blueGrey.darken3 btn2.tintColor = MaterialColor.blueGrey.darken3
btn2.setImage(img2, forState: .Normal) btn2.setImage(img2, forState: .Normal)
...@@ -123,7 +123,7 @@ class ViewController: UIViewController { ...@@ -123,7 +123,7 @@ class ViewController: UIViewController {
// Share button. // Share button.
let img3: UIImage? = MaterialIcon.share let img3: UIImage? = MaterialIcon.share
let btn3: FlatButton = FlatButton() let btn3: IconButton = IconButton()
btn3.pulseColor = MaterialColor.blueGrey.lighten1 btn3.pulseColor = MaterialColor.blueGrey.lighten1
btn3.tintColor = MaterialColor.blueGrey.darken3 btn3.tintColor = MaterialColor.blueGrey.darken3
btn3.setImage(img3, forState: .Normal) btn3.setImage(img3, forState: .Normal)
......
...@@ -59,7 +59,7 @@ class ViewController: UIViewController { ...@@ -59,7 +59,7 @@ class ViewController: UIViewController {
pulseView.shape = .Square pulseView.shape = .Square
pulseView.depth = .Depth1 pulseView.depth = .Depth1
pulseView.cornerRadiusPreset = .Radius3 pulseView.cornerRadiusPreset = .Radius3
// pulseView.pulseAnimation = .CenterWithBacking // Set a different type of pulse animation. pulseView.pulseAnimation = .CenterRadialBeyondBounds
// Add pulseView to UIViewController. // Add pulseView to UIViewController.
view.addSubview(pulseView) view.addSubview(pulseView)
...@@ -69,11 +69,11 @@ class ViewController: UIViewController { ...@@ -69,11 +69,11 @@ class ViewController: UIViewController {
// pulseView.pulse(CGPointMake(30, 30)) // pulseView.pulse(CGPointMake(30, 30))
// } // }
pulseView.animate(MaterialAnimation.animationGroup([ // pulseView.animate(MaterialAnimation.animationGroup([
MaterialAnimation.rotate(rotation: 0.5), // MaterialAnimation.rotate(rotation: 0.5),
MaterialAnimation.rotateX(rotation: 2), // MaterialAnimation.rotateX(rotation: 2),
MaterialAnimation.translateY(200) // MaterialAnimation.translateY(200)
], duration: 4)) // ], duration: 4))
} }
} }
...@@ -57,7 +57,7 @@ class ViewController: UIViewController { ...@@ -57,7 +57,7 @@ class ViewController: UIViewController {
var image: UIImage? = MaterialIcon.cm.arrowBack var image: UIImage? = MaterialIcon.cm.arrowBack
// Back button. // Back button.
let backButton: FlatButton = FlatButton() let backButton: IconButton = IconButton()
backButton.pulseColor = MaterialColor.grey.base backButton.pulseColor = MaterialColor.grey.base
backButton.tintColor = MaterialColor.grey.darken4 backButton.tintColor = MaterialColor.grey.darken4
backButton.setImage(image, forState: .Normal) backButton.setImage(image, forState: .Normal)
...@@ -68,7 +68,7 @@ class ViewController: UIViewController { ...@@ -68,7 +68,7 @@ class ViewController: UIViewController {
// More button. // More button.
image = MaterialIcon.cm.moreHorizontal image = MaterialIcon.cm.moreHorizontal
let moreButton: FlatButton = FlatButton() let moreButton: IconButton = IconButton()
moreButton.pulseColor = MaterialColor.grey.base moreButton.pulseColor = MaterialColor.grey.base
moreButton.tintColor = MaterialColor.grey.darken4 moreButton.tintColor = MaterialColor.grey.darken4
moreButton.setImage(image, forState: .Normal) moreButton.setImage(image, forState: .Normal)
......
...@@ -79,8 +79,7 @@ class AppSearchBarController: SearchBarController { ...@@ -79,8 +79,7 @@ class AppSearchBarController: SearchBarController {
var image: UIImage? = MaterialIcon.cm.arrowBack var image: UIImage? = MaterialIcon.cm.arrowBack
// Back button. // Back button.
let backButton: FlatButton = FlatButton() let backButton: IconButton = IconButton()
backButton.pulseColor = nil
backButton.tintColor = MaterialColor.blueGrey.darken4 backButton.tintColor = MaterialColor.blueGrey.darken4
backButton.setImage(image, forState: .Normal) backButton.setImage(image, forState: .Normal)
backButton.setImage(image, forState: .Highlighted) backButton.setImage(image, forState: .Highlighted)
...@@ -88,8 +87,7 @@ class AppSearchBarController: SearchBarController { ...@@ -88,8 +87,7 @@ class AppSearchBarController: SearchBarController {
// More button. // More button.
image = MaterialIcon.cm.moreHorizontal image = MaterialIcon.cm.moreHorizontal
let moreButton: FlatButton = FlatButton() let moreButton: IconButton = IconButton()
moreButton.pulseColor = nil
moreButton.tintColor = MaterialColor.blueGrey.darken4 moreButton.tintColor = MaterialColor.blueGrey.darken4
moreButton.setImage(image, forState: .Normal) moreButton.setImage(image, forState: .Normal)
moreButton.setImage(image, forState: .Highlighted) moreButton.setImage(image, forState: .Highlighted)
......
...@@ -105,8 +105,8 @@ class ViewController: UIViewController { ...@@ -105,8 +105,8 @@ class ViewController: UIViewController {
let closeButton: FlatButton = FlatButton() let closeButton: FlatButton = FlatButton()
closeButton.setTitle("Close", forState: .Normal) closeButton.setTitle("Close", forState: .Normal)
let image: UIImage? = UIImage(named: "ic_settings")?.imageWithRenderingMode(.AlwaysTemplate) let image: UIImage? = MaterialIcon.cm.settings
let settingButton: FlatButton = FlatButton() let settingButton: IconButton = IconButton()
settingButton.tintColor = MaterialColor.blue.accent3 settingButton.tintColor = MaterialColor.blue.accent3
settingButton.setImage(image, forState: .Normal) settingButton.setImage(image, forState: .Normal)
settingButton.setImage(image, forState: .Highlighted) settingButton.setImage(image, forState: .Highlighted)
......
...@@ -92,7 +92,6 @@ class ViewController: UIViewController, TextFieldDelegate { ...@@ -92,7 +92,6 @@ class ViewController: UIViewController, TextFieldDelegate {
nameField.detail = "Your given name" nameField.detail = "Your given name"
nameField.textAlignment = .Center nameField.textAlignment = .Center
nameField.clearButtonMode = .WhileEditing nameField.clearButtonMode = .WhileEditing
nameField.dividerActiveColor = MaterialColor.green.base
nameField.delegate = self nameField.delegate = self
// The translatesAutoresizingMaskIntoConstraints property must be set to enable AutoLayout correctly. // The translatesAutoresizingMaskIntoConstraints property must be set to enable AutoLayout correctly.
...@@ -110,7 +109,7 @@ class ViewController: UIViewController, TextFieldDelegate { ...@@ -110,7 +109,7 @@ class ViewController: UIViewController, TextFieldDelegate {
emailField = TextField(frame: CGRectMake(40, 120, view.bounds.width - 80, 32)) emailField = TextField(frame: CGRectMake(40, 120, view.bounds.width - 80, 32))
emailField.placeholder = "Email" emailField.placeholder = "Email"
emailField.detail = "Error, incorrect email" emailField.detail = "Error, incorrect email"
emailField.enableClearFlatButton = true emailField.enableClearIconButton = true
emailField.delegate = self emailField.delegate = self
emailField.placeholderColor = MaterialColor.amber.darken4 emailField.placeholderColor = MaterialColor.amber.darken4
...@@ -127,11 +126,11 @@ class ViewController: UIViewController, TextFieldDelegate { ...@@ -127,11 +126,11 @@ class ViewController: UIViewController, TextFieldDelegate {
passwordField.placeholder = "Password" passwordField.placeholder = "Password"
passwordField.detail = "At least 8 characters" passwordField.detail = "At least 8 characters"
passwordField.clearButtonMode = .WhileEditing passwordField.clearButtonMode = .WhileEditing
passwordField.enableVisibilityFlatButton = true passwordField.enableVisibilityIconButton = true
passwordField.delegate = self passwordField.delegate = self
// Setting the visibilityFlatButton color. // Setting the visibilityFlatButton color.
passwordField.visibilityFlatButton?.tintColor = MaterialColor.green.base.colorWithAlphaComponent(passwordField.secureTextEntry ? 0.38 : 0.54) passwordField.visibilityIconButton?.tintColor = MaterialColor.green.base.colorWithAlphaComponent(passwordField.secureTextEntry ? 0.38 : 0.54)
// The translatesAutoresizingMaskIntoConstraints property must be set to enable AutoLayout correctly. // The translatesAutoresizingMaskIntoConstraints property must be set to enable AutoLayout correctly.
passwordField.translatesAutoresizingMaskIntoConstraints = false passwordField.translatesAutoresizingMaskIntoConstraints = false
......
...@@ -71,7 +71,7 @@ class ViewController: UIViewController { ...@@ -71,7 +71,7 @@ class ViewController: UIViewController {
var image: UIImage? = MaterialIcon.cm.menu var image: UIImage? = MaterialIcon.cm.menu
// Menu button. // Menu button.
let menuButton: FlatButton = FlatButton() let menuButton: IconButton = IconButton()
menuButton.pulseColor = MaterialColor.white menuButton.pulseColor = MaterialColor.white
menuButton.tintColor = MaterialColor.white menuButton.tintColor = MaterialColor.white
menuButton.setImage(image, forState: .Normal) menuButton.setImage(image, forState: .Normal)
...@@ -82,7 +82,7 @@ class ViewController: UIViewController { ...@@ -82,7 +82,7 @@ class ViewController: UIViewController {
// Search button. // Search button.
image = MaterialIcon.cm.search image = MaterialIcon.cm.search
let searchButton: FlatButton = FlatButton() let searchButton: IconButton = IconButton()
searchButton.pulseColor = MaterialColor.white searchButton.pulseColor = MaterialColor.white
searchButton.tintColor = MaterialColor.white searchButton.tintColor = MaterialColor.white
searchButton.setImage(image, forState: .Normal) searchButton.setImage(image, forState: .Normal)
......
...@@ -94,8 +94,7 @@ class AppToolbarController: ToolbarController { ...@@ -94,8 +94,7 @@ class AppToolbarController: ToolbarController {
var image: UIImage? = MaterialIcon.cm.menu var image: UIImage? = MaterialIcon.cm.menu
// Menu button. // Menu button.
let menuButton: FlatButton = FlatButton() let menuButton: IconButton = IconButton()
menuButton.pulseColor = nil
menuButton.tintColor = MaterialColor.white menuButton.tintColor = MaterialColor.white
menuButton.setImage(image, forState: .Normal) menuButton.setImage(image, forState: .Normal)
menuButton.setImage(image, forState: .Highlighted) menuButton.setImage(image, forState: .Highlighted)
...@@ -107,8 +106,7 @@ class AppToolbarController: ToolbarController { ...@@ -107,8 +106,7 @@ class AppToolbarController: ToolbarController {
// Search button. // Search button.
image = MaterialIcon.cm.search image = MaterialIcon.cm.search
let searchButton: FlatButton = FlatButton() let searchButton: IconButton = IconButton()
searchButton.pulseColor = nil
searchButton.tintColor = MaterialColor.white searchButton.tintColor = MaterialColor.white
searchButton.setImage(image, forState: .Normal) searchButton.setImage(image, forState: .Normal)
searchButton.setImage(image, forState: .Highlighted) searchButton.setImage(image, forState: .Highlighted)
......
...@@ -61,7 +61,7 @@ class ViewController: UIViewController { ...@@ -61,7 +61,7 @@ class ViewController: UIViewController {
// Star button. // Star button.
let img1: UIImage? = MaterialIcon.cm.star let img1: UIImage? = MaterialIcon.cm.star
let btn1: FlatButton = FlatButton() let btn1: IconButton = IconButton()
btn1.pulseColor = MaterialColor.blueGrey.lighten1 btn1.pulseColor = MaterialColor.blueGrey.lighten1
btn1.tintColor = MaterialColor.blueGrey.lighten1 btn1.tintColor = MaterialColor.blueGrey.lighten1
btn1.setImage(img1, forState: .Normal) btn1.setImage(img1, forState: .Normal)
...@@ -69,7 +69,7 @@ class ViewController: UIViewController { ...@@ -69,7 +69,7 @@ class ViewController: UIViewController {
// Bell button. // Bell button.
let img2: UIImage? = MaterialIcon.cm.bell let img2: UIImage? = MaterialIcon.cm.bell
let btn2: FlatButton = FlatButton() let btn2: IconButton = IconButton()
btn2.pulseColor = MaterialColor.blueGrey.lighten1 btn2.pulseColor = MaterialColor.blueGrey.lighten1
btn2.tintColor = MaterialColor.blueGrey.lighten1 btn2.tintColor = MaterialColor.blueGrey.lighten1
btn2.setImage(img2, forState: .Normal) btn2.setImage(img2, forState: .Normal)
...@@ -77,7 +77,7 @@ class ViewController: UIViewController { ...@@ -77,7 +77,7 @@ class ViewController: UIViewController {
// Share button. // Share button.
let img3: UIImage? = MaterialIcon.cm.share let img3: UIImage? = MaterialIcon.cm.share
let btn3: FlatButton = FlatButton() let btn3: IconButton = IconButton()
btn3.pulseColor = MaterialColor.blueGrey.lighten1 btn3.pulseColor = MaterialColor.blueGrey.lighten1
btn3.tintColor = MaterialColor.blueGrey.lighten1 btn3.tintColor = MaterialColor.blueGrey.lighten1
btn3.setImage(img3, forState: .Normal) btn3.setImage(img3, forState: .Normal)
......
...@@ -95,7 +95,7 @@ class ViewController: UIViewController { ...@@ -95,7 +95,7 @@ class ViewController: UIViewController {
// Menu button. // Menu button.
let img1: UIImage? = MaterialIcon.cm.menu let img1: UIImage? = MaterialIcon.cm.menu
let btn1: FlatButton = FlatButton() let btn1: IconButton = IconButton()
btn1.pulseColor = MaterialColor.white btn1.pulseColor = MaterialColor.white
btn1.tintColor = MaterialColor.white btn1.tintColor = MaterialColor.white
btn1.setImage(img1, forState: .Normal) btn1.setImage(img1, forState: .Normal)
...@@ -103,7 +103,7 @@ class ViewController: UIViewController { ...@@ -103,7 +103,7 @@ class ViewController: UIViewController {
// Star button. // Star button.
let img2: UIImage? = MaterialIcon.cm.star let img2: UIImage? = MaterialIcon.cm.star
let btn2: FlatButton = FlatButton() let btn2: IconButton = IconButton()
btn2.pulseColor = MaterialColor.white btn2.pulseColor = MaterialColor.white
btn2.tintColor = MaterialColor.white btn2.tintColor = MaterialColor.white
btn2.setImage(img2, forState: .Normal) btn2.setImage(img2, forState: .Normal)
...@@ -111,7 +111,7 @@ class ViewController: UIViewController { ...@@ -111,7 +111,7 @@ class ViewController: UIViewController {
// Search button. // Search button.
let img3: UIImage? = MaterialIcon.cm.search let img3: UIImage? = MaterialIcon.cm.search
let btn3: FlatButton = FlatButton() let btn3: IconButton = IconButton()
btn3.pulseColor = MaterialColor.white btn3.pulseColor = MaterialColor.white
btn3.tintColor = MaterialColor.white btn3.tintColor = MaterialColor.white
btn3.setImage(img3, forState: .Normal) btn3.setImage(img3, forState: .Normal)
......
...@@ -9,6 +9,7 @@ ...@@ -9,6 +9,7 @@
/* Begin PBXBuildFile section */ /* Begin PBXBuildFile section */
96334EF61C8B84660083986B /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 96334EF51C8B84660083986B /* Assets.xcassets */; }; 96334EF61C8B84660083986B /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 96334EF51C8B84660083986B /* Assets.xcassets */; };
963832421B88DFD80015F710 /* Material.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 963832361B88DFD80015F710 /* Material.framework */; }; 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 */; }; 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, ); }; }; 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 */; }; 9679CEAB1CC69E080021685B /* Material+UIImage+TintColor.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9679CEAA1CC69E080021685B /* Material+UIImage+TintColor.swift */; };
...@@ -196,6 +197,7 @@ ...@@ -196,6 +197,7 @@
963832361B88DFD80015F710 /* Material.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Material.framework; sourceTree = BUILT_PRODUCTS_DIR; }; 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; }; 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>"; }; 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; }; 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; }; 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>"; }; 967887881C9777CB0037F6C9 /* MaterialViewTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MaterialViewTests.swift; sourceTree = "<group>"; };
...@@ -456,6 +458,7 @@ ...@@ -456,6 +458,7 @@
96BCB75F1CB40DC500C806FE /* FabButton.swift */, 96BCB75F1CB40DC500C806FE /* FabButton.swift */,
96BCB7601CB40DC500C806FE /* FlatButton.swift */, 96BCB7601CB40DC500C806FE /* FlatButton.swift */,
96BCB7931CB40DC500C806FE /* RaisedButton.swift */, 96BCB7931CB40DC500C806FE /* RaisedButton.swift */,
9658F2161CD6FA4700B902C1 /* IconButton.swift */,
); );
name = Button; name = Button;
sourceTree = "<group>"; sourceTree = "<group>";
...@@ -869,6 +872,7 @@ ...@@ -869,6 +872,7 @@
96BCB7C01CB40DC500C806FE /* MaterialDataSourceItem.swift in Sources */, 96BCB7C01CB40DC500C806FE /* MaterialDataSourceItem.swift in Sources */,
96BCB7AC1CB40DC500C806FE /* Material+Obj-C.swift in Sources */, 96BCB7AC1CB40DC500C806FE /* Material+Obj-C.swift in Sources */,
9679CEAB1CC69E080021685B /* Material+UIImage+TintColor.swift in Sources */, 9679CEAB1CC69E080021685B /* Material+UIImage+TintColor.swift in Sources */,
9658F2171CD6FA4700B902C1 /* IconButton.swift in Sources */,
96BCB7BB1CB40DC500C806FE /* MaterialCollectionViewCell.swift in Sources */, 96BCB7BB1CB40DC500C806FE /* MaterialCollectionViewCell.swift in Sources */,
96BCB7CF1CB40DC500C806FE /* MaterialShape.swift in Sources */, 96BCB7CF1CB40DC500C806FE /* MaterialShape.swift in Sources */,
96BCB7DF1CB40DC500C806FE /* SearchBarController.swift in Sources */, 96BCB7DF1CB40DC500C806FE /* SearchBarController.swift in Sources */,
......
...@@ -126,6 +126,7 @@ public class BottomNavigationController : UITabBarController, UITabBarController ...@@ -126,6 +126,7 @@ public class BottomNavigationController : UITabBarController, UITabBarController
*/ */
public func prepareView() { public func prepareView() {
view.clipsToBounds = true view.clipsToBounds = true
view.contentScaleFactor = MaterialDevice.scale
delegate = self delegate = self
prepareTabBar() prepareTabBar()
} }
......
...@@ -249,6 +249,7 @@ public class BottomTabBar : UITabBar { ...@@ -249,6 +249,7 @@ public class BottomTabBar : UITabBar {
*/ */
public func prepareView() { public func prepareView() {
depth = .Depth1 depth = .Depth1
contentScaleFactor = MaterialDevice.scale
backgroundColor = MaterialColor.white backgroundColor = MaterialColor.white
let image: UIImage? = UIImage.imageWithColor(MaterialColor.clear, size: CGSizeMake(1, 1)) let image: UIImage? = UIImage.imageWithColor(MaterialColor.clear, size: CGSizeMake(1, 1))
shadowImage = image shadowImage = image
......
...@@ -409,7 +409,6 @@ public class CardView : MaterialPulseView { ...@@ -409,7 +409,6 @@ public class CardView : MaterialPulseView {
*/ */
public override func prepareView() { public override func prepareView() {
super.prepareView() super.prepareView()
pulseColor = MaterialColor.grey.lighten1
depth = .Depth1 depth = .Depth1
dividerColor = MaterialColor.grey.lighten3 dividerColor = MaterialColor.grey.lighten3
cornerRadiusPreset = .Radius1 cornerRadiusPreset = .Radius1
......
...@@ -42,8 +42,9 @@ public class FabButton : MaterialButton { ...@@ -42,8 +42,9 @@ public class FabButton : MaterialButton {
super.prepareView() super.prepareView()
depth = .Depth1 depth = .Depth1
shape = .Circle shape = .Circle
backgroundColor = MaterialColor.blue.base pulseAnimation = .Center
pulseColor = MaterialColor.white pulseColor = MaterialColor.white
tintColor = MaterialColor.white tintColor = MaterialColor.white
backgroundColor = MaterialColor.blue.base
} }
} }
\ No newline at end of file
/*
* 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
...@@ -550,7 +550,6 @@ public class ImageCardView : MaterialPulseView { ...@@ -550,7 +550,6 @@ public class ImageCardView : MaterialPulseView {
*/ */
public override func prepareView() { public override func prepareView() {
super.prepareView() super.prepareView()
pulseColor = MaterialColor.grey.lighten1
depth = .Depth1 depth = .Depth1
dividerColor = MaterialColor.grey.lighten3 dividerColor = MaterialColor.grey.lighten3
cornerRadiusPreset = .Radius1 cornerRadiusPreset = .Radius1
......
...@@ -50,13 +50,17 @@ public class MaterialButton : UIButton { ...@@ -50,13 +50,17 @@ public class MaterialButton : UIButton {
public private(set) lazy var pulseLayers: Array<CAShapeLayer> = Array<CAShapeLayer>() public private(set) lazy var pulseLayers: Array<CAShapeLayer> = Array<CAShapeLayer>()
/// The opacity value for the pulse animation. /// 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. /// The color of the pulse effect.
@IBInspectable public var pulseColor: UIColor? @IBInspectable public var pulseColor: UIColor = MaterialColor.grey.base
/// The type of PulseAnimation. /// 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 This property is the same as clipsToBounds. It crops any of the view's
...@@ -411,7 +415,7 @@ public class MaterialButton : UIButton { ...@@ -411,7 +415,7 @@ public class MaterialButton : UIButton {
} }
MaterialAnimation.delay(0.35) { [weak self] in MaterialAnimation.delay(0.35) { [weak self] in
if let s: MaterialButton = self { 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 { ...@@ -435,7 +439,7 @@ public class MaterialButton : UIButton {
*/ */
public override func touchesEnded(touches: Set<UITouch>, withEvent event: UIEvent?) { public override func touchesEnded(touches: Set<UITouch>, withEvent event: UIEvent?) {
super.touchesEnded(touches, withEvent: event) 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 { ...@@ -446,7 +450,7 @@ public class MaterialButton : UIButton {
*/ */
public override func touchesCancelled(touches: Set<UITouch>?, withEvent event: UIEvent?) { public override func touchesCancelled(touches: Set<UITouch>?, withEvent event: UIEvent?) {
super.touchesCancelled(touches, withEvent: event) 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 { ...@@ -457,7 +461,6 @@ public class MaterialButton : UIButton {
when subclassing. when subclassing.
*/ */
public func prepareView() { public func prepareView() {
pulseColor = MaterialColor.black
contentScaleFactor = MaterialDevice.scale contentScaleFactor = MaterialDevice.scale
prepareVisualLayer() prepareVisualLayer()
} }
......
...@@ -118,6 +118,7 @@ public class MaterialCollectionView : UICollectionView { ...@@ -118,6 +118,7 @@ public class MaterialCollectionView : UICollectionView {
when subclassing. when subclassing.
*/ */
public func prepareView() { public func prepareView() {
contentScaleFactor = MaterialDevice.scale
backgroundColor = MaterialColor.clear backgroundColor = MaterialColor.clear
contentInset = UIEdgeInsetsZero contentInset = UIEdgeInsetsZero
} }
......
...@@ -50,13 +50,17 @@ public class MaterialCollectionViewCell : UICollectionViewCell { ...@@ -50,13 +50,17 @@ public class MaterialCollectionViewCell : UICollectionViewCell {
public private(set) lazy var pulseLayers: Array<CAShapeLayer> = Array<CAShapeLayer>() public private(set) lazy var pulseLayers: Array<CAShapeLayer> = Array<CAShapeLayer>()
/// The opcaity value for the pulse animation. /// 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. /// The color of the pulse effect.
@IBInspectable public var pulseColor: UIColor? @IBInspectable public var pulseColor: UIColor = MaterialColor.grey.base
/// The type of PulseAnimation. /// 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 A property that manages an image for the visualLayer's contents
...@@ -516,7 +520,7 @@ public class MaterialCollectionViewCell : UICollectionViewCell { ...@@ -516,7 +520,7 @@ public class MaterialCollectionViewCell : UICollectionViewCell {
} }
MaterialAnimation.delay(0.35) { [weak self] in MaterialAnimation.delay(0.35) { [weak self] in
if let s: MaterialCollectionViewCell = self { 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 { ...@@ -540,7 +544,7 @@ public class MaterialCollectionViewCell : UICollectionViewCell {
*/ */
public override func touchesEnded(touches: Set<UITouch>, withEvent event: UIEvent?) { public override func touchesEnded(touches: Set<UITouch>, withEvent event: UIEvent?) {
super.touchesEnded(touches, withEvent: event) 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 { ...@@ -551,7 +555,7 @@ public class MaterialCollectionViewCell : UICollectionViewCell {
*/ */
public override func touchesCancelled(touches: Set<UITouch>?, withEvent event: UIEvent?) { public override func touchesCancelled(touches: Set<UITouch>?, withEvent event: UIEvent?) {
super.touchesCancelled(touches, withEvent: event) 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 { ...@@ -562,7 +566,6 @@ public class MaterialCollectionViewCell : UICollectionViewCell {
when subclassing. when subclassing.
*/ */
public func prepareView() { public func prepareView() {
pulseColor = MaterialColor.black
contentScaleFactor = MaterialDevice.scale contentScaleFactor = MaterialDevice.scale
prepareVisualLayer() prepareVisualLayer()
} }
......
...@@ -147,6 +147,7 @@ public class MaterialLabel : UILabel { ...@@ -147,6 +147,7 @@ public class MaterialLabel : UILabel {
:name: prepareView :name: prepareView
*/ */
public func prepareView() { public func prepareView() {
contentScaleFactor = MaterialDevice.scale
textAlignment = .Left textAlignment = .Left
} }
} }
\ No newline at end of file
...@@ -34,6 +34,7 @@ public enum PulseAnimation { ...@@ -34,6 +34,7 @@ public enum PulseAnimation {
case None case None
case Center case Center
case CenterWithBacking case CenterWithBacking
case CenterRadialBeyondBounds
case Backing case Backing
case AtPoint case AtPoint
case AtPointWithBacking case AtPointWithBacking
...@@ -51,11 +52,9 @@ internal extension MaterialAnimation { ...@@ -51,11 +52,9 @@ internal extension MaterialAnimation {
- Parameter duration: Animation duration. - Parameter duration: Animation duration.
- Parameter pulseLayers: An Array of CAShapeLayers used in the animation. - 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 .None != pulseAnimation {
if let color: UIColor = pulseColor { if let n: CGFloat = .Center == pulseAnimation ? width < height ? width : height : width < height ? height : width {
if let n: CGFloat = width < height ? height : width {
if let pOpacity: CGFloat = pulseOpacity {
let bLayer: CAShapeLayer = CAShapeLayer() let bLayer: CAShapeLayer = CAShapeLayer()
let pLayer: CAShapeLayer = CAShapeLayer() let pLayer: CAShapeLayer = CAShapeLayer()
bLayer.addSublayer(pLayer) bLayer.addSublayer(pLayer)
...@@ -65,34 +64,32 @@ internal extension MaterialAnimation { ...@@ -65,34 +64,32 @@ internal extension MaterialAnimation {
bLayer.frame = visualLayer.bounds bLayer.frame = visualLayer.bounds
pLayer.bounds = CGRectMake(0, 0, n, n) pLayer.bounds = CGRectMake(0, 0, n, n)
switch pulseAnimation { switch pulseAnimation {
case .Center, .CenterWithBacking: case .Center, .CenterWithBacking, .CenterRadialBeyondBounds:
pLayer.position = CGPointMake(width / 2, height / 2) pLayer.position = CGPointMake(width / 2, height / 2)
default: default:
pLayer.position = point pLayer.position = point
} }
pLayer.cornerRadius = n / 2 pLayer.cornerRadius = n / 2
pLayer.backgroundColor = color.colorWithAlphaComponent(pOpacity).CGColor pLayer.backgroundColor = pulseColor.colorWithAlphaComponent(pulseOpacity).CGColor
pLayer.transform = CATransform3DMakeAffineTransform(CGAffineTransformMakeScale(0, 0)) pLayer.transform = CATransform3DMakeAffineTransform(CGAffineTransformMakeScale(0, 0))
}) })
bLayer.setValue(false, forKey: "animated") bLayer.setValue(false, forKey: "animated")
switch pulseAnimation { switch pulseAnimation {
case .CenterWithBacking, .Backing, .AtPointWithBacking: case .CenterWithBacking, .Backing, .AtPointWithBacking:
bLayer.addAnimation(MaterialAnimation.backgroundColor(color.colorWithAlphaComponent(pOpacity / 2), duration: 0.35), forKey: nil) bLayer.addAnimation(MaterialAnimation.backgroundColor(pulseColor.colorWithAlphaComponent(pulseOpacity / 2), duration: 0.325), forKey: nil)
default:break default:break
} }
switch pulseAnimation { switch pulseAnimation {
case .Center, .CenterWithBacking, .AtPoint, .AtPointWithBacking: case .Center, .CenterWithBacking, .CenterRadialBeyondBounds, .AtPoint, .AtPointWithBacking:
pLayer.addAnimation(MaterialAnimation.scale(1, duration: 0.35), forKey: nil) pLayer.addAnimation(MaterialAnimation.scale(1, duration: 0.325), forKey: nil)
default:break default:break
} }
MaterialAnimation.delay(0.35, completion: { MaterialAnimation.delay(0.325, completion: {
bLayer.setValue(true, forKey: "animated") bLayer.setValue(true, forKey: "animated")
}) })
} }
} }
} }
}
}
/** /**
Triggers the contracting animation. Triggers the contracting animation.
...@@ -100,26 +97,25 @@ internal extension MaterialAnimation { ...@@ -100,26 +97,25 @@ internal extension MaterialAnimation {
- Parameter pulseColor: The UIColor for the pulse. - Parameter pulseColor: The UIColor for the pulse.
- Parameter pulseLayers: An Array of CAShapeLayers used in the animation. - Parameter pulseLayers: An Array of CAShapeLayers used in the animation.
*/ */
internal static func pulseContractAnimation(layer: CALayer, pulseColor: UIColor?, inout pulseLayers: Array<CAShapeLayer>, pulseAnimation: PulseAnimation) { internal static func pulseContractAnimation(layer: CALayer, visualLayer: CALayer, pulseColor: UIColor, inout pulseLayers: Array<CAShapeLayer>, pulseAnimation: PulseAnimation) {
if let color: UIColor = pulseColor {
if let bLayer: CAShapeLayer = pulseLayers.popLast() { if let bLayer: CAShapeLayer = pulseLayers.popLast() {
let animated: Bool? = bLayer.valueForKey("animated") as? Bool let animated: Bool? = bLayer.valueForKey("animated") as? Bool
MaterialAnimation.delay(true == animated ? 0 : 0.15) { MaterialAnimation.delay(true == animated ? 0 : 0.15) {
if let pLayer: CAShapeLayer = bLayer.sublayers?.first as? CAShapeLayer { if let pLayer: CAShapeLayer = bLayer.sublayers?.first as? CAShapeLayer {
switch pulseAnimation { switch pulseAnimation {
case .CenterWithBacking, .Backing, .AtPointWithBacking: case .CenterWithBacking, .Backing, .AtPointWithBacking:
bLayer.addAnimation(MaterialAnimation.backgroundColor(color.colorWithAlphaComponent(0), duration: 0.35), forKey: nil) bLayer.addAnimation(MaterialAnimation.backgroundColor(pulseColor.colorWithAlphaComponent(0), duration: 0.325), forKey: nil)
default:break default:break
} }
switch pulseAnimation { switch pulseAnimation {
case .Center, .CenterWithBacking, .AtPoint, .AtPointWithBacking: case .Center, .CenterWithBacking, .CenterRadialBeyondBounds, .AtPoint, .AtPointWithBacking:
pLayer.addAnimation(MaterialAnimation.animationGroup([ pLayer.addAnimation(MaterialAnimation.animationGroup([
MaterialAnimation.scale(1.35), MaterialAnimation.scale(.Center == pulseAnimation ? 1 : 1.325),
MaterialAnimation.backgroundColor(color.colorWithAlphaComponent(0)) MaterialAnimation.backgroundColor(pulseColor.colorWithAlphaComponent(0))
], duration: 0.35), forKey: nil) ], duration: 0.325), forKey: nil)
default:break default:break
} }
MaterialAnimation.delay(0.35) { MaterialAnimation.delay(0.325) {
pLayer.removeFromSuperlayer() pLayer.removeFromSuperlayer()
bLayer.removeFromSuperlayer() bLayer.removeFromSuperlayer()
} }
...@@ -127,5 +123,4 @@ internal extension MaterialAnimation { ...@@ -127,5 +123,4 @@ internal extension MaterialAnimation {
} }
} }
} }
}
} }
\ No newline at end of file
...@@ -38,13 +38,17 @@ public class MaterialPulseView : MaterialView { ...@@ -38,13 +38,17 @@ public class MaterialPulseView : MaterialView {
public private(set) lazy var pulseLayers: Array<CAShapeLayer> = Array<CAShapeLayer>() public private(set) lazy var pulseLayers: Array<CAShapeLayer> = Array<CAShapeLayer>()
/// The opcaity value for the pulse animation. /// 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. /// The color of the pulse effect.
@IBInspectable public var pulseColor: UIColor? @IBInspectable public var pulseColor: UIColor = MaterialColor.grey.base
/// The type of PulseAnimation. /// The type of PulseAnimation.
public var pulseAnimation: PulseAnimation = .AtPointWithBacking public var pulseAnimation: PulseAnimation = .AtPointWithBacking {
didSet {
visualLayer.masksToBounds = .CenterRadialBeyondBounds != pulseAnimation
}
}
/** /**
Triggers the pulse animation. Triggers the pulse animation.
...@@ -58,7 +62,7 @@ public class MaterialPulseView : MaterialView { ...@@ -58,7 +62,7 @@ public class MaterialPulseView : MaterialView {
} }
MaterialAnimation.delay(0.35) { [weak self] in MaterialAnimation.delay(0.35) { [weak self] in
if let s: MaterialPulseView = self { 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 { ...@@ -82,7 +86,7 @@ public class MaterialPulseView : MaterialView {
*/ */
public override func touchesEnded(touches: Set<UITouch>, withEvent event: UIEvent?) { public override func touchesEnded(touches: Set<UITouch>, withEvent event: UIEvent?) {
super.touchesEnded(touches, withEvent: event) 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 { ...@@ -93,19 +97,6 @@ public class MaterialPulseView : MaterialView {
*/ */
public override func touchesCancelled(touches: Set<UITouch>?, withEvent event: UIEvent?) { public override func touchesCancelled(touches: Set<UITouch>?, withEvent event: UIEvent?) {
super.touchesCancelled(touches, withEvent: event) 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)
}
/**
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
} }
} }
...@@ -434,7 +434,7 @@ public class MaterialSwitch : UIControl { ...@@ -434,7 +434,7 @@ public class MaterialSwitch : UIControl {
/// Prepares the button. /// Prepares the button.
private func prepareButton() { private func prepareButton() {
button.pulseColor = nil button.pulseAnimation = .None
button.addTarget(self, action: #selector(handleTouchUpInside), forControlEvents: .TouchUpInside) button.addTarget(self, action: #selector(handleTouchUpInside), forControlEvents: .TouchUpInside)
button.addTarget(self, action: #selector(handleTouchDragInside), forControlEvents: .TouchDragInside) button.addTarget(self, action: #selector(handleTouchDragInside), forControlEvents: .TouchDragInside)
button.addTarget(self, action: #selector(handleTouchUpOutsideOrCanceled), forControlEvents: .TouchCancel) button.addTarget(self, action: #selector(handleTouchUpOutsideOrCanceled), forControlEvents: .TouchCancel)
......
...@@ -49,13 +49,17 @@ public class MaterialTableViewCell : UITableViewCell { ...@@ -49,13 +49,17 @@ public class MaterialTableViewCell : UITableViewCell {
public private(set) lazy var pulseLayers: Array<CAShapeLayer> = Array<CAShapeLayer>() public private(set) lazy var pulseLayers: Array<CAShapeLayer> = Array<CAShapeLayer>()
/// The opcaity value for the pulse animation. /// 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. /// The color of the pulse effect.
@IBInspectable public var pulseColor: UIColor? @IBInspectable public var pulseColor: UIColor = MaterialColor.grey.base
/// The type of PulseAnimation. /// 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 This property is the same as clipsToBounds. It crops any of the view's
...@@ -366,7 +370,7 @@ public class MaterialTableViewCell : UITableViewCell { ...@@ -366,7 +370,7 @@ public class MaterialTableViewCell : UITableViewCell {
} }
MaterialAnimation.delay(0.35) { [weak self] in MaterialAnimation.delay(0.35) { [weak self] in
if let s: MaterialTableViewCell = self { 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 { ...@@ -390,7 +394,7 @@ public class MaterialTableViewCell : UITableViewCell {
*/ */
public override func touchesEnded(touches: Set<UITouch>, withEvent event: UIEvent?) { public override func touchesEnded(touches: Set<UITouch>, withEvent event: UIEvent?) {
super.touchesEnded(touches, withEvent: event) 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 { ...@@ -401,7 +405,7 @@ public class MaterialTableViewCell : UITableViewCell {
*/ */
public override func touchesCancelled(touches: Set<UITouch>?, withEvent event: UIEvent?) { public override func touchesCancelled(touches: Set<UITouch>?, withEvent event: UIEvent?) {
super.touchesCancelled(touches, withEvent: event) 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 { ...@@ -412,13 +416,12 @@ public class MaterialTableViewCell : UITableViewCell {
when subclassing. when subclassing.
*/ */
public func prepareView() { public func prepareView() {
prepareVisualLayer()
selectionStyle = .None selectionStyle = .None
pulseColor = MaterialColor.black
contentScaleFactor = MaterialDevice.scale contentScaleFactor = MaterialDevice.scale
imageView?.userInteractionEnabled = false imageView?.userInteractionEnabled = false
textLabel?.userInteractionEnabled = false textLabel?.userInteractionEnabled = false
detailTextLabel?.userInteractionEnabled = false detailTextLabel?.userInteractionEnabled = false
prepareVisualLayer()
} }
/// Prepares the visualLayer property. /// Prepares the visualLayer property.
......
...@@ -457,8 +457,9 @@ public class MaterialView : UIView { ...@@ -457,8 +457,9 @@ public class MaterialView : UIView {
when subclassing. when subclassing.
*/ */
public func prepareView() { public func prepareView() {
prepareVisualLayer() contentScaleFactor = MaterialDevice.scale
backgroundColor = MaterialColor.white backgroundColor = MaterialColor.white
prepareVisualLayer()
} }
/// Prepares the visualLayer property. /// Prepares the visualLayer property.
......
...@@ -43,7 +43,7 @@ public class MenuView : MaterialPulseView { ...@@ -43,7 +43,7 @@ public class MenuView : MaterialPulseView {
*/ */
public override func prepareView() { public override func prepareView() {
super.prepareView() super.prepareView()
pulseColor = nil pulseAnimation = .None
clipsToBounds = false clipsToBounds = false
backgroundColor = nil backgroundColor = nil
} }
......
...@@ -172,9 +172,16 @@ public class MenuViewController : UIViewController { ...@@ -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.clipsToBounds = true
view.contentScaleFactor = MaterialDevice.scale
prepareMenuView() prepareMenuView()
prepareRootViewController() prepareRootViewController()
} }
......
...@@ -51,7 +51,7 @@ public class NavigationBar : UINavigationBar { ...@@ -51,7 +51,7 @@ public class NavigationBar : UINavigationBar {
private var rightSpacer: UIBarButtonItem = UIBarButtonItem(barButtonSystemItem: .FixedSpace, target: nil, action: nil) private var rightSpacer: UIBarButtonItem = UIBarButtonItem(barButtonSystemItem: .FixedSpace, target: nil, action: nil)
/// Reference to the backButton. /// Reference to the backButton.
public private(set) lazy var backButton: FlatButton = FlatButton() public private(set) lazy var backButton: IconButton = IconButton()
/** /**
The back button image writes to the backIndicatorImage property and The back button image writes to the backIndicatorImage property and
...@@ -402,6 +402,7 @@ public class NavigationBar : UINavigationBar { ...@@ -402,6 +402,7 @@ public class NavigationBar : UINavigationBar {
backgroundColor = MaterialColor.white backgroundColor = MaterialColor.white
depth = .Depth1 depth = .Depth1
contentInsetPreset = .Square1 contentInsetPreset = .Square1
contentScaleFactor = MaterialDevice.scale
prepareBackButton() prepareBackButton()
} }
......
...@@ -130,8 +130,15 @@ public class NavigationController : UINavigationController, UIGestureRecognizerD ...@@ -130,8 +130,15 @@ public class NavigationController : UINavigationController, UIGestureRecognizerD
popViewControllerAnimated(true) 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.clipsToBounds = true
view.contentScaleFactor = MaterialDevice.scale
} }
} }
...@@ -35,7 +35,7 @@ public class SearchBar : StatusBarView { ...@@ -35,7 +35,7 @@ public class SearchBar : StatusBarView {
public private(set) var textField: UITextField! public private(set) var textField: UITextField!
/// Reference to the clearButton. /// Reference to the clearButton.
public private(set) var clearButton: FlatButton! public private(set) var clearButton: IconButton!
/// Handle the clearButton manually. /// Handle the clearButton manually.
@IBInspectable public var clearButtonAutoHandleEnabled: Bool = true { @IBInspectable public var clearButtonAutoHandleEnabled: Bool = true {
...@@ -126,10 +126,8 @@ public class SearchBar : StatusBarView { ...@@ -126,10 +126,8 @@ public class SearchBar : StatusBarView {
/// Prepares the clearButton. /// Prepares the clearButton.
private func prepareClearButton() { private func prepareClearButton() {
let image: UIImage? = MaterialIcon.cm.close let image: UIImage? = MaterialIcon.cm.close
clearButton = FlatButton() clearButton = IconButton()
clearButton.contentEdgeInsets = UIEdgeInsetsZero clearButton.contentEdgeInsets = UIEdgeInsetsZero
clearButton.pulseColor = MaterialColor.black
clearButton.pulseOpacity = 0.12
clearButton.tintColor = placeholderTextColor clearButton.tintColor = placeholderTextColor
clearButton.setImage(image, forState: .Normal) clearButton.setImage(image, forState: .Normal)
clearButton.setImage(image, forState: .Highlighted) clearButton.setImage(image, forState: .Highlighted)
......
...@@ -748,9 +748,16 @@ public class SideNavigationController : UIViewController, UIGestureRecognizerDel ...@@ -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.clipsToBounds = true
view.contentScaleFactor = MaterialDevice.scale
prepareRootViewController() prepareRootViewController()
prepareLeftView() prepareLeftView()
prepareRightView() prepareRightView()
......
...@@ -136,6 +136,7 @@ public class StatusBarViewController : UIViewController { ...@@ -136,6 +136,7 @@ public class StatusBarViewController : UIViewController {
*/ */
public func prepareView() { public func prepareView() {
view.clipsToBounds = true view.clipsToBounds = true
view.contentScaleFactor = MaterialDevice.scale
prepareRootViewController() prepareRootViewController()
} }
......
...@@ -107,6 +107,7 @@ public class TabBar : MaterialView { ...@@ -107,6 +107,7 @@ public class TabBar : MaterialView {
public override func prepareView() { public override func prepareView() {
super.prepareView() super.prepareView()
autoresizingMask = .FlexibleWidth autoresizingMask = .FlexibleWidth
contentScaleFactor = MaterialDevice.scale
prepareBottomLayer() prepareBottomLayer()
} }
......
...@@ -148,7 +148,7 @@ public class TextField : UITextField { ...@@ -148,7 +148,7 @@ public class TextField : UITextField {
/// The placeholderLabel font value. /// The placeholderLabel font value.
@IBInspectable public override var font: UIFont? { @IBInspectable public override var font: UIFont? {
didSet { didSet {
placeholderLabel.font = self.font placeholderLabel.font = font
} }
} }
...@@ -243,87 +243,87 @@ public class TextField : UITextField { ...@@ -243,87 +243,87 @@ public class TextField : UITextField {
} }
} }
/// Enables the clearFlatButton. /// Enables the clearIconButton.
@IBInspectable public var enableClearFlatButton: Bool { @IBInspectable public var enableClearIconButton: Bool {
get { get {
return nil != clearFlatButton return nil != clearIconButton
} }
set(value) { set(value) {
if value { if value {
if nil == clearFlatButton { if nil == clearIconButton {
let image: UIImage? = MaterialIcon.cm.clear let image: UIImage? = MaterialIcon.cm.clear
clearFlatButton = FlatButton(frame: CGRectZero) clearIconButton = IconButton(frame: CGRectZero)
clearFlatButton!.contentEdgeInsets = UIEdgeInsetsZero clearIconButton!.contentEdgeInsets = UIEdgeInsetsZero
clearFlatButton!.pulseColor = nil clearIconButton!.pulseAnimation = .Center
clearFlatButton!.tintColor = placeholderColor clearIconButton!.tintColor = placeholderColor
clearFlatButton!.setImage(image, forState: .Normal) clearIconButton!.setImage(image, forState: .Normal)
clearFlatButton!.setImage(image, forState: .Highlighted) clearIconButton!.setImage(image, forState: .Highlighted)
clearButtonMode = .Never clearButtonMode = .Never
rightViewMode = .WhileEditing rightViewMode = .WhileEditing
rightView = clearFlatButton rightView = clearIconButton
clearFlatButtonAutoHandle = clearFlatButtonAutoHandle ? true : false clearIconButtonAutoHandle = clearIconButtonAutoHandle ? true : false
} }
} else { } else {
clearFlatButton?.removeTarget(self, action: #selector(handleClearButton), forControlEvents: .TouchUpInside) clearIconButton?.removeTarget(self, action: #selector(handleClearButton), forControlEvents: .TouchUpInside)
clearFlatButton = nil clearIconButton = nil
} }
} }
} }
/// Enables the automatic handling of the clearFlatButton. /// Enables the automatic handling of the clearIconButton.
@IBInspectable public var clearFlatButtonAutoHandle: Bool = true { @IBInspectable public var clearIconButtonAutoHandle: Bool = true {
didSet { didSet {
clearFlatButton?.removeTarget(self, action: #selector(handleClearButton), forControlEvents: .TouchUpInside) clearIconButton?.removeTarget(self, action: #selector(handleClearButton), forControlEvents: .TouchUpInside)
if clearFlatButtonAutoHandle { if clearIconButtonAutoHandle {
clearFlatButton?.addTarget(self, action: #selector(handleClearButton), forControlEvents: .TouchUpInside) clearIconButton?.addTarget(self, action: #selector(handleClearButton), forControlEvents: .TouchUpInside)
} }
} }
} }
/// Enables the visibilityFlatButton. /// Enables the visibilityIconButton.
@IBInspectable public var enableVisibilityFlatButton: Bool { @IBInspectable public var enableVisibilityIconButton: Bool {
get { get {
return nil != visibilityFlatButton return nil != visibilityIconButton
} }
set(value) { set(value) {
if value { if value {
if nil == visibilityFlatButton { if nil == visibilityIconButton {
let image: UIImage? = MaterialIcon.visibility let image: UIImage? = MaterialIcon.visibility
visibilityFlatButton = FlatButton(frame: CGRectZero) visibilityIconButton = IconButton(frame: CGRectZero)
visibilityFlatButton!.contentEdgeInsets = UIEdgeInsetsZero visibilityIconButton!.contentEdgeInsets = UIEdgeInsetsZero
visibilityFlatButton!.pulseColor = nil visibilityIconButton!.pulseAnimation = .Center
visibilityFlatButton!.tintColor = placeholderColor visibilityIconButton!.tintColor = placeholderColor
visibilityFlatButton!.setImage(image, forState: .Normal) visibilityIconButton!.setImage(image, forState: .Normal)
visibilityFlatButton!.setImage(image, forState: .Highlighted) visibilityIconButton!.setImage(image, forState: .Highlighted)
visibilityFlatButton!.tintColor = placeholderColor.colorWithAlphaComponent(secureTextEntry ? 0.38 : 0.54) visibilityIconButton!.tintColor = placeholderColor.colorWithAlphaComponent(secureTextEntry ? 0.38 : 0.54)
secureTextEntry = true secureTextEntry = true
clearButtonMode = .Never clearButtonMode = .Never
rightViewMode = .WhileEditing rightViewMode = .WhileEditing
rightView = visibilityFlatButton rightView = visibilityIconButton
visibilityFlatButtonAutoHandle = visibilityFlatButtonAutoHandle ? true : false visibilityIconButtonAutoHandle = visibilityIconButtonAutoHandle ? true : false
} }
} else { } else {
visibilityFlatButton?.removeTarget(self, action: #selector(handleClearButton), forControlEvents: .TouchUpInside) visibilityIconButton?.removeTarget(self, action: #selector(handleClearButton), forControlEvents: .TouchUpInside)
visibilityFlatButton = nil visibilityIconButton = nil
} }
} }
} }
/// Enables the automatic handling of the visibilityFlatButton. /// Enables the automatic handling of the visibilityIconButton.
@IBInspectable public var visibilityFlatButtonAutoHandle: Bool = true { @IBInspectable public var visibilityIconButtonAutoHandle: Bool = true {
didSet { didSet {
visibilityFlatButton?.removeTarget(self, action: #selector(handleVisibilityButton), forControlEvents: .TouchUpInside) visibilityIconButton?.removeTarget(self, action: #selector(handleVisibilityButton), forControlEvents: .TouchUpInside)
if visibilityFlatButtonAutoHandle { if visibilityIconButtonAutoHandle {
visibilityFlatButton?.addTarget(self, action: #selector(handleVisibilityButton), forControlEvents: .TouchUpInside) visibilityIconButton?.addTarget(self, action: #selector(handleVisibilityButton), forControlEvents: .TouchUpInside)
} }
} }
} }
/// A reference to the clearFlatButton. /// A reference to the clearIconButton.
public private(set) var clearFlatButton: FlatButton? public private(set) var clearIconButton: IconButton?
/// A reference to the visibilityFlatButton. /// A reference to the visibilityIconButton.
public private(set) var visibilityFlatButton: FlatButton? public private(set) var visibilityIconButton: IconButton?
/** /**
An initializer that initializes the object with a NSCoder object. An initializer that initializes the object with a NSCoder object.
...@@ -433,7 +433,7 @@ public class TextField : UITextField { ...@@ -433,7 +433,7 @@ public class TextField : UITextField {
placeholderEditingDidEndAnimation() placeholderEditingDidEndAnimation()
} }
/// Handles the clearFlatButton TouchUpInside event. /// Handles the clearIconButton TouchUpInside event.
public func handleClearButton() { public func handleClearButton() {
if false == delegate?.textFieldShouldClear?(self) { if false == delegate?.textFieldShouldClear?(self) {
return return
...@@ -441,10 +441,10 @@ public class TextField : UITextField { ...@@ -441,10 +441,10 @@ public class TextField : UITextField {
text = nil text = nil
} }
/// Handles the visibilityFlatButton TouchUpInside event. /// Handles the visibilityIconButton TouchUpInside event.
public func handleVisibilityButton() { public func handleVisibilityButton() {
secureTextEntry = !secureTextEntry secureTextEntry = !secureTextEntry
visibilityFlatButton?.tintColor = visibilityFlatButton?.tintColor.colorWithAlphaComponent(secureTextEntry ? 0.38 : 0.54) visibilityIconButton?.tintColor = visibilityIconButton?.tintColor.colorWithAlphaComponent(secureTextEntry ? 0.38 : 0.54)
} }
/** /**
...@@ -455,12 +455,13 @@ public class TextField : UITextField { ...@@ -455,12 +455,13 @@ public class TextField : UITextField {
when subclassing. when subclassing.
*/ */
public func prepareView() { public func prepareView() {
super.placeholder = nil
masksToBounds = false masksToBounds = false
borderStyle = .None borderStyle = .None
backgroundColor = nil backgroundColor = nil
super.placeholder = nil
textColor = MaterialColor.darkText.primary textColor = MaterialColor.darkText.primary
font = RobotoFont.regularWithSize(16) font = RobotoFont.regularWithSize(16)
contentScaleFactor = MaterialDevice.scale
prepareDivider() prepareDivider()
preparePlaceholderLabel() preparePlaceholderLabel()
prepareDetailLabel() prepareDetailLabel()
...@@ -472,8 +473,8 @@ public class TextField : UITextField { ...@@ -472,8 +473,8 @@ public class TextField : UITextField {
if !animating { if !animating {
layoutPlaceholderLabel() layoutPlaceholderLabel()
layoutDetailLabel() layoutDetailLabel()
layoutClearFlatButton() layoutClearIconButton()
layoutVisibilityFlatButton() layoutVisibilityIconButton()
} }
} }
...@@ -518,18 +519,18 @@ public class TextField : UITextField { ...@@ -518,18 +519,18 @@ public class TextField : UITextField {
detailLabel.frame = CGRectMake(0, divider.frame.origin.y + 8, width, h) detailLabel.frame = CGRectMake(0, divider.frame.origin.y + 8, width, h)
} }
/// Layout the clearFlatButton. /// Layout the clearIconButton.
public func layoutClearFlatButton() { public func layoutClearIconButton() {
if let v: FlatButton = clearFlatButton { if let v: IconButton = clearIconButton {
if 0 < width && 0 < height { if 0 < width && 0 < height {
v.frame = CGRectMake(width - height, 0, height, height) v.frame = CGRectMake(width - height, 0, height, height)
} }
} }
} }
/// Layout the visibilityFlatButton. /// Layout the visibilityIconButton.
public func layoutVisibilityFlatButton() { public func layoutVisibilityIconButton() {
if let v: FlatButton = visibilityFlatButton { if let v: IconButton = visibilityIconButton {
if 0 < width && 0 < height { if 0 < width && 0 < height {
v.frame = CGRectMake(width - height, 0, height, height) v.frame = CGRectMake(width - height, 0, height, height)
} }
......
...@@ -467,6 +467,7 @@ public class TextView: UITextView { ...@@ -467,6 +467,7 @@ public class TextView: UITextView {
when subclassing. when subclassing.
*/ */
public func prepareView() { public func prepareView() {
contentScaleFactor = MaterialDevice.scale
textContainerInset = MaterialEdgeInsetToValue(.None) textContainerInset = MaterialEdgeInsetToValue(.None)
backgroundColor = MaterialColor.white backgroundColor = MaterialColor.white
masksToBounds = false masksToBounds = false
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment