Commit 4674e69d by Daniel Dahan

progression commit for Swift 2.3 refactor

parent 7407d97f
...@@ -30,41 +30,41 @@ ...@@ -30,41 +30,41 @@
import UIKit import UIKit
public enum MaterialBorder { public enum BorderWidthPreset {
case None case none
case Border1 case border1
case Border2 case border2
case Border3 case border3
case Border4 case border4
case Border5 case border5
case Border6 case border6
case Border7 case border7
case Border8 case border8
case Border9 case border9
} }
/// Converts the MaterialBorder enum to a CGFloat value. /// Converts the BorderWidthPreset enum to a CGFloat value.
public func MaterialBorderToValue(border: MaterialBorder) -> CGFloat { public func BorderWidthPresetToValue(preset: BorderWidthPreset) -> CGFloat {
switch border { switch preset {
case .None: case .none:
return 0 return 0
case .Border1: case .border1:
return 0.5 return 0.5
case .Border2: case .border2:
return 1 return 1
case .Border3: case .border3:
return 2 return 2
case .Border4: case .border4:
return 3 return 3
case .Border5: case .border5:
return 4 return 4
case .Border6: case .border6:
return 5 return 5
case .Border7: case .border7:
return 6 return 6
case .Border8: case .border8:
return 7 return 7
case .Border9: case .border9:
return 8 return 8
} }
} }
\ No newline at end of file
...@@ -87,7 +87,7 @@ public class BottomTabBar: UITabBar { ...@@ -87,7 +87,7 @@ public class BottomTabBar: UITabBar {
/** /**
A property that accesses the layer.frame.size.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.
*/ */
@IBInspectable public var width: CGFloat { @IBInspectable public var width: CGFloat {
...@@ -102,7 +102,7 @@ public class BottomTabBar: UITabBar { ...@@ -102,7 +102,7 @@ public class BottomTabBar: UITabBar {
/** /**
A property that accesses the layer.frame.size.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.
*/ */
@IBInspectable public var height: CGFloat { @IBInspectable public var height: CGFloat {
...@@ -122,7 +122,7 @@ public class BottomTabBar: UITabBar { ...@@ -122,7 +122,7 @@ public class BottomTabBar: UITabBar {
} }
/// A property that accesses the backing layer's shadowOffset. /// A property that accesses the backing layer's shadowOffset.
@IBInspectable public var shadowOffset: CGSize { @IBInspectable public var shadowOffset: Offset {
get { get {
return layer.shadowOffset return layer.shadowOffset
} }
...@@ -152,9 +152,9 @@ public class BottomTabBar: UITabBar { ...@@ -152,9 +152,9 @@ public class BottomTabBar: UITabBar {
} }
/// A preset property to set the borderWidth. /// A preset property to set the borderWidth.
public var borderWidthPreset: MaterialBorder = .None { public var borderWidthPreset: BorderWidthPreset = .none {
didSet { didSet {
borderWidth = MaterialBorderToValue(border: borderWidthPreset) borderWidth = BorderWidthPresetToValue(preset: borderWidthPreset)
} }
} }
......
...@@ -107,7 +107,7 @@ public class Button: UIButton { ...@@ -107,7 +107,7 @@ public class Button: UIButton {
/** /**
A property that accesses the layer.frame.size.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.
*/ */
@IBInspectable public var width: CGFloat { @IBInspectable public var width: CGFloat {
...@@ -116,7 +116,7 @@ public class Button: UIButton { ...@@ -116,7 +116,7 @@ public class Button: UIButton {
} }
set(value) { set(value) {
layer.frame.size.width = value layer.frame.size.width = value
if .None != shape { if .none != shapePreset {
layer.frame.size.height = value layer.frame.size.height = value
} }
} }
...@@ -125,7 +125,7 @@ public class Button: UIButton { ...@@ -125,7 +125,7 @@ public class Button: UIButton {
/** /**
A property that accesses the layer.frame.size.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.
*/ */
@IBInspectable public var height: CGFloat { @IBInspectable public var height: CGFloat {
...@@ -134,7 +134,7 @@ public class Button: UIButton { ...@@ -134,7 +134,7 @@ public class Button: UIButton {
} }
set(value) { set(value) {
layer.frame.size.height = value layer.frame.size.height = value
if .None != shape { if .none != shapePreset {
layer.frame.size.width = value layer.frame.size.width = value
} }
} }
...@@ -148,12 +148,12 @@ public class Button: UIButton { ...@@ -148,12 +148,12 @@ public class Button: UIButton {
} }
/// A property that accesses the backing layer's shadowOffset. /// A property that accesses the backing layer's shadowOffset.
@IBInspectable public var shadowOffset: CGSize { @IBInspectable public var shadowOffset: Offset {
get { get {
return layer.shadowOffset return layer.shadowOffset.asOffset
} }
set(value) { set(value) {
layer.shadowOffset = value layer.shadowOffset = value.asSize
} }
} }
...@@ -218,13 +218,13 @@ public class Button: UIButton { ...@@ -218,13 +218,13 @@ public class Button: UIButton {
/** /**
A property that sets the cornerRadius of the backing layer. If the shape 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 property has a value of .circle when the cornerRadius is set, it will
become .None, as it no longer maintains its circle shape. become .none, as it no longer maintains its circle shape.
*/ */
public var cornerRadiusPreset: MaterialRadius = .None { public var cornerRadiusPreset: RadiusPreset = .none {
didSet { didSet {
if let v: MaterialRadius = cornerRadiusPreset { if let v: RadiusPreset = cornerRadiusPreset {
cornerRadius = MaterialRadiusToValue(radius: v) cornerRadius = RadiusPresetToValue(preset: v)
} }
} }
} }
...@@ -237,8 +237,8 @@ public class Button: UIButton { ...@@ -237,8 +237,8 @@ public class Button: UIButton {
set(value) { set(value) {
layer.cornerRadius = value layer.cornerRadius = value
layoutShadowPath() layoutShadowPath()
if .Circle == shape { if .circle == shapePreset {
shape = .None shapePreset = .none
} }
} }
} }
...@@ -248,9 +248,9 @@ public class Button: UIButton { ...@@ -248,9 +248,9 @@ public class Button: UIButton {
width or height property is set, the other will be automatically adjusted width or height property is set, the other will be automatically adjusted
to maintain the shape of the object. to maintain the shape of the object.
*/ */
public var shape: MaterialShape = .None { public var shapePreset: ShapePreset = .none {
didSet { didSet {
if .None != shape { if .none != shapePreset {
if width < height { if width < height {
frame.size.width = height frame.size.width = height
} else { } else {
...@@ -262,9 +262,9 @@ public class Button: UIButton { ...@@ -262,9 +262,9 @@ public class Button: UIButton {
} }
/// A preset property to set the borderWidth. /// A preset property to set the borderWidth.
public var borderWidthPreset: MaterialBorder = .None { public var borderWidthPreset: BorderWidthPreset = .none {
didSet { didSet {
borderWidth = MaterialBorderToValue(border: borderWidthPreset) borderWidth = BorderWidthPresetToValue(preset: borderWidthPreset)
} }
} }
...@@ -309,16 +309,16 @@ public class Button: UIButton { ...@@ -309,16 +309,16 @@ public class Button: UIButton {
} }
/// A preset property for updated contentEdgeInsets. /// A preset property for updated contentEdgeInsets.
public var contentInsetPreset: InsetPreset = .none { public var contentEdgeInsetsPreset: EdgeInsetsPreset = .none {
didSet { didSet {
contentInset = InsetPresetToValue(preset: contentInsetPreset) contentInset = EdgeInsetsPresetToValue(preset: contentEdgeInsetsPreset)
} }
} }
/** /**
:name: contentInset :name: contentInset
*/ */
@IBInspectable public var contentInset = Inset.zero { @IBInspectable public var contentInset = EdgeInsets.zero {
didSet { didSet {
contentEdgeInsets = contentInset.asEdgeInsets contentEdgeInsets = contentInset.asEdgeInsets
} }
...@@ -363,7 +363,7 @@ public class Button: UIButton { ...@@ -363,7 +363,7 @@ public class Button: UIButton {
} }
public override func alignmentRectInsets() -> UIEdgeInsets { public override func alignmentRectInsets() -> UIEdgeInsets {
return UIEdgeInset.zero return UIEdgeInsets.zero
} }
/** /**
...@@ -403,17 +403,17 @@ public class Button: UIButton { ...@@ -403,17 +403,17 @@ public class Button: UIButton {
if interrupted. if interrupted.
*/ */
public override func animationDidStop(_ animation: CAAnimation, finished flag: Bool) { public override func animationDidStop(_ animation: CAAnimation, finished flag: Bool) {
if let a: CAPropertyAnimation = animation as? CAPropertyAnimation { if let a = animation as? CAPropertyAnimation {
if let b: CABasicAnimation = a as? CABasicAnimation { if let b = a as? CABasicAnimation {
if let v: AnyObject = b.toValue { if let v = b.toValue {
if let k: String = b.keyPath { if let k = b.keyPath {
layer.setValue(v, forKeyPath: k) layer.setValue(v, forKeyPath: k)
layer.removeAnimation(forKey: k) layer.removeAnimation(forKey: k)
} }
} }
} }
(delegate as? MaterialAnimationDelegate)?.materialAnimationDidStop?(animation: animation, finished: flag) (delegate as? MaterialAnimationDelegate)?.materialAnimationDidStop?(animation: animation, finished: flag)
} else if let a: CAAnimationGroup = animation as? CAAnimationGroup { } else if let a = animation as? CAAnimationGroup {
for x in a.animations! { for x in a.animations! {
animationDidStop(x, finished: true) animationDidStop(x, finished: true)
} }
...@@ -427,10 +427,10 @@ public class Button: UIButton { ...@@ -427,10 +427,10 @@ public class Button: UIButton {
*/ */
public func pulse(point: CGPoint? = nil) { public func pulse(point: CGPoint? = nil) {
let p: CGPoint = nil == point ? CGPoint(x: CGFloat(width / 2), y: CGFloat(height / 2)) : point! let p: CGPoint = nil == point ? CGPoint(x: CGFloat(width / 2), y: CGFloat(height / 2)) : point!
MaterialAnimation.pulseExpandAnimation(layer, visualLayer: visualLayer, pulseColor: pulseColor, pulseOpacity: pulseOpacity, point: p, width: width, height: height, pulseLayers: &pulseLayers, pulseAnimation: pulseAnimation) MaterialAnimation.pulseExpandAnimation(layer: layer, visualLayer: visualLayer, pulseColor: pulseColor, pulseOpacity: pulseOpacity, point: p, width: width, height: height, pulseLayers: &pulseLayers, pulseAnimation: pulseAnimation)
MaterialAnimation.delay(0.35) { [weak self] in MaterialAnimation.delay(time: 0.35) { [weak self] in
if let s: Button = self { if let s = self {
MaterialAnimation.pulseContractAnimation(s.layer, visualLayer: s.visualLayer, pulseColor: s.pulseColor, pulseLayers: &s.pulseLayers, pulseAnimation: s.pulseAnimation) MaterialAnimation.pulseContractAnimation(layer: s.layer, visualLayer: s.visualLayer, pulseColor: s.pulseColor, pulseLayers: &s.pulseLayers, pulseAnimation: s.pulseAnimation)
} }
} }
} }
...@@ -443,7 +443,7 @@ public class Button: UIButton { ...@@ -443,7 +443,7 @@ public class Button: UIButton {
*/ */
public override func touchesBegan(_ touches: Set<UITouch>, with event: UIEvent?) { public override func touchesBegan(_ touches: Set<UITouch>, with event: UIEvent?) {
super.touchesBegan(touches, with: event) super.touchesBegan(touches, with: event)
MaterialAnimation.pulseExpandAnimation(layer, visualLayer: visualLayer, pulseColor: pulseColor, pulseOpacity: pulseOpacity, point: layer.convertPoint(touches.first!.locationInView(self), fromLayer: layer), width: width, height: height, pulseLayers: &pulseLayers, pulseAnimation: pulseAnimation) MaterialAnimation.pulseExpandAnimation(layer: layer, visualLayer: visualLayer, pulseColor: pulseColor, pulseOpacity: pulseOpacity, point: layer.convert(touches.first!.location(in: self), from: layer), width: width, height: height, pulseLayers: &pulseLayers, pulseAnimation: pulseAnimation)
} }
/** /**
...@@ -454,7 +454,7 @@ public class Button: UIButton { ...@@ -454,7 +454,7 @@ public class Button: UIButton {
*/ */
public override func touchesEnded(_ touches: Set<UITouch>, with event: UIEvent?) { public override func touchesEnded(_ touches: Set<UITouch>, with event: UIEvent?) {
super.touchesEnded(touches, with: event) super.touchesEnded(touches, with: event)
MaterialAnimation.pulseContractAnimation(layer, visualLayer: visualLayer, pulseColor: pulseColor, pulseLayers: &pulseLayers, pulseAnimation: pulseAnimation) MaterialAnimation.pulseContractAnimation(layer: layer, visualLayer: visualLayer, pulseColor: pulseColor, pulseLayers: &pulseLayers, pulseAnimation: pulseAnimation)
} }
/** /**
...@@ -465,7 +465,7 @@ public class Button: UIButton { ...@@ -465,7 +465,7 @@ public class Button: UIButton {
*/ */
public override func touchesCancelled(_ touches: Set<UITouch>, with event: UIEvent?) { public override func touchesCancelled(_ touches: Set<UITouch>, with event: UIEvent?) {
super.touchesCancelled(touches, with: event) super.touchesCancelled(touches, with: event)
MaterialAnimation.pulseContractAnimation(layer, visualLayer: visualLayer, pulseColor: pulseColor, pulseLayers: &pulseLayers, pulseAnimation: pulseAnimation) MaterialAnimation.pulseContractAnimation(layer: layer, visualLayer: visualLayer, pulseColor: pulseColor, pulseLayers: &pulseLayers, pulseAnimation: pulseAnimation)
} }
/** /**
...@@ -496,7 +496,7 @@ public class Button: UIButton { ...@@ -496,7 +496,7 @@ public class Button: UIButton {
/// Manages the layout for the shape of the view instance. /// Manages the layout for the shape of the view instance.
internal func layoutShape() { internal func layoutShape() {
if .Circle == shape { if .circle == shapePreset {
let w: CGFloat = (width / 2) let w: CGFloat = (width / 2)
if w != cornerRadius { if w != cornerRadius {
cornerRadius = w cornerRadius = w
......
...@@ -203,14 +203,14 @@ public class Capture : View, UIGestureRecognizerDelegate { ...@@ -203,14 +203,14 @@ public class Capture : View, UIGestureRecognizerDelegate {
} }
/// Insets preset value for content. /// Insets preset value for content.
public var contentInsetPreset: InsetPreset = .none { public var contentEdgeInsetsPreset: EdgeInsetsPreset = .none {
didSet { didSet {
contentInset = InsetPresetToValue(preset: contentInsetPreset) contentInset = EdgeInsetsPresetToValue(preset: contentEdgeInsetsPreset)
} }
} }
/// Content insert value. /// Content insert value.
public var contentInset: Inset = InsetPresetToValue(preset: .square4) { public var contentInset: Inset = EdgeInsetsPresetToValue(preset: .square4) {
didSet { didSet {
reloadView() reloadView()
} }
......
...@@ -57,16 +57,16 @@ public class Card: PulseView { ...@@ -57,16 +57,16 @@ public class Card: PulseView {
/** /**
:name: dividerInsets :name: dividerInsets
*/ */
public var dividerInsetPreset: InsetPreset = .none { public var dividerEdgeInsetsPreset: EdgeInsetsPreset = .none {
didSet { didSet {
dividerInset = InsetPresetToValue(preset: dividerInsetPreset) dividerInset = EdgeInsetsPresetToValue(preset: dividerEdgeInsetsPreset)
} }
} }
/** /**
:name: dividerInset :name: dividerInset
*/ */
@IBInspectable public var dividerInset = Inset(top: 8, left: 0, bottom: 8, right: 0) { @IBInspectable public var dividerInset = EdgeInsets(top: 8, left: 0, bottom: 8, right: 0) {
didSet { didSet {
reloadView() reloadView()
} }
...@@ -75,16 +75,16 @@ public class Card: PulseView { ...@@ -75,16 +75,16 @@ public class Card: PulseView {
/** /**
:name: contentInsets :name: contentInsets
*/ */
public var contentInsetPreset: InsetPreset = .square2 { public var contentEdgeInsetsPreset: EdgeInsetsPreset = .square2 {
didSet { didSet {
contentInset = InsetPresetToValue(preset: contentInsetPreset) contentInset = EdgeInsetsPresetToValue(preset: contentEdgeInsetsPreset)
} }
} }
/** /**
:name: contentInset :name: contentInset
*/ */
@IBInspectable public var contentInset = InsetPresetToValue(preset: .square2) { @IBInspectable public var contentInset = EdgeInsetsPresetToValue(preset: .square2) {
didSet { didSet {
reloadView() reloadView()
} }
...@@ -93,16 +93,16 @@ public class Card: PulseView { ...@@ -93,16 +93,16 @@ public class Card: PulseView {
/** /**
:name: titleLabelInsets :name: titleLabelInsets
*/ */
public var titleLabelInsetPreset: InsetPreset = .square2 { public var titleLabelEdgeInsetsPreset: EdgeInsetsPreset = .square2 {
didSet { didSet {
titleLabelInset = InsetPresetToValue(preset: titleLabelInsetPreset) titleLabelInset = EdgeInsetsPresetToValue(preset: titleLabelEdgeInsetsPreset)
} }
} }
/** /**
:name: titleLabelInset :name: titleLabelInset
*/ */
@IBInspectable public var titleLabelInset = InsetPresetToValue(preset: .square2) { @IBInspectable public var titleLabelInset = EdgeInsetsPresetToValue(preset: .square2) {
didSet { didSet {
reloadView() reloadView()
} }
...@@ -120,16 +120,16 @@ public class Card: PulseView { ...@@ -120,16 +120,16 @@ public class Card: PulseView {
/** /**
:name: contentViewInsets :name: contentViewInsets
*/ */
public var contentViewInsetPreset: InsetPreset = .square2 { public var contentViewEdgeInsetsPreset: EdgeInsetsPreset = .square2 {
didSet { didSet {
contentViewInset = InsetPresetToValue(preset: contentViewInsetPreset) contentViewInset = EdgeInsetsPresetToValue(preset: contentViewEdgeInsetsPreset)
} }
} }
/** /**
:name: contentViewInset :name: contentViewInset
*/ */
@IBInspectable public var contentViewInset = InsetPresetToValue(preset: .square2) { @IBInspectable public var contentViewInset = EdgeInsetsPresetToValue(preset: .square2) {
didSet { didSet {
reloadView() reloadView()
} }
...@@ -147,16 +147,16 @@ public class Card: PulseView { ...@@ -147,16 +147,16 @@ public class Card: PulseView {
/** /**
:name: leftButtonsInsets :name: leftButtonsInsets
*/ */
public var leftButtonsInsetPreset: InsetPreset = .none { public var leftButtonsEdgeInsetsPreset: EdgeInsetsPreset = .none {
didSet { didSet {
leftButtonsInset = InsetPresetToValue(preset: leftButtonsInsetPreset) leftButtonsInset = EdgeInsetsPresetToValue(preset: leftButtonsEdgeInsetsPreset)
} }
} }
/** /**
:name: leftButtonsInset :name: leftButtonsInset
*/ */
@IBInspectable public var leftButtonsInset = Inset.zero { @IBInspectable public var leftButtonsInset = EdgeInsets.zero {
didSet { didSet {
reloadView() reloadView()
} }
...@@ -174,16 +174,16 @@ public class Card: PulseView { ...@@ -174,16 +174,16 @@ public class Card: PulseView {
/** /**
:name: rightButtonsInsets :name: rightButtonsInsets
*/ */
public var rightButtonsInsetPreset: InsetPreset = .none { public var rightButtonsEdgeInsetsPreset: EdgeInsetsPreset = .none {
didSet { didSet {
rightButtonsInset = InsetPresetToValue(preset: rightButtonsInsetPreset) rightButtonsInset = EdgeInsetsPresetToValue(preset: rightButtonsEdgeInsetsPreset)
} }
} }
/** /**
:name: rightButtonsInset :name: rightButtonsInset
*/ */
@IBInspectable public var rightButtonsInset = Inset.zero { @IBInspectable public var rightButtonsInset = EdgeInsets.zero {
didSet { didSet {
reloadView() reloadView()
} }
......
...@@ -37,12 +37,12 @@ public class ControlView : View { ...@@ -37,12 +37,12 @@ public class ControlView : View {
} }
/// A preset wrapper around contentInset. /// A preset wrapper around contentInset.
public var contentInsetPreset: InsetPreset { public var contentEdgeInsetsPreset: EdgeInsetsPreset {
get { get {
return grid.contentInsetPreset return grid.contentEdgeInsetsPreset
} }
set(value) { set(value) {
grid.contentInsetPreset = value grid.contentEdgeInsetsPreset = value
} }
} }
...@@ -227,7 +227,7 @@ public class ControlView : View { ...@@ -227,7 +227,7 @@ public class ControlView : View {
public override func prepareView() { public override func prepareView() {
super.prepareView() super.prepareView()
interimSpacePreset = .interimSpace1 interimSpacePreset = .interimSpace1
contentInsetPreset = .Square1 contentEdgeInsetsPreset = .Square1
autoresizingMask = .FlexibleWidth autoresizingMask = .FlexibleWidth
shadowPathAutoSizeEnabled = false shadowPathAutoSizeEnabled = false
prepareContentView() prepareContentView()
......
...@@ -32,7 +32,7 @@ import UIKit ...@@ -32,7 +32,7 @@ import UIKit
import UIKit import UIKit
public enum InsetPreset { public enum EdgeInsetsPreset {
case none case none
// square // square
...@@ -69,110 +69,72 @@ public enum InsetPreset { ...@@ -69,110 +69,72 @@ public enum InsetPreset {
case tallRectangle9 case tallRectangle9
} }
public struct Inset { public typealias EdgeInsets = UIEdgeInsets
/// Top inset.
public var top: CGFloat
/// Left inset.
public var left: CGFloat
/// Bottom inset.
public var bottom: CGFloat
/// Right inset.
public var right: CGFloat
public var asEdgeInsets: UIEdgeInsets {
return UIEdgeInsets(top: top, left: left, bottom: bottom, right: right)
}
/**
Initializer.
- Parameter top: Top inset.
- Parameter left: Left inset.
- Parameter bottom: Bottom inset.
- Parameter right: Right inset.
*/
public init(top: CGFloat = 0, left: CGFloat = 0, bottom: CGFloat = 0, right: CGFloat = 0) {
self.top = top
self.left = left
self.bottom = bottom
self.right = right
}
/**
Static constructor for Inset with values of 0.
- Returns: An Inset struct with values of 0.
*/
static var zero: Inset {
return Inset()
}
}
/// Converts the InsetPreset to a Inset value. /// Converts the EdgeInsetsPreset to a Inset value.
public func InsetPresetToValue(preset: InsetPreset) -> Inset { public func EdgeInsetsPresetToValue(preset: EdgeInsetsPreset) -> EdgeInsets {
switch preset { switch preset {
case .none: case .none:
return Inset.zero return EdgeInsets.zero
// square // square
case .square1: case .square1:
return Inset(top: 4, left: 4, bottom: 4, right: 4) return EdgeInsets(top: 4, left: 4, bottom: 4, right: 4)
case .square2: case .square2:
return Inset(top: 8, left: 8, bottom: 8, right: 8) return EdgeInsets(top: 8, left: 8, bottom: 8, right: 8)
case .square3: case .square3:
return Inset(top: 16, left: 16, bottom: 16, right: 16) return EdgeInsets(top: 16, left: 16, bottom: 16, right: 16)
case .square4: case .square4:
return Inset(top: 24, left: 24, bottom: 24, right: 24) return EdgeInsets(top: 24, left: 24, bottom: 24, right: 24)
case .square5: case .square5:
return Inset(top: 32, left: 32, bottom: 32, right: 32) return EdgeInsets(top: 32, left: 32, bottom: 32, right: 32)
case .square6: case .square6:
return Inset(top: 40, left: 40, bottom: 40, right: 40) return EdgeInsets(top: 40, left: 40, bottom: 40, right: 40)
case .square7: case .square7:
return Inset(top: 48, left: 48, bottom: 48, right: 48) return EdgeInsets(top: 48, left: 48, bottom: 48, right: 48)
case .square8: case .square8:
return Inset(top: 56, left: 56, bottom: 56, right: 56) return EdgeInsets(top: 56, left: 56, bottom: 56, right: 56)
case .square9: case .square9:
return Inset(top: 64, left: 64, bottom: 64, right: 64) return EdgeInsets(top: 64, left: 64, bottom: 64, right: 64)
// rectangle // rectangle
case .wideRectangle1: case .wideRectangle1:
return Inset(top: 2, left: 4, bottom: 2, right: 4) return EdgeInsets(top: 2, left: 4, bottom: 2, right: 4)
case .wideRectangle2: case .wideRectangle2:
return Inset(top: 4, left: 8, bottom: 4, right: 8) return EdgeInsets(top: 4, left: 8, bottom: 4, right: 8)
case .wideRectangle3: case .wideRectangle3:
return Inset(top: 8, left: 16, bottom: 8, right: 16) return EdgeInsets(top: 8, left: 16, bottom: 8, right: 16)
case .wideRectangle4: case .wideRectangle4:
return Inset(top: 12, left: 24, bottom: 12, right: 24) return EdgeInsets(top: 12, left: 24, bottom: 12, right: 24)
case .wideRectangle5: case .wideRectangle5:
return Inset(top: 16, left: 32, bottom: 16, right: 32) return EdgeInsets(top: 16, left: 32, bottom: 16, right: 32)
case .wideRectangle6: case .wideRectangle6:
return Inset(top: 20, left: 40, bottom: 20, right: 40) return EdgeInsets(top: 20, left: 40, bottom: 20, right: 40)
case .wideRectangle7: case .wideRectangle7:
return Inset(top: 24, left: 48, bottom: 24, right: 48) return EdgeInsets(top: 24, left: 48, bottom: 24, right: 48)
case .wideRectangle8: case .wideRectangle8:
return Inset(top: 28, left: 56, bottom: 28, right: 56) return EdgeInsets(top: 28, left: 56, bottom: 28, right: 56)
case .wideRectangle9: case .wideRectangle9:
return Inset(top: 32, left: 64, bottom: 32, right: 64) return EdgeInsets(top: 32, left: 64, bottom: 32, right: 64)
// flipped rectangle // flipped rectangle
case .tallRectangle1: case .tallRectangle1:
return Inset(top: 4, left: 2, bottom: 4, right: 2) return EdgeInsets(top: 4, left: 2, bottom: 4, right: 2)
case .tallRectangle2: case .tallRectangle2:
return Inset(top: 8, left: 4, bottom: 8, right: 4) return EdgeInsets(top: 8, left: 4, bottom: 8, right: 4)
case .tallRectangle3: case .tallRectangle3:
return Inset(top: 16, left: 8, bottom: 16, right: 8) return EdgeInsets(top: 16, left: 8, bottom: 16, right: 8)
case .tallRectangle4: case .tallRectangle4:
return Inset(top: 24, left: 12, bottom: 24, right: 12) return EdgeInsets(top: 24, left: 12, bottom: 24, right: 12)
case .tallRectangle5: case .tallRectangle5:
return Inset(top: 32, left: 16, bottom: 32, right: 16) return EdgeInsets(top: 32, left: 16, bottom: 32, right: 16)
case .tallRectangle6: case .tallRectangle6:
return Inset(top: 40, left: 20, bottom: 40, right: 20) return EdgeInsets(top: 40, left: 20, bottom: 40, right: 20)
case .tallRectangle7: case .tallRectangle7:
return Inset(top: 48, left: 24, bottom: 48, right: 24) return EdgeInsets(top: 48, left: 24, bottom: 48, right: 24)
case .tallRectangle8: case .tallRectangle8:
return Inset(top: 56, left: 28, bottom: 56, right: 28) return EdgeInsets(top: 56, left: 28, bottom: 56, right: 28)
case .tallRectangle9: case .tallRectangle9:
return Inset(top: 64, left: 32, bottom: 64, right: 32) return EdgeInsets(top: 64, left: 32, bottom: 64, right: 32)
} }
} }
...@@ -41,7 +41,7 @@ public class FabButton: Button { ...@@ -41,7 +41,7 @@ public class FabButton: Button {
public override func prepareView() { public override func prepareView() {
super.prepareView() super.prepareView()
depthPreset = .depth1 depthPreset = .depth1
shape = .Circle shape = .circle
pulseAnimation = .CenterWithBacking pulseAnimation = .CenterWithBacking
pulseColor = Color.white pulseColor = Color.white
tintColor = Color.white tintColor = Color.white
......
...@@ -41,6 +41,6 @@ public class FlatButton: Button { ...@@ -41,6 +41,6 @@ public class FlatButton: Button {
public override func prepareView() { public override func prepareView() {
super.prepareView() super.prepareView()
cornerRadiusPreset = .Radius1 cornerRadiusPreset = .Radius1
contentInsetPreset = .wideRectangle3 contentEdgeInsetsPreset = .wideRectangle3
} }
} }
...@@ -129,28 +129,28 @@ public class Grid { ...@@ -129,28 +129,28 @@ public class Grid {
public private(set) var axis: GridAxis! public private(set) var axis: GridAxis!
/// Preset inset value for grid. /// Preset inset value for grid.
public var layoutInsetPreset: InsetPreset = .none { public var layoutEdgeInsetsPreset: EdgeInsetsPreset = .none {
didSet { didSet {
layoutInset = InsetPresetToValue(preset: contentInsetPreset) layoutInset = EdgeInsetsPresetToValue(preset: contentEdgeInsetsPreset)
} }
} }
/// Insets value for grid. /// Insets value for grid.
public var layoutInset = Inset.zero { public var layoutInset = EdgeInsets.zero {
didSet { didSet {
reload() reload()
} }
} }
/// Preset inset value for grid. /// Preset inset value for grid.
public var contentInsetPreset: InsetPreset = .none { public var contentEdgeInsetsPreset: EdgeInsetsPreset = .none {
didSet { didSet {
contentInset = InsetPresetToValue(preset: contentInsetPreset) contentInset = EdgeInsetsPresetToValue(preset: contentEdgeInsetsPreset)
} }
} }
/// Insets value for grid. /// Insets value for grid.
public var contentInset: Inset = InsetPresetToValue(preset: .none) { public var contentInset: Inset = EdgeInsetsPresetToValue(preset: .none) {
didSet { didSet {
reload() reload()
} }
......
...@@ -57,16 +57,16 @@ public class ImageCard: PulseView { ...@@ -57,16 +57,16 @@ public class ImageCard: PulseView {
/** /**
:name: dividerInsets :name: dividerInsets
*/ */
public var dividerInsetPreset: InsetPreset = .none { public var dividerEdgeInsetsPreset: EdgeInsetsPreset = .none {
didSet { didSet {
dividerInset = InsetPresetToValue(preset: dividerInsetPreset) dividerInset = EdgeInsetsPresetToValue(preset: dividerEdgeInsetsPreset)
} }
} }
/** /**
:name: dividerInset :name: dividerInset
*/ */
@IBInspectable public var dividerInset = Inset(top: 8, left: 0, bottom: 8, right: 0) { @IBInspectable public var dividerInset = EdgeInsets(top: 8, left: 0, bottom: 8, right: 0) {
didSet { didSet {
reloadView() reloadView()
} }
...@@ -168,16 +168,16 @@ public class ImageCard: PulseView { ...@@ -168,16 +168,16 @@ public class ImageCard: PulseView {
/** /**
:name: contentInsets :name: contentInsets
*/ */
public var contentInsetPreset: InsetPreset = .square2 { public var contentEdgeInsetsPreset: EdgeInsetsPreset = .square2 {
didSet { didSet {
contentInset = InsetPresetToValue(preset: contentInsetPreset) contentInset = EdgeInsetsPresetToValue(preset: contentEdgeInsetsPreset)
} }
} }
/** /**
:name: contentInset :name: contentInset
*/ */
@IBInspectable public var contentInset = InsetPresetToValue(preset: .square2) { @IBInspectable public var contentInset = EdgeInsetsPresetToValue(preset: .square2) {
didSet { didSet {
reloadView() reloadView()
} }
...@@ -186,16 +186,16 @@ public class ImageCard: PulseView { ...@@ -186,16 +186,16 @@ public class ImageCard: PulseView {
/** /**
:name: titleLabelInsets :name: titleLabelInsets
*/ */
public var titleLabelInsetPreset: InsetPreset = .square2 { public var titleLabelEdgeInsetsPreset: EdgeInsetsPreset = .square2 {
didSet { didSet {
titleLabelInset = InsetPresetToValue(preset: titleLabelInsetPreset) titleLabelInset = EdgeInsetsPresetToValue(preset: titleLabelEdgeInsetsPreset)
} }
} }
/** /**
:name: titleLabelInset :name: titleLabelInset
*/ */
@IBInspectable public var titleLabelInset = InsetPresetToValue(preset: .square2) { @IBInspectable public var titleLabelInset = EdgeInsetsPresetToValue(preset: .square2) {
didSet { didSet {
reloadView() reloadView()
} }
...@@ -213,16 +213,16 @@ public class ImageCard: PulseView { ...@@ -213,16 +213,16 @@ public class ImageCard: PulseView {
/** /**
:name: contentViewInsets :name: contentViewInsets
*/ */
public var contentViewInsetPreset: InsetPreset = .square2 { public var contentViewEdgeInsetsPreset: EdgeInsetsPreset = .square2 {
didSet { didSet {
contentViewInset = InsetPresetToValue(preset: contentViewInsetPreset) contentViewInset = EdgeInsetsPresetToValue(preset: contentViewEdgeInsetsPreset)
} }
} }
/** /**
:name: contentViewInset :name: contentViewInset
*/ */
@IBInspectable public var contentViewInset = InsetPresetToValue(preset: .square2) { @IBInspectable public var contentViewInset = EdgeInsetsPresetToValue(preset: .square2) {
didSet { didSet {
reloadView() reloadView()
} }
...@@ -240,16 +240,16 @@ public class ImageCard: PulseView { ...@@ -240,16 +240,16 @@ public class ImageCard: PulseView {
/** /**
:name: leftButtonsInsets :name: leftButtonsInsets
*/ */
public var leftButtonsInsetPreset: InsetPreset = .none { public var leftButtonsEdgeInsetsPreset: EdgeInsetsPreset = .none {
didSet { didSet {
leftButtonsInset = InsetPresetToValue(preset: leftButtonsInsetPreset) leftButtonsInset = EdgeInsetsPresetToValue(preset: leftButtonsEdgeInsetsPreset)
} }
} }
/** /**
:name: leftButtonsInset :name: leftButtonsInset
*/ */
@IBInspectable public var leftButtonsInset = Inset.zero { @IBInspectable public var leftButtonsInset = EdgeInsets.zero {
didSet { didSet {
reloadView() reloadView()
} }
...@@ -267,16 +267,16 @@ public class ImageCard: PulseView { ...@@ -267,16 +267,16 @@ public class ImageCard: PulseView {
/** /**
:name: rightButtonsInsets :name: rightButtonsInsets
*/ */
public var rightButtonsInsetPreset: InsetPreset = .none { public var rightButtonsEdgeInsetsPreset: EdgeInsetsPreset = .none {
didSet { didSet {
rightButtonsInset = InsetPresetToValue(preset: rightButtonsInsetPreset) rightButtonsInset = EdgeInsetsPresetToValue(preset: rightButtonsEdgeInsetsPreset)
} }
} }
/** /**
:name: rightButtonsInset :name: rightButtonsInset
*/ */
@IBInspectable public var rightButtonsInset = Inset.zero { @IBInspectable public var rightButtonsInset = EdgeInsets.zero {
didSet { didSet {
reloadView() reloadView()
} }
......
...@@ -41,7 +41,7 @@ public class Layer: CAShapeLayer { ...@@ -41,7 +41,7 @@ public class Layer: CAShapeLayer {
allows the dropshadow effect on the backing layer, while clipping allows the dropshadow effect on the backing layer, while clipping
the image to a desired shape within the visualLayer. the image to a desired shape within the visualLayer.
*/ */
public private(set) lazy var visualLayer: CAShapeLayer = CAShapeLayer() public private(set) var visualLayer: CAShapeLayer!
/// A property that accesses the layer.frame.origin.x property. /// A property that accesses the layer.frame.origin.x property.
@IBInspectable public var x: CGFloat { @IBInspectable public var x: CGFloat {
...@@ -66,7 +66,7 @@ public class Layer: CAShapeLayer { ...@@ -66,7 +66,7 @@ public class Layer: CAShapeLayer {
/** /**
A property that accesses the layer.frame.size.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.
*/ */
@IBInspectable public var width: CGFloat { @IBInspectable public var width: CGFloat {
...@@ -75,7 +75,7 @@ public class Layer: CAShapeLayer { ...@@ -75,7 +75,7 @@ public class Layer: CAShapeLayer {
} }
set(value) { set(value) {
frame.size.width = value frame.size.width = value
if .None != shape { if .none != shapePreset {
frame.size.height = value frame.size.height = value
} }
} }
...@@ -84,7 +84,7 @@ public class Layer: CAShapeLayer { ...@@ -84,7 +84,7 @@ public class Layer: CAShapeLayer {
/** /**
A property that accesses the layer.frame.size.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.
*/ */
@IBInspectable public var height: CGFloat { @IBInspectable public var height: CGFloat {
...@@ -93,7 +93,7 @@ public class Layer: CAShapeLayer { ...@@ -93,7 +93,7 @@ public class Layer: CAShapeLayer {
} }
set(value) { set(value) {
frame.size.height = value frame.size.height = value
if .None != shape { if .none != shapePreset {
frame.size.width = value frame.size.width = value
} }
} }
...@@ -169,44 +169,49 @@ public class Layer: CAShapeLayer { ...@@ -169,44 +169,49 @@ public class Layer: CAShapeLayer {
} }
} }
/** /// A preset value for Depth.
public var depthPreset: DepthPreset = .none {
didSet {
depth = DepthPresetToValue(preset: depthPreset)
}
}
/**
A property that sets the shadowOffset, shadowOpacity, and shadowRadius A property that sets the shadowOffset, shadowOpacity, and shadowRadius
for the backing layer. This is the preferred method of setting depth for the backing layer.
in order to maintain consitency across UI objects.
*/ */
public var depthPreset = .none { public var depth = Depth.zero {
didSet { didSet {
let value: Depth = DepthPresetToValue(preset: depth) shadowOffset = depth.offset.asSize
shadowOffset = value.offset shadowOpacity = depth.opacity
shadowOpacity = value.opacity shadowRadius = depth.radius
shadowRadius = value.radius layoutShadowPath()
layoutShadowPath() }
} }
}
/** /**
A property that sets the cornerRadius of the backing layer. If the shape 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 property has a value of .circle when the cornerRadius is set, it will
become .None, as it no longer maintains its circle shape. become .none, as it no longer maintains its circle shape.
*/ */
public var cornerRadiusPreset: MaterialRadius = .None { public var cornerRadiusPreset: RadiusPreset = .none {
didSet { didSet {
if let v: MaterialRadius = cornerRadiusPreset { if let v: RadiusPreset = cornerRadiusPreset {
cornerRadius = MaterialRadiusToValue(radius: v) cornerRadius = RadiusPresetToValue(preset: v)
} }
} }
} }
/** /**
A property that sets the cornerRadius of the backing layer. If the shape 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 property has a value of .circle when the cornerRadius is set, it will
become .None, as it no longer maintains its circle shape. become .none, as it no longer maintains its circle shape.
*/ */
@IBInspectable public override var cornerRadius: CGFloat { @IBInspectable public override var cornerRadius: CGFloat {
didSet { didSet {
layoutShadowPath() layoutShadowPath()
if .Circle == shape { if .circle == shapePreset {
shape = .None shapePreset = .none
} }
} }
} }
...@@ -216,9 +221,9 @@ public class Layer: CAShapeLayer { ...@@ -216,9 +221,9 @@ public class Layer: CAShapeLayer {
width or height property is set, the other will be automatically adjusted width or height property is set, the other will be automatically adjusted
to maintain the shape of the object. to maintain the shape of the object.
*/ */
public var shape: MaterialShape = .None { public var shapePreset: ShapePreset = .none {
didSet { didSet {
if .None != shape { if .none != shapePreset {
if width < height { if width < height {
frame.size.width = height frame.size.width = height
} else { } else {
...@@ -230,9 +235,9 @@ public class Layer: CAShapeLayer { ...@@ -230,9 +235,9 @@ public class Layer: CAShapeLayer {
} }
/// A preset property to set the borderWidth. /// A preset property to set the borderWidth.
public var borderWidthPreset: MaterialBorder = .None { public var borderWidthPreset: BorderWidthPreset = .none {
didSet { didSet {
borderWidth = MaterialBorderToValue(border: borderWidthPreset) borderWidth = BorderWidthPresetToValue(preset: borderWidthPreset)
} }
} }
...@@ -335,8 +340,8 @@ public class Layer: CAShapeLayer { ...@@ -335,8 +340,8 @@ public class Layer: CAShapeLayer {
/// Prepares the visualLayer property. /// Prepares the visualLayer property.
public func prepareVisualLayer() { public func prepareVisualLayer() {
// visualLayer visualLayer = CAShapeLayer(Z
visualLayer.zPosition = 0 visualLayer.zPosition = 0
visualLayer.masksToBounds = true visualLayer.masksToBounds = true
addSublayer(visualLayer) addSublayer(visualLayer)
} }
...@@ -349,8 +354,8 @@ public class Layer: CAShapeLayer { ...@@ -349,8 +354,8 @@ public class Layer: CAShapeLayer {
/// Manages the layout for the shape of the layer instance. /// Manages the layout for the shape of the layer instance.
internal func layoutShape() { internal func layoutShape() {
if .Circle == shape { if .circle == shapePreset {
let w: CGFloat = (width / 2) let w = width / 2
if w != cornerRadius { if w != cornerRadius {
cornerRadius = w cornerRadius = w
} }
...@@ -360,7 +365,7 @@ public class Layer: CAShapeLayer { ...@@ -360,7 +365,7 @@ public class Layer: CAShapeLayer {
/// Sets the shadow path. /// Sets the shadow path.
internal func layoutShadowPath() { internal func layoutShadowPath() {
if shadowPathAutoSizeEnabled { if shadowPathAutoSizeEnabled {
if .None == depth { if .none == depthPreset {
shadowPath = nil shadowPath = nil
} else if nil == shadowPath { } else if nil == shadowPath {
shadowPath = UIBezierPath(roundedRect: bounds, cornerRadius: cornerRadius).cgPath shadowPath = UIBezierPath(roundedRect: bounds, cornerRadius: cornerRadius).cgPath
......
...@@ -73,12 +73,12 @@ public class MaterialCollectionView : UICollectionView { ...@@ -73,12 +73,12 @@ public class MaterialCollectionView : UICollectionView {
} }
/// A preset wrapper around contentInset. /// A preset wrapper around contentInset.
public var contentInsetPreset: Insets { public var contentEdgeInsetsPreset: Insets {
get { get {
return (collectionViewLayout as? MaterialCollectionViewLayout)!.contentInsetPreset return (collectionViewLayout as? MaterialCollectionViewLayout)!.contentEdgeInsetsPreset
} }
set(value) { set(value) {
(collectionViewLayout as? MaterialCollectionViewLayout)!.contentInsetPreset = value (collectionViewLayout as? MaterialCollectionViewLayout)!.contentEdgeInsetsPreset = value
} }
} }
......
...@@ -133,12 +133,12 @@ public class MaterialCollectionViewCell : UICollectionViewCell { ...@@ -133,12 +133,12 @@ public class MaterialCollectionViewCell : UICollectionViewCell {
} }
/// A preset wrapper around contentInset. /// A preset wrapper around contentInset.
public var contentInsetPreset: InsetPreset { public var contentEdgeInsetsPreset: EdgeInsetsPreset {
get { get {
return contentView.grid.contentInsetPreset return contentView.grid.contentEdgeInsetsPreset
} }
set(value) { set(value) {
contentView.grid.contentInsetPreset = value contentView.grid.contentEdgeInsetsPreset = value
} }
} }
...@@ -214,7 +214,7 @@ public class MaterialCollectionViewCell : UICollectionViewCell { ...@@ -214,7 +214,7 @@ public class MaterialCollectionViewCell : UICollectionViewCell {
/** /**
A property that accesses the layer.frame.size.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.
*/ */
@IBInspectable public var width: CGFloat { @IBInspectable public var width: CGFloat {
...@@ -223,7 +223,7 @@ public class MaterialCollectionViewCell : UICollectionViewCell { ...@@ -223,7 +223,7 @@ public class MaterialCollectionViewCell : UICollectionViewCell {
} }
set(value) { set(value) {
layer.frame.size.width = value layer.frame.size.width = value
if .None != shape { if .none != shape {
layer.frame.size.height = value layer.frame.size.height = value
} }
} }
...@@ -232,7 +232,7 @@ public class MaterialCollectionViewCell : UICollectionViewCell { ...@@ -232,7 +232,7 @@ public class MaterialCollectionViewCell : UICollectionViewCell {
/** /**
A property that accesses the layer.frame.size.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.
*/ */
@IBInspectable public var height: CGFloat { @IBInspectable public var height: CGFloat {
...@@ -241,7 +241,7 @@ public class MaterialCollectionViewCell : UICollectionViewCell { ...@@ -241,7 +241,7 @@ public class MaterialCollectionViewCell : UICollectionViewCell {
} }
set(value) { set(value) {
layer.frame.size.height = value layer.frame.size.height = value
if .None != shape { if .none != shape {
layer.frame.size.width = value layer.frame.size.width = value
} }
} }
...@@ -255,7 +255,7 @@ public class MaterialCollectionViewCell : UICollectionViewCell { ...@@ -255,7 +255,7 @@ public class MaterialCollectionViewCell : UICollectionViewCell {
} }
/// A property that accesses the backing layer's shadowOffset. /// A property that accesses the backing layer's shadowOffset.
@IBInspectable public var shadowOffset: CGSize { @IBInspectable public var shadowOffset: Offset {
get { get {
return layer.shadowOffset return layer.shadowOffset
} }
...@@ -320,13 +320,13 @@ public class MaterialCollectionViewCell : UICollectionViewCell { ...@@ -320,13 +320,13 @@ public class MaterialCollectionViewCell : UICollectionViewCell {
/** /**
A property that sets the cornerRadius of the backing layer. If the shape 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 property has a value of .circle when the cornerRadius is set, it will
become .None, as it no longer maintains its circle shape. become .none, as it no longer maintains its circle shape.
*/ */
public var cornerRadiusPreset: MaterialRadius { public var cornerRadiusPreset: RadiusPreset {
didSet { didSet {
if let v: MaterialRadius = cornerRadiusPreset { if let v: RadiusPreset = cornerRadiusPreset {
cornerRadius = MaterialRadiusToValue(v) cornerRadius = RadiusPresetToValue(v)
} }
} }
} }
...@@ -339,8 +339,8 @@ public class MaterialCollectionViewCell : UICollectionViewCell { ...@@ -339,8 +339,8 @@ public class MaterialCollectionViewCell : UICollectionViewCell {
set(value) { set(value) {
layer.cornerRadius = value layer.cornerRadius = value
layoutShadowPath() layoutShadowPath()
if .Circle == shape { if .circle == shape {
shape = .None shape = .none
} }
} }
} }
...@@ -350,9 +350,9 @@ public class MaterialCollectionViewCell : UICollectionViewCell { ...@@ -350,9 +350,9 @@ public class MaterialCollectionViewCell : UICollectionViewCell {
width or height property is set, the other will be automatically adjusted width or height property is set, the other will be automatically adjusted
to maintain the shape of the object. to maintain the shape of the object.
*/ */
public var shape: MaterialShape { public var shape: ShapePreset {
didSet { didSet {
if .None != shape { if .none != shape {
if width < height { if width < height {
frame.size.width = height frame.size.width = height
} else { } else {
...@@ -364,9 +364,9 @@ public class MaterialCollectionViewCell : UICollectionViewCell { ...@@ -364,9 +364,9 @@ public class MaterialCollectionViewCell : UICollectionViewCell {
} }
/// A preset property to set the borderWidth. /// A preset property to set the borderWidth.
public var borderWidthPreset: MaterialBorder = .None { public var borderWidthPreset: BorderWidthPreset = .none {
didSet { didSet {
borderWidth = MaterialBorderToValue(borderWidthPreset) borderWidth = BorderWidthPresetToValue(presetWidthPreset)
} }
} }
...@@ -415,9 +415,9 @@ public class MaterialCollectionViewCell : UICollectionViewCell { ...@@ -415,9 +415,9 @@ public class MaterialCollectionViewCell : UICollectionViewCell {
- Parameter aDecoder: A NSCoder instance. - Parameter aDecoder: A NSCoder instance.
*/ */
public required init?(coder aDecoder: NSCoder) { public required init?(coder aDecoder: NSCoder) {
depth = .None depth = .none
cornerRadiusPreset = .None cornerRadiusPreset = .none
shape = .None shape = .none
contentsGravityPreset = .ResizeAspectFill contentsGravityPreset = .ResizeAspectFill
super.init(coder: aDecoder) super.init(coder: aDecoder)
prepareView() prepareView()
...@@ -430,9 +430,9 @@ public class MaterialCollectionViewCell : UICollectionViewCell { ...@@ -430,9 +430,9 @@ public class MaterialCollectionViewCell : UICollectionViewCell {
- Parameter frame: A CGRect instance. - Parameter frame: A CGRect instance.
*/ */
public override init(frame: CGRect) { public override init(frame: CGRect) {
depth = .None depth = .none
cornerRadiusPreset = .None cornerRadiusPreset = .none
shape = .None shape = .none
contentsGravityPreset = .ResizeAspectFill contentsGravityPreset = .ResizeAspectFill
super.init(frame: frame) super.init(frame: frame)
prepareView() prepareView()
...@@ -585,7 +585,7 @@ public class MaterialCollectionViewCell : UICollectionViewCell { ...@@ -585,7 +585,7 @@ public class MaterialCollectionViewCell : UICollectionViewCell {
/// Manages the layout for the shape of the view instance. /// Manages the layout for the shape of the view instance.
internal func layoutShape() { internal func layoutShape() {
if .Circle == shape { if .circle == shape {
let w: CGFloat = (width / 2) let w: CGFloat = (width / 2)
if w != cornerRadius { if w != cornerRadius {
cornerRadius = w cornerRadius = w
...@@ -596,7 +596,7 @@ public class MaterialCollectionViewCell : UICollectionViewCell { ...@@ -596,7 +596,7 @@ public class MaterialCollectionViewCell : UICollectionViewCell {
/// Sets the shadow path. /// Sets the shadow path.
internal func layoutShadowPath() { internal func layoutShadowPath() {
if shadowPathAutoSizeEnabled { if shadowPathAutoSizeEnabled {
if .None == depth { if .none == depth {
shadowPath = nil shadowPath = nil
} else if nil == shadowPath { } else if nil == shadowPath {
shadowPath = UIBezierPath(roundedRect: bounds, cornerRadius: cornerRadius).CGPath shadowPath = UIBezierPath(roundedRect: bounds, cornerRadius: cornerRadius).CGPath
......
...@@ -38,14 +38,14 @@ public class MaterialCollectionViewLayout : UICollectionViewLayout { ...@@ -38,14 +38,14 @@ public class MaterialCollectionViewLayout : UICollectionViewLayout {
public var itemSize: CGSize = CGSize.zero public var itemSize: CGSize = CGSize.zero
/// A preset wrapper around contentInset. /// A preset wrapper around contentInset.
public var contentInsetPreset: InsetPreset = .none { public var contentEdgeInsetsPreset: EdgeInsetsPreset = .none {
didSet { didSet {
contentInset = InsetPresetToValue(preset: contentInsetPreset) contentInset = EdgeInsetsPresetToValue(preset: contentEdgeInsetsPreset)
} }
} }
/// A wrapper around grid.contentInset. /// A wrapper around grid.contentInset.
public var contentInset = Inset.zero public var contentInset = EdgeInsets.zero
/// Size of the content. /// Size of the content.
public private(set) var contentSize: CGSize = CGSize.zero public private(set) var contentSize: CGSize = CGSize.zero
......
...@@ -43,7 +43,7 @@ public enum MaterialAnimationRotationMode { ...@@ -43,7 +43,7 @@ public enum MaterialAnimationRotationMode {
*/ */
public func MaterialAnimationRotationModeToValue(mode: MaterialAnimationRotationMode) -> MaterialAnimationRotationModeType? { public func MaterialAnimationRotationModeToValue(mode: MaterialAnimationRotationMode) -> MaterialAnimationRotationModeType? {
switch mode { switch mode {
case .None: case .none:
return nil return nil
case .Auto: case .Auto:
return kCAAnimationRotateAuto return kCAAnimationRotateAuto
...@@ -66,4 +66,4 @@ public extension MaterialAnimation { ...@@ -66,4 +66,4 @@ public extension MaterialAnimation {
} }
return animation return animation
} }
} }
\ No newline at end of file
...@@ -106,7 +106,7 @@ public class MaterialTableViewCell : UITableViewCell { ...@@ -106,7 +106,7 @@ public class MaterialTableViewCell : UITableViewCell {
/** /**
A property that accesses the layer.frame.size.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.
*/ */
@IBInspectable public var width: CGFloat { @IBInspectable public var width: CGFloat {
...@@ -121,7 +121,7 @@ public class MaterialTableViewCell : UITableViewCell { ...@@ -121,7 +121,7 @@ public class MaterialTableViewCell : UITableViewCell {
/** /**
A property that accesses the layer.frame.size.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.
*/ */
@IBInspectable public var height: CGFloat { @IBInspectable public var height: CGFloat {
...@@ -141,7 +141,7 @@ public class MaterialTableViewCell : UITableViewCell { ...@@ -141,7 +141,7 @@ public class MaterialTableViewCell : UITableViewCell {
} }
/// A property that accesses the backing layer's shadowOffset. /// A property that accesses the backing layer's shadowOffset.
@IBInspectable public var shadowOffset: CGSize { @IBInspectable public var shadowOffset: Offset {
get { get {
return layer.shadowOffset return layer.shadowOffset
} }
...@@ -211,13 +211,13 @@ public class MaterialTableViewCell : UITableViewCell { ...@@ -211,13 +211,13 @@ public class MaterialTableViewCell : UITableViewCell {
/** /**
A property that sets the cornerRadius of the backing layer. If the shape 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 property has a value of .circle when the cornerRadius is set, it will
become .None, as it no longer maintains its circle shape. become .none, as it no longer maintains its circle shape.
*/ */
public var cornerRadiusPreset: MaterialRadius = .None { public var cornerRadiusPreset: RadiusPreset = .none {
didSet { didSet {
if let v: MaterialRadius = cornerRadiusPreset { if let v: RadiusPreset = cornerRadiusPreset {
cornerRadius = MaterialRadiusToValue(radius: v) cornerRadius = RadiusPresetToValue(preset: v)
} }
} }
} }
...@@ -234,9 +234,9 @@ public class MaterialTableViewCell : UITableViewCell { ...@@ -234,9 +234,9 @@ public class MaterialTableViewCell : UITableViewCell {
} }
/// A preset property to set the borderWidth. /// A preset property to set the borderWidth.
public var borderWidthPreset: MaterialBorder = .None { public var borderWidthPreset: BorderWidthPreset = .none {
didSet { didSet {
borderWidth = MaterialBorderToValue(border: borderWidthPreset) borderWidth = BorderWidthPresetToValue(preset: borderWidthPreset)
} }
} }
...@@ -421,7 +421,7 @@ public class MaterialTableViewCell : UITableViewCell { ...@@ -421,7 +421,7 @@ public class MaterialTableViewCell : UITableViewCell {
when subclassing. when subclassing.
*/ */
public func prepareView() { public func prepareView() {
selectionStyle = .None selectionStyle = .none
separatorInset = UIEdgeInsetsZero separatorInset = UIEdgeInsetsZero
contentScaleFactor = Device.scale contentScaleFactor = Device.scale
imageView?.isUserInteractionEnabled = false imageView?.isUserInteractionEnabled = false
...@@ -446,7 +446,7 @@ public class MaterialTableViewCell : UITableViewCell { ...@@ -446,7 +446,7 @@ public class MaterialTableViewCell : UITableViewCell {
/// Sets the shadow path. /// Sets the shadow path.
internal func layoutShadowPath() { internal func layoutShadowPath() {
if shadowPathAutoSizeEnabled { if shadowPathAutoSizeEnabled {
if .None == depth { if .none == depth {
shadowPath = nil shadowPath = nil
} else if nil == shadowPath { } else if nil == shadowPath {
shadowPath = UIBezierPath(roundedRect: bounds, cornerRadius: cornerRadius).CGPath shadowPath = UIBezierPath(roundedRect: bounds, cornerRadius: cornerRadius).CGPath
......
...@@ -50,7 +50,7 @@ public class MenuView : PulseView { ...@@ -50,7 +50,7 @@ public class MenuView : PulseView {
*/ */
public override func prepareView() { public override func prepareView() {
super.prepareView() super.prepareView()
pulseAnimation = .None pulseAnimation = .none
clipsToBounds = false clipsToBounds = false
backgroundColor = nil backgroundColor = nil
} }
......
...@@ -62,14 +62,14 @@ public class NavigationBar : UINavigationBar { ...@@ -62,14 +62,14 @@ public class NavigationBar : UINavigationBar {
} }
/// A preset wrapper around contentInset. /// A preset wrapper around contentInset.
public var contentInsetPreset: InsetPreset = .none { public var contentEdgeInsetsPreset: EdgeInsetsPreset = .none {
didSet { didSet {
contentInset = InsetPresetToValue(preset: contentInsetPreset) contentInset = EdgeInsetsPresetToValue(preset: contentEdgeInsetsPreset)
} }
} }
/// A wrapper around grid.contentInset. /// A wrapper around grid.contentInset.
@IBInspectable public var contentInset: Insets = Inset.zero { @IBInspectable public var contentInset: Insets = EdgeInsets.zero {
didSet { didSet {
layoutSubviews() layoutSubviews()
} }
...@@ -157,7 +157,7 @@ public class NavigationBar : UINavigationBar { ...@@ -157,7 +157,7 @@ public class NavigationBar : UINavigationBar {
/** /**
A property that accesses the layer.frame.size.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.
*/ */
@IBInspectable public var width: CGFloat { @IBInspectable public var width: CGFloat {
...@@ -172,7 +172,7 @@ public class NavigationBar : UINavigationBar { ...@@ -172,7 +172,7 @@ public class NavigationBar : UINavigationBar {
/** /**
A property that accesses the layer.frame.size.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.
*/ */
@IBInspectable public var height: CGFloat { @IBInspectable public var height: CGFloat {
...@@ -192,7 +192,7 @@ public class NavigationBar : UINavigationBar { ...@@ -192,7 +192,7 @@ public class NavigationBar : UINavigationBar {
} }
/// A property that accesses the backing layer's shadowOffset. /// A property that accesses the backing layer's shadowOffset.
@IBInspectable public var shadowOffset: CGSize { @IBInspectable public var shadowOffset: Offset {
get { get {
return layer.shadowOffset return layer.shadowOffset
} }
...@@ -236,9 +236,9 @@ public class NavigationBar : UINavigationBar { ...@@ -236,9 +236,9 @@ public class NavigationBar : UINavigationBar {
} }
/// A preset property to set the borderWidth. /// A preset property to set the borderWidth.
public var borderWidthPreset: MaterialBorder = .None { public var borderWidthPreset: BorderWidthPreset = .none {
didSet { didSet {
borderWidth = MaterialBorderToValue(borderWidthPreset) borderWidth = BorderWidthPresetToValue(presetWidthPreset)
} }
} }
...@@ -433,7 +433,7 @@ public class NavigationBar : UINavigationBar { ...@@ -433,7 +433,7 @@ public class NavigationBar : UINavigationBar {
translucent = false translucent = false
depth = .depth1 depth = .depth1
interimSpacePreset = .interimSpace1 interimSpacePreset = .interimSpace1
contentInsetPreset = .Square1 contentEdgeInsetsPreset = .Square1
contentScaleFactor = Device.scale contentScaleFactor = Device.scale
backButtonImage = Icon.cm.arrowBack backButtonImage = Icon.cm.arrowBack
let image: UIImage? = UIImage.imageWithColor(Color.clear, size: CGSizeMake(1, 1)) let image: UIImage? = UIImage.imageWithColor(Color.clear, size: CGSizeMake(1, 1))
......
...@@ -1098,7 +1098,7 @@ public class NavigationDrawerController : RootController, UIGestureRecognizerDel ...@@ -1098,7 +1098,7 @@ public class NavigationDrawerController : RootController, UIGestureRecognizerDel
- Parameter container: A container view. - Parameter container: A container view.
*/ */
private func hideView(container: View) { private func hideView(container: View) {
container.depth = .None container.depth = .none
container.isHidden = true container.isHidden = true
} }
} }
...@@ -32,7 +32,25 @@ import UIKit ...@@ -32,7 +32,25 @@ import UIKit
public typealias Offset = UIOffset public typealias Offset = UIOffset
public extension CGSize {
/// Returns an Offset version of the CGSize.
public var asOffset: Offset {
return Offset(size: self)
}
}
public extension Offset {
/**
Initializer that accepts a CGSize value.
- Parameter size: A CGSize value.
*/
public init(size: CGSize) {
self.init(horizontal: size.width, vertical: size.height)
}
}
public extension Offset { public extension Offset {
/// Returns a CGSize version of the Offset.
public var asSize: CGSize { public var asSize: CGSize {
return CGSize(width: horizontal, height: vertical) return CGSize(width: horizontal, height: vertical)
} }
......
...@@ -30,41 +30,41 @@ ...@@ -30,41 +30,41 @@
import UIKit import UIKit
public enum MaterialRadius { public enum RadiusPreset {
case None case none
case Radius1 case radius1
case Radius2 case radius2
case Radius3 case radius3
case Radius4 case radius4
case Radius5 case radius5
case Radius6 case radius6
case Radius7 case radius7
case Radius8 case radius8
case Radius9 case radius9
} }
/// Converts the MaterialRadius enum to a CGFloat value. /// Converts the RadiusPreset enum to a CGFloat value.
public func MaterialRadiusToValue(radius: MaterialRadius) -> CGFloat { public func RadiusPresetToValue(preset: RadiusPreset) -> CGFloat {
switch radius { switch preset {
case .None: case .none:
return 0 return 0
case .Radius1: case .radius1:
return 4 return 4
case .Radius2: case .radius2:
return 8 return 8
case .Radius3: case .radius3:
return 16 return 16
case .Radius4: case .radius4:
return 24 return 24
case .Radius5: case .radius5:
return 32 return 32
case .Radius6: case .radius6:
return 40 return 40
case .Radius7: case .radius7:
return 48 return 48
case .Radius8: case .radius8:
return 56 return 56
case .Radius9: case .radius9:
return 64 return 64
} }
} }
...@@ -42,7 +42,7 @@ public class RaisedButton: Button { ...@@ -42,7 +42,7 @@ public class RaisedButton: Button {
super.prepareView() super.prepareView()
depthPreset = .depth1 depthPreset = .depth1
cornerRadiusPreset = .Radius1 cornerRadiusPreset = .Radius1
contentInsetPreset = .wideRectangle3 contentEdgeInsetsPreset = .wideRectangle3
backgroundColor = Color.white backgroundColor = Color.white
} }
} }
...@@ -28,8 +28,8 @@ ...@@ -28,8 +28,8 @@
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/ */
public enum MaterialShape { public enum ShapePreset {
case None case none
case Square case square
case Circle case circle
} }
...@@ -438,7 +438,7 @@ public class Switch: UIControl { ...@@ -438,7 +438,7 @@ public class Switch: UIControl {
/// Prepares the button. /// Prepares the button.
private func prepareButton() { private func prepareButton() {
button.pulseAnimation = .None button.pulseAnimation = .none
button.addTarget(self, action: #selector(handleTouchUpInside), for: .touchUpInside) button.addTarget(self, action: #selector(handleTouchUpInside), for: .touchUpInside)
button.addTarget(self, action: #selector(handleTouchDragInside), for: .touchDragInside) button.addTarget(self, action: #selector(handleTouchDragInside), for: .touchDragInside)
button.addTarget(self, action: #selector(handleTouchUpOutsideOrCanceled), for: .touchCancel) button.addTarget(self, action: #selector(handleTouchUpOutsideOrCanceled), for: .touchCancel)
......
...@@ -468,7 +468,7 @@ public class TextField : UITextField { ...@@ -468,7 +468,7 @@ public class TextField : UITextField {
public func prepareView() { public func prepareView() {
super.placeholder = nil super.placeholder = nil
masksToBounds = false masksToBounds = false
borderStyle = .None borderStyle = .none
backgroundColor = nil backgroundColor = nil
textColor = Color.darkText.primary textColor = Color.darkText.primary
font = RobotoFont.regularWithSize(16) font = RobotoFont.regularWithSize(16)
......
...@@ -104,7 +104,7 @@ public class TextView: UITextView { ...@@ -104,7 +104,7 @@ public class TextView: UITextView {
} }
/// A property that accesses the backing layer's shadowOffset. /// A property that accesses the backing layer's shadowOffset.
@IBInspectable public var shadowOffset: CGSize { @IBInspectable public var shadowOffset: Offset {
get { get {
return layer.shadowOffset return layer.shadowOffset
} }
...@@ -168,10 +168,10 @@ public class TextView: UITextView { ...@@ -168,10 +168,10 @@ public class TextView: UITextView {
} }
/// A property that sets the cornerRadius of the backing layer. /// A property that sets the cornerRadius of the backing layer.
public var cornerRadiusPreset: MaterialRadius = .None { public var cornerRadiusPreset: RadiusPreset = .none {
didSet { didSet {
if let v: MaterialRadius = cornerRadiusPreset { if let v: RadiusPreset = cornerRadiusPreset {
cornerRadius = MaterialRadiusToValue(v) cornerRadius = RadiusPresetToValue(v)
} }
} }
} }
...@@ -188,9 +188,9 @@ public class TextView: UITextView { ...@@ -188,9 +188,9 @@ public class TextView: UITextView {
} }
/// A preset property to set the borderWidth. /// A preset property to set the borderWidth.
public var borderWidthPreset: MaterialBorder = .None { public var borderWidthPreset: BorderWidthPreset = .none {
didSet { didSet {
borderWidth = MaterialBorderToValue(borderWidthPreset) borderWidth = BorderWidthPresetToValue(presetWidthPreset)
} }
} }
...@@ -286,9 +286,9 @@ public class TextView: UITextView { ...@@ -286,9 +286,9 @@ public class TextView: UITextView {
Text container UIEdgeInset preset property. This updates the Text container UIEdgeInset preset property. This updates the
textContainerInset property with a preset value. textContainerInset property with a preset value.
*/ */
public var textContainerInsetPreset: InsetPreset = .none { public var textContainerEdgeInsetsPreset: EdgeInsetsPreset = .none {
didSet { didSet {
textContainerInset = InsetPresetToValue(preset: textContainerInsetPreset) textContainerInset = EdgeInsetsPresetToValue(preset: textContainerEdgeInsetsPreset)
} }
} }
...@@ -440,7 +440,7 @@ public class TextView: UITextView { ...@@ -440,7 +440,7 @@ public class TextView: UITextView {
/// Sets the shadow path. /// Sets the shadow path.
internal func layoutShadowPath() { internal func layoutShadowPath() {
if shadowPathAutoSizeEnabled { if shadowPathAutoSizeEnabled {
if .None == depth { if .none == depth {
shadowPath = nil shadowPath = nil
} else if nil == shadowPath { } else if nil == shadowPath {
shadowPath = UIBezierPath(roundedRect: bounds, cornerRadius: cornerRadius).CGPath shadowPath = UIBezierPath(roundedRect: bounds, cornerRadius: cornerRadius).CGPath
...@@ -459,7 +459,7 @@ public class TextView: UITextView { ...@@ -459,7 +459,7 @@ public class TextView: UITextView {
*/ */
public func prepareView() { public func prepareView() {
contentScaleFactor = Device.scale contentScaleFactor = Device.scale
textContainerInset = Inset.zero textContainerInset = EdgeInsets.zero
backgroundColor = Color.white backgroundColor = Color.white
masksToBounds = false masksToBounds = false
removeNotificationHandlers() removeNotificationHandlers()
......
...@@ -159,7 +159,7 @@ public class View: UIView { ...@@ -159,7 +159,7 @@ public class View: UIView {
/** /**
A property that accesses the layer.frame.size.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.
*/ */
@IBInspectable public var width: CGFloat { @IBInspectable public var width: CGFloat {
...@@ -168,7 +168,7 @@ public class View: UIView { ...@@ -168,7 +168,7 @@ public class View: UIView {
} }
set(value) { set(value) {
layer.frame.size.width = value layer.frame.size.width = value
if .None != shape { if .none != shape {
layer.frame.size.height = value layer.frame.size.height = value
} }
} }
...@@ -177,7 +177,7 @@ public class View: UIView { ...@@ -177,7 +177,7 @@ public class View: UIView {
/** /**
A property that accesses the layer.frame.size.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.
*/ */
@IBInspectable public var height: CGFloat { @IBInspectable public var height: CGFloat {
...@@ -186,7 +186,7 @@ public class View: UIView { ...@@ -186,7 +186,7 @@ public class View: UIView {
} }
set(value) { set(value) {
layer.frame.size.height = value layer.frame.size.height = value
if .None != shape { if .none != shape {
layer.frame.size.width = value layer.frame.size.width = value
} }
} }
...@@ -200,7 +200,7 @@ public class View: UIView { ...@@ -200,7 +200,7 @@ public class View: UIView {
} }
/// A property that accesses the backing layer's shadowOffset. /// A property that accesses the backing layer's shadowOffset.
@IBInspectable public var shadowOffset: CGSize { @IBInspectable public var shadowOffset: Offset {
get { get {
return layer.shadowOffset return layer.shadowOffset
} }
...@@ -261,7 +261,7 @@ public class View: UIView { ...@@ -261,7 +261,7 @@ public class View: UIView {
*/ */
public var depth = Depth.zero { public var depth = Depth.zero {
didSet { didSet {
shadowOffset = depth.offset.asSize shadowOffset = depth.offset
shadowOpacity = depth.opacity shadowOpacity = depth.opacity
shadowRadius = depth.radius shadowRadius = depth.radius
layoutShadowPath() layoutShadowPath()
...@@ -270,13 +270,13 @@ public class View: UIView { ...@@ -270,13 +270,13 @@ public class View: UIView {
/** /**
A property that sets the cornerRadius of the backing layer. If the shape 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 property has a value of .circle when the cornerRadius is set, it will
become .None, as it no longer maintains its circle shape. become .none, as it no longer maintains its circle shape.
*/ */
public var cornerRadiusPreset: MaterialRadius = .None { public var cornerRadiusPreset: RadiusPreset = .none {
didSet { didSet {
if let v: MaterialRadius = cornerRadiusPreset { if let v: RadiusPreset = cornerRadiusPreset {
cornerRadius = MaterialRadiusToValue(radius: v) cornerRadius = RadiusPresetToValue(preset: v)
} }
} }
} }
...@@ -289,8 +289,8 @@ public class View: UIView { ...@@ -289,8 +289,8 @@ public class View: UIView {
set(value) { set(value) {
layer.cornerRadius = value layer.cornerRadius = value
layoutShadowPath() layoutShadowPath()
if .Circle == shape { if .circle == shape {
shape = .None shape = .none
} }
} }
} }
...@@ -300,9 +300,9 @@ public class View: UIView { ...@@ -300,9 +300,9 @@ public class View: UIView {
width or height property is set, the other will be automatically adjusted width or height property is set, the other will be automatically adjusted
to maintain the shape of the object. to maintain the shape of the object.
*/ */
public var shape: MaterialShape = .None { public var shape: ShapePreset = .none {
didSet { didSet {
if .None != shape { if .none != shape {
if width < height { if width < height {
frame.size.width = height frame.size.width = height
} else { } else {
...@@ -314,9 +314,9 @@ public class View: UIView { ...@@ -314,9 +314,9 @@ public class View: UIView {
} }
/// A preset property to set the borderWidth. /// A preset property to set the borderWidth.
public var borderWidthPreset: MaterialBorder = .None { public var borderWidthPreset: BorderWidthPreset = .none {
didSet { didSet {
borderWidth = MaterialBorderToValue(border: borderWidthPreset) borderWidth = BorderWidthPresetToValue(preset: borderWidthPreset)
} }
} }
...@@ -482,7 +482,7 @@ public class View: UIView { ...@@ -482,7 +482,7 @@ public class View: UIView {
/// Manages the layout for the shape of the view instance. /// Manages the layout for the shape of the view instance.
internal func layoutShape() { internal func layoutShape() {
if .Circle == shape { if .circle == shape {
let w: CGFloat = (width / 2) let w: CGFloat = (width / 2)
if w != cornerRadius { if w != cornerRadius {
cornerRadius = w cornerRadius = w
...@@ -493,7 +493,7 @@ public class View: UIView { ...@@ -493,7 +493,7 @@ public class View: UIView {
/// Sets the shadow path. /// Sets the shadow path.
internal func layoutShadowPath() { internal func layoutShadowPath() {
if shadowPathAutoSizeEnabled { if shadowPathAutoSizeEnabled {
if .None == depth { if .none == depth {
shadowPath = nil shadowPath = nil
} else if nil == shadowPath { } else if nil == shadowPath {
shadowPath = UIBezierPath(roundedRect: bounds, cornerRadius: cornerRadius).cgPath shadowPath = UIBezierPath(roundedRect: bounds, cornerRadius: cornerRadius).cgPath
......
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