Commit 40cbb847 by Daniel Dahan

phase 1 update for string convertable animation types

parent a0a1e257
......@@ -22,7 +22,7 @@
96AEB6901EE4610F009A3BE0 /* MotionViewPropertyViewContext.swift in Sources */ = {isa = PBXBuildFile; fileRef = 96AEB6681EE4610F009A3BE0 /* MotionViewPropertyViewContext.swift */; };
96AEB6911EE4610F009A3BE0 /* MotionDebugPlugin.swift in Sources */ = {isa = PBXBuildFile; fileRef = 96AEB66A1EE4610F009A3BE0 /* MotionDebugPlugin.swift */; };
96AEB6921EE4610F009A3BE0 /* MotionDebugView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 96AEB66B1EE4610F009A3BE0 /* MotionDebugView.swift */; };
96AEB6931EE4610F009A3BE0 /* DefaultAnimationPreprocessor.swift in Sources */ = {isa = PBXBuildFile; fileRef = 96AEB66C1EE4610F009A3BE0 /* DefaultAnimationPreprocessor.swift */; };
96AEB6931EE4610F009A3BE0 /* TransitionPreprocessor.swift in Sources */ = {isa = PBXBuildFile; fileRef = 96AEB66C1EE4610F009A3BE0 /* TransitionPreprocessor.swift */; };
96AEB6941EE4610F009A3BE0 /* Motion+Array.swift in Sources */ = {isa = PBXBuildFile; fileRef = 96AEB66E1EE4610F009A3BE0 /* Motion+Array.swift */; };
96AEB6951EE4610F009A3BE0 /* Motion+CALayer.swift in Sources */ = {isa = PBXBuildFile; fileRef = 96AEB66F1EE4610F009A3BE0 /* Motion+CALayer.swift */; };
96AEB6961EE4610F009A3BE0 /* Motion+CAMediaTimingFunction.swift in Sources */ = {isa = PBXBuildFile; fileRef = 96AEB6701EE4610F009A3BE0 /* Motion+CAMediaTimingFunction.swift */; };
......@@ -67,7 +67,7 @@
96AEB6681EE4610F009A3BE0 /* MotionViewPropertyViewContext.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MotionViewPropertyViewContext.swift; sourceTree = "<group>"; };
96AEB66A1EE4610F009A3BE0 /* MotionDebugPlugin.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MotionDebugPlugin.swift; sourceTree = "<group>"; };
96AEB66B1EE4610F009A3BE0 /* MotionDebugView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MotionDebugView.swift; sourceTree = "<group>"; };
96AEB66C1EE4610F009A3BE0 /* DefaultAnimationPreprocessor.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = DefaultAnimationPreprocessor.swift; path = ../DefaultAnimationPreprocessor.swift; sourceTree = "<group>"; };
96AEB66C1EE4610F009A3BE0 /* TransitionPreprocessor.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = TransitionPreprocessor.swift; path = ../TransitionPreprocessor.swift; sourceTree = "<group>"; };
96AEB66E1EE4610F009A3BE0 /* Motion+Array.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "Motion+Array.swift"; sourceTree = "<group>"; };
96AEB66F1EE4610F009A3BE0 /* Motion+CALayer.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "Motion+CALayer.swift"; sourceTree = "<group>"; };
96AEB6701EE4610F009A3BE0 /* Motion+CAMediaTimingFunction.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "Motion+CAMediaTimingFunction.swift"; sourceTree = "<group>"; };
......@@ -165,12 +165,12 @@
isa = PBXGroup;
children = (
968989DB1EE65F2B003B8F3D /* MotionPreprocessor.swift */,
96AEB66C1EE4610F009A3BE0 /* TransitionPreprocessor.swift */,
96AEB6881EE4610F009A3BE0 /* CascadePreprocessor.swift */,
96AEB6891EE4610F009A3BE0 /* DurationPreprocessor.swift */,
96AEB68A1EE4610F009A3BE0 /* IgnoreSubviewModifiersPreprocessor.swift */,
96AEB68B1EE4610F009A3BE0 /* MatchPreprocessor.swift */,
96AEB68C1EE4610F009A3BE0 /* SourcePreprocessor.swift */,
96AEB66C1EE4610F009A3BE0 /* DefaultAnimationPreprocessor.swift */,
);
path = Preprocessors;
sourceTree = "<group>";
......@@ -304,7 +304,7 @@
96AEB6A31EE4610F009A3BE0 /* MotionPlugin.swift in Sources */,
96AEB69A1EE4610F009A3BE0 /* Motion+UIView.swift in Sources */,
96AEB6AD1EE4610F009A3BE0 /* DurationPreprocessor.swift in Sources */,
96AEB6931EE4610F009A3BE0 /* DefaultAnimationPreprocessor.swift in Sources */,
96AEB6931EE4610F009A3BE0 /* TransitionPreprocessor.swift in Sources */,
96AEB68F1EE4610F009A3BE0 /* MotionDefaultAnimator.swift in Sources */,
96AEB69D1EE4610F009A3BE0 /* Motion.swift in Sources */,
963150D61EE51C7A002B0D42 /* MotionAnimation.swift in Sources */,
......
......@@ -32,13 +32,13 @@ fileprivate var AssociatedInstanceKey: UInt8 = 0
fileprivate struct AssociatedInstance {
/// A reference to the modal animation.
var modalAnimationType: MotionDefaultAnimationType
var modalTransitionType: MotionTransitionType
/// A reference to the navigation animation.
var navigationAnimationType: MotionDefaultAnimationType
var navigationTransitionType: MotionTransitionType
/// A reference to the tabBar animation.
var tabBarAnimationType: MotionDefaultAnimationType
var tabBarTransitionType: MotionTransitionType
/// A reference to the stored snapshot.
var storedSnapshot: UIView?
......@@ -61,9 +61,9 @@ extension UIViewController {
fileprivate var associatedInstance: AssociatedInstance {
get {
return AssociatedObject.get(base: self, key: &AssociatedInstanceKey) {
return AssociatedInstance(modalAnimationType: .auto,
navigationAnimationType: .auto,
tabBarAnimationType: .auto,
return AssociatedInstance(modalTransitionType: .auto,
navigationTransitionType: .auto,
tabBarTransitionType: .auto,
storedSnapshot: nil,
previousNavigationDelegate: nil,
previousTabBarDelegate: nil)
......@@ -75,22 +75,22 @@ extension UIViewController {
}
/// default motion animation type for presenting & dismissing modally
public var motionModalAnimationType: MotionDefaultAnimationType {
public var motionModalTransitionType: MotionTransitionType {
get {
return associatedInstance.modalAnimationType
return associatedInstance.modalTransitionType
}
set(value) {
associatedInstance.modalAnimationType = value
associatedInstance.modalTransitionType = value
}
}
@IBInspectable
public var motionModalAnimationTypeString: String? {
public var motionModalTransitionTypeString: String? {
get {
return associatedInstance.modalAnimationType.label
return associatedInstance.modalTransitionType.label
}
set(value) {
associatedInstance.modalAnimationType = value?.parseOne() ?? .auto
associatedInstance.modalTransitionType = value?.parseOne() ?? .auto
}
}
......@@ -170,45 +170,45 @@ extension UIViewController {
extension UINavigationController {
/// Default motion animation type for push and pop within the navigation controller.
public var motionNavigationAnimationType: MotionDefaultAnimationType {
public var motionNavigationTransitionType: MotionTransitionType {
get {
return associatedInstance.navigationAnimationType
return associatedInstance.navigationTransitionType
}
set(value) {
associatedInstance.navigationAnimationType = value
associatedInstance.navigationTransitionType = value
}
}
/// A String representation for the motionNavigationAnimationType.
/// A String representation for the motionNavigationTransitionType.
@IBInspectable
public var motionNavigationAnimationTypeString: String? {
public var motionNavigationTransitionTypeString: String? {
get {
return associatedInstance.navigationAnimationType.label
return associatedInstance.navigationTransitionType.label
}
set(value) {
associatedInstance.navigationAnimationType = value?.parseOne() ?? .auto
associatedInstance.navigationTransitionType = value?.parseOne() ?? .auto
}
}
}
extension UITabBarController {
/// Default motion animation type for switching tabs within the tab bar controller.
public var motionTabBarAnimationType: MotionDefaultAnimationType {
public var motionTabBarTransitionType: MotionTransitionType {
get {
return associatedInstance.tabBarAnimationType
return associatedInstance.tabBarTransitionType
}
set(value) {
associatedInstance.tabBarAnimationType = value
associatedInstance.tabBarTransitionType = value
}
}
/// A String representation for the motionTabBarAnimationTypeString.
/// A String representation for the motionTabBarTransitionTypeString.
@IBInspectable
public var motionTabBarAnimationTypeString: String? {
public var motionTabBarTransitionTypeString: String? {
get {
return associatedInstance.tabBarAnimationType.label }
return associatedInstance.tabBarTransitionType.label }
set(value) {
associatedInstance.tabBarAnimationType = value?.parseOne() ?? .auto
associatedInstance.tabBarTransitionType = value?.parseOne() ?? .auto
}
}
}
......
......@@ -81,7 +81,7 @@ public class Motion: MotionController {
internal var fullScreenSnapshot: UIView!
/// Default animation type.
internal var defaultAnimation = MotionDefaultAnimationType.auto
internal var defaultAnimation = MotionTransitionType.auto
/// The color of the transitioning container.
internal var containerBackgroundColor: UIColor?
......@@ -142,9 +142,9 @@ public extension Motion {
/**
Set the default animation for the next transition. This may override the
root-view's motionTransitions during the transition.
- Parameter animation: A MotionDefaultAnimationType.
- Parameter animation: A MotionTransitionType.
*/
func setDefaultAnimationForNextTransition(_ animation: MotionDefaultAnimationType) {
func setDefaultAnimationForNextTransition(_ animation: MotionTransitionType) {
defaultAnimation = animation
}
......@@ -344,7 +344,7 @@ fileprivate extension Motion {
internal extension Motion {
override func prepareTransition() {
super.prepareTransition()
insert(preprocessor: DefaultAnimationPreprocessor(motion: self), before: DurationPreprocessor.self)
insert(preprocessor: TransitionPreprocessor(motion: self), before: DurationPreprocessor.self)
}
override func prepareTransitionPairs() {
......
......@@ -28,7 +28,7 @@
import UIKit
public enum MotionDefaultAnimationType {
public enum MotionTransitionType {
public enum Direction: MotionStringConvertible {
case left, right, up, down
public static func from(node: ExprNode) -> Direction? {
......@@ -54,15 +54,15 @@ public enum MotionDefaultAnimationType {
case zoom
case zoomOut
indirect case selectBy(presenting: MotionDefaultAnimationType, dismissing: MotionDefaultAnimationType)
indirect case selectBy(presenting: MotionTransitionType, dismissing: MotionTransitionType)
public static func autoReverse(presenting: MotionDefaultAnimationType) -> MotionDefaultAnimationType {
public static func autoReverse(presenting: MotionTransitionType) -> MotionTransitionType {
return .selectBy(presenting: presenting, dismissing: presenting.reversed())
}
case none
func reversed() -> MotionDefaultAnimationType {
func reversed() -> MotionTransitionType {
switch self {
case .push(direction: .up):
return .pull(direction: .down)
......@@ -152,8 +152,8 @@ public enum MotionDefaultAnimationType {
}
}
extension MotionDefaultAnimationType: MotionStringConvertible {
public static func from(node: ExprNode) -> MotionDefaultAnimationType? {
extension MotionTransitionType: MotionStringConvertible {
public static func from(node: ExprNode) -> MotionTransitionType? {
let name: String = node.name
let parameters: [ExprNode] = (node as? CallNode)?.arguments ?? []
......@@ -197,9 +197,9 @@ extension MotionDefaultAnimationType: MotionStringConvertible {
case "zoomOut": return .zoomOut
case "selectBy":
if let presentingNode = parameters.get(0),
let presenting = MotionDefaultAnimationType.from(node: presentingNode),
let presenting = MotionTransitionType.from(node: presentingNode),
let dismissingNode = parameters.get(1),
let dismissing = MotionDefaultAnimationType.from(node: dismissingNode) {
let dismissing = MotionTransitionType.from(node: dismissingNode) {
return .selectBy(presenting: presenting, dismissing: dismissing)
}
case "none": return .none
......@@ -209,7 +209,7 @@ extension MotionDefaultAnimationType: MotionStringConvertible {
}
}
class DefaultAnimationPreprocessor: MotionPreprocessor {
class TransitionPreprocessor: MotionPreprocessor {
/// A reference to a MotionContext.
weak var context: MotionContext!
......@@ -219,7 +219,7 @@ class DefaultAnimationPreprocessor: MotionPreprocessor {
self.motion = motion
}
func shift(direction: MotionDefaultAnimationType.Direction, isAppearing: Bool, size: CGSize? = nil, transpose: Bool = false) -> CGPoint {
func shift(direction: MotionTransitionType.Direction, isAppearing: Bool, size: CGSize? = nil, transpose: Bool = false) -> CGPoint {
let size = size ?? context.container.bounds.size
let rtn: CGPoint
switch direction {
......@@ -254,11 +254,11 @@ class DefaultAnimationPreprocessor: MotionPreprocessor {
let animators = motion.animators
if case .auto = defaultAnimation {
if inNavigationController, let navAnim = toViewController?.navigationController?.motionNavigationAnimationType {
if inNavigationController, let navAnim = toViewController?.navigationController?.motionNavigationTransitionType {
defaultAnimation = navAnim
} else if inTabBarController, let tabAnim = toViewController?.tabBarController?.motionTabBarAnimationType {
} else if inTabBarController, let tabAnim = toViewController?.tabBarController?.motionTabBarTransitionType {
defaultAnimation = tabAnim
} else if let modalAnim = (presenting ? toViewController : fromViewController)?.motionModalAnimationType {
} else if let modalAnim = (presenting ? toViewController : fromViewController)?.motionModalTransitionType {
defaultAnimation = modalAnim
}
}
......
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