Commit 4674e69d by Daniel Dahan

progression commit for Swift 2.3 refactor

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