Skip to content

Commit

Permalink
Use lowercase switch cases
Browse files Browse the repository at this point in the history
To adhere to Swift's best practices
  • Loading branch information
alejandro-isaza committed Oct 14, 2017
1 parent 086701c commit 52bb19c
Show file tree
Hide file tree
Showing 5 changed files with 49 additions and 49 deletions.
8 changes: 4 additions & 4 deletions C4/Core/Path.swift
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,12 @@ public enum FillRule {
/// Specifies the non-zero winding rule. Count each left-to-right path as +1 and each right-to-left path as -1. If the
/// sum of all crossings is 0, the point is outside the path. If the sum is nonzero, the point is inside the path and
/// the region containing it is filled.
case NonZero
case nonZero

/// Specifies the even-odd winding rule. Count the total number of path crossings. If the number of crossings is even,
/// the point is outside the path. If the number of crossings is odd, the point is inside the path and the region
/// containing it should be filled.
case EvenOdd
case evenOdd
}

/// A Path is a sequence of geometric segments which can be straight lines or curves.
Expand Down Expand Up @@ -72,8 +72,8 @@ public class Path: Equatable {
/// - parameter point: The point to test.
/// - parameter fillRule: The fill rule to use when testing for containment.
/// - returns: `true` if `point` is inside the path, `false` otherwise.
public func containsPoint(_ point: Point, fillRule: FillRule = .NonZero) -> Bool {
let rule = fillRule == .EvenOdd ? CGPathFillRule.evenOdd : CGPathFillRule.winding
public func containsPoint(_ point: Point, fillRule: FillRule = .nonZero) -> Bool {
let rule = fillRule == .evenOdd ? CGPathFillRule.evenOdd : CGPathFillRule.winding
return internalPath.contains(CGPoint(point), using: rule, transform: CGAffineTransform.identity)
}

Expand Down
10 changes: 5 additions & 5 deletions C4/UI/Animation.swift
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,13 @@ public class Animation {
/// ````
public enum Curve {
/// A linear animation curve causes an animation to occur evenly over its duration.
case Linear
case linear
/// An ease-out curve causes the animation to begin quickly, and then slow down as it completes.
case EaseOut
case easeOut
/// An ease-in curve causes the animation to begin slowly, and then speed up as it progresses.
case EaseIn
case easeIn
/// An ease-in ease-out curve causes the animation to begin slowly, accelerate through the middle of its duration, and then slow again before completing. This is the default curve for most animations.
case EaseInOut
case easeInOut
}

/// Determines if the animation plays in the reverse upon completion.
Expand All @@ -64,7 +64,7 @@ public class Animation {
public var duration: TimeInterval = 1

/// The animation curve that the receiver will apply to the changes it is supposed to animate.
public var curve: Curve = .EaseInOut
public var curve: Curve = .easeInOut

private var completionObservers: [AnyObject] = []
private var cancelObservers: [AnyObject] = []
Expand Down
56 changes: 28 additions & 28 deletions C4/UI/Shape.swift
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,8 @@ open class Shape: View {
strokeColor = C4Purple
fillColor = C4Blue
lineWidth = 1
lineCap = .Round
lineJoin = .Round
lineCap = .round
lineJoin = .round

let image = UIImage.createWithColor(UIColor.clear, size: CGSize(width: 1, height: 1)).cgImage
shapeLayer.contents = image
Expand All @@ -93,8 +93,8 @@ open class Shape: View {
strokeColor = C4Purple
fillColor = C4Blue
lineWidth = 1
lineCap = .Round
lineJoin = .Round
lineCap = .round
lineJoin = .round

let image = UIImage.createWithColor(UIColor.clear, size: CGSize(width: 1, height: 1)).cgImage
shapeLayer.contents = image
Expand Down Expand Up @@ -212,23 +212,23 @@ open class Shape: View {
}
}

/// The fill rule used when filling the path. Defaults to `NonZero`.
/// The fill rule used when filling the path. Defaults to `nonZero`.
public var fillRule: FillRule {
get {
switch shapeLayer.fillRule {
case kCAFillRuleNonZero:
return .NonZero
return .nonZero
case kCAFillRuleEvenOdd:
return .EvenOdd
return .evenOdd
default:
return .NonZero
return .nonZero
}
}
set(fillRule) {
switch fillRule {
case .NonZero:
case .nonZero:
shapeLayer.fillRule = kCAFillRuleNonZero
case .EvenOdd:
case .evenOdd:
shapeLayer.fillRule = kCAFillRuleEvenOdd
}
}
Expand Down Expand Up @@ -276,20 +276,20 @@ open class Shape: View {
get {
switch shapeLayer.lineCap {
case kCALineCapRound:
return .Round
return .round
case kCALineCapSquare:
return .Square
return .square
default:
return .Butt
return .butt
}
}
set(lineCap) {
switch lineCap {
case .Butt:
case .butt:
shapeLayer.lineCap = kCALineCapButt
case .Round:
case .round:
shapeLayer.lineCap = kCALineCapRound
case .Square:
case .square:
shapeLayer.lineCap = kCALineCapSquare
}
}
Expand All @@ -300,20 +300,20 @@ open class Shape: View {
get {
switch shapeLayer.lineJoin {
case kCALineJoinRound:
return .Round
return .round
case kCALineJoinBevel:
return .Bevel
return .bevel
default:
return .Miter
return .miter
}
}
set(lineJoin) {
switch lineJoin {
case .Miter:
case .miter:
shapeLayer.lineJoin = kCALineJoinMiter
case .Round:
case .round:
shapeLayer.lineJoin = kCALineJoinRound
case .Bevel:
case .bevel:
shapeLayer.lineJoin = kCALineJoinBevel
}
}
Expand Down Expand Up @@ -350,25 +350,25 @@ open class Shape: View {
/// The join style for joints on the shape's path.
public enum LineJoin {
/// Specifies a miter line shape of the joints between connected segments of a stroked path.
case Miter
case miter

/// Specifies a round line shape of the joints between connected segments of a stroked path.
case Round
case round

/// Specifies a bevel line shape of the joints between connected segments of a stroked path.
case Bevel
case bevel
}

/// The cap style for the ends of the shape's path.
public enum LineCap {
/// Specifies a butt line cap style for endpoints for an open path when stroked.
case Butt
case butt

/// Specifies a round line cap style for endpoints for an open path when stroked.
case Round
case round

/// Specifies a square line cap style for endpoints for an open path when stroked.
case Square
case square
}

public override func hitTest(_ point: Point) -> Bool {
Expand Down
8 changes: 4 additions & 4 deletions C4/UI/StoredAnimation.swift
Original file line number Diff line number Diff line change
Expand Up @@ -37,16 +37,16 @@ public class StoredAnimation: Animation {
var options: UIViewAnimationOptions = [UIViewAnimationOptions.beginFromCurrentState]

switch curve {
case .Linear:
case .linear:
options = [options, .curveLinear]
timing = CAMediaTimingFunction(name: kCAMediaTimingFunctionLinear)
case .EaseOut:
case .easeOut:
options = [options, .curveEaseOut]
timing = CAMediaTimingFunction(name: kCAMediaTimingFunctionEaseOut)
case .EaseIn:
case .easeIn:
options = [options, .curveEaseIn]
timing = CAMediaTimingFunction(name: kCAMediaTimingFunctionEaseIn)
case .EaseInOut:
case .easeInOut:
options = [options, .curveEaseIn, .curveEaseOut]
timing = CAMediaTimingFunction(name: kCAMediaTimingFunctionEaseInEaseOut)
}
Expand Down
16 changes: 8 additions & 8 deletions C4/UI/ViewAnimation.swift
Original file line number Diff line number Diff line change
Expand Up @@ -94,13 +94,13 @@ public class ViewAnimation: Animation {
/// Options are `Linear`, `EaseOut`, `EaseIn`, `EaseInOut`
public var timingFunction: CAMediaTimingFunction {
switch curve {
case .Linear:
case .linear:
return CAMediaTimingFunction(name: kCAMediaTimingFunctionLinear)
case .EaseOut:
case .easeOut:
return CAMediaTimingFunction(name: kCAMediaTimingFunctionEaseOut)
case .EaseIn:
case .easeIn:
return CAMediaTimingFunction(name: kCAMediaTimingFunctionEaseIn)
case .EaseInOut:
case .easeInOut:
return CAMediaTimingFunction(name: kCAMediaTimingFunctionEaseInEaseOut)
}
}
Expand All @@ -109,13 +109,13 @@ public class ViewAnimation: Animation {
public var options: UIViewAnimationOptions {
var options: UIViewAnimationOptions = [UIViewAnimationOptions.beginFromCurrentState]
switch curve {
case .Linear:
case .linear:
options = [options, .curveLinear]
case .EaseOut:
case .easeOut:
options = [options, .curveEaseOut]
case .EaseIn:
case .easeIn:
options = [options, .curveEaseIn]
case .EaseInOut:
case .easeInOut:
options = [options, .curveEaseIn, .curveEaseOut]
}

Expand Down

0 comments on commit 52bb19c

Please sign in to comment.