Commit 13d10d3d by Daniel Dahan

updated for Swift 4

parent 85bfd266
...@@ -16,3 +16,7 @@ profile ...@@ -16,3 +16,7 @@ profile
*.moved-aside *.moved-aside
*.playground *.playground
*.framework *.framework
DerivedData
Index
Build
Pod::Spec.new do |s| Pod::Spec.new do |s|
s.name = 'Motion' s.name = 'Motion'
s.version = '1.1.2' s.version = '1.2.0'
s.license = 'MIT' s.license = 'MIT'
s.summary = 'A library used to create beautiful animations and transitions for Apple devices.' s.summary = 'A library used to create beautiful animations and transitions for Apple devices.'
s.homepage = 'http://cosmicmind.com' s.homepage = 'http://cosmicmind.com'
......
...@@ -399,6 +399,7 @@ ...@@ -399,6 +399,7 @@
SDKROOT = iphoneos; SDKROOT = iphoneos;
SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG; SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG;
SWIFT_OPTIMIZATION_LEVEL = "-Onone"; SWIFT_OPTIMIZATION_LEVEL = "-Onone";
SWIFT_VERSION = 4.0;
TARGETED_DEVICE_FAMILY = "1,2"; TARGETED_DEVICE_FAMILY = "1,2";
VERSIONING_SYSTEM = "apple-generic"; VERSIONING_SYSTEM = "apple-generic";
VERSION_INFO_PREFIX = ""; VERSION_INFO_PREFIX = "";
...@@ -444,6 +445,7 @@ ...@@ -444,6 +445,7 @@
MTL_ENABLE_DEBUG_INFO = NO; MTL_ENABLE_DEBUG_INFO = NO;
SDKROOT = iphoneos; SDKROOT = iphoneos;
SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
SWIFT_VERSION = 4.0;
TARGETED_DEVICE_FAMILY = "1,2"; TARGETED_DEVICE_FAMILY = "1,2";
VALIDATE_PRODUCT = YES; VALIDATE_PRODUCT = YES;
VERSIONING_SYSTEM = "apple-generic"; VERSIONING_SYSTEM = "apple-generic";
...@@ -470,7 +472,7 @@ ...@@ -470,7 +472,7 @@
SKIP_INSTALL = YES; SKIP_INSTALL = YES;
SWIFT_OBJC_INTERFACE_HEADER_NAME = "$(SWIFT_MODULE_NAME)-Swift.h"; SWIFT_OBJC_INTERFACE_HEADER_NAME = "$(SWIFT_MODULE_NAME)-Swift.h";
SWIFT_OPTIMIZATION_LEVEL = "-Onone"; SWIFT_OPTIMIZATION_LEVEL = "-Onone";
SWIFT_VERSION = 3.0; SWIFT_VERSION = 4.0;
}; };
name = Debug; name = Debug;
}; };
...@@ -491,7 +493,7 @@ ...@@ -491,7 +493,7 @@
PRODUCT_NAME = Motion; PRODUCT_NAME = Motion;
SKIP_INSTALL = YES; SKIP_INSTALL = YES;
SWIFT_OBJC_INTERFACE_HEADER_NAME = "$(SWIFT_MODULE_NAME)-Swift.h"; SWIFT_OBJC_INTERFACE_HEADER_NAME = "$(SWIFT_MODULE_NAME)-Swift.h";
SWIFT_VERSION = 3.0; SWIFT_VERSION = 4.0;
}; };
name = Release; name = Release;
}; };
......
...@@ -170,7 +170,7 @@ extension MotionCoreAnimationViewContext { ...@@ -170,7 +170,7 @@ extension MotionCoreAnimationViewContext {
} }
if false != snapshot.layer.animationKeys()?.isEmpty { 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) return (snapshot.layer.presentation() ?? snapshot.layer).value(forKeyPath: key)
......
...@@ -47,13 +47,13 @@ fileprivate struct AssociatedInstance { ...@@ -47,13 +47,13 @@ fileprivate struct AssociatedInstance {
A reference to the previous navigation controller delegate A reference to the previous navigation controller delegate
before Motion was enabled. before Motion was enabled.
*/ */
var previousNavigationDelegate: UINavigationControllerDelegate? weak var previousNavigationDelegate: UINavigationControllerDelegate?
/** /**
A reference to the previous tab bar controller delegate A reference to the previous tab bar controller delegate
before Motion was enabled. before Motion was enabled.
*/ */
var previousTabBarDelegate: UITabBarControllerDelegate? weak var previousTabBarDelegate: UITabBarControllerDelegate?
} }
extension UIViewController { extension UIViewController {
......
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
<key>CFBundlePackageType</key> <key>CFBundlePackageType</key>
<string>FMWK</string> <string>FMWK</string>
<key>CFBundleShortVersionString</key> <key>CFBundleShortVersionString</key>
<string>1.1.2</string> <string>1.2.0</string>
<key>CFBundleVersion</key> <key>CFBundleVersion</key>
<string>$(CURRENT_PROJECT_VERSION)</string> <string>$(CURRENT_PROJECT_VERSION)</string>
<key>NSPrincipalClass</key> <key>NSPrincipalClass</key>
......
...@@ -770,21 +770,28 @@ extension Motion: UITabBarControllerDelegate { ...@@ -770,21 +770,28 @@ extension Motion: UITabBarControllerDelegate {
} }
} }
public typealias MotionDelayCancelBlock = (Bool) -> Void public typealias MotionCancelBlock = (Bool) -> Void
extension Motion { 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. Executes a block of code after a time delay.
- Parameter duration: An animation duration time. - Parameter _ time: A delay time.
- Parameter animations: An animation block. - Parameter execute: A block that is executed once delay has passed.
- Parameter execute block: A completion block that is executed once - Returns: An optional MotionCancelBlock.
the animations have completed.
*/ */
@discardableResult @discardableResult
public class func delay(_ time: TimeInterval, execute: @escaping () -> Void) -> MotionDelayCancelBlock? { public class func delay(_ time: TimeInterval, execute: @escaping () -> Void) -> MotionCancelBlock? {
var cancelable: MotionDelayCancelBlock? var cancelable: MotionCancelBlock?
let delayed: MotionDelayCancelBlock = { let delayed: MotionCancelBlock = {
if !$0 { if !$0 {
DispatchQueue.main.async(execute: execute) DispatchQueue.main.async(execute: execute)
} }
...@@ -802,10 +809,10 @@ extension Motion { ...@@ -802,10 +809,10 @@ extension Motion {
} }
/** /**
Cancels the delayed MotionDelayCancelBlock. Cancels the delayed MotionCancelBlock.
- Parameter delayed completion: An MotionDelayCancelBlock. - Parameter delayed completion: An MotionCancelBlock.
*/ */
public class func cancel(delayed completion: MotionDelayCancelBlock) { public class func cancel(delayed completion: MotionCancelBlock) {
completion(true) completion(true)
} }
......
...@@ -227,6 +227,16 @@ public extension MotionAnimation { ...@@ -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. /// Fades the view in during an animation.
static var fadeIn = MotionAnimation.fade(1) static var fadeIn = MotionAnimation.fade(1)
...@@ -267,6 +277,16 @@ public extension MotionAnimation { ...@@ -267,6 +277,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. Animates a view's current shadow path to the given one.
- Parameter path: A CGPath. - Parameter path: A CGPath.
- Returns: A MotionAnimation. - Returns: A MotionAnimation.
......
...@@ -310,6 +310,7 @@ internal extension MotionController { ...@@ -310,6 +310,7 @@ internal extension MotionController {
Subclasses should call context.set(fromViews: toViews) after Subclasses should call context.set(fromViews: toViews) after
inserting fromViews & toViews into the container inserting fromViews & toViews into the container
*/ */
@objc
func prepareTransition() { func prepareTransition() {
guard isTransitioning else { guard isTransitioning else {
return return
...@@ -323,6 +324,7 @@ internal extension MotionController { ...@@ -323,6 +324,7 @@ internal extension MotionController {
} }
/// Prepares the transition fromView & toView pairs. /// Prepares the transition fromView & toView pairs.
@objc
func prepareTransitionPairs() { func prepareTransitionPairs() {
guard isTransitioning else { guard isTransitioning else {
return return
...@@ -358,6 +360,7 @@ internal extension MotionController { ...@@ -358,6 +360,7 @@ internal extension MotionController {
Animates the views. Subclasses should call `prepareTransition` & Animates the views. Subclasses should call `prepareTransition` &
`prepareTransitionPairs` before calling `animate`. `prepareTransitionPairs` before calling `animate`.
*/ */
@objc
func animate() { func animate() {
guard isTransitioning else { guard isTransitioning else {
return return
...@@ -424,6 +427,7 @@ internal extension MotionController { ...@@ -424,6 +427,7 @@ internal extension MotionController {
- Parameter isFinished: A Boolean indicating if the transition - Parameter isFinished: A Boolean indicating if the transition
has completed. has completed.
*/ */
@objc
func complete(isFinished: Bool) { func complete(isFinished: Bool) {
guard isTransitioning else { guard isTransitioning else {
return return
......
...@@ -234,6 +234,16 @@ public extension MotionTransition { ...@@ -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. /// Forces the view to not fade during a transition.
static var forceNonFade = MotionTransition { static var forceNonFade = MotionTransition {
$0.nonFade = true $0.nonFade = true
...@@ -279,6 +289,16 @@ public extension MotionTransition { ...@@ -279,6 +289,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. Animates the view's current shadow path to the given one.
- Parameter path: A CGPath. - Parameter path: A CGPath.
- Returns: A MotionTransition. - Returns: A MotionTransition.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment