Commit b66f37d2 by Daniel Dahan

updated internal presets and default values

parent 0209d364
......@@ -141,9 +141,9 @@ class ViewController: UIViewController {
*/
private func prepareCardViewWithAlteredAlignmentExample() {
let cardView: CardView = CardView()
cardView.dividerInsetsRef.left = 100
cardView.titleLabelInsetsRef.left = 100
cardView.detailLabelInsetsRef.left = 100
cardView.dividerInset.left = 100
cardView.titleLabelInset.left = 100
cardView.detailLabelInset.left = 100
cardView.pulseColor = MaterialColor.teal.lighten4
// Image.
......
......@@ -69,7 +69,7 @@ class ViewController: UIViewController {
titleLabel.textColor = MaterialColor.white
titleLabel.font = RobotoFont.mediumWithSize(24)
imageCardView.titleLabel = titleLabel
imageCardView.titleLabelInsetsRef.top = 100
imageCardView.titleLabelInset.top = 100
// Detail label.
let detailLabel: UILabel = UILabel()
......@@ -120,7 +120,7 @@ class ViewController: UIViewController {
titleLabel.textColor = MaterialColor.white
titleLabel.font = RobotoFont.regularWithSize(24)
imageCardView.titleLabel = titleLabel
imageCardView.titleLabelInsetsRef.top = 80
imageCardView.titleLabelInset.top = 80
// Star button.
let img1: UIImage? = UIImage(named: "ic_star_grey_darken_2")
......
......@@ -253,7 +253,7 @@ class ViewController: UIViewController {
titleLabel.textColor = MaterialColor.white
titleLabel.font = RobotoFont.regularWithSize(20)
navigationBarView.titleLabel = titleLabel
navigationBarView.titleLabelInsetsRef.left = 64
navigationBarView.titleLabelInset.left = 64
// Detail label.
let detailLabel: UILabel = UILabel()
......@@ -262,7 +262,7 @@ class ViewController: UIViewController {
detailLabel.textColor = MaterialColor.white
detailLabel.font = RobotoFont.regularWithSize(12)
navigationBarView.detailLabel = detailLabel
navigationBarView.detailLabelInsetsRef.left = 64
navigationBarView.detailLabelInset.left = 64
// Menu button.
let img1: UIImage? = UIImage(named: "ic_menu_white")
......
......@@ -7,6 +7,8 @@
objects = {
/* 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 */; };
966F57A31C226BAA009185B7 /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 966F57A21C226BAA009185B7 /* ViewController.swift */; };
966F57A81C226BAA009185B7 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 966F57A71C226BAA009185B7 /* Assets.xcassets */; };
......@@ -20,6 +22,7 @@
dstPath = "";
dstSubfolderSpec = 10;
files = (
960590371C38B80400691E88 /* MaterialKit.framework in Embed Frameworks */,
);
name = "Embed Frameworks";
runOnlyForDeploymentPostprocessing = 0;
......@@ -27,6 +30,7 @@
/* End PBXCopyFilesBuildPhase 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; };
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>"; };
......@@ -40,6 +44,7 @@
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
960590361C38B80400691E88 /* MaterialKit.framework in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
};
......@@ -49,6 +54,7 @@
966F57941C226BAA009185B7 = {
isa = PBXGroup;
children = (
960590351C38B80400691E88 /* MaterialKit.framework */,
966F579F1C226BAA009185B7 /* TextField */,
966F579E1C226BAA009185B7 /* Products */,
);
......
......@@ -50,8 +50,8 @@ class ViewController: UIViewController, TextFieldDelegate {
nameField.textColor = MaterialColor.black
nameField.titleLabel = UILabel()
nameField.titleLabel!.font = RobotoFont.mediumWithSize(12)
nameField.titleLabelNormalColor = MaterialColor.grey.lighten2
nameField.titleLabelHighlightedColor = MaterialColor.blue.accent3
nameField.titleLabelTextColor = MaterialColor.grey.lighten2
nameField.titleLabelActiveTextColor = MaterialColor.blue.accent3
nameField.clearButtonMode = .WhileEditing
view.addSubview(nameField)
}
......@@ -68,13 +68,13 @@ class ViewController: UIViewController, TextFieldDelegate {
emailField.textColor = MaterialColor.black
emailField.titleLabel = UILabel()
emailField.titleLabel!.font = RobotoFont.mediumWithSize(12)
emailField.titleLabelNormalColor = MaterialColor.grey.lighten2
emailField.titleLabelHighlightedColor = MaterialColor.blue.accent3
emailField.titleLabelTextColor = MaterialColor.grey.lighten2
emailField.titleLabelActiveTextColor = MaterialColor.blue.accent3
emailField.clearButtonMode = .WhileEditing
emailField.detailLabel = UILabel()
emailField.detailLabel!.text = "Email is incorrect."
emailField.detailLabel!.font = RobotoFont.mediumWithSize(12)
emailField.detailLabelHighlightedColor = MaterialColor.red.accent3
emailField.detailLabelActiveTextColor = MaterialColor.red.accent3
view.addSubview(emailField)
}
......
......@@ -53,8 +53,8 @@ class ViewController: UIViewController, TextDelegate, TextViewDelegate {
textView.titleLabel = UILabel()
textView.titleLabel!.font = RobotoFont.mediumWithSize(12)
textView.titleLabelNormalColor = MaterialColor.grey.lighten2
textView.titleLabelHighlightedColor = MaterialColor.blue.accent3
textView.titleLabelTextColor = MaterialColor.grey.lighten2
textView.titleLabelActiveTextColor = MaterialColor.blue.accent3
view.addSubview(textView)
textView!.translatesAutoresizingMaskIntoConstraints = false
......@@ -69,6 +69,5 @@ class ViewController: UIViewController, TextDelegate, TextViewDelegate {
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)
}
}
......@@ -83,9 +83,9 @@ class ViewController: UIViewController {
:description: General usage example.
*/
func prepareCardViewExampleTwo() {
secondCardView.dividerInsetsRef.left = 100
secondCardView.titleLabelInsetsRef.left = 100
secondCardView.detailLabelInsetsRef.left = 100
secondCardView.dividerInset.left = 100
secondCardView.titleLabelInset.left = 100
secondCardView.detailLabelInset.left = 100
secondCardView.pulseColor = MaterialColor.teal.lighten4
// Image.
......
......@@ -46,7 +46,7 @@ class ViewController: UIViewController {
titleLabel.textColor = MaterialColor.white
titleLabel.font = RobotoFont.regularWithSize(24)
imageCardView.titleLabel = titleLabel
imageCardView.titleLabelInsetsRef.top = 80
imageCardView.titleLabelInset.top = 80
// Star button.
let img1: UIImage? = UIImage(named: "ic_star_grey_darken_2")
......@@ -77,7 +77,7 @@ class ViewController: UIViewController {
// Add buttons to right side.
imageCardView.rightButtons = [btn1, btn2, btn3]
imageCardView.rightButtonsInsetsRef.top = imageCardView.contentInsetsRef.top
imageCardView.rightButtonsInset.top = imageCardView.contentInset.top
}
}
......@@ -58,7 +58,7 @@ class ViewController: UIViewController {
titleLabel.textColor = MaterialColor.white
titleLabel.font = RobotoFont.regularWithSize(20)
navigationBarView.titleLabel = titleLabel
navigationBarView.titleLabelInsetsRef.left = 64
navigationBarView.titleLabelInset.left = 64
// Detail label.
let detailLabel: UILabel = UILabel()
......@@ -67,7 +67,7 @@ class ViewController: UIViewController {
detailLabel.textColor = MaterialColor.white
detailLabel.font = RobotoFont.regularWithSize(12)
navigationBarView.detailLabel = detailLabel
navigationBarView.detailLabelInsetsRef.left = 64
navigationBarView.detailLabelInset.left = 64
// Menu button.
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
### Table of Contents
* [MaterialColor](#materialcolor)
* [MaterialLayer](#materiallayer)
* [MaterialView](#materialview)
* [MaterialPulseView](#materialpulseview)
......@@ -43,7 +44,6 @@ Run carthage to build the framework and drag the built MaterialKit.framework int
* [Crop Image](#cropimage)
* [Save Image To PhotoLibrary](#saveimagetophotolibrary)
* [Asynchronous Image Loading](#asynchronousimageloading)
* [MaterialColor](#materialcolor)
* [TextField](#textfield)
* [TextView](#textview)
* [Lines of Text](#linesoftext)
......@@ -63,6 +63,40 @@ Run carthage to build the framework and drag the built MaterialKit.framework int
* TimePicker
* 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"/>
### MaterialLayer
......@@ -266,9 +300,9 @@ Adjust the alignment of the UI elements to create different configurations of th
```swift
let cardView: CardView = CardView()
cardView.dividerInsetsRef.left = 100
cardView.titleLabelInsetsRef.left = 100
cardView.detailLabelInsetsRef.left = 100
cardView.dividerInset.left = 100
cardView.titleLabelInset.left = 100
cardView.detailLabelInset.left = 100
cardView.pulseColor = MaterialColor.teal.lighten4
// Image.
......@@ -376,7 +410,7 @@ titleLabel.text = "Welcome Back!"
titleLabel.textColor = MaterialColor.white
titleLabel.font = RobotoFont.mediumWithSize(24)
imageCardView.titleLabel = titleLabel
imageCardView.titleLabelInsetsRef.top = 100
imageCardView.titleLabelInset.top = 100
// Detail label.
let detailLabel: UILabel = UILabel()
......@@ -427,7 +461,7 @@ titleLabel.text = "Material Design"
titleLabel.textColor = MaterialColor.white
titleLabel.font = RobotoFont.regularWithSize(24)
imageCardView.titleLabel = titleLabel
imageCardView.titleLabelInsetsRef.top = 80
imageCardView.titleLabelInset.top = 80
// Star button.
let img1: UIImage? = UIImage(named: "ic_star_grey_darken_2")
......@@ -490,7 +524,7 @@ titleLabel.textAlignment = .Left
titleLabel.textColor = MaterialColor.white
titleLabel.font = RobotoFont.regularWithSize(20)
navigationBarView.titleLabel = titleLabel
navigationBarView.titleLabelInsetsRef.left = 64
navigationBarView.titleLabelInset.left = 64
// Detail label.
let detailLabel: UILabel = UILabel()
......@@ -499,7 +533,7 @@ detailLabel.textAlignment = .Left
detailLabel.textColor = MaterialColor.white
detailLabel.font = RobotoFont.regularWithSize(12)
navigationBarView.detailLabel = detailLabel
navigationBarView.detailLabelInsetsRef.left = 64
navigationBarView.detailLabelInset.left = 64
// Menu button.
let img1: UIImage? = UIImage(named: "ic_menu_white")
......@@ -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"/>
### TextView
......@@ -664,7 +664,7 @@ Easily match any regular expression pattern in a body of text. Below is an examp
```swift
class ViewController: UIViewController, TextDelegate, TextViewDelegate {
lazy var text: Text = Text()
var textView: TextView?
var textView: TextView!
override func viewDidLoad() {
super.viewDidLoad()
......@@ -685,18 +685,23 @@ class ViewController: UIViewController, TextDelegate, TextViewDelegate {
text.textStorage.addLayoutManager(layoutManager)
textView = TextView(frame: CGRectNull, textContainer: textContainer)
textView?.delegate = self
textView!.editable = true
textView!.selectable = true
textView!.font = RobotoFont.regular
textView.delegate = self
textView.editable = true
textView.selectable = true
textView.font = RobotoFont.regular
textView.placeholderLabel = UILabel()
textView.placeholderLabel!.textColor = MaterialColor.grey.base
textView.placeholderLabel!.text = "Description"
textView!.placeholderLabel = UILabel()
textView!.placeholderLabel!.textColor = MaterialColor.grey.base
textView!.placeholderLabel!.text = "MaterialKit TextView"
textView.titleLabel = UILabel()
textView.titleLabel!.font = RobotoFont.mediumWithSize(12)
textView.titleLabelNormalColor = MaterialColor.grey.lighten2
textView.titleLabelHighlightedColor = MaterialColor.blue.accent3
view.addSubview(textView!)
view.addSubview(textView)
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) {
......
......@@ -173,16 +173,16 @@ public class CaptureView : MaterialView, UIGestureRecognizerDelegate {
/**
:name: contentInsets
*/
public var contentInsets: MaterialEdgeInsets = .None {
public var contentInsetPreset: MaterialEdgeInsets = .None {
didSet {
contentInsetsRef = MaterialEdgeInsetsToValue(contentInsets)
contentInset = MaterialEdgeInsetsToValue(contentInsetPreset)
}
}
/**
:name: contentInsetsRef
:name: contentInset
*/
public var contentInsetsRef: UIEdgeInsets = MaterialEdgeInsetsToValue(.Square4) {
public var contentInset: UIEdgeInsets = MaterialEdgeInsetsToValue(.Square4) {
didSet {
reloadView()
}
......@@ -287,16 +287,16 @@ public class CaptureView : MaterialView, UIGestureRecognizerDelegate {
previewView.frame = bounds
if let v: UIButton = cameraButton {
v.frame.origin.y = bounds.height - contentInsetsRef.bottom - v.bounds.height
v.frame.origin.x = contentInsetsRef.left
v.frame.origin.y = bounds.height - contentInset.bottom - v.bounds.height
v.frame.origin.x = contentInset.left
}
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
}
if let v: UIButton = videoButton {
v.frame.origin.y = bounds.height - contentInsetsRef.bottom - v.bounds.height
v.frame.origin.x = bounds.width - v.bounds.width - contentInsetsRef.right
v.frame.origin.y = bounds.height - contentInset.bottom - v.bounds.height
v.frame.origin.x = bounds.width - v.bounds.width - contentInset.right
}
if let v: AVCaptureConnection = (previewView.layer as! AVCaptureVideoPreviewLayer).connection {
v.videoOrientation = captureSession.currentVideoOrientation
......
......@@ -31,6 +31,6 @@ public class FlatButton : MaterialButton {
setTitleColor(MaterialColor.blue.accent3, forState: .Normal)
pulseColor = MaterialColor.blue.accent3
cornerRadius = .Radius1
contentInsets = .WideRectangle3
contentInsetPreset = .WideRectangle3
}
}
\ No newline at end of file
......@@ -276,9 +276,9 @@ public class MaterialButton : UIButton {
/**
:name: contentInsets
*/
public var contentInsets: MaterialEdgeInsets {
public var contentInsetPreset: MaterialEdgeInsets {
didSet {
let value: UIEdgeInsets = MaterialEdgeInsetsToValue(contentInsets)
let value: UIEdgeInsets = MaterialEdgeInsetsToValue(contentInsetPreset)
contentEdgeInsets = UIEdgeInsetsMake(value.top, value.left, value.bottom, value.right)
}
}
......@@ -292,7 +292,7 @@ public class MaterialButton : UIButton {
depth = .None
shape = .None
cornerRadius = .None
contentInsets = .None
contentInsetPreset = .None
super.init(coder: aDecoder)
prepareView()
}
......@@ -308,7 +308,7 @@ public class MaterialButton : UIButton {
depth = .None
shape = .None
cornerRadius = .None
contentInsets = .None
contentInsetPreset = .None
super.init(frame: frame)
prepareView()
}
......@@ -318,7 +318,7 @@ public class MaterialButton : UIButton {
self.init(frame: CGRectNull)
}
/// Overriding the layout callback for layer sublayers.
/// Overriding the layout callback for sublayers.
public override func layoutSublayersOfLayer(layer: CALayer) {
super.layoutSublayersOfLayer(layer)
if self.layer == layer {
......
......@@ -325,7 +325,7 @@ public class MaterialView : UIView {
self.init(frame: CGRectNull)
}
/// Overriding the layout callback for layer sublayers.
/// Overriding the layout callback for sublayers.
public override func layoutSublayersOfLayer(layer: CALayer) {
super.layoutSublayersOfLayer(layer)
if self.layer == layer {
......
......@@ -31,16 +31,16 @@ public class NavigationBarView : MaterialView {
/**
:name: contentInsets
*/
public var contentInsets: MaterialEdgeInsets = .None {
public var contentInsetPreset: MaterialEdgeInsets = .None {
didSet {
contentInsetsRef = MaterialEdgeInsetsToValue(contentInsets)
contentInset = MaterialEdgeInsetsToValue(contentInsetPreset)
}
}
/**
:name: contentInsetsRef
:name: contentInset
*/
public var contentInsetsRef: UIEdgeInsets = MaterialEdgeInsetsToValue(.Square2) {
public var contentInset: UIEdgeInsets = MaterialEdgeInsetsToValue(.Square2) {
didSet {
reloadView()
}
......@@ -49,16 +49,16 @@ public class NavigationBarView : MaterialView {
/**
:name: titleLabelInsets
*/
public var titleLabelInsets: MaterialEdgeInsets = .None {
public var titleLabelInsetPreset: MaterialEdgeInsets = .None {
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 {
reloadView()
}
......@@ -77,16 +77,16 @@ public class NavigationBarView : MaterialView {
/**
:name: detailLabelInsets
*/
public var detailLabelInsets: MaterialEdgeInsets = .None {
public var detailLabelInsetPreset: MaterialEdgeInsets = .None {
didSet {
detailLabelInsetsRef = MaterialEdgeInsetsToValue(detailLabelInsets)
detailLabelInset = MaterialEdgeInsetsToValue(detailLabelInsetPreset)
}
}
/**
:name: detailLabelInsetsRef
:name: detailLabelInset
*/
public var detailLabelInsetsRef: UIEdgeInsets = MaterialEdgeInsetsToValue(.None) {
public var detailLabelInset: UIEdgeInsets = MaterialEdgeInsetsToValue(.None) {
didSet {
reloadView()
}
......@@ -105,16 +105,16 @@ public class NavigationBarView : MaterialView {
/**
:name: leftButtonsInsets
*/
public var leftButtonsInsets: MaterialEdgeInsets = .None {
public var leftButtonsInsetPreset: MaterialEdgeInsets = .None {
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 {
reloadView()
}
......@@ -137,16 +137,16 @@ public class NavigationBarView : MaterialView {
/**
:name: rightButtonsInsets
*/
public var rightButtonsInsets: MaterialEdgeInsets = .None {
public var rightButtonsInsetPreset: MaterialEdgeInsets = .None {
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 {
reloadView()
}
......@@ -211,10 +211,10 @@ public class NavigationBarView : MaterialView {
if nil != titleLabel {
verticalFormat += "-(insetTop)"
metrics["insetTop"] = contentInsetsRef.top + titleLabelInsetsRef.top
metrics["insetTop"] = contentInset.top + titleLabelInset.top
} else if nil != detailLabel {
verticalFormat += "-(insetTop)"
metrics["insetTop"] = contentInsetsRef.top + detailLabelInsetsRef.top
metrics["insetTop"] = contentInset.top + detailLabelInset.top
}
// title
......@@ -223,21 +223,21 @@ public class NavigationBarView : MaterialView {
views["titleLabel"] = 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
if let v = detailLabel {
if nil != titleLabel {
verticalFormat += "-(insetB)"
metrics["insetB"] = titleLabelInsetsRef.bottom + detailLabelInsetsRef.top
metrics["insetB"] = titleLabelInset.bottom + detailLabelInset.top
}
verticalFormat += "-[detailLabel]"
views["detailLabel"] = 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
......@@ -260,10 +260,10 @@ public class NavigationBarView : MaterialView {
h += "[\(k)]"
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 {
}
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 == metrics["insetC"] {
metrics["insetBottom"] = contentInsetsRef.bottom + detailLabelInsetsRef.bottom
metrics["insetBottom"] = contentInset.bottom + detailLabelInset.bottom
} else {
metrics["insetC"] = (metrics["insetC"] as! CGFloat) + detailLabelInsetsRef.bottom
metrics["insetC"] = (metrics["insetC"] as! CGFloat) + detailLabelInset.bottom
}
} else if nil != titleLabel {
if nil == metrics["insetC"] {
metrics["insetBottom"] = contentInsetsRef.bottom + titleLabelInsetsRef.bottom
metrics["insetBottom"] = contentInset.bottom + titleLabelInset.bottom
} 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 {
backgroundColor = MaterialColor.blue.accent3
depth = .Depth2
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