Commit b66f37d2 by Daniel Dahan

updated internal presets and default values

parent 0209d364
...@@ -141,9 +141,9 @@ class ViewController: UIViewController { ...@@ -141,9 +141,9 @@ class ViewController: UIViewController {
*/ */
private func prepareCardViewWithAlteredAlignmentExample() { private func prepareCardViewWithAlteredAlignmentExample() {
let cardView: CardView = CardView() let cardView: CardView = CardView()
cardView.dividerInsetsRef.left = 100 cardView.dividerInset.left = 100
cardView.titleLabelInsetsRef.left = 100 cardView.titleLabelInset.left = 100
cardView.detailLabelInsetsRef.left = 100 cardView.detailLabelInset.left = 100
cardView.pulseColor = MaterialColor.teal.lighten4 cardView.pulseColor = MaterialColor.teal.lighten4
// Image. // Image.
......
...@@ -69,7 +69,7 @@ class ViewController: UIViewController { ...@@ -69,7 +69,7 @@ class ViewController: UIViewController {
titleLabel.textColor = MaterialColor.white titleLabel.textColor = MaterialColor.white
titleLabel.font = RobotoFont.mediumWithSize(24) titleLabel.font = RobotoFont.mediumWithSize(24)
imageCardView.titleLabel = titleLabel imageCardView.titleLabel = titleLabel
imageCardView.titleLabelInsetsRef.top = 100 imageCardView.titleLabelInset.top = 100
// Detail label. // Detail label.
let detailLabel: UILabel = UILabel() let detailLabel: UILabel = UILabel()
...@@ -120,7 +120,7 @@ class ViewController: UIViewController { ...@@ -120,7 +120,7 @@ class ViewController: UIViewController {
titleLabel.textColor = MaterialColor.white titleLabel.textColor = MaterialColor.white
titleLabel.font = RobotoFont.regularWithSize(24) titleLabel.font = RobotoFont.regularWithSize(24)
imageCardView.titleLabel = titleLabel imageCardView.titleLabel = titleLabel
imageCardView.titleLabelInsetsRef.top = 80 imageCardView.titleLabelInset.top = 80
// Star button. // Star button.
let img1: UIImage? = UIImage(named: "ic_star_grey_darken_2") let img1: UIImage? = UIImage(named: "ic_star_grey_darken_2")
......
...@@ -253,7 +253,7 @@ class ViewController: UIViewController { ...@@ -253,7 +253,7 @@ class ViewController: UIViewController {
titleLabel.textColor = MaterialColor.white titleLabel.textColor = MaterialColor.white
titleLabel.font = RobotoFont.regularWithSize(20) titleLabel.font = RobotoFont.regularWithSize(20)
navigationBarView.titleLabel = titleLabel navigationBarView.titleLabel = titleLabel
navigationBarView.titleLabelInsetsRef.left = 64 navigationBarView.titleLabelInset.left = 64
// Detail label. // Detail label.
let detailLabel: UILabel = UILabel() let detailLabel: UILabel = UILabel()
...@@ -262,7 +262,7 @@ class ViewController: UIViewController { ...@@ -262,7 +262,7 @@ class ViewController: UIViewController {
detailLabel.textColor = MaterialColor.white detailLabel.textColor = MaterialColor.white
detailLabel.font = RobotoFont.regularWithSize(12) detailLabel.font = RobotoFont.regularWithSize(12)
navigationBarView.detailLabel = detailLabel navigationBarView.detailLabel = detailLabel
navigationBarView.detailLabelInsetsRef.left = 64 navigationBarView.detailLabelInset.left = 64
// Menu button. // Menu button.
let img1: UIImage? = UIImage(named: "ic_menu_white") let img1: UIImage? = UIImage(named: "ic_menu_white")
......
...@@ -7,6 +7,8 @@ ...@@ -7,6 +7,8 @@
objects = { objects = {
/* Begin PBXBuildFile section */ /* Begin PBXBuildFile section */
960590361C38B80400691E88 /* MaterialKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 960590351C38B80400691E88 /* MaterialKit.framework */; };
960590371C38B80400691E88 /* MaterialKit.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 960590351C38B80400691E88 /* MaterialKit.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
966F57A11C226BAA009185B7 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 966F57A01C226BAA009185B7 /* AppDelegate.swift */; }; 966F57A11C226BAA009185B7 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 966F57A01C226BAA009185B7 /* AppDelegate.swift */; };
966F57A31C226BAA009185B7 /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 966F57A21C226BAA009185B7 /* ViewController.swift */; }; 966F57A31C226BAA009185B7 /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 966F57A21C226BAA009185B7 /* ViewController.swift */; };
966F57A81C226BAA009185B7 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 966F57A71C226BAA009185B7 /* Assets.xcassets */; }; 966F57A81C226BAA009185B7 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 966F57A71C226BAA009185B7 /* Assets.xcassets */; };
...@@ -20,6 +22,7 @@ ...@@ -20,6 +22,7 @@
dstPath = ""; dstPath = "";
dstSubfolderSpec = 10; dstSubfolderSpec = 10;
files = ( files = (
960590371C38B80400691E88 /* MaterialKit.framework in Embed Frameworks */,
); );
name = "Embed Frameworks"; name = "Embed Frameworks";
runOnlyForDeploymentPostprocessing = 0; runOnlyForDeploymentPostprocessing = 0;
...@@ -27,6 +30,7 @@ ...@@ -27,6 +30,7 @@
/* End PBXCopyFilesBuildPhase section */ /* End PBXCopyFilesBuildPhase section */
/* Begin PBXFileReference section */ /* Begin PBXFileReference section */
960590351C38B80400691E88 /* MaterialKit.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; name = MaterialKit.framework; path = "/Users/danieldahan/Library/Developer/Xcode/DerivedData/MaterialKit-gdulktuccbcfwbdfadtpxkworhyc/Build/Products/Debug-iphoneos/MaterialKit.framework"; sourceTree = "<absolute>"; };
966F579D1C226BAA009185B7 /* TextField.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = TextField.app; sourceTree = BUILT_PRODUCTS_DIR; }; 966F579D1C226BAA009185B7 /* TextField.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = TextField.app; sourceTree = BUILT_PRODUCTS_DIR; };
966F57A01C226BAA009185B7 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = "<group>"; }; 966F57A01C226BAA009185B7 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = "<group>"; };
966F57A21C226BAA009185B7 /* ViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ViewController.swift; sourceTree = "<group>"; }; 966F57A21C226BAA009185B7 /* ViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ViewController.swift; sourceTree = "<group>"; };
...@@ -40,6 +44,7 @@ ...@@ -40,6 +44,7 @@
isa = PBXFrameworksBuildPhase; isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647; buildActionMask = 2147483647;
files = ( files = (
960590361C38B80400691E88 /* MaterialKit.framework in Frameworks */,
); );
runOnlyForDeploymentPostprocessing = 0; runOnlyForDeploymentPostprocessing = 0;
}; };
...@@ -49,6 +54,7 @@ ...@@ -49,6 +54,7 @@
966F57941C226BAA009185B7 = { 966F57941C226BAA009185B7 = {
isa = PBXGroup; isa = PBXGroup;
children = ( children = (
960590351C38B80400691E88 /* MaterialKit.framework */,
966F579F1C226BAA009185B7 /* TextField */, 966F579F1C226BAA009185B7 /* TextField */,
966F579E1C226BAA009185B7 /* Products */, 966F579E1C226BAA009185B7 /* Products */,
); );
......
...@@ -50,8 +50,8 @@ class ViewController: UIViewController, TextFieldDelegate { ...@@ -50,8 +50,8 @@ class ViewController: UIViewController, TextFieldDelegate {
nameField.textColor = MaterialColor.black nameField.textColor = MaterialColor.black
nameField.titleLabel = UILabel() nameField.titleLabel = UILabel()
nameField.titleLabel!.font = RobotoFont.mediumWithSize(12) nameField.titleLabel!.font = RobotoFont.mediumWithSize(12)
nameField.titleLabelNormalColor = MaterialColor.grey.lighten2 nameField.titleLabelTextColor = MaterialColor.grey.lighten2
nameField.titleLabelHighlightedColor = MaterialColor.blue.accent3 nameField.titleLabelActiveTextColor = MaterialColor.blue.accent3
nameField.clearButtonMode = .WhileEditing nameField.clearButtonMode = .WhileEditing
view.addSubview(nameField) view.addSubview(nameField)
} }
...@@ -68,13 +68,13 @@ class ViewController: UIViewController, TextFieldDelegate { ...@@ -68,13 +68,13 @@ class ViewController: UIViewController, TextFieldDelegate {
emailField.textColor = MaterialColor.black emailField.textColor = MaterialColor.black
emailField.titleLabel = UILabel() emailField.titleLabel = UILabel()
emailField.titleLabel!.font = RobotoFont.mediumWithSize(12) emailField.titleLabel!.font = RobotoFont.mediumWithSize(12)
emailField.titleLabelNormalColor = MaterialColor.grey.lighten2 emailField.titleLabelTextColor = MaterialColor.grey.lighten2
emailField.titleLabelHighlightedColor = MaterialColor.blue.accent3 emailField.titleLabelActiveTextColor = MaterialColor.blue.accent3
emailField.clearButtonMode = .WhileEditing emailField.clearButtonMode = .WhileEditing
emailField.detailLabel = UILabel() emailField.detailLabel = UILabel()
emailField.detailLabel!.text = "Email is incorrect." emailField.detailLabel!.text = "Email is incorrect."
emailField.detailLabel!.font = RobotoFont.mediumWithSize(12) emailField.detailLabel!.font = RobotoFont.mediumWithSize(12)
emailField.detailLabelHighlightedColor = MaterialColor.red.accent3 emailField.detailLabelActiveTextColor = MaterialColor.red.accent3
view.addSubview(emailField) view.addSubview(emailField)
} }
......
...@@ -53,8 +53,8 @@ class ViewController: UIViewController, TextDelegate, TextViewDelegate { ...@@ -53,8 +53,8 @@ class ViewController: UIViewController, TextDelegate, TextViewDelegate {
textView.titleLabel = UILabel() textView.titleLabel = UILabel()
textView.titleLabel!.font = RobotoFont.mediumWithSize(12) textView.titleLabel!.font = RobotoFont.mediumWithSize(12)
textView.titleLabelNormalColor = MaterialColor.grey.lighten2 textView.titleLabelTextColor = MaterialColor.grey.lighten2
textView.titleLabelHighlightedColor = MaterialColor.blue.accent3 textView.titleLabelActiveTextColor = MaterialColor.blue.accent3
view.addSubview(textView) view.addSubview(textView)
textView!.translatesAutoresizingMaskIntoConstraints = false textView!.translatesAutoresizingMaskIntoConstraints = false
...@@ -69,6 +69,5 @@ class ViewController: UIViewController, TextDelegate, TextViewDelegate { ...@@ -69,6 +69,5 @@ class ViewController: UIViewController, TextDelegate, TextViewDelegate {
func textDidProcessEdit(text: Text, textStorage: TextStorage, string: String, result: NSTextCheckingResult?, flags: NSMatchingFlags, stop: UnsafeMutablePointer<ObjCBool>) { func textDidProcessEdit(text: Text, textStorage: TextStorage, string: String, result: NSTextCheckingResult?, flags: NSMatchingFlags, stop: UnsafeMutablePointer<ObjCBool>) {
textStorage.addAttribute(NSFontAttributeName, value: UIFont.boldSystemFontOfSize(16), range: result!.range) textStorage.addAttribute(NSFontAttributeName, value: UIFont.boldSystemFontOfSize(16), range: result!.range)
} }
} }
...@@ -83,9 +83,9 @@ class ViewController: UIViewController { ...@@ -83,9 +83,9 @@ class ViewController: UIViewController {
:description: General usage example. :description: General usage example.
*/ */
func prepareCardViewExampleTwo() { func prepareCardViewExampleTwo() {
secondCardView.dividerInsetsRef.left = 100 secondCardView.dividerInset.left = 100
secondCardView.titleLabelInsetsRef.left = 100 secondCardView.titleLabelInset.left = 100
secondCardView.detailLabelInsetsRef.left = 100 secondCardView.detailLabelInset.left = 100
secondCardView.pulseColor = MaterialColor.teal.lighten4 secondCardView.pulseColor = MaterialColor.teal.lighten4
// Image. // Image.
......
...@@ -46,7 +46,7 @@ class ViewController: UIViewController { ...@@ -46,7 +46,7 @@ class ViewController: UIViewController {
titleLabel.textColor = MaterialColor.white titleLabel.textColor = MaterialColor.white
titleLabel.font = RobotoFont.regularWithSize(24) titleLabel.font = RobotoFont.regularWithSize(24)
imageCardView.titleLabel = titleLabel imageCardView.titleLabel = titleLabel
imageCardView.titleLabelInsetsRef.top = 80 imageCardView.titleLabelInset.top = 80
// Star button. // Star button.
let img1: UIImage? = UIImage(named: "ic_star_grey_darken_2") let img1: UIImage? = UIImage(named: "ic_star_grey_darken_2")
...@@ -77,7 +77,7 @@ class ViewController: UIViewController { ...@@ -77,7 +77,7 @@ class ViewController: UIViewController {
// Add buttons to right side. // Add buttons to right side.
imageCardView.rightButtons = [btn1, btn2, btn3] imageCardView.rightButtons = [btn1, btn2, btn3]
imageCardView.rightButtonsInsetsRef.top = imageCardView.contentInsetsRef.top imageCardView.rightButtonsInset.top = imageCardView.contentInset.top
} }
} }
...@@ -58,7 +58,7 @@ class ViewController: UIViewController { ...@@ -58,7 +58,7 @@ class ViewController: UIViewController {
titleLabel.textColor = MaterialColor.white titleLabel.textColor = MaterialColor.white
titleLabel.font = RobotoFont.regularWithSize(20) titleLabel.font = RobotoFont.regularWithSize(20)
navigationBarView.titleLabel = titleLabel navigationBarView.titleLabel = titleLabel
navigationBarView.titleLabelInsetsRef.left = 64 navigationBarView.titleLabelInset.left = 64
// Detail label. // Detail label.
let detailLabel: UILabel = UILabel() let detailLabel: UILabel = UILabel()
...@@ -67,7 +67,7 @@ class ViewController: UIViewController { ...@@ -67,7 +67,7 @@ class ViewController: UIViewController {
detailLabel.textColor = MaterialColor.white detailLabel.textColor = MaterialColor.white
detailLabel.font = RobotoFont.regularWithSize(12) detailLabel.font = RobotoFont.regularWithSize(12)
navigationBarView.detailLabel = detailLabel navigationBarView.detailLabel = detailLabel
navigationBarView.detailLabelInsetsRef.left = 64 navigationBarView.detailLabelInset.left = 64
// Menu button. // Menu button.
let img1: UIImage? = UIImage(named: "ic_menu_white") let img1: UIImage? = UIImage(named: "ic_menu_white")
......
...@@ -28,6 +28,7 @@ Run carthage to build the framework and drag the built MaterialKit.framework int ...@@ -28,6 +28,7 @@ Run carthage to build the framework and drag the built MaterialKit.framework int
### Table of Contents ### Table of Contents
* [MaterialColor](#materialcolor)
* [MaterialLayer](#materiallayer) * [MaterialLayer](#materiallayer)
* [MaterialView](#materialview) * [MaterialView](#materialview)
* [MaterialPulseView](#materialpulseview) * [MaterialPulseView](#materialpulseview)
...@@ -43,7 +44,6 @@ Run carthage to build the framework and drag the built MaterialKit.framework int ...@@ -43,7 +44,6 @@ Run carthage to build the framework and drag the built MaterialKit.framework int
* [Crop Image](#cropimage) * [Crop Image](#cropimage)
* [Save Image To PhotoLibrary](#saveimagetophotolibrary) * [Save Image To PhotoLibrary](#saveimagetophotolibrary)
* [Asynchronous Image Loading](#asynchronousimageloading) * [Asynchronous Image Loading](#asynchronousimageloading)
* [MaterialColor](#materialcolor)
* [TextField](#textfield) * [TextField](#textfield)
* [TextView](#textview) * [TextView](#textview)
* [Lines of Text](#linesoftext) * [Lines of Text](#linesoftext)
...@@ -63,6 +63,40 @@ Run carthage to build the framework and drag the built MaterialKit.framework int ...@@ -63,6 +63,40 @@ Run carthage to build the framework and drag the built MaterialKit.framework int
* TimePicker * TimePicker
* More Examples * More Examples
<a name="materialcolor"/>
### MaterialColor
Explore a complete range of Material Design colors using MaterialColor. Below is an example of setting a button's background color property.
![MaterialKitMaterialColorPalette](http://www.materialkit.io/MK/MaterialKitMaterialColorPalette.png)
```swift
let button: FabButton = FabButton()
button.backgroundColor = MaterialColor.blue.darken1
```
<a name="textfield"/>
### TextField
A TextField is an excellent way to improve UX. Checkout the Examples directory for a project using this component.
![MaterialKitTextField](http://www.materialkit.io/MK/MaterialKitTextField.gif)
```swift
let nameField: TextField = TextField(frame: CGRectMake(57, 100, 300, 24))
nameField.placeholder = "First Name"
nameField.font = RobotoFont.regularWithSize(20)
nameField.textColor = MaterialColor.black
nameField.titleLabel = UILabel()
nameField.titleLabel!.font = RobotoFont.mediumWithSize(12)
nameField.titleLabelNormalColor = MaterialColor.grey.lighten2
nameField.titleLabelHighlightedColor = MaterialColor.blue.accent3
nameField.clearButtonMode = .WhileEditing
// Add nameField to UIViewController.
view.addSubview(nameField)
```
<a name="materiallayer"/> <a name="materiallayer"/>
### MaterialLayer ### MaterialLayer
...@@ -266,9 +300,9 @@ Adjust the alignment of the UI elements to create different configurations of th ...@@ -266,9 +300,9 @@ Adjust the alignment of the UI elements to create different configurations of th
```swift ```swift
let cardView: CardView = CardView() let cardView: CardView = CardView()
cardView.dividerInsetsRef.left = 100 cardView.dividerInset.left = 100
cardView.titleLabelInsetsRef.left = 100 cardView.titleLabelInset.left = 100
cardView.detailLabelInsetsRef.left = 100 cardView.detailLabelInset.left = 100
cardView.pulseColor = MaterialColor.teal.lighten4 cardView.pulseColor = MaterialColor.teal.lighten4
// Image. // Image.
...@@ -376,7 +410,7 @@ titleLabel.text = "Welcome Back!" ...@@ -376,7 +410,7 @@ titleLabel.text = "Welcome Back!"
titleLabel.textColor = MaterialColor.white titleLabel.textColor = MaterialColor.white
titleLabel.font = RobotoFont.mediumWithSize(24) titleLabel.font = RobotoFont.mediumWithSize(24)
imageCardView.titleLabel = titleLabel imageCardView.titleLabel = titleLabel
imageCardView.titleLabelInsetsRef.top = 100 imageCardView.titleLabelInset.top = 100
// Detail label. // Detail label.
let detailLabel: UILabel = UILabel() let detailLabel: UILabel = UILabel()
...@@ -427,7 +461,7 @@ titleLabel.text = "Material Design" ...@@ -427,7 +461,7 @@ titleLabel.text = "Material Design"
titleLabel.textColor = MaterialColor.white titleLabel.textColor = MaterialColor.white
titleLabel.font = RobotoFont.regularWithSize(24) titleLabel.font = RobotoFont.regularWithSize(24)
imageCardView.titleLabel = titleLabel imageCardView.titleLabel = titleLabel
imageCardView.titleLabelInsetsRef.top = 80 imageCardView.titleLabelInset.top = 80
// Star button. // Star button.
let img1: UIImage? = UIImage(named: "ic_star_grey_darken_2") let img1: UIImage? = UIImage(named: "ic_star_grey_darken_2")
...@@ -490,7 +524,7 @@ titleLabel.textAlignment = .Left ...@@ -490,7 +524,7 @@ titleLabel.textAlignment = .Left
titleLabel.textColor = MaterialColor.white titleLabel.textColor = MaterialColor.white
titleLabel.font = RobotoFont.regularWithSize(20) titleLabel.font = RobotoFont.regularWithSize(20)
navigationBarView.titleLabel = titleLabel navigationBarView.titleLabel = titleLabel
navigationBarView.titleLabelInsetsRef.left = 64 navigationBarView.titleLabelInset.left = 64
// Detail label. // Detail label.
let detailLabel: UILabel = UILabel() let detailLabel: UILabel = UILabel()
...@@ -499,7 +533,7 @@ detailLabel.textAlignment = .Left ...@@ -499,7 +533,7 @@ detailLabel.textAlignment = .Left
detailLabel.textColor = MaterialColor.white detailLabel.textColor = MaterialColor.white
detailLabel.font = RobotoFont.regularWithSize(12) detailLabel.font = RobotoFont.regularWithSize(12)
navigationBarView.detailLabel = detailLabel navigationBarView.detailLabel = detailLabel
navigationBarView.detailLabelInsetsRef.left = 64 navigationBarView.detailLabelInset.left = 64
// Menu button. // Menu button.
let img1: UIImage? = UIImage(named: "ic_menu_white") let img1: UIImage? = UIImage(named: "ic_menu_white")
...@@ -620,40 +654,6 @@ UIImage.contentsOfURL(url) { (image: UIImage?, error: NSError?) in ...@@ -620,40 +654,6 @@ UIImage.contentsOfURL(url) { (image: UIImage?, error: NSError?) in
} }
``` ```
<a name="materialcolor"/>
### MaterialColor
Explore a complete range of Material Design colors using MaterialColor. Below is an example of setting a button's background color property.
![MaterialKitMaterialColorPalette](http://www.materialkit.io/MK/MaterialKitMaterialColorPalette.png)
```swift
let button: FabButton = FabButton()
button.backgroundColor = MaterialColor.blue.darken1
```
<a name="textfield"/>
### TextField
A TextField is an excellent way to improve UX. Checkout the Examples directory for a project using this component.
![MaterialKitTextField](http://www.materialkit.io/MK/MaterialKitTextField.gif)
```swift
let nameField: TextField = TextField(frame: CGRectMake(57, 100, 300, 24))
nameField.placeholder = "First Name"
nameField.font = RobotoFont.regularWithSize(20)
nameField.textColor = MaterialColor.black
nameField.titleLabel = UILabel()
nameField.titleLabel!.font = RobotoFont.mediumWithSize(12)
nameField.titleLabelNormalColor = MaterialColor.grey.lighten2
nameField.titleLabelHighlightedColor = MaterialColor.blue.accent3
nameField.clearButtonMode = .WhileEditing
// Add nameField to UIViewController.
view.addSubview(nameField)
```
<a name="textview"/> <a name="textview"/>
### TextView ### TextView
...@@ -664,7 +664,7 @@ Easily match any regular expression pattern in a body of text. Below is an examp ...@@ -664,7 +664,7 @@ Easily match any regular expression pattern in a body of text. Below is an examp
```swift ```swift
class ViewController: UIViewController, TextDelegate, TextViewDelegate { class ViewController: UIViewController, TextDelegate, TextViewDelegate {
lazy var text: Text = Text() lazy var text: Text = Text()
var textView: TextView? var textView: TextView!
override func viewDidLoad() { override func viewDidLoad() {
super.viewDidLoad() super.viewDidLoad()
...@@ -685,18 +685,23 @@ class ViewController: UIViewController, TextDelegate, TextViewDelegate { ...@@ -685,18 +685,23 @@ class ViewController: UIViewController, TextDelegate, TextViewDelegate {
text.textStorage.addLayoutManager(layoutManager) text.textStorage.addLayoutManager(layoutManager)
textView = TextView(frame: CGRectNull, textContainer: textContainer) textView = TextView(frame: CGRectNull, textContainer: textContainer)
textView?.delegate = self textView.delegate = self
textView!.editable = true textView.editable = true
textView!.selectable = true textView.selectable = true
textView!.font = RobotoFont.regular textView.font = RobotoFont.regular
textView.placeholderLabel = UILabel()
textView.placeholderLabel!.textColor = MaterialColor.grey.base
textView.placeholderLabel!.text = "Description"
textView!.placeholderLabel = UILabel() textView.titleLabel = UILabel()
textView!.placeholderLabel!.textColor = MaterialColor.grey.base textView.titleLabel!.font = RobotoFont.mediumWithSize(12)
textView!.placeholderLabel!.text = "MaterialKit TextView" textView.titleLabelNormalColor = MaterialColor.grey.lighten2
textView.titleLabelHighlightedColor = MaterialColor.blue.accent3
view.addSubview(textView!) view.addSubview(textView)
textView!.translatesAutoresizingMaskIntoConstraints = false textView!.translatesAutoresizingMaskIntoConstraints = false
MaterialLayout.alignToParent(view, child: textView!, top: 24, left: 24, bottom: 24, right: 24) MaterialLayout.alignToParent(view, child: textView!, top: 124, left: 24, bottom: 24, right: 24)
} }
func textWillProcessEdit(text: Text, textStorage: TextStorage, string: String, range: NSRange) { func textWillProcessEdit(text: Text, textStorage: TextStorage, string: String, range: NSRange) {
......
...@@ -173,16 +173,16 @@ public class CaptureView : MaterialView, UIGestureRecognizerDelegate { ...@@ -173,16 +173,16 @@ public class CaptureView : MaterialView, UIGestureRecognizerDelegate {
/** /**
:name: contentInsets :name: contentInsets
*/ */
public var contentInsets: MaterialEdgeInsets = .None { public var contentInsetPreset: MaterialEdgeInsets = .None {
didSet { didSet {
contentInsetsRef = MaterialEdgeInsetsToValue(contentInsets) contentInset = MaterialEdgeInsetsToValue(contentInsetPreset)
} }
} }
/** /**
:name: contentInsetsRef :name: contentInset
*/ */
public var contentInsetsRef: UIEdgeInsets = MaterialEdgeInsetsToValue(.Square4) { public var contentInset: UIEdgeInsets = MaterialEdgeInsetsToValue(.Square4) {
didSet { didSet {
reloadView() reloadView()
} }
...@@ -287,16 +287,16 @@ public class CaptureView : MaterialView, UIGestureRecognizerDelegate { ...@@ -287,16 +287,16 @@ public class CaptureView : MaterialView, UIGestureRecognizerDelegate {
previewView.frame = bounds previewView.frame = bounds
if let v: UIButton = cameraButton { if let v: UIButton = cameraButton {
v.frame.origin.y = bounds.height - contentInsetsRef.bottom - v.bounds.height v.frame.origin.y = bounds.height - contentInset.bottom - v.bounds.height
v.frame.origin.x = contentInsetsRef.left v.frame.origin.x = contentInset.left
} }
if let v: UIButton = captureButton { if let v: UIButton = captureButton {
v.frame.origin.y = bounds.height - contentInsetsRef.bottom - v.bounds.height v.frame.origin.y = bounds.height - contentInset.bottom - v.bounds.height
v.frame.origin.x = (bounds.width - v.bounds.width) / 2 v.frame.origin.x = (bounds.width - v.bounds.width) / 2
} }
if let v: UIButton = videoButton { if let v: UIButton = videoButton {
v.frame.origin.y = bounds.height - contentInsetsRef.bottom - v.bounds.height v.frame.origin.y = bounds.height - contentInset.bottom - v.bounds.height
v.frame.origin.x = bounds.width - v.bounds.width - contentInsetsRef.right v.frame.origin.x = bounds.width - v.bounds.width - contentInset.right
} }
if let v: AVCaptureConnection = (previewView.layer as! AVCaptureVideoPreviewLayer).connection { if let v: AVCaptureConnection = (previewView.layer as! AVCaptureVideoPreviewLayer).connection {
v.videoOrientation = captureSession.currentVideoOrientation v.videoOrientation = captureSession.currentVideoOrientation
......
...@@ -45,16 +45,16 @@ public class CardView : MaterialPulseView { ...@@ -45,16 +45,16 @@ public class CardView : MaterialPulseView {
/** /**
:name: dividerInsets :name: dividerInsets
*/ */
public var dividerInsets: MaterialEdgeInsets = .None { public var dividerInsetPreset: MaterialEdgeInsets = .None {
didSet { didSet {
dividerInsetsRef = MaterialEdgeInsetsToValue(dividerInsets) dividerInset = MaterialEdgeInsetsToValue(dividerInsetPreset)
} }
} }
/** /**
:name: dividerInsetsRef :name: dividerInset
*/ */
public var dividerInsetsRef: UIEdgeInsets = UIEdgeInsets(top: 8, left: 0, bottom: 8, right: 0) { public var dividerInset: UIEdgeInsets = UIEdgeInsets(top: 8, left: 0, bottom: 8, right: 0) {
didSet { didSet {
reloadView() reloadView()
} }
...@@ -63,16 +63,16 @@ public class CardView : MaterialPulseView { ...@@ -63,16 +63,16 @@ public class CardView : MaterialPulseView {
/** /**
:name: contentInsets :name: contentInsets
*/ */
public var contentInsets: MaterialEdgeInsets = .None { public var contentInsetPreset: MaterialEdgeInsets = .None {
didSet { didSet {
contentInsetsRef = MaterialEdgeInsetsToValue(contentInsets) contentInset = MaterialEdgeInsetsToValue(contentInsetPreset)
} }
} }
/** /**
:name: contentInsetsRef :name: contentInset
*/ */
public var contentInsetsRef: UIEdgeInsets = MaterialEdgeInsetsToValue(.Square2) { public var contentInset: UIEdgeInsets = MaterialEdgeInsetsToValue(.Square2) {
didSet { didSet {
reloadView() reloadView()
} }
...@@ -81,16 +81,16 @@ public class CardView : MaterialPulseView { ...@@ -81,16 +81,16 @@ public class CardView : MaterialPulseView {
/** /**
:name: titleLabelInsets :name: titleLabelInsets
*/ */
public var titleLabelInsets: MaterialEdgeInsets = .None { public var titleLabelInsetPreset: MaterialEdgeInsets = .None {
didSet { didSet {
titleLabelInsetsRef = MaterialEdgeInsetsToValue(titleLabelInsets) titleLabelInset = MaterialEdgeInsetsToValue(titleLabelInsetPreset)
} }
} }
/** /**
:name: titleLabelInsetsRef :name: titleLabelInset
*/ */
public var titleLabelInsetsRef: UIEdgeInsets = MaterialEdgeInsetsToValue(.Square2) { public var titleLabelInset: UIEdgeInsets = MaterialEdgeInsetsToValue(.Square2) {
didSet { didSet {
reloadView() reloadView()
} }
...@@ -109,16 +109,16 @@ public class CardView : MaterialPulseView { ...@@ -109,16 +109,16 @@ public class CardView : MaterialPulseView {
/** /**
:name: detailLabelInsets :name: detailLabelInsets
*/ */
public var detailLabelInsets: MaterialEdgeInsets = .None { public var detailLabelInsetPreset: MaterialEdgeInsets = .None {
didSet { didSet {
detailLabelInsetsRef = MaterialEdgeInsetsToValue(detailLabelInsets) detailLabelInset = MaterialEdgeInsetsToValue(detailLabelInsetPreset)
} }
} }
/** /**
:name: detailLabelInsetsRef :name: detailLabelInset
*/ */
public var detailLabelInsetsRef: UIEdgeInsets = MaterialEdgeInsetsToValue(.Square2) { public var detailLabelInset: UIEdgeInsets = MaterialEdgeInsetsToValue(.Square2) {
didSet { didSet {
reloadView() reloadView()
} }
...@@ -137,16 +137,16 @@ public class CardView : MaterialPulseView { ...@@ -137,16 +137,16 @@ public class CardView : MaterialPulseView {
/** /**
:name: leftButtonsInsets :name: leftButtonsInsets
*/ */
public var leftButtonsInsets: MaterialEdgeInsets = .None { public var leftButtonsInsetPreset: MaterialEdgeInsets = .None {
didSet { didSet {
leftButtonsInsetsRef = MaterialEdgeInsetsToValue(leftButtonsInsets) leftButtonsInset = MaterialEdgeInsetsToValue(leftButtonsInsetPreset)
} }
} }
/** /**
:name: leftButtonsInsetsRef :name: leftButtonsInset
*/ */
public var leftButtonsInsetsRef: UIEdgeInsets = MaterialEdgeInsetsToValue(.None) { public var leftButtonsInset: UIEdgeInsets = MaterialEdgeInsetsToValue(.None) {
didSet { didSet {
reloadView() reloadView()
} }
...@@ -169,16 +169,16 @@ public class CardView : MaterialPulseView { ...@@ -169,16 +169,16 @@ public class CardView : MaterialPulseView {
/** /**
:name: rightButtonsInsets :name: rightButtonsInsets
*/ */
public var rightButtonsInsets: MaterialEdgeInsets = .None { public var rightButtonsInsetPreset: MaterialEdgeInsets = .None {
didSet { didSet {
rightButtonsInsetsRef = MaterialEdgeInsetsToValue(rightButtonsInsets) rightButtonsInset = MaterialEdgeInsetsToValue(rightButtonsInsetPreset)
} }
} }
/** /**
:name: rightButtonsInsetsRef :name: rightButtonsInset
*/ */
public var rightButtonsInsetsRef: UIEdgeInsets = MaterialEdgeInsetsToValue(.None) { public var rightButtonsInset: UIEdgeInsets = MaterialEdgeInsetsToValue(.None) {
didSet { didSet {
reloadView() reloadView()
} }
...@@ -234,11 +234,11 @@ public class CardView : MaterialPulseView { ...@@ -234,11 +234,11 @@ public class CardView : MaterialPulseView {
super.layoutSublayersOfLayer(layer) super.layoutSublayersOfLayer(layer)
if self.layer == layer { if self.layer == layer {
if divider { if divider {
var y: CGFloat = contentInsetsRef.bottom + dividerInsetsRef.bottom var y: CGFloat = contentInset.bottom + dividerInset.bottom
if 0 < leftButtons?.count { if 0 < leftButtons?.count {
y += leftButtonsInsetsRef.top + leftButtonsInsetsRef.bottom + leftButtons![0].frame.height y += leftButtonsInset.top + leftButtonsInset.bottom + leftButtons![0].frame.height
} else if 0 < rightButtons?.count { } else if 0 < rightButtons?.count {
y += rightButtonsInsetsRef.top + rightButtonsInsetsRef.bottom + rightButtons![0].frame.height y += rightButtonsInset.top + rightButtonsInset.bottom + rightButtons![0].frame.height
} }
if 0 < y { if 0 < y {
prepareDivider(bounds.height - y - 0.5, width: bounds.width) prepareDivider(bounds.height - y - 0.5, width: bounds.width)
...@@ -266,10 +266,10 @@ public class CardView : MaterialPulseView { ...@@ -266,10 +266,10 @@ public class CardView : MaterialPulseView {
if nil != titleLabel { if nil != titleLabel {
verticalFormat += "-(insetTop)" verticalFormat += "-(insetTop)"
metrics["insetTop"] = contentInsetsRef.top + titleLabelInsetsRef.top metrics["insetTop"] = contentInset.top + titleLabelInset.top
} else if nil != detailLabel { } else if nil != detailLabel {
verticalFormat += "-(insetTop)" verticalFormat += "-(insetTop)"
metrics["insetTop"] = contentInsetsRef.top + detailLabelInsetsRef.top metrics["insetTop"] = contentInset.top + detailLabelInset.top
} }
// title // title
...@@ -279,7 +279,7 @@ public class CardView : MaterialPulseView { ...@@ -279,7 +279,7 @@ public class CardView : MaterialPulseView {
verticalFormat += "-[titleLabel]" verticalFormat += "-[titleLabel]"
views["titleLabel"] = v views["titleLabel"] = v
MaterialLayout.alignToParentHorizontally(self, child: v, left: contentInsetsRef.left + titleLabelInsetsRef.left, right: contentInsetsRef.right + titleLabelInsetsRef.right) MaterialLayout.alignToParentHorizontally(self, child: v, left: contentInset.left + titleLabelInset.left, right: contentInset.right + titleLabelInset.right)
} }
// detail // detail
...@@ -287,16 +287,16 @@ public class CardView : MaterialPulseView { ...@@ -287,16 +287,16 @@ public class CardView : MaterialPulseView {
addSubview(v) addSubview(v)
if nil == titleLabel { if nil == titleLabel {
metrics["insetTop"] = (metrics["insetTop"] as! CGFloat) + detailLabelInsetsRef.top metrics["insetTop"] = (metrics["insetTop"] as! CGFloat) + detailLabelInset.top
} else { } else {
verticalFormat += "-(insetB)" verticalFormat += "-(insetB)"
metrics["insetB"] = titleLabelInsetsRef.bottom + detailLabelInsetsRef.top metrics["insetB"] = titleLabelInset.bottom + detailLabelInset.top
} }
verticalFormat += "-[detailLabel]" verticalFormat += "-[detailLabel]"
views["detailLabel"] = v views["detailLabel"] = v
MaterialLayout.alignToParentHorizontally(self, child: v, left: contentInsetsRef.left + detailLabelInsetsRef.left, right: contentInsetsRef.right + detailLabelInsetsRef.right) MaterialLayout.alignToParentHorizontally(self, child: v, left: contentInset.left + detailLabelInset.left, right: contentInset.right + detailLabelInset.right)
} }
// leftButtons // leftButtons
...@@ -319,10 +319,10 @@ public class CardView : MaterialPulseView { ...@@ -319,10 +319,10 @@ public class CardView : MaterialPulseView {
h += "[\(k)]" h += "[\(k)]"
addSubview(b) addSubview(b)
MaterialLayout.alignFromBottom(self, child: b, bottom: contentInsetsRef.bottom + leftButtonsInsetsRef.bottom) MaterialLayout.alignFromBottom(self, child: b, bottom: contentInset.bottom + leftButtonsInset.bottom)
} }
addConstraints(MaterialLayout.constraint(h, options: [], metrics: ["left" : contentInsetsRef.left + leftButtonsInsetsRef.left, "left_right" : leftButtonsInsetsRef.left + leftButtonsInsetsRef.right], views: d)) addConstraints(MaterialLayout.constraint(h, options: [], metrics: ["left" : contentInset.left + leftButtonsInset.left, "left_right" : leftButtonsInset.left + leftButtonsInset.right], views: d))
} }
} }
...@@ -347,39 +347,39 @@ public class CardView : MaterialPulseView { ...@@ -347,39 +347,39 @@ public class CardView : MaterialPulseView {
} }
addSubview(b) addSubview(b)
MaterialLayout.alignFromBottom(self, child: b, bottom: contentInsetsRef.bottom + rightButtonsInsetsRef.bottom) MaterialLayout.alignFromBottom(self, child: b, bottom: contentInset.bottom + rightButtonsInset.bottom)
} }
addConstraints(MaterialLayout.constraint(h + "|", options: [], metrics: ["right" : contentInsetsRef.right + rightButtonsInsetsRef.right, "right_left" : rightButtonsInsetsRef.right + rightButtonsInsetsRef.left], views: d)) addConstraints(MaterialLayout.constraint(h + "|", options: [], metrics: ["right" : contentInset.right + rightButtonsInset.right, "right_left" : rightButtonsInset.right + rightButtonsInset.left], views: d))
} }
} }
if 0 < leftButtons?.count { if 0 < leftButtons?.count {
verticalFormat += "-(insetC)-[button]" verticalFormat += "-(insetC)-[button]"
views["button"] = leftButtons![0] views["button"] = leftButtons![0]
metrics["insetC"] = leftButtonsInsetsRef.top metrics["insetC"] = leftButtonsInset.top
metrics["insetBottom"] = contentInsetsRef.bottom + leftButtonsInsetsRef.bottom metrics["insetBottom"] = contentInset.bottom + leftButtonsInset.bottom
} else if 0 < rightButtons?.count { } else if 0 < rightButtons?.count {
verticalFormat += "-(insetC)-[button]" verticalFormat += "-(insetC)-[button]"
views["button"] = rightButtons![0] views["button"] = rightButtons![0]
metrics["insetC"] = rightButtonsInsetsRef.top metrics["insetC"] = rightButtonsInset.top
metrics["insetBottom"] = contentInsetsRef.bottom + rightButtonsInsetsRef.bottom metrics["insetBottom"] = contentInset.bottom + rightButtonsInset.bottom
} }
if nil != detailLabel { if nil != detailLabel {
if nil == metrics["insetC"] { if nil == metrics["insetC"] {
metrics["insetBottom"] = contentInsetsRef.bottom + detailLabelInsetsRef.bottom + (divider ? dividerInsetsRef.top + dividerInsetsRef.bottom : 0) metrics["insetBottom"] = contentInset.bottom + detailLabelInset.bottom + (divider ? dividerInset.top + dividerInset.bottom : 0)
} else { } else {
metrics["insetC"] = (metrics["insetC"] as! CGFloat) + detailLabelInsetsRef.bottom + (divider ? dividerInsetsRef.top + dividerInsetsRef.bottom : 0) metrics["insetC"] = (metrics["insetC"] as! CGFloat) + detailLabelInset.bottom + (divider ? dividerInset.top + dividerInset.bottom : 0)
} }
} else if nil != titleLabel { } else if nil != titleLabel {
if nil == metrics["insetC"] { if nil == metrics["insetC"] {
metrics["insetBottom"] = contentInsetsRef.bottom + titleLabelInsetsRef.bottom + (divider ? dividerInsetsRef.top + dividerInsetsRef.bottom : 0) metrics["insetBottom"] = contentInset.bottom + titleLabelInset.bottom + (divider ? dividerInset.top + dividerInset.bottom : 0)
} else { } else {
metrics["insetC"] = (metrics["insetTop"] as! CGFloat) + titleLabelInsetsRef.bottom + (divider ? dividerInsetsRef.top + dividerInsetsRef.bottom : 0) metrics["insetC"] = (metrics["insetTop"] as! CGFloat) + titleLabelInset.bottom + (divider ? dividerInset.top + dividerInset.bottom : 0)
} }
} else if nil != metrics["insetC"] { } else if nil != metrics["insetC"] {
metrics["insetC"] = (metrics["insetC"] as! CGFloat) + contentInsetsRef.top + (divider ? dividerInsetsRef.top + dividerInsetsRef.bottom : 0) metrics["insetC"] = (metrics["insetC"] as! CGFloat) + contentInset.top + (divider ? dividerInset.top + dividerInset.bottom : 0)
} }
...@@ -409,7 +409,7 @@ public class CardView : MaterialPulseView { ...@@ -409,7 +409,7 @@ public class CardView : MaterialPulseView {
layer.addSublayer(dividerLayer!) layer.addSublayer(dividerLayer!)
} }
dividerLayer?.backgroundColor = dividerColor?.CGColor dividerLayer?.backgroundColor = dividerColor?.CGColor
dividerLayer?.frame = CGRectMake(dividerInsetsRef.left, y, width - dividerInsetsRef.left - dividerInsetsRef.right, 1) dividerLayer?.frame = CGRectMake(dividerInset.left, y, width - dividerInset.left - dividerInset.right, 1)
} }
/** /**
......
...@@ -31,6 +31,6 @@ public class FlatButton : MaterialButton { ...@@ -31,6 +31,6 @@ public class FlatButton : MaterialButton {
setTitleColor(MaterialColor.blue.accent3, forState: .Normal) setTitleColor(MaterialColor.blue.accent3, forState: .Normal)
pulseColor = MaterialColor.blue.accent3 pulseColor = MaterialColor.blue.accent3
cornerRadius = .Radius1 cornerRadius = .Radius1
contentInsets = .WideRectangle3 contentInsetPreset = .WideRectangle3
} }
} }
\ No newline at end of file
...@@ -45,16 +45,16 @@ public class ImageCardView : MaterialPulseView { ...@@ -45,16 +45,16 @@ public class ImageCardView : MaterialPulseView {
/** /**
:name: dividerInsets :name: dividerInsets
*/ */
public var dividerInsets: MaterialEdgeInsets = .None { public var dividerInsetPreset: MaterialEdgeInsets = .None {
didSet { didSet {
dividerInsetsRef = MaterialEdgeInsetsToValue(dividerInsets) dividerInset = MaterialEdgeInsetsToValue(dividerInsetPreset)
} }
} }
/** /**
:name: dividerInsetsRef :name: dividerInset
*/ */
public var dividerInsetsRef: UIEdgeInsets = UIEdgeInsets(top: 8, left: 0, bottom: 8, right: 0) { public var dividerInset: UIEdgeInsets = UIEdgeInsets(top: 8, left: 0, bottom: 8, right: 0) {
didSet { didSet {
reloadView() reloadView()
} }
...@@ -153,16 +153,16 @@ public class ImageCardView : MaterialPulseView { ...@@ -153,16 +153,16 @@ public class ImageCardView : MaterialPulseView {
/** /**
:name: contentInsets :name: contentInsets
*/ */
public var contentInsets: MaterialEdgeInsets = .None { public var contentInsetPreset: MaterialEdgeInsets = .None {
didSet { didSet {
contentInsetsRef = MaterialEdgeInsetsToValue(contentInsets) contentInset = MaterialEdgeInsetsToValue(contentInsetPreset)
} }
} }
/** /**
:name: contentInsetsRef :name: contentInset
*/ */
public var contentInsetsRef: UIEdgeInsets = MaterialEdgeInsetsToValue(.Square2) { public var contentInset: UIEdgeInsets = MaterialEdgeInsetsToValue(.Square2) {
didSet { didSet {
reloadView() reloadView()
} }
...@@ -171,16 +171,16 @@ public class ImageCardView : MaterialPulseView { ...@@ -171,16 +171,16 @@ public class ImageCardView : MaterialPulseView {
/** /**
:name: titleLabelInsets :name: titleLabelInsets
*/ */
public var titleLabelInsets: MaterialEdgeInsets = .None { public var titleLabelInsetPreset: MaterialEdgeInsets = .None {
didSet { didSet {
titleLabelInsetsRef = MaterialEdgeInsetsToValue(titleLabelInsets) titleLabelInset = MaterialEdgeInsetsToValue(titleLabelInsetPreset)
} }
} }
/** /**
:name: titleLabelInsetsRef :name: titleLabelInset
*/ */
public var titleLabelInsetsRef: UIEdgeInsets = MaterialEdgeInsetsToValue(.Square2) { public var titleLabelInset: UIEdgeInsets = MaterialEdgeInsetsToValue(.Square2) {
didSet { didSet {
reloadView() reloadView()
} }
...@@ -199,16 +199,16 @@ public class ImageCardView : MaterialPulseView { ...@@ -199,16 +199,16 @@ public class ImageCardView : MaterialPulseView {
/** /**
:name: detailLabelInsets :name: detailLabelInsets
*/ */
public var detailLabelInsets: MaterialEdgeInsets = .None { public var detailLabelInsetPreset: MaterialEdgeInsets = .None {
didSet { didSet {
detailLabelInsetsRef = MaterialEdgeInsetsToValue(detailLabelInsets) detailLabelInset = MaterialEdgeInsetsToValue(detailLabelInsetPreset)
} }
} }
/** /**
:name: detailLabelInsetsRef :name: detailLabelInset
*/ */
public var detailLabelInsetsRef: UIEdgeInsets = MaterialEdgeInsetsToValue(.Square2) { public var detailLabelInset: UIEdgeInsets = MaterialEdgeInsetsToValue(.Square2) {
didSet { didSet {
reloadView() reloadView()
} }
...@@ -227,16 +227,16 @@ public class ImageCardView : MaterialPulseView { ...@@ -227,16 +227,16 @@ public class ImageCardView : MaterialPulseView {
/** /**
:name: leftButtonsInsets :name: leftButtonsInsets
*/ */
public var leftButtonsInsets: MaterialEdgeInsets = .None { public var leftButtonsInsetPreset: MaterialEdgeInsets = .None {
didSet { didSet {
leftButtonsInsetsRef = MaterialEdgeInsetsToValue(leftButtonsInsets) leftButtonsInset = MaterialEdgeInsetsToValue(leftButtonsInsetPreset)
} }
} }
/** /**
:name: leftButtonsInsetsRef :name: leftButtonsInset
*/ */
public var leftButtonsInsetsRef: UIEdgeInsets = MaterialEdgeInsetsToValue(.None) { public var leftButtonsInset: UIEdgeInsets = MaterialEdgeInsetsToValue(.None) {
didSet { didSet {
reloadView() reloadView()
} }
...@@ -259,16 +259,16 @@ public class ImageCardView : MaterialPulseView { ...@@ -259,16 +259,16 @@ public class ImageCardView : MaterialPulseView {
/** /**
:name: rightButtonsInsets :name: rightButtonsInsets
*/ */
public var rightButtonsInsets: MaterialEdgeInsets = .None { public var rightButtonsInsetPreset: MaterialEdgeInsets = .None {
didSet { didSet {
rightButtonsInsetsRef = MaterialEdgeInsetsToValue(rightButtonsInsets) rightButtonsInset = MaterialEdgeInsetsToValue(rightButtonsInsetPreset)
} }
} }
/** /**
:name: rightButtonsInsetsRef :name: rightButtonsInset
*/ */
public var rightButtonsInsetsRef: UIEdgeInsets = MaterialEdgeInsetsToValue(.None) { public var rightButtonsInset: UIEdgeInsets = MaterialEdgeInsetsToValue(.None) {
didSet { didSet {
reloadView() reloadView()
} }
...@@ -328,11 +328,11 @@ public class ImageCardView : MaterialPulseView { ...@@ -328,11 +328,11 @@ public class ImageCardView : MaterialPulseView {
// divider // divider
if divider { if divider {
var y: CGFloat = contentInsetsRef.bottom + dividerInsetsRef.bottom var y: CGFloat = contentInset.bottom + dividerInset.bottom
if 0 < leftButtons?.count { if 0 < leftButtons?.count {
y += leftButtonsInsetsRef.top + leftButtonsInsetsRef.bottom + leftButtons![0].frame.height y += leftButtonsInset.top + leftButtonsInset.bottom + leftButtons![0].frame.height
} else if 0 < rightButtons?.count { } else if 0 < rightButtons?.count {
y += rightButtonsInsetsRef.top + rightButtonsInsetsRef.bottom + rightButtons![0].frame.height y += rightButtonsInset.top + rightButtonsInset.bottom + rightButtons![0].frame.height
} }
if 0 < y { if 0 < y {
prepareDivider(bounds.height - y - 0.5, width: bounds.width) prepareDivider(bounds.height - y - 0.5, width: bounds.width)
...@@ -363,10 +363,10 @@ public class ImageCardView : MaterialPulseView { ...@@ -363,10 +363,10 @@ public class ImageCardView : MaterialPulseView {
metrics["insetTop"] = imageLayer!.frame.height metrics["insetTop"] = imageLayer!.frame.height
} else if nil != titleLabel { } else if nil != titleLabel {
verticalFormat += "-(insetTop)" verticalFormat += "-(insetTop)"
metrics["insetTop"] = contentInsetsRef.top + titleLabelInsetsRef.top metrics["insetTop"] = contentInset.top + titleLabelInset.top
} else if nil != detailLabel { } else if nil != detailLabel {
verticalFormat += "-(insetTop)" verticalFormat += "-(insetTop)"
metrics["insetTop"] = contentInsetsRef.top + detailLabelInsetsRef.top metrics["insetTop"] = contentInset.top + detailLabelInset.top
} }
// title // title
...@@ -377,9 +377,9 @@ public class ImageCardView : MaterialPulseView { ...@@ -377,9 +377,9 @@ public class ImageCardView : MaterialPulseView {
verticalFormat += "-[titleLabel]" verticalFormat += "-[titleLabel]"
views["titleLabel"] = v views["titleLabel"] = v
} else { } else {
MaterialLayout.alignFromTop(self, child: v, top: contentInsetsRef.top + titleLabelInsetsRef.top) MaterialLayout.alignFromTop(self, child: v, top: contentInset.top + titleLabelInset.top)
} }
MaterialLayout.alignToParentHorizontally(self, child: v, left: contentInsetsRef.left + titleLabelInsetsRef.left, right: contentInsetsRef.right + titleLabelInsetsRef.right) MaterialLayout.alignToParentHorizontally(self, child: v, left: contentInset.left + titleLabelInset.left, right: contentInset.right + titleLabelInset.right)
} }
// detail // detail
...@@ -388,15 +388,15 @@ public class ImageCardView : MaterialPulseView { ...@@ -388,15 +388,15 @@ public class ImageCardView : MaterialPulseView {
if nil == imageLayer?.contents && nil != titleLabel { if nil == imageLayer?.contents && nil != titleLabel {
verticalFormat += "-(insetB)" verticalFormat += "-(insetB)"
metrics["insetB"] = titleLabelInsetsRef.bottom + detailLabelInsetsRef.top metrics["insetB"] = titleLabelInset.bottom + detailLabelInset.top
} else { } else {
metrics["insetTop"] = (metrics["insetTop"] as! CGFloat) + detailLabelInsetsRef.top metrics["insetTop"] = (metrics["insetTop"] as! CGFloat) + detailLabelInset.top
} }
verticalFormat += "-[detailLabel]" verticalFormat += "-[detailLabel]"
views["detailLabel"] = v views["detailLabel"] = v
MaterialLayout.alignToParentHorizontally(self, child: v, left: contentInsetsRef.left + detailLabelInsetsRef.left, right: contentInsetsRef.right + detailLabelInsetsRef.right) MaterialLayout.alignToParentHorizontally(self, child: v, left: contentInset.left + detailLabelInset.left, right: contentInset.right + detailLabelInset.right)
} }
// leftButtons // leftButtons
...@@ -419,10 +419,10 @@ public class ImageCardView : MaterialPulseView { ...@@ -419,10 +419,10 @@ public class ImageCardView : MaterialPulseView {
h += "[\(k)]" h += "[\(k)]"
addSubview(b) addSubview(b)
MaterialLayout.alignFromBottom(self, child: b, bottom: contentInsetsRef.bottom + leftButtonsInsetsRef.bottom) MaterialLayout.alignFromBottom(self, child: b, bottom: contentInset.bottom + leftButtonsInset.bottom)
} }
addConstraints(MaterialLayout.constraint(h, options: [], metrics: ["left" : contentInsetsRef.left + leftButtonsInsetsRef.left, "left_right" : leftButtonsInsetsRef.left + leftButtonsInsetsRef.right], views: d)) addConstraints(MaterialLayout.constraint(h, options: [], metrics: ["left" : contentInset.left + leftButtonsInset.left, "left_right" : leftButtonsInset.left + leftButtonsInset.right], views: d))
} }
} }
...@@ -447,10 +447,10 @@ public class ImageCardView : MaterialPulseView { ...@@ -447,10 +447,10 @@ public class ImageCardView : MaterialPulseView {
} }
addSubview(b) addSubview(b)
MaterialLayout.alignFromBottom(self, child: b, bottom: contentInsetsRef.bottom + rightButtonsInsetsRef.bottom) MaterialLayout.alignFromBottom(self, child: b, bottom: contentInset.bottom + rightButtonsInset.bottom)
} }
addConstraints(MaterialLayout.constraint(h + "|", options: [], metrics: ["right" : contentInsetsRef.right + rightButtonsInsetsRef.right, "right_left" : rightButtonsInsetsRef.right + rightButtonsInsetsRef.left], views: d)) addConstraints(MaterialLayout.constraint(h + "|", options: [], metrics: ["right" : contentInset.right + rightButtonsInset.right, "right_left" : rightButtonsInset.right + rightButtonsInset.left], views: d))
} }
} }
...@@ -458,59 +458,59 @@ public class ImageCardView : MaterialPulseView { ...@@ -458,59 +458,59 @@ public class ImageCardView : MaterialPulseView {
if 0 < leftButtons?.count { if 0 < leftButtons?.count {
verticalFormat += "-(insetC)-[button]" verticalFormat += "-(insetC)-[button]"
views["button"] = leftButtons![0] views["button"] = leftButtons![0]
metrics["insetC"] = leftButtonsInsetsRef.top metrics["insetC"] = leftButtonsInset.top
metrics["insetBottom"] = contentInsetsRef.bottom + leftButtonsInsetsRef.bottom metrics["insetBottom"] = contentInset.bottom + leftButtonsInset.bottom
} else if 0 < rightButtons?.count { } else if 0 < rightButtons?.count {
verticalFormat += "-(insetC)-[button]" verticalFormat += "-(insetC)-[button]"
views["button"] = rightButtons![0] views["button"] = rightButtons![0]
metrics["insetC"] = rightButtonsInsetsRef.top metrics["insetC"] = rightButtonsInset.top
metrics["insetBottom"] = contentInsetsRef.bottom + rightButtonsInsetsRef.bottom metrics["insetBottom"] = contentInset.bottom + rightButtonsInset.bottom
} }
if nil != detailLabel { if nil != detailLabel {
if nil == metrics["insetC"] { if nil == metrics["insetC"] {
metrics["insetBottom"] = contentInsetsRef.bottom + detailLabelInsetsRef.bottom + (divider ? dividerInsetsRef.top + dividerInsetsRef.bottom : 0) metrics["insetBottom"] = contentInset.bottom + detailLabelInset.bottom + (divider ? dividerInset.top + dividerInset.bottom : 0)
} else { } else {
metrics["insetC"] = (metrics["insetC"] as! CGFloat) + detailLabelInsetsRef.bottom + (divider ? dividerInsetsRef.top + dividerInsetsRef.bottom : 0) metrics["insetC"] = (metrics["insetC"] as! CGFloat) + detailLabelInset.bottom + (divider ? dividerInset.top + dividerInset.bottom : 0)
} }
} else if nil != titleLabel { } else if nil != titleLabel {
if nil == metrics["insetC"] { if nil == metrics["insetC"] {
metrics["insetBottom"] = contentInsetsRef.bottom + titleLabelInsetsRef.bottom + (divider ? dividerInsetsRef.top + dividerInsetsRef.bottom : 0) metrics["insetBottom"] = contentInset.bottom + titleLabelInset.bottom + (divider ? dividerInset.top + dividerInset.bottom : 0)
} else { } else {
metrics["insetC"] = (metrics["insetC"] as! CGFloat) + titleLabelInsetsRef.bottom + (divider ? dividerInsetsRef.top + dividerInsetsRef.bottom : 0) metrics["insetC"] = (metrics["insetC"] as! CGFloat) + titleLabelInset.bottom + (divider ? dividerInset.top + dividerInset.bottom : 0)
} }
} else if nil != metrics["insetC"] { } else if nil != metrics["insetC"] {
metrics["insetC"] = (metrics["insetC"] as! CGFloat) + contentInsetsRef.top + (divider ? dividerInsetsRef.top + dividerInsetsRef.bottom : 0) metrics["insetC"] = (metrics["insetC"] as! CGFloat) + contentInset.top + (divider ? dividerInset.top + dividerInset.bottom : 0)
} }
} else if nil != detailLabel { } else if nil != detailLabel {
if 0 < leftButtons?.count { if 0 < leftButtons?.count {
verticalFormat += "-(insetC)-[button]" verticalFormat += "-(insetC)-[button]"
views["button"] = leftButtons![0] views["button"] = leftButtons![0]
metrics["insetC"] = leftButtonsInsetsRef.top metrics["insetC"] = leftButtonsInset.top
metrics["insetBottom"] = contentInsetsRef.bottom + leftButtonsInsetsRef.bottom metrics["insetBottom"] = contentInset.bottom + leftButtonsInset.bottom
} else if 0 < rightButtons?.count { } else if 0 < rightButtons?.count {
verticalFormat += "-(insetC)-[button]" verticalFormat += "-(insetC)-[button]"
views["button"] = rightButtons![0] views["button"] = rightButtons![0]
metrics["insetC"] = rightButtonsInsetsRef.top metrics["insetC"] = rightButtonsInset.top
metrics["insetBottom"] = contentInsetsRef.bottom + rightButtonsInsetsRef.bottom metrics["insetBottom"] = contentInset.bottom + rightButtonsInset.bottom
} }
if nil == metrics["insetC"] { if nil == metrics["insetC"] {
metrics["insetBottom"] = contentInsetsRef.bottom + detailLabelInsetsRef.bottom + (divider ? dividerInsetsRef.top + dividerInsetsRef.bottom : 0) metrics["insetBottom"] = contentInset.bottom + detailLabelInset.bottom + (divider ? dividerInset.top + dividerInset.bottom : 0)
} else { } else {
metrics["insetC"] = (metrics["insetC"] as! CGFloat) + detailLabelInsetsRef.bottom + (divider ? dividerInsetsRef.top + dividerInsetsRef.bottom : 0) metrics["insetC"] = (metrics["insetC"] as! CGFloat) + detailLabelInset.bottom + (divider ? dividerInset.top + dividerInset.bottom : 0)
} }
} else { } else {
if 0 < leftButtons?.count { if 0 < leftButtons?.count {
verticalFormat += "-[button]" verticalFormat += "-[button]"
views["button"] = leftButtons![0] views["button"] = leftButtons![0]
metrics["insetTop"] = (metrics["insetTop"] as! CGFloat) + contentInsetsRef.top + leftButtonsInsetsRef.top + (divider ? dividerInsetsRef.top + dividerInsetsRef.bottom : 0) metrics["insetTop"] = (metrics["insetTop"] as! CGFloat) + contentInset.top + leftButtonsInset.top + (divider ? dividerInset.top + dividerInset.bottom : 0)
metrics["insetBottom"] = contentInsetsRef.bottom + leftButtonsInsetsRef.bottom metrics["insetBottom"] = contentInset.bottom + leftButtonsInset.bottom
} else if 0 < rightButtons?.count { } else if 0 < rightButtons?.count {
verticalFormat += "-[button]" verticalFormat += "-[button]"
views["button"] = rightButtons![0] views["button"] = rightButtons![0]
metrics["insetTop"] = (metrics["insetTop"] as! CGFloat) + contentInsetsRef.top + rightButtonsInsetsRef.top + (divider ? dividerInsetsRef.top + dividerInsetsRef.bottom : 0) metrics["insetTop"] = (metrics["insetTop"] as! CGFloat) + contentInset.top + rightButtonsInset.top + (divider ? dividerInset.top + dividerInset.bottom : 0)
metrics["insetBottom"] = contentInsetsRef.bottom + rightButtonsInsetsRef.bottom metrics["insetBottom"] = contentInset.bottom + rightButtonsInset.bottom
} else { } else {
if translatesAutoresizingMaskIntoConstraints { if translatesAutoresizingMaskIntoConstraints {
addConstraints(MaterialLayout.constraint("V:[view(height)]", options: [], metrics: ["height": imageLayer!.frame.height], views: ["view": self])) addConstraints(MaterialLayout.constraint("V:[view(height)]", options: [], metrics: ["height": imageLayer!.frame.height], views: ["view": self]))
...@@ -558,7 +558,7 @@ public class ImageCardView : MaterialPulseView { ...@@ -558,7 +558,7 @@ public class ImageCardView : MaterialPulseView {
layer.addSublayer(dividerLayer!) layer.addSublayer(dividerLayer!)
} }
dividerLayer?.backgroundColor = dividerColor?.CGColor dividerLayer?.backgroundColor = dividerColor?.CGColor
dividerLayer?.frame = CGRectMake(dividerInsetsRef.left, y, width - dividerInsetsRef.left - dividerInsetsRef.right, 1) dividerLayer?.frame = CGRectMake(dividerInset.left, y, width - dividerInset.left - dividerInset.right, 1)
} }
/** /**
......
...@@ -276,9 +276,9 @@ public class MaterialButton : UIButton { ...@@ -276,9 +276,9 @@ public class MaterialButton : UIButton {
/** /**
:name: contentInsets :name: contentInsets
*/ */
public var contentInsets: MaterialEdgeInsets { public var contentInsetPreset: MaterialEdgeInsets {
didSet { didSet {
let value: UIEdgeInsets = MaterialEdgeInsetsToValue(contentInsets) let value: UIEdgeInsets = MaterialEdgeInsetsToValue(contentInsetPreset)
contentEdgeInsets = UIEdgeInsetsMake(value.top, value.left, value.bottom, value.right) contentEdgeInsets = UIEdgeInsetsMake(value.top, value.left, value.bottom, value.right)
} }
} }
...@@ -292,7 +292,7 @@ public class MaterialButton : UIButton { ...@@ -292,7 +292,7 @@ public class MaterialButton : UIButton {
depth = .None depth = .None
shape = .None shape = .None
cornerRadius = .None cornerRadius = .None
contentInsets = .None contentInsetPreset = .None
super.init(coder: aDecoder) super.init(coder: aDecoder)
prepareView() prepareView()
} }
...@@ -308,7 +308,7 @@ public class MaterialButton : UIButton { ...@@ -308,7 +308,7 @@ public class MaterialButton : UIButton {
depth = .None depth = .None
shape = .None shape = .None
cornerRadius = .None cornerRadius = .None
contentInsets = .None contentInsetPreset = .None
super.init(frame: frame) super.init(frame: frame)
prepareView() prepareView()
} }
...@@ -318,7 +318,7 @@ public class MaterialButton : UIButton { ...@@ -318,7 +318,7 @@ public class MaterialButton : UIButton {
self.init(frame: CGRectNull) self.init(frame: CGRectNull)
} }
/// Overriding the layout callback for layer sublayers. /// Overriding the layout callback for sublayers.
public override func layoutSublayersOfLayer(layer: CALayer) { public override func layoutSublayersOfLayer(layer: CALayer) {
super.layoutSublayersOfLayer(layer) super.layoutSublayersOfLayer(layer)
if self.layer == layer { if self.layer == layer {
......
...@@ -325,7 +325,7 @@ public class MaterialView : UIView { ...@@ -325,7 +325,7 @@ public class MaterialView : UIView {
self.init(frame: CGRectNull) self.init(frame: CGRectNull)
} }
/// Overriding the layout callback for layer sublayers. /// Overriding the layout callback for sublayers.
public override func layoutSublayersOfLayer(layer: CALayer) { public override func layoutSublayersOfLayer(layer: CALayer) {
super.layoutSublayersOfLayer(layer) super.layoutSublayersOfLayer(layer)
if self.layer == layer { if self.layer == layer {
......
...@@ -31,16 +31,16 @@ public class NavigationBarView : MaterialView { ...@@ -31,16 +31,16 @@ public class NavigationBarView : MaterialView {
/** /**
:name: contentInsets :name: contentInsets
*/ */
public var contentInsets: MaterialEdgeInsets = .None { public var contentInsetPreset: MaterialEdgeInsets = .None {
didSet { didSet {
contentInsetsRef = MaterialEdgeInsetsToValue(contentInsets) contentInset = MaterialEdgeInsetsToValue(contentInsetPreset)
} }
} }
/** /**
:name: contentInsetsRef :name: contentInset
*/ */
public var contentInsetsRef: UIEdgeInsets = MaterialEdgeInsetsToValue(.Square2) { public var contentInset: UIEdgeInsets = MaterialEdgeInsetsToValue(.Square2) {
didSet { didSet {
reloadView() reloadView()
} }
...@@ -49,16 +49,16 @@ public class NavigationBarView : MaterialView { ...@@ -49,16 +49,16 @@ public class NavigationBarView : MaterialView {
/** /**
:name: titleLabelInsets :name: titleLabelInsets
*/ */
public var titleLabelInsets: MaterialEdgeInsets = .None { public var titleLabelInsetPreset: MaterialEdgeInsets = .None {
didSet { didSet {
titleLabelInsetsRef = MaterialEdgeInsetsToValue(titleLabelInsets) titleLabelInset = MaterialEdgeInsetsToValue(titleLabelInsetPreset)
} }
} }
/** /**
:name: titleLabelInsetsRef :name: titleLabelInset
*/ */
public var titleLabelInsetsRef: UIEdgeInsets = UIEdgeInsets(top: 8, left: 0, bottom: 0, right: 0) { public var titleLabelInset: UIEdgeInsets = UIEdgeInsets(top: 8, left: 0, bottom: 0, right: 0) {
didSet { didSet {
reloadView() reloadView()
} }
...@@ -77,16 +77,16 @@ public class NavigationBarView : MaterialView { ...@@ -77,16 +77,16 @@ public class NavigationBarView : MaterialView {
/** /**
:name: detailLabelInsets :name: detailLabelInsets
*/ */
public var detailLabelInsets: MaterialEdgeInsets = .None { public var detailLabelInsetPreset: MaterialEdgeInsets = .None {
didSet { didSet {
detailLabelInsetsRef = MaterialEdgeInsetsToValue(detailLabelInsets) detailLabelInset = MaterialEdgeInsetsToValue(detailLabelInsetPreset)
} }
} }
/** /**
:name: detailLabelInsetsRef :name: detailLabelInset
*/ */
public var detailLabelInsetsRef: UIEdgeInsets = MaterialEdgeInsetsToValue(.None) { public var detailLabelInset: UIEdgeInsets = MaterialEdgeInsetsToValue(.None) {
didSet { didSet {
reloadView() reloadView()
} }
...@@ -105,16 +105,16 @@ public class NavigationBarView : MaterialView { ...@@ -105,16 +105,16 @@ public class NavigationBarView : MaterialView {
/** /**
:name: leftButtonsInsets :name: leftButtonsInsets
*/ */
public var leftButtonsInsets: MaterialEdgeInsets = .None { public var leftButtonsInsetPreset: MaterialEdgeInsets = .None {
didSet { didSet {
leftButtonsInsetsRef = MaterialEdgeInsetsToValue(leftButtonsInsets) leftButtonsInset = MaterialEdgeInsetsToValue(leftButtonsInsetPreset)
} }
} }
/** /**
:name: leftButtonsInsetsRef :name: leftButtonsInset
*/ */
public var leftButtonsInsetsRef: UIEdgeInsets = UIEdgeInsets(top: 8, left: 0, bottom: 0, right: 0) { public var leftButtonsInset: UIEdgeInsets = UIEdgeInsets(top: 8, left: 0, bottom: 0, right: 0) {
didSet { didSet {
reloadView() reloadView()
} }
...@@ -137,16 +137,16 @@ public class NavigationBarView : MaterialView { ...@@ -137,16 +137,16 @@ public class NavigationBarView : MaterialView {
/** /**
:name: rightButtonsInsets :name: rightButtonsInsets
*/ */
public var rightButtonsInsets: MaterialEdgeInsets = .None { public var rightButtonsInsetPreset: MaterialEdgeInsets = .None {
didSet { didSet {
rightButtonsInsetsRef = MaterialEdgeInsetsToValue(rightButtonsInsets) rightButtonsInset = MaterialEdgeInsetsToValue(rightButtonsInsetPreset)
} }
} }
/** /**
:name: rightButtonsInsetsRef :name: rightButtonsInset
*/ */
public var rightButtonsInsetsRef: UIEdgeInsets = UIEdgeInsets(top: 8, left: 0, bottom: 0, right: 0) { public var rightButtonsInset: UIEdgeInsets = UIEdgeInsets(top: 8, left: 0, bottom: 0, right: 0) {
didSet { didSet {
reloadView() reloadView()
} }
...@@ -211,10 +211,10 @@ public class NavigationBarView : MaterialView { ...@@ -211,10 +211,10 @@ public class NavigationBarView : MaterialView {
if nil != titleLabel { if nil != titleLabel {
verticalFormat += "-(insetTop)" verticalFormat += "-(insetTop)"
metrics["insetTop"] = contentInsetsRef.top + titleLabelInsetsRef.top metrics["insetTop"] = contentInset.top + titleLabelInset.top
} else if nil != detailLabel { } else if nil != detailLabel {
verticalFormat += "-(insetTop)" verticalFormat += "-(insetTop)"
metrics["insetTop"] = contentInsetsRef.top + detailLabelInsetsRef.top metrics["insetTop"] = contentInset.top + detailLabelInset.top
} }
// title // title
...@@ -223,21 +223,21 @@ public class NavigationBarView : MaterialView { ...@@ -223,21 +223,21 @@ public class NavigationBarView : MaterialView {
views["titleLabel"] = v views["titleLabel"] = v
addSubview(v) addSubview(v)
MaterialLayout.alignToParentHorizontally(self, child: v, left: contentInsetsRef.left + titleLabelInsetsRef.left, right: contentInsetsRef.right + titleLabelInsetsRef.right) MaterialLayout.alignToParentHorizontally(self, child: v, left: contentInset.left + titleLabelInset.left, right: contentInset.right + titleLabelInset.right)
} }
// detail // detail
if let v = detailLabel { if let v = detailLabel {
if nil != titleLabel { if nil != titleLabel {
verticalFormat += "-(insetB)" verticalFormat += "-(insetB)"
metrics["insetB"] = titleLabelInsetsRef.bottom + detailLabelInsetsRef.top metrics["insetB"] = titleLabelInset.bottom + detailLabelInset.top
} }
verticalFormat += "-[detailLabel]" verticalFormat += "-[detailLabel]"
views["detailLabel"] = v views["detailLabel"] = v
addSubview(v) addSubview(v)
MaterialLayout.alignToParentHorizontally(self, child: v, left: contentInsetsRef.left + detailLabelInsetsRef.left, right: contentInsetsRef.right + detailLabelInsetsRef.right) MaterialLayout.alignToParentHorizontally(self, child: v, left: contentInset.left + detailLabelInset.left, right: contentInset.right + detailLabelInset.right)
} }
// leftButtons // leftButtons
...@@ -260,10 +260,10 @@ public class NavigationBarView : MaterialView { ...@@ -260,10 +260,10 @@ public class NavigationBarView : MaterialView {
h += "[\(k)]" h += "[\(k)]"
addSubview(b) addSubview(b)
MaterialLayout.alignFromBottom(self, child: b, bottom: contentInsetsRef.bottom + leftButtonsInsetsRef.bottom) MaterialLayout.alignFromBottom(self, child: b, bottom: contentInset.bottom + leftButtonsInset.bottom)
} }
addConstraints(MaterialLayout.constraint(h, options: [], metrics: ["left" : contentInsetsRef.left + leftButtonsInsetsRef.left, "left_right" : leftButtonsInsetsRef.left + leftButtonsInsetsRef.right], views: d)) addConstraints(MaterialLayout.constraint(h, options: [], metrics: ["left" : contentInset.left + leftButtonsInset.left, "left_right" : leftButtonsInset.left + leftButtonsInset.right], views: d))
} }
} }
...@@ -288,24 +288,24 @@ public class NavigationBarView : MaterialView { ...@@ -288,24 +288,24 @@ public class NavigationBarView : MaterialView {
} }
addSubview(b) addSubview(b)
MaterialLayout.alignFromBottom(self, child: b, bottom: contentInsetsRef.bottom + rightButtonsInsetsRef.bottom) MaterialLayout.alignFromBottom(self, child: b, bottom: contentInset.bottom + rightButtonsInset.bottom)
} }
addConstraints(MaterialLayout.constraint(h + "|", options: [], metrics: ["right" : contentInsetsRef.right + rightButtonsInsetsRef.right, "right_left" : rightButtonsInsetsRef.right + rightButtonsInsetsRef.left], views: d)) addConstraints(MaterialLayout.constraint(h + "|", options: [], metrics: ["right" : contentInset.right + rightButtonsInset.right, "right_left" : rightButtonsInset.right + rightButtonsInset.left], views: d))
} }
} }
if nil != detailLabel { if nil != detailLabel {
if nil == metrics["insetC"] { if nil == metrics["insetC"] {
metrics["insetBottom"] = contentInsetsRef.bottom + detailLabelInsetsRef.bottom metrics["insetBottom"] = contentInset.bottom + detailLabelInset.bottom
} else { } else {
metrics["insetC"] = (metrics["insetC"] as! CGFloat) + detailLabelInsetsRef.bottom metrics["insetC"] = (metrics["insetC"] as! CGFloat) + detailLabelInset.bottom
} }
} else if nil != titleLabel { } else if nil != titleLabel {
if nil == metrics["insetC"] { if nil == metrics["insetC"] {
metrics["insetBottom"] = contentInsetsRef.bottom + titleLabelInsetsRef.bottom metrics["insetBottom"] = contentInset.bottom + titleLabelInset.bottom
} else { } else {
metrics["insetC"] = (metrics["insetC"] as! CGFloat) + titleLabelInsetsRef.bottom metrics["insetC"] = (metrics["insetC"] as! CGFloat) + titleLabelInset.bottom
} }
} }
......
...@@ -32,6 +32,6 @@ public class RaisedButton : MaterialButton { ...@@ -32,6 +32,6 @@ public class RaisedButton : MaterialButton {
backgroundColor = MaterialColor.blue.accent3 backgroundColor = MaterialColor.blue.accent3
depth = .Depth2 depth = .Depth2
cornerRadius = .Radius1 cornerRadius = .Radius1
contentInsets = .WideRectangle3 contentInsetPreset = .WideRectangle3
} }
} }
\ No newline at end of file
...@@ -24,6 +24,21 @@ public class TextField : UITextField { ...@@ -24,6 +24,21 @@ public class TextField : UITextField {
/// The bottom border layer. /// The bottom border layer.
public private(set) lazy var bottomBorderLayer: CAShapeLayer = CAShapeLayer() public private(set) lazy var bottomBorderLayer: CAShapeLayer = CAShapeLayer()
/**
This property is the same as clipsToBounds. It crops any of the view's
contents from bleeding past the view's frame. If an image is set using
the image property, then this value does not need to be set, since the
visualLayer's maskToBounds is set to true by default.
*/
public var masksToBounds: Bool {
get {
return layer.masksToBounds
}
set(value) {
layer.masksToBounds = value
}
}
/// A property that accesses the backing layer's backgroundColor. /// A property that accesses the backing layer's backgroundColor.
public override var backgroundColor: UIColor? { public override var backgroundColor: UIColor? {
didSet { didSet {
...@@ -63,6 +78,9 @@ public class TextField : UITextField { ...@@ -63,6 +78,9 @@ public class TextField : UITextField {
} }
set(value) { set(value) {
layer.frame.size.width = value layer.frame.size.width = value
if .None != shape {
layer.frame.size.height = value
}
} }
} }
...@@ -78,6 +96,93 @@ public class TextField : UITextField { ...@@ -78,6 +96,93 @@ public class TextField : UITextField {
} }
set(value) { set(value) {
layer.frame.size.height = value layer.frame.size.height = value
if .None != shape {
layer.frame.size.width = value
}
}
}
/// A property that accesses the backing layer's shadowColor.
public var shadowColor: UIColor? {
didSet {
layer.shadowColor = shadowColor?.CGColor
}
}
/// A property that accesses the backing layer's shadowOffset.
public var shadowOffset: CGSize {
get {
return layer.shadowOffset
}
set(value) {
layer.shadowOffset = value
}
}
/// A property that accesses the backing layer's shadowOpacity.
public var shadowOpacity: Float {
get {
return layer.shadowOpacity
}
set(value) {
layer.shadowOpacity = value
}
}
/// A property that accesses the backing layer's shadowRadius.
public var shadowRadius: CGFloat {
get {
return layer.shadowRadius
}
set(value) {
layer.shadowRadius = value
}
}
/**
A property that sets the shadowOffset, shadowOpacity, and shadowRadius
for the backing layer. This is the preferred method of setting depth
in order to maintain consitency across UI objects.
*/
public var depth: MaterialDepth {
didSet {
let value: MaterialDepthType = MaterialDepthToValue(depth)
shadowOffset = value.offset
shadowOpacity = value.opacity
shadowRadius = value.radius
}
}
/**
A property that sets the cornerRadius of the backing layer. If the shape
property has a value of .Circle when the cornerRadius is set, it will
become .None, as it no longer maintains its circle shape.
*/
public var cornerRadius: MaterialRadius {
didSet {
if let v: MaterialRadius = cornerRadius {
layer.cornerRadius = MaterialRadiusToValue(v)
if .Circle == shape {
shape = .None
}
}
}
}
/**
A property that manages the overall shape for the object. If either the
width or height property is set, the other will be automatically adjusted
to maintain the shape of the object.
*/
public var shape: MaterialShape {
didSet {
if .None != shape {
if width < height {
frame.size.width = height
} else {
frame.size.height = width
}
}
} }
} }
...@@ -119,36 +224,35 @@ public class TextField : UITextField { ...@@ -119,36 +224,35 @@ public class TextField : UITextField {
} }
/** /**
:name: titleLabelNormalColor The title UILabel that is displayed when there is text. The
titleLabel text value is updated with the placeholder text
value before being displayed.
*/ */
public var titleLabelNormalColor: UIColor? { public var titleLabel: UILabel? {
didSet { didSet {
titleLabel?.textColor = titleLabelNormalColor prepareTitleLabel()
bottomBorderLayer.backgroundColor = titleLabelNormalColor?.CGColor
} }
} }
/** /// The color of the titleLabel text when the textField is not active.
:name: titleLabelHighlightedColor public var titleLabelTextColor: UIColor? {
*/ didSet {
public var titleLabelHighlightedColor: UIColor? titleLabel?.textColor = titleLabelTextColor
bottomBorderLayer.backgroundColor = titleLabelTextColor?.CGColor
}
}
/** /// The color of the titleLabel text when the textField is active.
:name: detailLabelHighlightedColor public var titleLabelActiveTextColor: UIColor?
*/
public var detailLabelHighlightedColor: UIColor?
/** /**
:name: titleLabel :name: detailLabelActiveTextColor
*/ */
public var titleLabel: UILabel? { public var detailLabelActiveTextColor: UIColor?
didSet {
prepareTitleLabel()
}
}
/** /**
:name: detailLabel The detail UILabel that is displayed when the detailLabelHidden property
is set to false.
*/ */
public var detailLabel: UILabel? { public var detailLabel: UILabel? {
didSet { didSet {
...@@ -162,11 +266,11 @@ public class TextField : UITextField { ...@@ -162,11 +266,11 @@ public class TextField : UITextField {
public var detailLabelHidden: Bool = false { public var detailLabelHidden: Bool = false {
didSet { didSet {
if detailLabelHidden { if detailLabelHidden {
bottomBorderLayer.backgroundColor = editing ? titleLabelHighlightedColor?.CGColor : titleLabelNormalColor?.CGColor bottomBorderLayer.backgroundColor = editing ? titleLabelActiveTextColor?.CGColor : titleLabelTextColor?.CGColor
hideDetailLabel() hideDetailLabel()
} else { } else {
detailLabel?.textColor = detailLabelHighlightedColor detailLabel?.textColor = detailLabelActiveTextColor
bottomBorderLayer.backgroundColor = detailLabelHighlightedColor?.CGColor bottomBorderLayer.backgroundColor = detailLabelActiveTextColor?.CGColor
showDetailLabel() showDetailLabel()
} }
} }
...@@ -176,6 +280,9 @@ public class TextField : UITextField { ...@@ -176,6 +280,9 @@ public class TextField : UITextField {
:name: init :name: init
*/ */
public required init?(coder aDecoder: NSCoder) { public required init?(coder aDecoder: NSCoder) {
depth = .None
shape = .None
cornerRadius = .None
borderWidth = .None borderWidth = .None
super.init(coder: aDecoder) super.init(coder: aDecoder)
prepareView() prepareView()
...@@ -185,6 +292,9 @@ public class TextField : UITextField { ...@@ -185,6 +292,9 @@ public class TextField : UITextField {
:name: init :name: init
*/ */
public override init(frame: CGRect) { public override init(frame: CGRect) {
depth = .None
shape = .None
cornerRadius = .None
borderWidth = .None borderWidth = .None
super.init(frame: frame) super.init(frame: frame)
prepareView() prepareView()
...@@ -197,21 +307,79 @@ public class TextField : UITextField { ...@@ -197,21 +307,79 @@ public class TextField : UITextField {
self.init(frame: CGRectNull) self.init(frame: CGRectNull)
} }
/** /// Overriding the layout callback for sublayers.
:name: layoutSublayersOfLayer
*/
public override func layoutSublayersOfLayer(layer: CALayer) { public override func layoutSublayersOfLayer(layer: CALayer) {
super.layoutSublayersOfLayer(layer) super.layoutSublayersOfLayer(layer)
if self.layer == layer { if self.layer == layer {
bottomBorderLayer.frame = CGRectMake(0, bounds.height + 8, bounds.width, 1) bottomBorderLayer.frame = CGRectMake(0, bounds.height + 8, bounds.width, 1)
layoutShape()
}
}
/**
A method that accepts CAAnimation objects and executes them on the
view's backing layer.
- Parameter animation: A CAAnimation instance.
*/
public func animate(animation: CAAnimation) {
animation.delegate = self
if let a: CABasicAnimation = animation as? CABasicAnimation {
a.fromValue = (nil == layer.presentationLayer() ? layer : layer.presentationLayer() as! CALayer).valueForKeyPath(a.keyPath!)
} }
if let a: CAPropertyAnimation = animation as? CAPropertyAnimation {
layer.addAnimation(a, forKey: a.keyPath!)
} else if let a: CAAnimationGroup = animation as? CAAnimationGroup {
layer.addAnimation(a, forKey: nil)
} else if let a: CATransition = animation as? CATransition {
layer.addAnimation(a, forKey: kCATransition)
}
}
/**
A delegation method that is executed when the backing layer starts
running an animation.
- Parameter anim: The currently running CAAnimation instance.
*/
public override func animationDidStart(anim: CAAnimation) {
(delegate as? MaterialAnimationDelegate)?.materialAnimationDidStart?(anim)
} }
/** /**
:name: prepareView A delegation method that is executed when the backing layer stops
running an animation.
- Parameter anim: The CAAnimation instance that stopped running.
- Parameter flag: A boolean that indicates if the animation stopped
because it was completed or interrupted. True if completed, false
if interrupted.
*/
public override func animationDidStop(anim: CAAnimation, finished flag: Bool) {
if let a: CAPropertyAnimation = anim as? CAPropertyAnimation {
if let b: CABasicAnimation = a as? CABasicAnimation {
MaterialAnimation.animationDisabled {
self.layer.setValue(nil == b.toValue ? b.byValue : b.toValue, forKey: b.keyPath!)
}
}
(delegate as? MaterialAnimationDelegate)?.materialAnimationDidStop?(anim, finished: flag)
layer.removeAnimationForKey(a.keyPath!)
} else if let a: CAAnimationGroup = anim as? CAAnimationGroup {
for x in a.animations! {
animationDidStop(x, finished: true)
}
}
}
/**
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() { public func prepareView() {
clipsToBounds = false backgroundColor = MaterialColor.white
shadowColor = MaterialColor.black
borderColor = MaterialColor.black
masksToBounds = false
prepareBottomBorderLayer() prepareBottomBorderLayer()
} }
...@@ -221,12 +389,12 @@ public class TextField : UITextField { ...@@ -221,12 +389,12 @@ public class TextField : UITextField {
internal func textFieldDidBegin(textField: TextField) { internal func textFieldDidBegin(textField: TextField) {
titleLabel?.text = placeholder titleLabel?.text = placeholder
if 0 == text?.utf16.count { if 0 == text?.utf16.count {
titleLabel?.textColor = titleLabelNormalColor titleLabel?.textColor = titleLabelTextColor
bottomBorderLayer.backgroundColor = titleLabelNormalColor?.CGColor bottomBorderLayer.backgroundColor = titleLabelTextColor?.CGColor
detailLabelHidden = true detailLabelHidden = true
} else { } else {
titleLabel?.textColor = titleLabelHighlightedColor titleLabel?.textColor = titleLabelActiveTextColor
bottomBorderLayer.backgroundColor = detailLabelHidden ? titleLabelHighlightedColor?.CGColor : detailLabelHighlightedColor?.CGColor bottomBorderLayer.backgroundColor = detailLabelHidden ? titleLabelActiveTextColor?.CGColor : detailLabelActiveTextColor?.CGColor
} }
} }
...@@ -236,8 +404,8 @@ public class TextField : UITextField { ...@@ -236,8 +404,8 @@ public class TextField : UITextField {
internal func textFieldDidChange(textField: TextField) { internal func textFieldDidChange(textField: TextField) {
if 0 < text?.utf16.count { if 0 < text?.utf16.count {
showTitleLabel() showTitleLabel()
titleLabel?.textColor = titleLabelHighlightedColor titleLabel?.textColor = titleLabelActiveTextColor
bottomBorderLayer.backgroundColor = detailLabelHidden ? titleLabelHighlightedColor?.CGColor : detailLabelHighlightedColor?.CGColor bottomBorderLayer.backgroundColor = detailLabelHidden ? titleLabelActiveTextColor?.CGColor : detailLabelActiveTextColor?.CGColor
} else if 0 == text?.utf16.count { } else if 0 == text?.utf16.count {
hideTitleLabel() hideTitleLabel()
detailLabelHidden = true detailLabelHidden = true
...@@ -253,8 +421,15 @@ public class TextField : UITextField { ...@@ -253,8 +421,15 @@ public class TextField : UITextField {
} else if 0 == text?.utf16.count { } else if 0 == text?.utf16.count {
hideTitleLabel() hideTitleLabel()
} }
titleLabel?.textColor = titleLabelNormalColor titleLabel?.textColor = titleLabelTextColor
bottomBorderLayer.backgroundColor = detailLabelHidden ? titleLabelNormalColor?.CGColor : detailLabelHighlightedColor?.CGColor bottomBorderLayer.backgroundColor = detailLabelHidden ? titleLabelTextColor?.CGColor : detailLabelActiveTextColor?.CGColor
}
/// Manages the layout for the shape of the view instance.
internal func layoutShape() {
if .Circle == shape {
layer.cornerRadius = width / 2
}
} }
/** /**
......
...@@ -21,49 +21,226 @@ import UIKit ...@@ -21,49 +21,226 @@ import UIKit
public protocol TextViewDelegate : UITextViewDelegate {} public protocol TextViewDelegate : UITextViewDelegate {}
public class TextView: UITextView { public class TextView: UITextView {
public var titleLabel: UILabel? { /**
This property is the same as clipsToBounds. It crops any of the view's
contents from bleeding past the view's frame. If an image is set using
the image property, then this value does not need to be set, since the
visualLayer's maskToBounds is set to true by default.
*/
public var masksToBounds: Bool {
get {
return layer.masksToBounds
}
set(value) {
layer.masksToBounds = value
}
}
/// A property that accesses the backing layer's backgroundColor.
public override var backgroundColor: UIColor? {
didSet { didSet {
prepareTitleLabel() layer.backgroundColor = backgroundColor?.CGColor
}
}
/// A property that accesses the layer.frame.origin.x property.
public var x: CGFloat {
get {
return layer.frame.origin.x
}
set(value) {
layer.frame.origin.x = value
}
}
/// A property that accesses the layer.frame.origin.y property.
public var y: CGFloat {
get {
return layer.frame.origin.y
}
set(value) {
layer.frame.origin.y = value
}
}
/**
A property that accesses the layer.frame.origin.width property.
When setting this property in conjunction with the shape property having a
value that is not .None, the height will be adjusted to maintain the correct
shape.
*/
public var width: CGFloat {
get {
return layer.frame.size.width
}
set(value) {
layer.frame.size.width = value
if .None != shape {
layer.frame.size.height = value
}
}
}
/**
A property that accesses the layer.frame.origin.height property.
When setting this property in conjunction with the shape property having a
value that is not .None, the width will be adjusted to maintain the correct
shape.
*/
public var height: CGFloat {
get {
return layer.frame.size.height
}
set(value) {
layer.frame.size.height = value
if .None != shape {
layer.frame.size.width = value
}
}
}
/// A property that accesses the backing layer's shadowColor.
public var shadowColor: UIColor? {
didSet {
layer.shadowColor = shadowColor?.CGColor
}
}
/// A property that accesses the backing layer's shadowOffset.
public var shadowOffset: CGSize {
get {
return layer.shadowOffset
}
set(value) {
layer.shadowOffset = value
}
}
/// A property that accesses the backing layer's shadowOpacity.
public var shadowOpacity: Float {
get {
return layer.shadowOpacity
}
set(value) {
layer.shadowOpacity = value
}
}
/// A property that accesses the backing layer's shadowRadius.
public var shadowRadius: CGFloat {
get {
return layer.shadowRadius
}
set(value) {
layer.shadowRadius = value
} }
} }
/** /**
:name: titleLabelNormalColor A property that sets the shadowOffset, shadowOpacity, and shadowRadius
for the backing layer. This is the preferred method of setting depth
in order to maintain consitency across UI objects.
*/ */
public var titleLabelNormalColor: UIColor? { public var depth: MaterialDepth {
didSet { didSet {
titleLabel?.textColor = titleLabelNormalColor let value: MaterialDepthType = MaterialDepthToValue(depth)
shadowOffset = value.offset
shadowOpacity = value.opacity
shadowRadius = value.radius
} }
} }
/** /**
:name: titleLabelHighlightedColor A property that sets the cornerRadius of the backing layer. If the shape
property has a value of .Circle when the cornerRadius is set, it will
become .None, as it no longer maintains its circle shape.
*/ */
public var titleLabelHighlightedColor: UIColor? public var cornerRadius: MaterialRadius {
didSet {
if let v: MaterialRadius = cornerRadius {
layer.cornerRadius = MaterialRadiusToValue(v)
if .Circle == shape {
shape = .None
}
}
}
}
/** /**
:name: init A property that manages the overall shape for the object. If either the
width or height property is set, the other will be automatically adjusted
to maintain the shape of the object.
*/ */
public required init?(coder aDecoder: NSCoder) { public var shape: MaterialShape {
super.init(coder: aDecoder) didSet {
prepareView() if .None != shape {
if width < height {
frame.size.width = height
} else {
frame.size.height = width
}
}
}
} }
/** /**
:name: init A property that accesses the layer.borderWith using a MaterialBorder
enum preset.
*/ */
public override init(frame: CGRect, textContainer: NSTextContainer?) { public var borderWidth: MaterialBorder {
super.init(frame: frame, textContainer: textContainer) didSet {
prepareView() layer.borderWidth = MaterialBorderToValue(borderWidth)
}
} }
// /// A property that accesses the layer.borderColor property.
// :name: deinit public var borderColor: UIColor? {
// didSet {
deinit { layer.borderColor = borderColor?.CGColor
removeNotificationHandlers() }
} }
/// A property that accesses the layer.position property.
public var position: CGPoint {
get {
return layer.position
}
set(value) {
layer.position = value
}
}
/// A property that accesses the layer.zPosition property.
public var zPosition: CGFloat {
get {
return layer.zPosition
}
set(value) {
layer.zPosition = value
}
}
/**
The title UILabel that is displayed when there is text. The
titleLabel text value is updated with the placeholderLabel
text value before being displayed.
*/
public var titleLabel: UILabel? {
didSet {
prepareTitleLabel()
}
}
/// The color of the titleLabel text when the textView is not active.
public var titleLabelTextColor: UIColor? {
didSet {
titleLabel?.textColor = titleLabelTextColor
}
}
/// The color of the titleLabel text when the textView is active.
public var titleLabelActiveTextColor: UIColor?
/** /**
:name: placeholderLabel :name: placeholderLabel
*/ */
...@@ -95,18 +272,119 @@ public class TextView: UITextView { ...@@ -95,18 +272,119 @@ public class TextView: UITextView {
/** /**
:name: textContainerInset :name: textContainerInset
*/ */
public var textContainerInsetPreset: MaterialEdgeInsets = .None {
didSet {
textContainerInset = MaterialEdgeInsetsToValue(textContainerInsetPreset)
}
}
/**
:name: textContainerInset
*/
public override var textContainerInset: UIEdgeInsets { public override var textContainerInset: UIEdgeInsets {
didSet { didSet {
reloadView() reloadView()
} }
} }
/**
:name: init
*/
public required init?(coder aDecoder: NSCoder) {
depth = .None
shape = .None
cornerRadius = .None
borderWidth = .None
super.init(coder: aDecoder)
prepareView()
}
/**
:name: init
*/
public override init(frame: CGRect, textContainer: NSTextContainer?) {
depth = .None
shape = .None
cornerRadius = .None
borderWidth = .None
super.init(frame: frame, textContainer: textContainer)
prepareView()
}
//
// :name: deinit
//
deinit {
removeNotificationHandlers()
}
/// Overriding the layout callback for subviews.
public override func layoutSubviews() { public override func layoutSubviews() {
super.layoutSubviews() super.layoutSubviews()
placeholderLabel?.preferredMaxLayoutWidth = textContainer.size.width - textContainer.lineFragmentPadding * 2 placeholderLabel?.preferredMaxLayoutWidth = textContainer.size.width - textContainer.lineFragmentPadding * 2
titleLabel?.frame.size.width = bounds.width titleLabel?.frame.size.width = bounds.width
} }
/// Overriding the layout callback for sublayers.
public override func layoutSublayersOfLayer(layer: CALayer) {
super.layoutSublayersOfLayer(layer)
if self.layer == layer {
layoutShape()
}
}
/**
A method that accepts CAAnimation objects and executes them on the
view's backing layer.
- Parameter animation: A CAAnimation instance.
*/
public func animate(animation: CAAnimation) {
animation.delegate = self
if let a: CABasicAnimation = animation as? CABasicAnimation {
a.fromValue = (nil == layer.presentationLayer() ? layer : layer.presentationLayer() as! CALayer).valueForKeyPath(a.keyPath!)
}
if let a: CAPropertyAnimation = animation as? CAPropertyAnimation {
layer.addAnimation(a, forKey: a.keyPath!)
} else if let a: CAAnimationGroup = animation as? CAAnimationGroup {
layer.addAnimation(a, forKey: nil)
} else if let a: CATransition = animation as? CATransition {
layer.addAnimation(a, forKey: kCATransition)
}
}
/**
A delegation method that is executed when the backing layer starts
running an animation.
- Parameter anim: The currently running CAAnimation instance.
*/
public override func animationDidStart(anim: CAAnimation) {
(delegate as? MaterialAnimationDelegate)?.materialAnimationDidStart?(anim)
}
/**
A delegation method that is executed when the backing layer stops
running an animation.
- Parameter anim: The CAAnimation instance that stopped running.
- Parameter flag: A boolean that indicates if the animation stopped
because it was completed or interrupted. True if completed, false
if interrupted.
*/
public override func animationDidStop(anim: CAAnimation, finished flag: Bool) {
if let a: CAPropertyAnimation = anim as? CAPropertyAnimation {
if let b: CABasicAnimation = a as? CABasicAnimation {
MaterialAnimation.animationDisabled {
self.layer.setValue(nil == b.toValue ? b.byValue : b.toValue, forKey: b.keyPath!)
}
}
(delegate as? MaterialAnimationDelegate)?.materialAnimationDidStop?(anim, finished: flag)
layer.removeAnimationForKey(a.keyPath!)
} else if let a: CAAnimationGroup = anim as? CAAnimationGroup {
for x in a.animations! {
animationDidStop(x, finished: true)
}
}
}
/** /**
:name: reloadView :name: reloadView
*/ */
...@@ -128,9 +406,9 @@ public class TextView: UITextView { ...@@ -128,9 +406,9 @@ public class TextView: UITextView {
internal func handleTextViewTextDidBegin() { internal func handleTextViewTextDidBegin() {
titleLabel?.text = placeholderLabel?.text titleLabel?.text = placeholderLabel?.text
if 0 == text?.utf16.count { if 0 == text?.utf16.count {
titleLabel?.textColor = titleLabelNormalColor titleLabel?.textColor = titleLabelTextColor
} else { } else {
titleLabel?.textColor = titleLabelHighlightedColor titleLabel?.textColor = titleLabelActiveTextColor
} }
} }
...@@ -144,7 +422,7 @@ public class TextView: UITextView { ...@@ -144,7 +422,7 @@ public class TextView: UITextView {
if 0 < text?.utf16.count { if 0 < text?.utf16.count {
showTitleLabel() showTitleLabel()
titleLabel?.textColor = titleLabelHighlightedColor titleLabel?.textColor = titleLabelActiveTextColor
} else if 0 == text?.utf16.count { } else if 0 == text?.utf16.count {
hideTitleLabel() hideTitleLabel()
} }
...@@ -159,16 +437,23 @@ public class TextView: UITextView { ...@@ -159,16 +437,23 @@ public class TextView: UITextView {
} else if 0 == text?.utf16.count { } else if 0 == text?.utf16.count {
hideTitleLabel() hideTitleLabel()
} }
titleLabel?.textColor = titleLabelNormalColor titleLabel?.textColor = titleLabelTextColor
}
/// Manages the layout for the shape of the view instance.
internal func layoutShape() {
if .Circle == shape {
layer.cornerRadius = width / 2
}
} }
// //
// :name: prepareView // :name: prepareView
// //
private func prepareView() { private func prepareView() {
textContainerInset = UIEdgeInsets(top: 24, left: 0, bottom: 24, right: 0) textContainerInset = UIEdgeInsets(top: 8, left: 0, bottom: 8, right: 0)
backgroundColor = MaterialColor.clear backgroundColor = MaterialColor.white
clipsToBounds = false masksToBounds = false
removeNotificationHandlers() removeNotificationHandlers()
prepareNotificationHandlers() prepareNotificationHandlers()
reloadView() reloadView()
...@@ -180,7 +465,7 @@ public class TextView: UITextView { ...@@ -180,7 +465,7 @@ public class TextView: UITextView {
v.font = font v.font = font
v.textAlignment = textAlignment v.textAlignment = textAlignment
v.numberOfLines = 0 v.numberOfLines = 0
v.backgroundColor = .clearColor() v.backgroundColor = MaterialColor.clear
titleLabel?.text = placeholderLabel?.text titleLabel?.text = placeholderLabel?.text
addSubview(v) addSubview(v)
reloadView() reloadView()
...@@ -188,9 +473,7 @@ public class TextView: UITextView { ...@@ -188,9 +473,7 @@ public class TextView: UITextView {
} }
} }
/** /// Prepares the titleLabel property.
:name: prepareTitleLabel
*/
private func prepareTitleLabel() { private func prepareTitleLabel() {
if let v: UILabel = titleLabel { if let v: UILabel = titleLabel {
MaterialAnimation.animationDisabled { MaterialAnimation.animationDisabled {
...@@ -204,9 +487,7 @@ public class TextView: UITextView { ...@@ -204,9 +487,7 @@ public class TextView: UITextView {
} }
} }
/** /// Shows and animates the titleLabel property.
:name: showTitleLabel
*/
private func showTitleLabel() { private func showTitleLabel() {
if let v: UILabel = titleLabel { if let v: UILabel = titleLabel {
v.frame.size.height = v.font.pointSize v.frame.size.height = v.font.pointSize
...@@ -218,9 +499,7 @@ public class TextView: UITextView { ...@@ -218,9 +499,7 @@ public class TextView: UITextView {
} }
} }
/** /// Hides and animates the titleLabel property.
:name: hideTitleLabel
*/
private func hideTitleLabel() { private func hideTitleLabel() {
if let v: UILabel = titleLabel { if let v: UILabel = titleLabel {
UIView.animateWithDuration(0.25, animations: { UIView.animateWithDuration(0.25, animations: {
...@@ -232,12 +511,14 @@ public class TextView: UITextView { ...@@ -232,12 +511,14 @@ public class TextView: UITextView {
} }
} }
/// Prepares the Notification handlers.
private func prepareNotificationHandlers() { private func prepareNotificationHandlers() {
NSNotificationCenter.defaultCenter().addObserver(self, selector: "handleTextViewTextDidBegin", name: UITextViewTextDidBeginEditingNotification, object: nil) NSNotificationCenter.defaultCenter().addObserver(self, selector: "handleTextViewTextDidBegin", name: UITextViewTextDidBeginEditingNotification, object: nil)
NSNotificationCenter.defaultCenter().addObserver(self, selector: "handleTextViewTextDidChange", name: UITextViewTextDidChangeNotification, object: nil) NSNotificationCenter.defaultCenter().addObserver(self, selector: "handleTextViewTextDidChange", name: UITextViewTextDidChangeNotification, object: nil)
NSNotificationCenter.defaultCenter().addObserver(self, selector: "handleTextViewTextDidEnd", name: UITextViewTextDidEndEditingNotification, object: nil) NSNotificationCenter.defaultCenter().addObserver(self, selector: "handleTextViewTextDidEnd", name: UITextViewTextDidEndEditingNotification, object: nil)
} }
/// Removes the Notification handlers.
private func removeNotificationHandlers() { private func removeNotificationHandlers() {
NSNotificationCenter.defaultCenter().removeObserver(self, name: UITextViewTextDidBeginEditingNotification, object: nil) NSNotificationCenter.defaultCenter().removeObserver(self, name: UITextViewTextDidBeginEditingNotification, object: nil)
NSNotificationCenter.defaultCenter().removeObserver(self, name: UITextViewTextDidChangeNotification, object: nil) NSNotificationCenter.defaultCenter().removeObserver(self, name: UITextViewTextDidChangeNotification, object: nil)
......
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