Skip to content

Commit

Permalink
updated for Swift 4
Browse files Browse the repository at this point in the history
  • Loading branch information
Daniel Dahan committed Oct 2, 2017
1 parent 85bfd26 commit 13d10d3
Show file tree
Hide file tree
Showing 11 changed files with 76 additions and 19 deletions.
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,7 @@ profile
*.moved-aside
*.playground
*.framework
DerivedData
Index
Build

2 changes: 1 addition & 1 deletion .swift-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
3.0
4.0
2 changes: 1 addition & 1 deletion Motion.podspec
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Pod::Spec.new do |s|
s.name = 'Motion'
s.version = '1.1.2'
s.version = '1.2.0'
s.license = 'MIT'
s.summary = 'A library used to create beautiful animations and transitions for Apple devices.'
s.homepage = 'http://cosmicmind.com'
Expand Down
6 changes: 4 additions & 2 deletions Motion.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -399,6 +399,7 @@
SDKROOT = iphoneos;
SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG;
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
SWIFT_VERSION = 4.0;
TARGETED_DEVICE_FAMILY = "1,2";
VERSIONING_SYSTEM = "apple-generic";
VERSION_INFO_PREFIX = "";
Expand Down Expand Up @@ -444,6 +445,7 @@
MTL_ENABLE_DEBUG_INFO = NO;
SDKROOT = iphoneos;
SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
SWIFT_VERSION = 4.0;
TARGETED_DEVICE_FAMILY = "1,2";
VALIDATE_PRODUCT = YES;
VERSIONING_SYSTEM = "apple-generic";
Expand All @@ -470,7 +472,7 @@
SKIP_INSTALL = YES;
SWIFT_OBJC_INTERFACE_HEADER_NAME = "$(SWIFT_MODULE_NAME)-Swift.h";
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
SWIFT_VERSION = 3.0;
SWIFT_VERSION = 4.0;
};
name = Debug;
};
Expand All @@ -491,7 +493,7 @@
PRODUCT_NAME = Motion;
SKIP_INSTALL = YES;
SWIFT_OBJC_INTERFACE_HEADER_NAME = "$(SWIFT_MODULE_NAME)-Swift.h";
SWIFT_VERSION = 3.0;
SWIFT_VERSION = 4.0;
};
name = Release;
};
Expand Down
2 changes: 1 addition & 1 deletion Sources/Animator/MotionCoreAnimationViewContext.swift
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ extension MotionCoreAnimationViewContext {
}

if false != snapshot.layer.animationKeys()?.isEmpty {
return snapshot.layer.value(forKeyPath:key)
return snapshot.layer.value(forKeyPath: key)
}

return (snapshot.layer.presentation() ?? snapshot.layer).value(forKeyPath: key)
Expand Down
4 changes: 2 additions & 2 deletions Sources/Extensions/Motion+UIViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -47,13 +47,13 @@ fileprivate struct AssociatedInstance {
A reference to the previous navigation controller delegate
before Motion was enabled.
*/
var previousNavigationDelegate: UINavigationControllerDelegate?
weak var previousNavigationDelegate: UINavigationControllerDelegate?

/**
A reference to the previous tab bar controller delegate
before Motion was enabled.
*/
var previousTabBarDelegate: UITabBarControllerDelegate?
weak var previousTabBarDelegate: UITabBarControllerDelegate?
}

extension UIViewController {
Expand Down
2 changes: 1 addition & 1 deletion Sources/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<key>CFBundlePackageType</key>
<string>FMWK</string>
<key>CFBundleShortVersionString</key>
<string>1.1.2</string>
<string>1.2.0</string>
<key>CFBundleVersion</key>
<string>$(CURRENT_PROJECT_VERSION)</string>
<key>NSPrincipalClass</key>
Expand Down
29 changes: 18 additions & 11 deletions Sources/Motion.swift
Original file line number Diff line number Diff line change
Expand Up @@ -770,21 +770,28 @@ extension Motion: UITabBarControllerDelegate {
}
}

public typealias MotionDelayCancelBlock = (Bool) -> Void
public typealias MotionCancelBlock = (Bool) -> Void

