Commit a5a35b4c by Daniel Dahan

issue-27: updated default colors

parent e991d1ff
...@@ -24,7 +24,7 @@ public class FlatButton : MaterialButton { ...@@ -24,7 +24,7 @@ public class FlatButton : MaterialButton {
// //
internal override func prepareView() { internal override func prepareView() {
super.prepareView() super.prepareView()
setTitleColor(MaterialTheme.blue.darken1, forState: .Normal) setTitleColor(MaterialTheme.blueGrey.darken1, forState: .Normal)
backgroundColor = MaterialTheme.clear.color backgroundColor = MaterialTheme.clear.color
contentEdgeInsets = UIEdgeInsetsMake(4, 16, 4, 16) contentEdgeInsets = UIEdgeInsetsMake(4, 16, 4, 16)
} }
......
...@@ -44,7 +44,7 @@ public class MaterialButton : UIButton { ...@@ -44,7 +44,7 @@ public class MaterialButton : UIButton {
/** /**
:name: pulseColor :name: pulseColor
*/ */
public var pulseColor: UIColor? = MaterialTheme.blue.lighten3 public var pulseColor: UIColor? = MaterialTheme.blueGrey.lighten3
/** /**
:name: init :name: init
......
...@@ -49,7 +49,7 @@ public class MaterialCardView : UIView { ...@@ -49,7 +49,7 @@ public class MaterialCardView : UIView {
/** /**
:name: pulseColor :name: pulseColor
*/ */
public var pulseColor: UIColor = MaterialTheme.blue.lighten3 public var pulseColor: UIColor = MaterialTheme.blueGrey.lighten3
/** /**
:name: init :name: init
......
...@@ -25,7 +25,7 @@ public class RaisedButton : MaterialButton { ...@@ -25,7 +25,7 @@ public class RaisedButton : MaterialButton {
internal override func prepareView() { internal override func prepareView() {
super.prepareView() super.prepareView()
setTitleColor(MaterialTheme.white.color, forState: .Normal) setTitleColor(MaterialTheme.white.color, forState: .Normal)
backgroundColor = MaterialTheme.blue.darken1 backgroundColor = MaterialTheme.blueGrey.darken1
contentEdgeInsets = UIEdgeInsetsMake(4, 16, 4, 16) contentEdgeInsets = UIEdgeInsetsMake(4, 16, 4, 16)
} }
......
...@@ -57,12 +57,16 @@ public class TextView: UITextView { ...@@ -57,12 +57,16 @@ public class TextView: UITextView {
*/ */
public var placeholderLabel: UILabel? { public var placeholderLabel: UILabel? {
didSet { didSet {
placeholderLabel!.setTranslatesAutoresizingMaskIntoConstraints(false) if let p = placeholderLabel {
placeholderLabel!.font = font p.setTranslatesAutoresizingMaskIntoConstraints(false)
placeholderLabel!.textAlignment = textAlignment p.font = font
placeholderLabel!.numberOfLines = 0 p.textAlignment = textAlignment
placeholderLabel!.backgroundColor = MaterialTheme.clear.color p.numberOfLines = 0
addSubview(placeholderLabel!) p.backgroundColor = MaterialTheme.clear.color
addSubview(p)
updateLabelConstraints()
textViewTextDidChange()
}
} }
} }
...@@ -107,7 +111,9 @@ public class TextView: UITextView { ...@@ -107,7 +111,9 @@ public class TextView: UITextView {
// :description: Updates the label visibility when text is empty or not. // :description: Updates the label visibility when text is empty or not.
// //
internal func textViewTextDidChange() { internal func textViewTextDidChange() {
placeholderLabel?.hidden = !text.isEmpty if let p = placeholderLabel {
p.hidden = !text.isEmpty
}
} }
// //
...@@ -118,7 +124,7 @@ public class TextView: UITextView { ...@@ -118,7 +124,7 @@ public class TextView: UITextView {
// label needs to be added to the view // label needs to be added to the view
// hierarchy before setting insets // hierarchy before setting insets
textContainerInset = UIEdgeInsetsMake(16, 16, 16, 16) textContainerInset = UIEdgeInsetsMake(16, 16, 16, 16)
backgroundColor = MaterialTheme.clear.color
NSNotificationCenter.defaultCenter().addObserver(self, selector: "textViewTextDidChange", name: UITextViewTextDidChangeNotification, object: nil) NSNotificationCenter.defaultCenter().addObserver(self, selector: "textViewTextDidChange", name: UITextViewTextDidChangeNotification, object: nil)
updateLabelConstraints() updateLabelConstraints()
} }
...@@ -128,27 +134,26 @@ public class TextView: UITextView { ...@@ -128,27 +134,26 @@ public class TextView: UITextView {
// :description: Updates the placeholder constraints. // :description: Updates the placeholder constraints.
// //
private func updateLabelConstraints() { private func updateLabelConstraints() {
if nil != placeholderLabel { if let p = placeholderLabel {
NSLayoutConstraint.deactivateConstraints(layoutConstraints) NSLayoutConstraint.deactivateConstraints(layoutConstraints)
layoutConstraints = Layout.constraint("H:|-(left)-[placeholder]-(right)-|", layoutConstraints = Layout.constraint("H:|-(left)-[placeholderLabel]-(right)-|",
options: nil, options: nil,
metrics: [ metrics: [
"left": textContainerInset.left + textContainer.lineFragmentPadding, "left": textContainerInset.left + textContainer.lineFragmentPadding,
"right": textContainerInset.right + textContainer.lineFragmentPadding "right": textContainerInset.right + textContainer.lineFragmentPadding
], views: [ ], views: [
"placeholder": placeholderLabel! "placeholderLabel": p
]) ])
layoutConstraints += Layout.constraint("V:|-(top)-[placeholder]-(>=bottom)-|", layoutConstraints += Layout.constraint("V:|-(top)-[placeholderLabel]-(>=bottom)-|",
options: nil, options: nil,
metrics: [ metrics: [
"top": textContainerInset.top, "top": textContainerInset.top,
"bottom": textContainerInset.bottom "bottom": textContainerInset.bottom
], ],
views: [ views: [
"placeholder": placeholderLabel! "placeholderLabel": p
]) ])
NSLayoutConstraint.activateConstraints(layoutConstraints) NSLayoutConstraint.activateConstraints(layoutConstraints)
} }
} }
......
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