Commit 9ee829f1 by Daniel Dahan

development: updated MotionTransition delegation and animator

parent f4a5cc8c
......@@ -31,9 +31,6 @@
import UIKit
open class BottomNavigationController: UITabBarController, UITabBarControllerDelegate {
/// The transition animation to use when selecting a new tab.
open var motionTransition = MotionTransition.fade
/**
An initializer that initializes the object with a NSCoder object.
- Parameter aDecoder: A NSCoder instance.
......@@ -119,7 +116,7 @@ open class BottomNavigationController: UITabBarController, UITabBarControllerDel
/// Handles transitions when tabBarItems are pressed.
open func tabBarController(_ tabBarController: UITabBarController, animationControllerForTransitionFrom fromVC: UIViewController, to toVC: UIViewController) -> UIViewControllerAnimatedTransitioning? {
return .fade == motionTransition ? FadeMotionTransition() : nil
return FadeMotionTransition()
}
/// Prepares the tabBar.
......
......@@ -191,7 +191,7 @@ open class Button: UIButton, Pulseable {
let p = point ?? center
pulse.expand(point: p)
Motion.delay(time: 0.35) { [weak self] in
Motion.delay(0.35) { [weak self] in
self?.pulse.contract()
}
}
......
......@@ -243,7 +243,7 @@ open class CollectionReusableView: UICollectionReusableView, Pulseable {
let p = point ?? center
pulse.expand(point: p)
Motion.delay(time: 0.35) { [weak self] in
Motion.delay(0.35) { [weak self] in
self?.pulse.contract()
}
}
......
......@@ -201,7 +201,7 @@ open class CollectionViewCell: UICollectionViewCell, Pulseable {
let p = point ?? center
pulse.expand(point: p)
Motion.delay(time: 0.35) { [weak self] in
Motion.delay(0.35) { [weak self] in
self?.pulse.contract()
}
}
......
......@@ -95,7 +95,7 @@ public struct Motion {
the animations have completed.
*/
@discardableResult
public static func delay(time: TimeInterval, execute block: @escaping () -> Void) -> MotionDelayCancelBlock? {
public static func delay(_ time: TimeInterval, execute block: @escaping () -> Void) -> MotionDelayCancelBlock? {
func asyncAfter(completion: @escaping () -> Void) {
DispatchQueue.main.asyncAfter(deadline: DispatchTime.now() + time, execute: completion)
......@@ -179,7 +179,7 @@ public struct Motion {
the animations have completed.
*/
public static func animate(delay time: CFTimeInterval, duration: CFTimeInterval, animations: @escaping (() -> Void), completion: (() -> Void)? = nil) {
delay(time: time) {
delay(time) {
animate(duration: duration, animations: animations, completion: completion)
}
}
......
......@@ -168,7 +168,7 @@ extension CALayer {
}
}
Motion.delay(time: t) { [weak self] in
Motion.delay(t) { [weak self] in
guard let s = self else {
return
}
......
......@@ -121,7 +121,7 @@ open class NavigationController: UINavigationController {
open func prepare() {
navigationBar.heightPreset = .normal
navigationBar.width = view.width
delegate = self
delegate = transitionDelegate
view.clipsToBounds = true
view.backgroundColor = .white
view.contentScaleFactor = Screen.scale
......@@ -134,12 +134,6 @@ open class NavigationController: UINavigationController {
}
}
extension NavigationController: UINavigationControllerDelegate {
open func navigationController(_ navigationController: UINavigationController, animationControllerFor operation: UINavigationControllerOperation, from fromVC: UIViewController, to toVC: UIViewController) -> UIViewControllerAnimatedTransitioning? {
return SlideMotionTransition(operation: operation)
}
}
extension NavigationController: UINavigationBarDelegate {
/**
Delegation method that is called when a new UINavigationItem is about to be pushed.
......
......@@ -156,7 +156,7 @@ extension PulseMotion {
default:break
}
Motion.delay(time: duration) {
Motion.delay(duration) {
bLayer.setValue(true, forKey: "animated")
}
}
......@@ -173,7 +173,7 @@ extension PulseMotion {
return
}
Motion.delay(time: animated ? 0 : 0.15) { [animation = animation, color = color] in
Motion.delay(animated ? 0 : 0.15) { [animation = animation, color = color] in
guard let pLayer = bLayer.sublayers?.first as? CAShapeLayer else {
return
}
......@@ -192,7 +192,7 @@ extension PulseMotion {
default:break
}
Motion.delay(time: duration) {
Motion.delay(duration) {
pLayer.removeFromSuperlayer()
bLayer.removeFromSuperlayer()
}
......
......@@ -75,7 +75,7 @@ open class PulseView: View, Pulseable {
let p = point ?? center
pulse.expand(point: p)
Motion.delay(time: 0.35) { [weak self] in
Motion.delay(0.35) { [weak self] in
self?.pulse.contract()
}
}
......
......@@ -123,7 +123,7 @@ open class SnackbarController: RootController {
*/
@discardableResult
open func animate(snackbar status: SnackbarStatus, delay: TimeInterval = 0, animations: ((Snackbar) -> Void)? = nil, completion: ((Snackbar) -> Void)? = nil) -> MotionDelayCancelBlock? {
return Motion.delay(time: delay) { [weak self, status = status, animations = animations, completion = completion] in
return Motion.delay(delay) { [weak self, status = status, animations = animations, completion = completion] in
guard let s = self else {
return
}
......
......@@ -117,7 +117,7 @@ open class TableViewCell: UITableViewCell, Pulseable {
let p = point ?? center
pulse.expand(point: p)
Motion.delay(time: 0.35) { [weak self] in
Motion.delay(0.35) { [weak self] in
self?.pulse.contract()
}
}
......
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