Commit b54e9c05 by Daniel Dahan

Removed shape code that was not needed in TextField and TextView.

parent 3cafeeb0
...@@ -85,7 +85,7 @@ public class BottomTabBar : UITabBar { ...@@ -85,7 +85,7 @@ public class BottomTabBar : UITabBar {
} }
/** /**
A property that accesses the layer.frame.origin.width property. A property that accesses the layer.frame.size.width property.
When setting this property in conjunction with the shape property having a 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 value that is not .None, the height will be adjusted to maintain the correct
shape. shape.
...@@ -100,7 +100,7 @@ public class BottomTabBar : UITabBar { ...@@ -100,7 +100,7 @@ public class BottomTabBar : UITabBar {
} }
/** /**
A property that accesses the layer.frame.origin.height property. A property that accesses the layer.frame.size.height property.
When setting this property in conjunction with the shape property having a 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 value that is not .None, the width will be adjusted to maintain the correct
shape. shape.
......
...@@ -104,7 +104,7 @@ public class MaterialButton : UIButton { ...@@ -104,7 +104,7 @@ public class MaterialButton : UIButton {
} }
/** /**
A property that accesses the layer.frame.origin.width property. A property that accesses the layer.frame.size.width property.
When setting this property in conjunction with the shape property having a 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 value that is not .None, the height will be adjusted to maintain the correct
shape. shape.
...@@ -122,7 +122,7 @@ public class MaterialButton : UIButton { ...@@ -122,7 +122,7 @@ public class MaterialButton : UIButton {
} }
/** /**
A property that accesses the layer.frame.origin.height property. A property that accesses the layer.frame.size.height property.
When setting this property in conjunction with the shape property having a 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 value that is not .None, the width will be adjusted to maintain the correct
shape. shape.
......
...@@ -211,7 +211,7 @@ public class MaterialCollectionViewCell : UICollectionViewCell { ...@@ -211,7 +211,7 @@ public class MaterialCollectionViewCell : UICollectionViewCell {
} }
/** /**
A property that accesses the layer.frame.origin.width property. A property that accesses the layer.frame.size.width property.
When setting this property in conjunction with the shape property having a 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 value that is not .None, the height will be adjusted to maintain the correct
shape. shape.
...@@ -229,7 +229,7 @@ public class MaterialCollectionViewCell : UICollectionViewCell { ...@@ -229,7 +229,7 @@ public class MaterialCollectionViewCell : UICollectionViewCell {
} }
/** /**
A property that accesses the layer.frame.origin.height property. A property that accesses the layer.frame.size.height property.
When setting this property in conjunction with the shape property having a 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 value that is not .None, the width will be adjusted to maintain the correct
shape. shape.
......
...@@ -64,7 +64,7 @@ public class MaterialLayer : CAShapeLayer { ...@@ -64,7 +64,7 @@ public class MaterialLayer : CAShapeLayer {
} }
/** /**
A property that accesses the layer.frame.origin.width property. A property that accesses the layer.frame.size.width property.
When setting this property in conjunction with the shape property having a 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 value that is not .None, the height will be adjusted to maintain the correct
shape. shape.
...@@ -82,7 +82,7 @@ public class MaterialLayer : CAShapeLayer { ...@@ -82,7 +82,7 @@ public class MaterialLayer : CAShapeLayer {
} }
/** /**
A property that accesses the layer.frame.origin.height property. A property that accesses the layer.frame.size.height property.
When setting this property in conjunction with the shape property having a 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 value that is not .None, the width will be adjusted to maintain the correct
shape. shape.
......
...@@ -94,7 +94,7 @@ public class MaterialSwitch : UIControl { ...@@ -94,7 +94,7 @@ public class MaterialSwitch : UIControl {
} }
} }
/// A property that accesses the layer.frame.origin.width property. /// A property that accesses the layer.frame.size.width property.
@IBInspectable public var width: CGFloat { @IBInspectable public var width: CGFloat {
get { get {
return layer.frame.size.width return layer.frame.size.width
...@@ -104,7 +104,7 @@ public class MaterialSwitch : UIControl { ...@@ -104,7 +104,7 @@ public class MaterialSwitch : UIControl {
} }
} }
/// A property that accesses the layer.frame.origin.height property. /// A property that accesses the layer.frame.size.height property.
@IBInspectable public var height: CGFloat { @IBInspectable public var height: CGFloat {
get { get {
return layer.frame.size.height return layer.frame.size.height
......
...@@ -103,7 +103,7 @@ public class MaterialTableViewCell : UITableViewCell { ...@@ -103,7 +103,7 @@ public class MaterialTableViewCell : UITableViewCell {
} }
/** /**
A property that accesses the layer.frame.origin.width property. A property that accesses the layer.frame.size.width property.
When setting this property in conjunction with the shape property having a 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 value that is not .None, the height will be adjusted to maintain the correct
shape. shape.
...@@ -118,7 +118,7 @@ public class MaterialTableViewCell : UITableViewCell { ...@@ -118,7 +118,7 @@ public class MaterialTableViewCell : UITableViewCell {
} }
/** /**
A property that accesses the layer.frame.origin.height property. A property that accesses the layer.frame.size.height property.
When setting this property in conjunction with the shape property having a 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 value that is not .None, the width will be adjusted to maintain the correct
shape. shape.
......
...@@ -159,7 +159,7 @@ public class MaterialView : UIView { ...@@ -159,7 +159,7 @@ public class MaterialView : UIView {
} }
/** /**
A property that accesses the layer.frame.origin.width property. A property that accesses the layer.frame.size.width property.
When setting this property in conjunction with the shape property having a 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 value that is not .None, the height will be adjusted to maintain the correct
shape. shape.
...@@ -177,7 +177,7 @@ public class MaterialView : UIView { ...@@ -177,7 +177,7 @@ public class MaterialView : UIView {
} }
/** /**
A property that accesses the layer.frame.origin.height property. A property that accesses the layer.frame.size.height property.
When setting this property in conjunction with the shape property having a 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 value that is not .None, the width will be adjusted to maintain the correct
shape. shape.
......
...@@ -127,7 +127,7 @@ public class NavigationBar : UINavigationBar { ...@@ -127,7 +127,7 @@ public class NavigationBar : UINavigationBar {
} }
/** /**
A property that accesses the layer.frame.origin.width property. A property that accesses the layer.frame.size.width property.
When setting this property in conjunction with the shape property having a 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 value that is not .None, the height will be adjusted to maintain the correct
shape. shape.
...@@ -142,7 +142,7 @@ public class NavigationBar : UINavigationBar { ...@@ -142,7 +142,7 @@ public class NavigationBar : UINavigationBar {
} }
/** /**
A property that accesses the layer.frame.origin.height property. A property that accesses the layer.frame.size.height property.
When setting this property in conjunction with the shape property having a 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 value that is not .None, the width will be adjusted to maintain the correct
shape. shape.
......
...@@ -74,39 +74,23 @@ public class TextField : UITextField { ...@@ -74,39 +74,23 @@ public class TextField : UITextField {
} }
} }
/** /// A property that accesses the layer.frame.size.width property.
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.
*/
@IBInspectable public var width: CGFloat { @IBInspectable public var width: CGFloat {
get { get {
return layer.frame.size.width return layer.frame.size.width
} }
set(value) { set(value) {
layer.frame.size.width = value layer.frame.size.width = value
if .None != shape {
layer.frame.size.height = value
}
} }
} }
/** /// A property that accesses the layer.frame.size.height property.
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.
*/
@IBInspectable public var height: CGFloat { @IBInspectable public var height: CGFloat {
get { get {
return layer.frame.size.height return layer.frame.size.height
} }
set(value) { set(value) {
layer.frame.size.height = value layer.frame.size.height = value
if .None != shape {
layer.frame.size.width = value
}
} }
} }
...@@ -183,11 +167,7 @@ public class TextField : UITextField { ...@@ -183,11 +167,7 @@ public class TextField : UITextField {
} }
} }
/** /// A property that sets the cornerRadius of the backing layer.
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 cornerRadiusPreset: MaterialRadius = .None { public var cornerRadiusPreset: MaterialRadius = .None {
didSet { didSet {
if let v: MaterialRadius = cornerRadiusPreset { if let v: MaterialRadius = cornerRadiusPreset {
...@@ -204,27 +184,6 @@ public class TextField : UITextField { ...@@ -204,27 +184,6 @@ public class TextField : UITextField {
set(value) { set(value) {
layer.cornerRadius = value layer.cornerRadius = value
layoutShadowPath() layoutShadowPath()
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 = .None {
didSet {
if .None != shape {
if width < height {
frame.size.width = height
} else {
frame.size.height = width
}
layoutShadowPath()
}
} }
} }
...@@ -436,7 +395,6 @@ public class TextField : UITextField { ...@@ -436,7 +395,6 @@ public class TextField : UITextField {
super.layoutSublayersOfLayer(layer) super.layoutSublayersOfLayer(layer)
if self.layer == layer { if self.layer == layer {
bottomBorderLayer.frame = CGRectMake(0, bounds.height + bottomBorderLayerDistance, bounds.width, 1) bottomBorderLayer.frame = CGRectMake(0, bounds.height + bottomBorderLayerDistance, bounds.width, 1)
layoutShape()
layoutShadowPath() layoutShadowPath()
} }
} }
...@@ -513,10 +471,8 @@ public class TextField : UITextField { ...@@ -513,10 +471,8 @@ public class TextField : UITextField {
/// Reloads the view. /// Reloads the view.
public func reloadView() { public func reloadView() {
/// Prepare the clearButton. /// Align the clearButton.
if let v: FlatButton = clearButton { clearButton.frame = CGRectMake(width - height, 0, height, height)
v.frame = CGRectMake(width - height, 0, height, height)
}
} }
...@@ -566,16 +522,6 @@ public class TextField : UITextField { ...@@ -566,16 +522,6 @@ public class TextField : UITextField {
} }
} }
/// Manages the layout for the shape of the view instance.
internal func layoutShape() {
if .Circle == shape {
let w: CGFloat = (width / 2)
if w != cornerRadius {
cornerRadius = w
}
}
}
/// Sets the shadow path. /// Sets the shadow path.
internal func layoutShadowPath() { internal func layoutShadowPath() {
if shadowPathAutoSizeEnabled { if shadowPathAutoSizeEnabled {
...@@ -642,9 +588,7 @@ public class TextField : UITextField { ...@@ -642,9 +588,7 @@ public class TextField : UITextField {
clearButton.tintColor = MaterialColor.grey.base clearButton.tintColor = MaterialColor.grey.base
clearButton.setImage(image, forState: .Normal) clearButton.setImage(image, forState: .Normal)
clearButton.setImage(image, forState: .Highlighted) clearButton.setImage(image, forState: .Highlighted)
if clearButtonAutoHandleEnabled { clearButtonAutoHandleEnabled = true
clearButton.addTarget(self, action: #selector(handleClearButton), forControlEvents: .TouchUpInside)
}
clearButtonMode = .Never clearButtonMode = .Never
rightViewMode = .WhileEditing rightViewMode = .WhileEditing
rightView = clearButton rightView = clearButton
......
...@@ -76,39 +76,23 @@ public class TextView: UITextView { ...@@ -76,39 +76,23 @@ public class TextView: UITextView {
} }
} }
/** /// A property that accesses the layer.frame.size.width property.
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.
*/
@IBInspectable public var width: CGFloat { @IBInspectable public var width: CGFloat {
get { get {
return layer.frame.size.width return layer.frame.size.width
} }
set(value) { set(value) {
layer.frame.size.width = value layer.frame.size.width = value
if .None != shape {
layer.frame.size.height = value
}
} }
} }
/** /// A property that accesses the layer.frame.size.height property.
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.
*/
@IBInspectable public var height: CGFloat { @IBInspectable public var height: CGFloat {
get { get {
return layer.frame.size.height return layer.frame.size.height
} }
set(value) { set(value) {
layer.frame.size.height = value layer.frame.size.height = value
if .None != shape {
layer.frame.size.width = value
}
} }
} }
...@@ -185,11 +169,7 @@ public class TextView: UITextView { ...@@ -185,11 +169,7 @@ public class TextView: UITextView {
} }
} }
/** /// A property that sets the cornerRadius of the backing layer.
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 cornerRadiusPreset: MaterialRadius = .None { public var cornerRadiusPreset: MaterialRadius = .None {
didSet { didSet {
if let v: MaterialRadius = cornerRadiusPreset { if let v: MaterialRadius = cornerRadiusPreset {
...@@ -206,27 +186,6 @@ public class TextView: UITextView { ...@@ -206,27 +186,6 @@ public class TextView: UITextView {
set(value) { set(value) {
layer.cornerRadius = value layer.cornerRadius = value
layoutShadowPath() layoutShadowPath()
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 = .None {
didSet {
if .None != shape {
if width < height {
frame.size.width = height
} else {
frame.size.height = width
}
layoutShadowPath()
}
} }
} }
...@@ -389,7 +348,6 @@ public class TextView: UITextView { ...@@ -389,7 +348,6 @@ public class TextView: UITextView {
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 {
layoutShape()
layoutShadowPath() layoutShadowPath()
} }
} }
...@@ -489,16 +447,6 @@ public class TextView: UITextView { ...@@ -489,16 +447,6 @@ public class TextView: UITextView {
titleLabel?.textColor = titleLabelColor titleLabel?.textColor = titleLabelColor
} }
/// Manages the layout for the shape of the view instance.
internal func layoutShape() {
if .Circle == shape {
let w: CGFloat = (width / 2)
if w != cornerRadius {
cornerRadius = w
}
}
}
/// Sets the shadow path. /// Sets the shadow path.
internal func layoutShadowPath() { internal func layoutShadowPath() {
if shadowPathAutoSizeEnabled { if shadowPathAutoSizeEnabled {
......
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