Skip to content

Commit 202a97e

Browse files
committed
Changed MotionOptions optionset to use lower case to match newer Swift naming convention
1 parent fd19646 commit 202a97e

11 files changed

+54
-43
lines changed

Package.swift

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,13 +32,16 @@ let package = Package(
3232
platforms: [
3333
.iOS(.v8), .tvOS(.v9)
3434
],
35+
products: [
36+
.library(name: "MotionMachine", targets: ["MotionMachine"])
37+
],
3538
targets: [
3639
.target(name: "MotionMachine", path: "Sources/"),
3740
.testTarget(
38-
name: "MotionMachineTests",
39-
dependencies: ["MotionMachine"],
40-
path: "Tests/Tests/"
41-
)
41+
name: "MotionMachineTests",
42+
dependencies: ["MotionMachine"],
43+
path: "Tests/Tests/"
44+
)
4245
],
4346
swiftLanguageVersions: [.v5]
4447
)

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
![MotionMachine logo](Guides/mmlogo.png)
22

3-
![swift](https://img.shields.io/badge/Swift-4.2-005AA5.svg)
3+
![swift](https://img.shields.io/badge/Swift-5.0-005AA5.svg)
44
![platforms](https://img.shields.io/badge/platforms-iOS%20%7C%20tvOS-005AA5.svg)
55
![license](https://img.shields.io/badge/license-MIT-005AA5.svg)
66

@@ -170,7 +170,7 @@ Or add the Sources directory to your project.
170170
## Compatibility
171171

172172
MotionMachine currently requires:
173-
* Swift 4.2
173+
* Swift 5.0
174174
* Xcode 10.0 or later
175175
* iOS 8.0 or later, tvOS 9.0 or later
176176

Sources/Motion.swift

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -522,7 +522,7 @@ public class Motion: Moveable, Additive, TempoDriven, PropertyDataDelegate {
522522
* - easing: An optional `EasingUpdateClosure` easing equation to use when moving the values of the given properties. `EasingLinear.easeNone()` is the default equation if none is provided.
523523
* - options: An optional set of `MotionsOptions`.
524524
*/
525-
public convenience init(target targetObject: NSObject, properties: [PropertyData], duration: TimeInterval, easing: EasingUpdateClosure?=EasingLinear.easeNone(), options: MotionOptions?=MotionOptions.None) {
525+
public convenience init(target targetObject: NSObject, properties: [PropertyData], duration: TimeInterval, easing: EasingUpdateClosure?=EasingLinear.easeNone(), options: MotionOptions? = .none) {
526526

527527
self.init(target: targetObject, properties: properties, statesForProperties: nil, duration: duration, easing: easing, options: options)
528528

@@ -537,7 +537,7 @@ public class Motion: Moveable, Additive, TempoDriven, PropertyDataDelegate {
537537
* - easing: An optional `EasingUpdateClosure` easing equation to use when moving the values of the given properties. `EasingLinear.easeNone()` is the default equation if none is provided.
538538
* - options: An optional set of `MotionsOptions`.
539539
*/
540-
public convenience init(target targetObject: NSObject, duration: TimeInterval, easing: EasingUpdateClosure?=EasingLinear.easeNone(), options: MotionOptions?=MotionOptions.None) {
540+
public convenience init(target targetObject: NSObject, duration: TimeInterval, easing: EasingUpdateClosure?=EasingLinear.easeNone(), options: MotionOptions? = .none) {
541541

542542
self.init(target: targetObject, properties: [], statesForProperties: nil, duration: duration, easing: easing, options: options)
543543
}
@@ -552,13 +552,13 @@ public class Motion: Moveable, Additive, TempoDriven, PropertyDataDelegate {
552552
* - easing: An optional `EasingUpdateClosure` easing equation to use when moving the values of the given properties. `EasingLinear.easeNone()` is the default equation if none is provided.
553553
* - options: An optional set of `MotionsOptions`.
554554
*/
555-
public convenience init(target targetObject: NSObject, statesForProperties templateObjects: [PropertyStates], duration: TimeInterval, easing: EasingUpdateClosure?=EasingLinear.easeNone(), options: MotionOptions?=MotionOptions.None) {
555+
public convenience init(target targetObject: NSObject, statesForProperties templateObjects: [PropertyStates], duration: TimeInterval, easing: EasingUpdateClosure?=EasingLinear.easeNone(), options: MotionOptions? = .none) {
556556

557557
self.init(target: targetObject, properties: nil, statesForProperties: templateObjects, duration: duration, easing: easing, options: options)
558558
}
559559

560560

561-
private init(target targetObject: NSObject, properties props: [PropertyData]?, statesForProperties: [PropertyStates]?, duration: TimeInterval, easing: EasingUpdateClosure?, options: MotionOptions?) {
561+
private init(target targetObject: NSObject, properties props: [PropertyData]?, statesForProperties: [PropertyStates]?, duration: TimeInterval, easing: EasingUpdateClosure?, options: MotionOptions? = .none) {
562562

563563
var properties = props ?? []
564564

@@ -578,9 +578,11 @@ public class Motion: Moveable, Additive, TempoDriven, PropertyDataDelegate {
578578
#endif
579579

580580
// unpack options values
581-
repeating = options!.contains(.Repeat)
582-
reversing = options!.contains(.Reverse)
583-
resetObjectStateOnRepeat = options!.contains(.ResetStateOnRepeat)
581+
if let unwrappedOptions = options {
582+
repeating = unwrappedOptions.contains(.repeats)
583+
reversing = unwrappedOptions.contains(.reverses)
584+
resetObjectStateOnRepeat = unwrappedOptions.contains(.resetsStateOnRepeat)
585+
}
584586

585587
motionState = .stopped
586588
motionDirection = .forward

Sources/MotionGroup.swift

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -468,11 +468,13 @@ public class MotionGroup: Moveable, MoveableCollection, TempoDriven, MotionUpdat
468468
* - motions: An array of `Moveable` objects which the MotionGroup should control.
469469
* - options: An optional set of `MotionsOptions`.
470470
*/
471-
public init(motions: [Moveable]=[], options: MotionOptions?=MotionOptions.None) {
471+
public init(motions: [Moveable] = [], options: MotionOptions? = .none) {
472472

473473
// unpack options values
474-
repeating = options!.contains(.Repeat)
475-
_reversing = options!.contains(.Reverse)
474+
if let unwrappedOptions = options {
475+
repeating = unwrappedOptions.contains(.repeats)
476+
_reversing = unwrappedOptions.contains(.reverses)
477+
}
476478

477479
motionState = .stopped
478480
motionDirection = .forward

Sources/MotionMachine.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -505,20 +505,20 @@ public struct MotionOptions : OptionSet {
505505
public init(rawValue: Int) { self.rawValue = rawValue }
506506

507507
/// No options are specified.
508-
public static let None = MotionOptions(rawValue: 0)
508+
public static let none = MotionOptions(rawValue: 0)
509509

510510
/// Specifies that a motion should repeat.
511-
public static let Repeat = MotionOptions(rawValue: 1 << 0)
511+
public static let repeats = MotionOptions(rawValue: 1 << 0)
512512

513513
/// Specifies that a motion should reverse directions after moving in the forward direction.
514-
public static let Reverse = MotionOptions(rawValue: 1 << 1)
514+
public static let reverses = MotionOptions(rawValue: 1 << 1)
515515

516516
/**
517517
* Specifies that a motion's property (or parent, if property is not KVC-compliant) should be reset to its starting value on repeats or restarts.
518518
*
519519
* - remark: `Motion` and `PhysicsMotion` are the only MotionMachine classes that currently accept this option.
520520
*/
521-
public static let ResetStateOnRepeat = MotionOptions(rawValue: 1 << 2)
521+
public static let resetsStateOnRepeat = MotionOptions(rawValue: 1 << 2)
522522
}
523523

524524

Sources/MotionSequence.swift

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -485,11 +485,13 @@ public class MotionSequence: Moveable, MoveableCollection, TempoDriven, MotionUp
485485
* - steps: An array of `Moveable` objects the MotionSequence should control. The positions of the objects in the Array will determine the order in which the child motions should move.
486486
* - options: An optional set of `MotionsOptions`.
487487
*/
488-
public init(steps: [Moveable]=[], options: MotionOptions?=MotionOptions.None) {
488+
public init(steps: [Moveable] = [], options: MotionOptions? = .none) {
489489

490490
// unpack options values
491-
repeating = options!.contains(.Repeat)
492-
_reversing = options!.contains(.Reverse)
491+
if let unwrappedOptions = options {
492+
repeating = unwrappedOptions.contains(.repeats)
493+
_reversing = unwrappedOptions.contains(.reverses)
494+
}
493495

494496
motionState = .stopped
495497
motionDirection = .forward

Sources/PhysicsMotion.swift

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -547,7 +547,7 @@ public class PhysicsMotion: Moveable, Additive, TempoDriven, PropertyDataDelegat
547547
* - friction: The friction used to calculate new values in the `PhysicsSolving` system. Acceptable values are 0.0 (no friction) to 1.0 (no movement); values outside of this range will be clamped to the nearest edge.
548548
* - options: An optional set of `MotionsOptions`.
549549
*/
550-
public convenience init(target targetObject: NSObject, properties: [PropertyData], velocity: Double, friction: Double, options: MotionOptions?=MotionOptions.None) {
550+
public convenience init(target targetObject: NSObject, properties: [PropertyData], velocity: Double, friction: Double, options: MotionOptions? = .none) {
551551

552552
self.init(targetObject: targetObject, properties: properties, velocity: velocity, friction: friction, options: options)
553553

@@ -562,13 +562,13 @@ public class PhysicsMotion: Moveable, Additive, TempoDriven, PropertyDataDelegat
562562
* - friction: The friction used to calculate new values in the `PhysicsSolving` system. Acceptable values are 0.0 (no friction) to 1.0 (no movement); values outside of this range will be clamped to the nearest edge.
563563
* - options: An optional set of `MotionsOptions`.
564564
*/
565-
public convenience init(target targetObject: NSObject, velocity: Double, friction: Double, options: MotionOptions?=MotionOptions.None) {
565+
public convenience init(target targetObject: NSObject, velocity: Double, friction: Double, options: MotionOptions? = .none) {
566566

567567
self.init(targetObject: targetObject, properties: [], velocity: velocity, friction: friction, options: options)
568568
}
569569

570570

571-
private init(targetObject: NSObject, properties props: [PropertyData]?, velocity: Double, friction: Double, options: MotionOptions?) {
571+
private init(targetObject: NSObject, properties props: [PropertyData]?, velocity: Double, friction: Double, options: MotionOptions? = .none) {
572572

573573
let properties = props ?? []
574574

@@ -583,9 +583,11 @@ public class PhysicsMotion: Moveable, Additive, TempoDriven, PropertyDataDelegat
583583
#endif
584584

585585
// unpack options values
586-
repeating = options!.contains(.Repeat)
587-
reversing = options!.contains(.Reverse)
588-
resetObjectStateOnRepeat = options!.contains(.ResetStateOnRepeat)
586+
if let unwrappedOptions = options {
587+
repeating = unwrappedOptions.contains(.repeats)
588+
reversing = unwrappedOptions.contains(.reverses)
589+
resetObjectStateOnRepeat = unwrappedOptions.contains(.resetsStateOnRepeat)
590+
}
589591

590592
motionState = .stopped
591593
motionDirection = .forward

Tests/Tests/MotionGroupTests.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ class MotionGroupTests: XCTestCase {
165165
let did_repeat = expectation(description: "group called cycleRepeated notify closure")
166166
let did_complete = expectation(description: "group called completed notify closure")
167167

168-
let group = MotionGroup(motions: [motion, motion2], options: [.Repeat])
168+
let group = MotionGroup(motions: [motion, motion2], options: [.repeats])
169169
.cycleRepeated({ (group) in
170170
XCTAssertEqual(group.totalProgress, 0.5)
171171
XCTAssertEqual(group.cycleProgress, 0.0)
@@ -206,7 +206,7 @@ class MotionGroupTests: XCTestCase {
206206
let did_reverse = expectation(description: "group called reversed notify closure")
207207
let did_complete = expectation(description: "group called completed notify closure")
208208

209-
let group = MotionGroup(motions: [motion, motion2], options: [.Reverse])
209+
let group = MotionGroup(motions: [motion, motion2], options: [.reverses])
210210
.reversed({ (group) in
211211
XCTAssertTrue(group.totalProgress <= 0.5)
212212
XCTAssertTrue(group.cycleProgress <= 0.5)

Tests/Tests/MotionSequenceTests.swift

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ class MotionSequenceTests: XCTestCase {
173173
let motion3 = Motion(target: tester, properties: [PropertyData("value", 40.0)], duration: 0.2)
174174
let motion4 = Motion(target: tester, properties: [PropertyData("value", 60.0)], duration: 0.2)
175175

176-
let sequence = MotionSequence(steps: [group, motion3, motion4], options: [.Repeat])
176+
let sequence = MotionSequence(steps: [group, motion3, motion4], options: [.repeats])
177177
.cycleRepeated { (sequence) in
178178
let motion = sequence.steps.first as! MotionGroup
179179
XCTAssertTrue(sequence.currentStep() === motion)
@@ -214,7 +214,7 @@ class MotionSequenceTests: XCTestCase {
214214
let motion3 = Motion(target: tester, properties: [PropertyData("value", 40.0)], duration: 0.2)
215215
let motion4 = Motion(target: tester, properties: [PropertyData("value", 60.0)], duration: 0.2)
216216

217-
let sequence = MotionSequence(steps: [group, motion3, motion4], options: [.Reverse])
217+
let sequence = MotionSequence(steps: [group, motion3, motion4], options: [.reverses])
218218
.reversed({ (sequence) in
219219
let motion = sequence.steps.last as! Motion
220220

@@ -279,7 +279,7 @@ class MotionSequenceTests: XCTestCase {
279279
let motion5 = Motion(target: tester, properties: [PropertyData("value", 80.0)], duration: 0.2)
280280
let sub_sequence = MotionSequence(steps: [motion3, motion4])
281281

282-
let sequence = MotionSequence(steps: [group, sub_sequence, motion5], options: [.Reverse])
282+
let sequence = MotionSequence(steps: [group, sub_sequence, motion5], options: [.reverses])
283283
.reversed({ (sequence) in
284284
let motion = sequence.steps.last as! Motion
285285
let subsequence = sequence.steps[1] as! MotionSequence
@@ -350,7 +350,7 @@ class MotionSequenceTests: XCTestCase {
350350
let motion4 = Motion(target: tester, properties: [PropertyData("value", 60.0)], duration: 0.2)
351351
let sub_sequence = MotionSequence(steps: [motion3, motion4])
352352

353-
let sequence = MotionSequence(steps: [group, sub_sequence], options: [.Reverse])
353+
let sequence = MotionSequence(steps: [group, sub_sequence], options: [.reverses])
354354
.reversed({ (sequence) in
355355
let motion = sequence.steps.first as! MotionGroup
356356
let subsequence = sequence.steps.last as! MotionSequence
@@ -419,7 +419,7 @@ class MotionSequenceTests: XCTestCase {
419419
let sub_sequence = MotionSequence(steps: [motion3, motion4])
420420
let motion5 = Motion(target: tester, properties: [PropertyData("value", 80.0)], duration: 0.2)
421421

422-
let sequence = MotionSequence(steps: [group, sub_sequence, motion5], options: [.Reverse])
422+
let sequence = MotionSequence(steps: [group, sub_sequence, motion5], options: [.reverses])
423423
.reversed({ (sequence) in
424424
let motion = sequence.steps.last as! Motion
425425
let subsequence = sequence.steps[1] as! MotionSequence
@@ -486,7 +486,7 @@ class MotionSequenceTests: XCTestCase {
486486
let motion3 = Motion(target: tester, properties: [PropertyData("value", 40.0)], duration: 0.2)
487487
let motion4 = Motion(target: tester, properties: [PropertyData("value", 60.0)], duration: 0.2)
488488

489-
let sequence = MotionSequence(steps: [group, motion3, motion4], options: [.Reverse])
489+
let sequence = MotionSequence(steps: [group, motion3, motion4], options: [.reverses])
490490
.reversed({ (sequence) in
491491
let motion = sequence.steps.last as! Motion
492492

Tests/Tests/MotionTests.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -287,7 +287,7 @@ class MotionTests: XCTestCase {
287287
let did_repeat = expectation(description: "motion called cycleRepeated notify closure")
288288
let did_complete = expectation(description: "motion called completed notify closure")
289289

290-
let motion = Motion(target: tester, properties: [PropertyData("value", 100.0)], duration: 0.2, options:[.Repeat])
290+
let motion = Motion(target: tester, properties: [PropertyData("value", 100.0)], duration: 0.2, options:[.repeats])
291291
.cycleRepeated({ (motion) in
292292
XCTAssertEqual(motion.totalProgress, 0.5)
293293
XCTAssertEqual(motion.cycleProgress, 0.0)
@@ -318,7 +318,7 @@ class MotionTests: XCTestCase {
318318
let did_reverse = expectation(description: "motion called reversed notify closure")
319319
let did_complete = expectation(description: "motion called completed notify closure")
320320

321-
let motion = Motion(target: tester, properties: [PropertyData("value", 100.0)], duration: 0.4, options:[.Reverse])
321+
let motion = Motion(target: tester, properties: [PropertyData("value", 100.0)], duration: 0.4, options:[.reverses])
322322
.reversed({ (motion) in
323323
XCTAssertTrue(motion.totalProgress <= 0.5)
324324
XCTAssertTrue(motion.cycleProgress <= 0.5)
@@ -348,7 +348,7 @@ class MotionTests: XCTestCase {
348348
let did_repeat = expectation(description: "motion called cycleRepeated notify closure")
349349
let did_complete = expectation(description: "motion called completed notify closure")
350350

351-
let motion = Motion(target: tester, properties: [PropertyData("value", 100.0)], duration: 0.4, options:[.Reverse, .Repeat])
351+
let motion = Motion(target: tester, properties: [PropertyData("value", 100.0)], duration: 0.4, options:[.reverses, .repeats])
352352
.reversed({ (motion) in
353353
if (motion.cyclesCompletedCount == 0) {
354354
XCTAssertTrue(motion.totalProgress <= 0.25)

Tests/Tests/PhysicsMotionTests.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ class PhysicsMotionTests: XCTestCase {
163163
let did_repeat = expectation(description: "motion called cycleRepeated notify closure")
164164
let did_complete = expectation(description: "motion called completed notify closure")
165165

166-
let motion = PhysicsMotion(target: tester, properties: [PropertyData("value")], velocity: 2.0, friction: 0.98, options: [.Repeat])
166+
let motion = PhysicsMotion(target: tester, properties: [PropertyData("value")], velocity: 2.0, friction: 0.98, options: [.repeats])
167167
.cycleRepeated({ (motion) in
168168
XCTAssertEqual(motion.totalProgress, 0.5)
169169
XCTAssertEqual(motion.cycleProgress, 0.0)
@@ -192,7 +192,7 @@ class PhysicsMotionTests: XCTestCase {
192192
let did_reverse = expectation(description: "motion called reversed notify closure")
193193
let did_complete = expectation(description: "motion called completed notify closure")
194194

195-
let motion = PhysicsMotion(target: tester, properties: [PropertyData("value")], velocity: 2.0, friction: 0.98, options: [.Reverse])
195+
let motion = PhysicsMotion(target: tester, properties: [PropertyData("value")], velocity: 2.0, friction: 0.98, options: [.reverses])
196196
.reversed({ (motion) in
197197
XCTAssertTrue(motion.totalProgress <= 0.5)
198198
XCTAssertTrue(motion.cycleProgress <= 0.5)
@@ -220,7 +220,7 @@ class PhysicsMotionTests: XCTestCase {
220220
let did_repeat = expectation(description: "motion called cycleRepeated notify closure")
221221
let did_complete = expectation(description: "motion called completed notify closure")
222222

223-
let motion = PhysicsMotion(target: tester, properties: [PropertyData("value")], velocity: 2.0, friction: 0.98, options: [.Reverse, .Repeat])
223+
let motion = PhysicsMotion(target: tester, properties: [PropertyData("value")], velocity: 2.0, friction: 0.98, options: [.reverses, .repeats])
224224
.reversed({ (motion) in
225225
if (motion.cyclesCompletedCount == 0) {
226226
XCTAssertTrue(motion.totalProgress <= 0.25)

0 commit comments

Comments
 (0)