Skip to content

Commit

Permalink
Renamed the animation presets to the animation generator.
Browse files Browse the repository at this point in the history
  • Loading branch information
brandon-mcquilkin-kr committed Oct 6, 2016
1 parent 99f32d9 commit 489ab17
Show file tree
Hide file tree
Showing 12 changed files with 83 additions and 83 deletions.
28 changes: 14 additions & 14 deletions M13Checkbox.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
EA96F9071CBEB5190066C6B7 /* M13Checkbox.swift in Sources */ = {isa = PBXBuildFile; fileRef = EA67202E1C7D0349008054BA /* M13Checkbox.swift */; };
EA96F9081CBEB5190066C6B7 /* M13CheckboxController.swift in Sources */ = {isa = PBXBuildFile; fileRef = EA508D1A1C9CE605007142F6 /* M13CheckboxController.swift */; };
EA96F9091CBEB5190066C6B7 /* M13CheckboxPathPresets.swift in Sources */ = {isa = PBXBuildFile; fileRef = EAA098361CA8AF68001AAF6E /* M13CheckboxPathPresets.swift */; };
EA96F90A1CBEB5190066C6B7 /* M13CheckboxAnimationPresets.swift in Sources */ = {isa = PBXBuildFile; fileRef = EAA098381CA8B206001AAF6E /* M13CheckboxAnimationPresets.swift */; };
EA96F90A1CBEB5190066C6B7 /* M13CheckboxAnimationGenerator.swift in Sources */ = {isa = PBXBuildFile; fileRef = EAA098381CA8B206001AAF6E /* M13CheckboxAnimationGenerator.swift */; };
EA96F90B1CBEB5190066C6B7 /* M13CheckboxGestureRecognizer.swift in Sources */ = {isa = PBXBuildFile; fileRef = EAD2FDA41CBD2FA400086119 /* M13CheckboxGestureRecognizer.swift */; };
EA96F90C1CBEB5190066C6B7 /* M13CheckboxDotPathPresets.swift in Sources */ = {isa = PBXBuildFile; fileRef = EA26E1F11CAEF7A600ACB4F4 /* M13CheckboxDotPathPresets.swift */; };
EA96F90D1CBEB5190066C6B7 /* M13CheckboxSpiralPathPresets.swift in Sources */ = {isa = PBXBuildFile; fileRef = EA26E1F51CAEFDC500ACB4F4 /* M13CheckboxSpiralPathPresets.swift */; };
Expand Down Expand Up @@ -92,10 +92,10 @@
EA6720221C7D0296008054BA /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; name = Assets.xcassets; path = "../M13Checkbox Demo/Assets.xcassets"; sourceTree = "<group>"; };
EA6720251C7D0296008054BA /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = "<group>"; };
EA6720271C7D0296008054BA /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; name = Info.plist; path = "../M13Checkbox Demo/Info.plist"; sourceTree = "<group>"; };
EA67202E1C7D0349008054BA /* M13Checkbox.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = M13Checkbox.swift; path = Sources/M13Checkbox.swift; sourceTree = SOURCE_ROOT; };
EA67202E1C7D0349008054BA /* M13Checkbox.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; lineEnding = 0; name = M13Checkbox.swift; path = Sources/M13Checkbox.swift; sourceTree = SOURCE_ROOT; xcLanguageSpecificationIdentifier = xcode.lang.swift; };
EA6720301C7DFC3D008054BA /* M13Checkbox+IB.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = "M13Checkbox+IB.swift"; path = "Sources/M13Checkbox+IB.swift"; sourceTree = SOURCE_ROOT; };
EA6D7D021C933F0D00F30778 /* AnimationSelectionTableViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = AnimationSelectionTableViewController.swift; path = "../M13Checkbox Demo/AnimationSelectionTableViewController.swift"; sourceTree = "<group>"; };
EA86104B1C8F4F0000F9FDBA /* DemoViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = DemoViewController.swift; path = "../M13Checkbox Demo/DemoViewController.swift"; sourceTree = "<group>"; };
EA6D7D021C933F0D00F30778 /* AnimationSelectionTableViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; lineEnding = 0; name = AnimationSelectionTableViewController.swift; path = "../M13Checkbox Demo/AnimationSelectionTableViewController.swift"; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.swift; };
EA86104B1C8F4F0000F9FDBA /* DemoViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; lineEnding = 0; name = DemoViewController.swift; path = "../M13Checkbox Demo/DemoViewController.swift"; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.swift; };
EA86104E1C8F4FA900F9FDBA /* SegmentedControlCollectionViewCell.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = SegmentedControlCollectionViewCell.swift; path = "../M13Checkbox Demo/SegmentedControlCollectionViewCell.swift"; sourceTree = "<group>"; };
EA8610501C8F4FE300F9FDBA /* BaseCollectionViewCell.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = BaseCollectionViewCell.swift; path = "../M13Checkbox Demo/BaseCollectionViewCell.swift"; sourceTree = "<group>"; };
EA8610521C8F588E00F9FDBA /* SliderCollectionViewCell.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = SliderCollectionViewCell.swift; path = "../M13Checkbox Demo/SliderCollectionViewCell.swift"; sourceTree = "<group>"; };
Expand All @@ -107,7 +107,7 @@
EA96F9051CBEB4EC0066C6B7 /* CoreGraphics.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreGraphics.framework; path = System/Library/Frameworks/CoreGraphics.framework; sourceTree = SDKROOT; };
EA96F9181CBEB73D0066C6B7 /* Package.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Package.swift; sourceTree = "<group>"; };
EAA098361CA8AF68001AAF6E /* M13CheckboxPathPresets.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = M13CheckboxPathPresets.swift; path = ../Sources/M13CheckboxPathPresets.swift; sourceTree = "<group>"; };
EAA098381CA8B206001AAF6E /* M13CheckboxAnimationPresets.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = M13CheckboxAnimationPresets.swift; path = ../Sources/M13CheckboxAnimationPresets.swift; sourceTree = "<group>"; };
EAA098381CA8B206001AAF6E /* M13CheckboxAnimationGenerator.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = M13CheckboxAnimationGenerator.swift; path = ../Sources/M13CheckboxAnimationGenerator.swift; sourceTree = "<group>"; };
EAA0983E1CA8BEF1001AAF6E /* M13CheckboxStrokeController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = M13CheckboxStrokeController.swift; path = ../Sources/Managers/M13CheckboxStrokeController.swift; sourceTree = "<group>"; };
EAD2FDA41CBD2FA400086119 /* M13CheckboxGestureRecognizer.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = M13CheckboxGestureRecognizer.swift; path = ../Sources/M13CheckboxGestureRecognizer.swift; sourceTree = "<group>"; };
/* End PBXFileReference section */
Expand Down Expand Up @@ -156,13 +156,13 @@
name = Frameworks;
sourceTree = "<group>";
};
EA26E1EC1CAEDD0800ACB4F4 /* Presets */ = {
EA26E1EC1CAEDD0800ACB4F4 /* Path Generators */ = {
isa = PBXGroup;
children = (
EA26E1F11CAEF7A600ACB4F4 /* M13CheckboxDotPathPresets.swift */,
EA26E1F51CAEFDC500ACB4F4 /* M13CheckboxSpiralPathPresets.swift */,
);
name = Presets;
name = "Path Generators";
sourceTree = "<group>";
};
EA67200D1C7D0296008054BA = {
Expand Down Expand Up @@ -210,10 +210,10 @@
EA67202E1C7D0349008054BA /* M13Checkbox.swift */,
EA508D1A1C9CE605007142F6 /* M13CheckboxController.swift */,
EAA098361CA8AF68001AAF6E /* M13CheckboxPathPresets.swift */,
EAA098381CA8B206001AAF6E /* M13CheckboxAnimationPresets.swift */,
EAA098381CA8B206001AAF6E /* M13CheckboxAnimationGenerator.swift */,
EAD2FDA41CBD2FA400086119 /* M13CheckboxGestureRecognizer.swift */,
EA26E1EC1CAEDD0800ACB4F4 /* Presets */,
EAA0983C1CA8BE7F001AAF6E /* Managers */,
EA26E1EC1CAEDD0800ACB4F4 /* Path Generators */,
EAA0983C1CA8BE7F001AAF6E /* Controllers */,
EA6720301C7DFC3D008054BA /* M13Checkbox+IB.swift */,
);
name = Source;
Expand Down Expand Up @@ -241,7 +241,7 @@
path = M13Checkbox;
sourceTree = "<group>";
};
EAA0983C1CA8BE7F001AAF6E /* Managers */ = {
EAA0983C1CA8BE7F001AAF6E /* Controllers */ = {
isa = PBXGroup;
children = (
EAA0983E1CA8BEF1001AAF6E /* M13CheckboxStrokeController.swift */,
Expand All @@ -253,7 +253,7 @@
EA26E1F71CAEFE7800ACB4F4 /* M13CheckboxSpiralController.swift */,
EA26E1F31CAEFA6300ACB4F4 /* M13CheckboxDotController.swift */,
);
name = Managers;
name = Controllers;
sourceTree = "<group>";
};
/* End PBXGroup section */
Expand Down Expand Up @@ -382,7 +382,7 @@
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "diff \"${PODS_ROOT}/../Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [[ $? != 0 ]] ; then\n cat << EOM\nerror: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\nEOM\n exit 1\nfi\n";
shellScript = "diff \"${PODS_ROOT}/../Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n";
showEnvVarsInLog = 0;
};
3AE30ADBBC1FF6B62D2D7432 /* [CP] Embed Pods Frameworks */ = {
Expand Down Expand Up @@ -448,7 +448,7 @@
EA96F90E1CBEB5190066C6B7 /* M13CheckboxStrokeController.swift in Sources */,
EA96F9141CBEB5190066C6B7 /* M13CheckboxSpiralController.swift in Sources */,
EA96F90B1CBEB5190066C6B7 /* M13CheckboxGestureRecognizer.swift in Sources */,
EA96F90A1CBEB5190066C6B7 /* M13CheckboxAnimationPresets.swift in Sources */,
EA96F90A1CBEB5190066C6B7 /* M13CheckboxAnimationGenerator.swift in Sources */,
EA96F9101CBEB5190066C6B7 /* M13CheckboxBounceController.swift in Sources */,
EA96F9111CBEB5190066C6B7 /* M13CheckboxExpandController.swift in Sources */,
EA96F9161CBEB5190066C6B7 /* M13Checkbox+IB.swift in Sources */,
Expand Down
6 changes: 3 additions & 3 deletions Sources/M13Checkbox.swift
Original file line number Diff line number Diff line change
Expand Up @@ -339,10 +339,10 @@ public class M13Checkbox: UIControl {
/// The duration of the animation that occurs when the checkbox switches states. The default is 0.3 seconds.
@IBInspectable public var animationDuration: TimeInterval {
get {
return manager.animations.animationDuration
return manager.animationGenerator.animationDuration
}
set {
manager.animations.animationDuration = newValue
manager.animationGenerator.animationDuration = newValue
}
}

Expand Down Expand Up @@ -372,7 +372,7 @@ public class M13Checkbox: UIControl {
newManager.paths.cornerRadius = manager.paths.cornerRadius
newManager.paths.markType = manager.paths.markType

newManager.animations.animationDuration = manager.animations.animationDuration
newManager.animationGenerator.animationDuration = manager.animationGenerator.animationDuration

// Set up the inital state.
for aLayer in newManager.layersToDisplay {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//
// M13CheckboxAnimationManager.swift
// M13CheckboxAnimationGenerator.swift
// M13Checkbox
//
// Created by McQuilkin, Brandon on 3/27/16.
Expand All @@ -13,7 +13,7 @@

import UIKit

internal class M13CheckboxAnimationPresets {
internal class M13CheckboxAnimationGenerator {

//----------------------------
// MARK: - Properties
Expand Down
2 changes: 1 addition & 1 deletion Sources/M13CheckboxController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ internal class M13CheckboxController {
var paths: M13CheckboxPathPresets = M13CheckboxPathPresets()

/// The animation presets for the manager.
var animations: M13CheckboxAnimationPresets = M13CheckboxAnimationPresets()
var animationGenerator: M13CheckboxAnimationGenerator = M13CheckboxAnimationGenerator()

/// The current state of the checkbox.
var state: M13Checkbox.CheckState = .unchecked
Expand Down
16 changes: 8 additions & 8 deletions Sources/Managers/M13CheckboxBounceController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -128,10 +128,10 @@ internal class M13CheckboxBounceController: M13CheckboxController {
if toState == .unchecked {

let amplitude: CGFloat = paths.boxType == .square ? 0.20 : 0.35
let wiggleAnimation = animations.fillAnimation(1, amplitude: amplitude, reverse: true)
let opacityAnimation = animations.opacityAnimation(true)
let wiggleAnimation = animationGenerator.fillAnimation(1, amplitude: amplitude, reverse: true)
let opacityAnimation = animationGenerator.opacityAnimation(true)
opacityAnimation.duration = opacityAnimation.duration / 1.5
opacityAnimation.beginTime = CACurrentMediaTime() + animations.animationDuration - opacityAnimation.duration
opacityAnimation.beginTime = CACurrentMediaTime() + animationGenerator.animationDuration - opacityAnimation.duration

CATransaction.begin()
CATransaction.setCompletionBlock({ () -> Void in
Expand All @@ -148,9 +148,9 @@ internal class M13CheckboxBounceController: M13CheckboxController {
markLayer.path = paths.path(toState)?.cgPath

let amplitude: CGFloat = paths.boxType == .square ? 0.20 : 0.35
let wiggleAnimation = animations.fillAnimation(1, amplitude: amplitude, reverse: false)
let wiggleAnimation = animationGenerator.fillAnimation(1, amplitude: amplitude, reverse: false)

let opacityAnimation = animations.opacityAnimation(false)
let opacityAnimation = animationGenerator.opacityAnimation(false)
opacityAnimation.duration = opacityAnimation.duration / 1.5

CATransaction.begin()
Expand All @@ -167,7 +167,7 @@ internal class M13CheckboxBounceController: M13CheckboxController {
let fromPath = paths.path(fromState)
let toPath = paths.path(toState)

let morphAnimation = animations.morphAnimation(fromPath!, toPath: toPath!)
let morphAnimation = animationGenerator.morphAnimation(fromPath!, toPath: toPath!)

CATransaction.begin()
CATransaction.setCompletionBlock({ [unowned self] () -> Void in
Expand All @@ -185,13 +185,13 @@ internal class M13CheckboxBounceController: M13CheckboxController {
let scale: CGFloat = 0.5 / 0.665
toPath?.apply(CGAffineTransform(scaleX: scale, y: 0.002))
toPath?.apply(CGAffineTransform(translationX: ((paths.size * 0.665) - (paths.size * 0.5)) * scale, y: (paths.size / 2.0) - (paths.boxLineWidth * 0.5 * scale)))
compressionAnimation = animations.morphAnimation(paths.path(fromState)!, toPath: toPath!)
compressionAnimation = animationGenerator.morphAnimation(paths.path(fromState)!, toPath: toPath!)
} else {
let fromPath = paths.path(toState)
let scale: CGFloat = 0.5 / 0.665
fromPath?.apply(CGAffineTransform(scaleX: scale, y: 0.002))
fromPath?.apply(CGAffineTransform(translationX: ((paths.size * 0.665) - (paths.size * 0.5)) * scale, y: (paths.size / 2.0) - (paths.boxLineWidth * 0.5 * scale)))
compressionAnimation = animations.morphAnimation(fromPath!, toPath: paths.path(toState)!)
compressionAnimation = animationGenerator.morphAnimation(fromPath!, toPath: paths.path(toState)!)
}

CATransaction.begin()
Expand Down
18 changes: 9 additions & 9 deletions Sources/Managers/M13CheckboxDotController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -127,8 +127,8 @@ internal class M13CheckboxDotController: M13CheckboxController {
super.animate(fromState, toState: toState)

if toState == .unchecked {
let scaleAnimation = animations.fillAnimation(1, amplitude: 0.18, reverse: true)
let opacityAnimation = animations.opacityAnimation(true)
let scaleAnimation = animationGenerator.fillAnimation(1, amplitude: 0.18, reverse: true)
let opacityAnimation = animationGenerator.opacityAnimation(true)

CATransaction.begin()
CATransaction.setCompletionBlock({ () -> Void in
Expand All @@ -137,7 +137,7 @@ internal class M13CheckboxDotController: M13CheckboxController {

if style == .stroke {
unselectedBoxLayer.opacity = 0.0
let quickOpacityAnimation = animations.quickOpacityAnimation(false)
let quickOpacityAnimation = animationGenerator.quickOpacityAnimation(false)
quickOpacityAnimation.beginTime = CACurrentMediaTime() + scaleAnimation.duration - quickOpacityAnimation.duration
unselectedBoxLayer.add(quickOpacityAnimation, forKey: "opacity")
}
Expand All @@ -150,16 +150,16 @@ internal class M13CheckboxDotController: M13CheckboxController {
if fromState == .unchecked {
markLayer.path = paths.path(toState)?.cgPath

let scaleAnimation = animations.fillAnimation(1, amplitude: 0.18, reverse: false)
let opacityAnimation = animations.opacityAnimation(false)
let scaleAnimation = animationGenerator.fillAnimation(1, amplitude: 0.18, reverse: false)
let opacityAnimation = animationGenerator.opacityAnimation(false)

CATransaction.begin()
CATransaction.setCompletionBlock({ () -> Void in
self.resetLayersForState(toState)
})

if style == .stroke {
let quickOpacityAnimation = animations.quickOpacityAnimation(true)
let quickOpacityAnimation = animationGenerator.quickOpacityAnimation(true)
quickOpacityAnimation.beginTime = CACurrentMediaTime()
unselectedBoxLayer.add(quickOpacityAnimation, forKey: "opacity")
}
Expand All @@ -172,7 +172,7 @@ internal class M13CheckboxDotController: M13CheckboxController {
let fromPath = paths.path(fromState)
let toPath = paths.path(toState)

let morphAnimation = animations.morphAnimation(fromPath!, toPath: toPath!)
let morphAnimation = animationGenerator.morphAnimation(fromPath!, toPath: toPath!)

CATransaction.begin()
CATransaction.setCompletionBlock({ [unowned self] () -> Void in
Expand All @@ -190,13 +190,13 @@ internal class M13CheckboxDotController: M13CheckboxController {
let scale: CGFloat = 0.5 / 0.665
toPath?.apply(CGAffineTransform(scaleX: scale, y: 0.002))
toPath?.apply(CGAffineTransform(translationX: ((paths.size * 0.665) - (paths.size * 0.5)) * scale, y: (paths.size / 2.0) - (paths.boxLineWidth * 0.5 * scale)))
compressionAnimation = animations.morphAnimation(paths.path(fromState)!, toPath: toPath!)
compressionAnimation = animationGenerator.morphAnimation(paths.path(fromState)!, toPath: toPath!)
} else {
let fromPath = paths.path(toState)
let scale: CGFloat = 0.5 / 0.665
fromPath?.apply(CGAffineTransform(scaleX: scale, y: 0.002))
fromPath?.apply(CGAffineTransform(translationX: ((paths.size * 0.665) - (paths.size * 0.5)) * scale, y: (paths.size / 2.0) - (paths.boxLineWidth * 0.5 * scale)))
compressionAnimation = animations.morphAnimation(fromPath!, toPath: paths.path(toState)!)
compressionAnimation = animationGenerator.morphAnimation(fromPath!, toPath: paths.path(toState)!)
}

CATransaction.begin()
Expand Down
Loading

0 comments on commit 489ab17

Please sign in to comment.