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
......
...@@ -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
...@@ -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
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