marcosgriselli / SwipeableTabBarController

UITabBarController with swipe interaction between its tabs.
MIT License
1.54k stars 107 forks source link

Allow setting the tap animation duration #75

Closed DarkDust closed 4 years ago

DarkDust commented 4 years ago

Make the SwipeTransitionAnimator public and allow setting the animationDuration property. This way subclasses of SwipeableTabBarController can tweak the duration like this:

override
func tabBarController(
    _ tabBarController: UITabBarController,
    animationControllerForTransitionFrom fromVC: UIViewController,
    to toVC: UIViewController
) -> UIViewControllerAnimatedTransitioning? {
    let transitioning = super.tabBarController(
        tabBarController,
        animationControllerForTransitionFrom: fromVC, to: toVC
    )

    guard let animator = transitioning as? SwipeTransitionAnimator else {
        return transitioning
    }

    animator.animationDuration = 0.2
    return transitioning
}

Fixes #72.

coditobot commented 4 years ago
2 Warnings
:warning: This PR does not have any assignees yet.
:warning: SwipeableTabBarController/Classes/SwipeTransitioningProtocol.swift#L11 - TODOs should be resolved ((marcosgriselli): - Support Ob…).
todo SwipeTransitioningProtocol.swift:11
1 Message
:book: Thanks @DarkDust! :tada:

Current coverage for SwipeableTabBarController.framework is 85.96%

Files changed - -
SwipeTransitionAnimator.swift 100.00% :white_check_mark:

Current coverage for SwipeableTabBarController_Example.app is 100.00%

No files affecting coverage found


Powered by xcov

Generated by :no_entry_sign: Danger

marcosgriselli commented 4 years ago

Thanks for the PR @DarkDust. I was thinking we can add the animationDuration property to the SwipeTransitioningProtocol definition so we avoid the guard let animator = transitioning as? SwipeTransitionAnimator.

This change will let us define the duration in our viewDidLoad method like this: tapAnimatedTransitioning?.animationDuration = 0.5.

What do you think?

DarkDust commented 4 years ago

That is indeed a better solution. I've updated my PR.