Skip to content

Commit 52bb19c

Browse files
Use lowercase switch cases
To adhere to Swift's best practices
1 parent 086701c commit 52bb19c

File tree

5 files changed

+49
-49
lines changed

5 files changed

+49
-49
lines changed

C4/Core/Path.swift

+4-4
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,12 @@ public enum FillRule {
2525
/// Specifies the non-zero winding rule. Count each left-to-right path as +1 and each right-to-left path as -1. If the
2626
/// sum of all crossings is 0, the point is outside the path. If the sum is nonzero, the point is inside the path and
2727
/// the region containing it is filled.
28-
case NonZero
28+
case nonZero
2929

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

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

C4/UI/Animation.swift

+5-5
Original file line numberDiff line numberDiff line change
@@ -31,13 +31,13 @@ public class Animation {
3131
/// ````
3232
public enum Curve {
3333
/// A linear animation curve causes an animation to occur evenly over its duration.
34-
case Linear
34+
case linear
3535
/// An ease-out curve causes the animation to begin quickly, and then slow down as it completes.
36-
case EaseOut
36+
case easeOut
3737
/// An ease-in curve causes the animation to begin slowly, and then speed up as it progresses.
38-
case EaseIn
38+
case easeIn
3939
/// 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.
40-
case EaseInOut
40+
case easeInOut
4141
}
4242

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

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

6969
private var completionObservers: [AnyObject] = []
7070
private var cancelObservers: [AnyObject] = []

C4/UI/Shape.swift

+28-28
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,8 @@ open class Shape: View {
6767
strokeColor = C4Purple
6868
fillColor = C4Blue
6969
lineWidth = 1
70-
lineCap = .Round
71-
lineJoin = .Round
70+
lineCap = .round
71+
lineJoin = .round
7272

7373
let image = UIImage.createWithColor(UIColor.clear, size: CGSize(width: 1, height: 1)).cgImage
7474
shapeLayer.contents = image
@@ -93,8 +93,8 @@ open class Shape: View {
9393
strokeColor = C4Purple
9494
fillColor = C4Blue
9595
lineWidth = 1
96-
lineCap = .Round
97-
lineJoin = .Round
96+
lineCap = .round
97+
lineJoin = .round
9898

9999
let image = UIImage.createWithColor(UIColor.clear, size: CGSize(width: 1, height: 1)).cgImage
100100
shapeLayer.contents = image
@@ -212,23 +212,23 @@ open class Shape: View {
212212
}
213213
}
214214

215-
/// The fill rule used when filling the path. Defaults to `NonZero`.
215+
/// The fill rule used when filling the path. Defaults to `nonZero`.
216216
public var fillRule: FillRule {
217217
get {
218218
switch shapeLayer.fillRule {
219219
case kCAFillRuleNonZero:
220-
return .NonZero
220+
return .nonZero
221221
case kCAFillRuleEvenOdd:
222-
return .EvenOdd
222+
return .evenOdd
223223
default:
224-
return .NonZero
224+
return .nonZero
225225
}
226226
}
227227
set(fillRule) {
228228
switch fillRule {
229-
case .NonZero:
229+
case .nonZero:
230230
shapeLayer.fillRule = kCAFillRuleNonZero
231-
case .EvenOdd:
231+
case .evenOdd:
232232
shapeLayer.fillRule = kCAFillRuleEvenOdd
233233
}
234234
}
@@ -276,20 +276,20 @@ open class Shape: View {
276276
get {
277277
switch shapeLayer.lineCap {
278278
case kCALineCapRound:
279-
return .Round
279+
return .round
280280
case kCALineCapSquare:
281-
return .Square
281+
return .square
282282
default:
283-
return .Butt
283+
return .butt
284284
}
285285
}
286286
set(lineCap) {
287287
switch lineCap {
288-
case .Butt:
288+
case .butt:
289289
shapeLayer.lineCap = kCALineCapButt
290-
case .Round:
290+
case .round:
291291
shapeLayer.lineCap = kCALineCapRound
292-
case .Square:
292+
case .square:
293293
shapeLayer.lineCap = kCALineCapSquare
294294
}
295295
}
@@ -300,20 +300,20 @@ open class Shape: View {
300300
get {
301301
switch shapeLayer.lineJoin {
302302
case kCALineJoinRound:
303-
return .Round
303+
return .round
304304
case kCALineJoinBevel:
305-
return .Bevel
305+
return .bevel
306306
default:
307-
return .Miter
307+
return .miter
308308
}
309309
}
310310
set(lineJoin) {
311311
switch lineJoin {
312-
case .Miter:
312+
case .miter:
313313
shapeLayer.lineJoin = kCALineJoinMiter
314-
case .Round:
314+
case .round:
315315
shapeLayer.lineJoin = kCALineJoinRound
316-
case .Bevel:
316+
case .bevel:
317317
shapeLayer.lineJoin = kCALineJoinBevel
318318
}
319319
}
@@ -350,25 +350,25 @@ open class Shape: View {
350350
/// The join style for joints on the shape's path.
351351
public enum LineJoin {
352352
/// Specifies a miter line shape of the joints between connected segments of a stroked path.
353-
case Miter
353+
case miter
354354

355355
/// Specifies a round line shape of the joints between connected segments of a stroked path.
356-
case Round
356+
case round
357357

358358
/// Specifies a bevel line shape of the joints between connected segments of a stroked path.
359-
case Bevel
359+
case bevel
360360
}
361361

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

367367
/// Specifies a round line cap style for endpoints for an open path when stroked.
368-
case Round
368+
case round
369369

370370
/// Specifies a square line cap style for endpoints for an open path when stroked.
371-
case Square
371+
case square
372372
}
373373

374374
public override func hitTest(_ point: Point) -> Bool {

C4/UI/StoredAnimation.swift

+4-4
Original file line numberDiff line numberDiff line change
@@ -37,16 +37,16 @@ public class StoredAnimation: Animation {
3737
var options: UIViewAnimationOptions = [UIViewAnimationOptions.beginFromCurrentState]
3838

3939
switch curve {
40-
case .Linear:
40+
case .linear:
4141
options = [options, .curveLinear]
4242
timing = CAMediaTimingFunction(name: kCAMediaTimingFunctionLinear)
43-
case .EaseOut:
43+
case .easeOut:
4444
options = [options, .curveEaseOut]
4545
timing = CAMediaTimingFunction(name: kCAMediaTimingFunctionEaseOut)
46-
case .EaseIn:
46+
case .easeIn:
4747
options = [options, .curveEaseIn]
4848
timing = CAMediaTimingFunction(name: kCAMediaTimingFunctionEaseIn)
49-
case .EaseInOut:
49+
case .easeInOut:
5050
options = [options, .curveEaseIn, .curveEaseOut]
5151
timing = CAMediaTimingFunction(name: kCAMediaTimingFunctionEaseInEaseOut)
5252
}

C4/UI/ViewAnimation.swift

+8-8
Original file line numberDiff line numberDiff line change
@@ -94,13 +94,13 @@ public class ViewAnimation: Animation {
9494
/// Options are `Linear`, `EaseOut`, `EaseIn`, `EaseInOut`
9595
public var timingFunction: CAMediaTimingFunction {
9696
switch curve {
97-
case .Linear:
97+
case .linear:
9898
return CAMediaTimingFunction(name: kCAMediaTimingFunctionLinear)
99-
case .EaseOut:
99+
case .easeOut:
100100
return CAMediaTimingFunction(name: kCAMediaTimingFunctionEaseOut)
101-
case .EaseIn:
101+
case .easeIn:
102102
return CAMediaTimingFunction(name: kCAMediaTimingFunctionEaseIn)
103-
case .EaseInOut:
103+
case .easeInOut:
104104
return CAMediaTimingFunction(name: kCAMediaTimingFunctionEaseInEaseOut)
105105
}
106106
}
@@ -109,13 +109,13 @@ public class ViewAnimation: Animation {
109109
public var options: UIViewAnimationOptions {
110110
var options: UIViewAnimationOptions = [UIViewAnimationOptions.beginFromCurrentState]
111111
switch curve {
112-
case .Linear:
112+
case .linear:
113113
options = [options, .curveLinear]
114-
case .EaseOut:
114+
case .easeOut:
115115
options = [options, .curveEaseOut]
116-
case .EaseIn:
116+
case .easeIn:
117117
options = [options, .curveEaseIn]
118-
case .EaseInOut:
118+
case .easeInOut:
119119
options = [options, .curveEaseIn, .curveEaseOut]
120120
}
121121

0 commit comments

Comments
 (0)