extension Motion {
/**
Executes a block of code asynchronously on the main thread.
- Parameter execute: A block that is executed asynchronously on the main thread.
*/
public class func async(_ execute: @escaping () -> Void) {
Motion.delay(0, execute: execute)
}

/**
Executes a block of code after a time delay.
- Parameter duration: An animation duration time.
- Parameter animations: An animation block.
- Parameter execute block: A completion block that is executed once
the animations have completed.
- Parameter _ time: A delay time.
- Parameter execute: A block that is executed once delay has passed.
- Returns: An optional MotionCancelBlock.
*/
@discardableResult
public class func delay(_ time: TimeInterval, execute: @escaping () -> Void) -> MotionDelayCancelBlock? {
var cancelable: MotionDelayCancelBlock?
public class func delay(_ time: TimeInterval, execute: @escaping () -> Void) -> MotionCancelBlock? {
var cancelable: MotionCancelBlock?

let delayed: MotionDelayCancelBlock = {
let delayed: MotionCancelBlock = {
if !$0 {
DispatchQueue.main.async(execute: execute)
}
Expand All @@ -802,10 +809,10 @@ extension Motion {
}

/**
Cancels the delayed MotionDelayCancelBlock.
- Parameter delayed completion: An MotionDelayCancelBlock.
Cancels the delayed MotionCancelBlock.
- Parameter delayed completion: An MotionCancelBlock.
*/
public class func cancel(delayed completion: MotionDelayCancelBlock) {
public class func cancel(delayed completion: MotionCancelBlock) {
completion(true)
}

Expand Down
20 changes: 20 additions & 0 deletions Sources/MotionAnimation.swift
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,16 @@ public extension MotionAnimation {
}
}

/**
Animates a view's current position to the given x and y values.
- Parameter x: A CGloat.
- Parameter y: A CGloat.
- Returns: A MotionAnimation.
*/
static func position(x: CGFloat, y: CGFloat) -> MotionAnimation {
return .position(CGPoint(x: x, y: y))
}

/// Fades the view in during an animation.
static var fadeIn = MotionAnimation.fade(1)

Expand Down Expand Up @@ -266,6 +276,16 @@ public extension MotionAnimation {
}
}

/**
Animates the view's current size to the given width and height.
- Parameter width: A CGFloat.
- Parameter height: A CGFloat.
- Returns: A MotionAnimation.
*/
static func size(width: CGFloat, height: CGFloat) -> MotionAnimation {
return .size(CGSize(width: width, height: height))
}

/**
Animates a view's current shadow path to the given one.
- Parameter path: A CGPath.
Expand Down
4 changes: 4 additions & 0 deletions Sources/MotionController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -310,6 +310,7 @@ internal extension MotionController {
Subclasses should call context.set(fromViews: toViews) after
inserting fromViews & toViews into the container
*/
@objc
func prepareTransition() {
guard isTransitioning else {
return
Expand All @@ -323,6 +324,7 @@ internal extension MotionController {
}

/// Prepares the transition fromView & toView pairs.
@objc
func prepareTransitionPairs() {
guard isTransitioning else {
return
Expand Down Expand Up @@ -358,6 +360,7 @@ internal extension MotionController {
Animates the views. Subclasses should call `prepareTransition` &
`prepareTransitionPairs` before calling `animate`.
*/
@objc
func animate() {
guard isTransitioning else {
return
Expand Down Expand Up @@ -424,6 +427,7 @@ internal extension MotionController {
- Parameter isFinished: A Boolean indicating if the transition
has completed.
*/
@objc
func complete(isFinished: Bool) {
guard isTransitioning else {
return
Expand Down
20 changes: 20 additions & 0 deletions Sources/MotionTransition.swift
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,16 @@ public extension MotionTransition {
}
}

/**
Animates a view's current position to the given x and y values.
- Parameter x: A CGloat.
- Parameter y: A CGloat.
- Returns: A MotionTransition.
*/
static func position(x: CGFloat, y: CGFloat) -> MotionTransition {
return .position(CGPoint(x: x, y: y))
}

/// Forces the view to not fade during a transition.
static var forceNonFade = MotionTransition {
$0.nonFade = true
Expand Down Expand Up @@ -278,6 +288,16 @@ public extension MotionTransition {
}
}

/**
Animates the view's current size to the given width and height.
- Parameter width: A CGFloat.
- Parameter height: A CGFloat.
- Returns: A MotionTransition.
*/
static func size(width: CGFloat, height: CGFloat) -> MotionTransition {
return .size(CGSize(width: width, height: height))
}

/**
Animates the view's current shadow path to the given one.
- Parameter path: A CGPath.
Expand Down

0 comments on commit 13d10d3

Please sign in to comment.