Swiftpack.co - mohpor/TransEasy as Swift Package

Swiftpack.co is a collection of thousands of indexed Swift packages. Search packages.
mohpor/TransEasy
An easy to implement custom transitions
.package(url: "https://github.com/mohpor/TransEasy.git", from: "1.0.0")

Platform iOS Swift 3.0 compatible MIT

TransEasy

An easy to implement custom transitions.

demo
## Overview:

This library will help easily customize your transitions (Modal and Push) so that you can be able to move your views from one to another.


How to setup:

Cocoapods (Recommended)

1- In your pod file add:

pod 'TransEasy'

2- In terminal:

$ pod update

Manual

Clone or download this repo, add files inside Source folder to your project.


How to use:

Real easy approach:

In this method you will setup the EasyTrans very easily using a simple method and us it for both push transitions and modal presentations.

 func next() {

    guard let destinationViewController = storyboard?.instantiateViewControllerWithIdentifier("secondVC") else {
      return
    }
    // This method adds easy trans to the SecondViewController using the provided options for present and dismiss.

    setupEasyTransition(on: destinationViewController, presentOptions: TransEasyPresentOptions(duration: 0.4, sourceView: qrButton, blurStyle: UIBlurEffectStyle.Dark), dismissOptions: TransEasyDismissOptions(duration: 0.4, destinationView: qrButton, interactive: true))

    if modal {
      presentViewController(destinationViewController, animated: true, completion: nil)
    } else {
      performSegueWithIdentifier(toSecondViewSegueID, sender: sender)
    }

  }

In the destination view controller:

extension SecondViewController: TransEasyDestinationViewControllerProtocol {

  func transEasyDestinationView() -> UIView {
    return qrImage
  }

}

And to be able to use TransEasy for pop transitions in source view controller:


func transEasyDestinationView() -> UIView {
    return qrButton
  }

Not so easy approach (Modal Presentation Only):

Alternatively, you can implement the transitioningDelegate yourself and just use the animator controller.

  • In your view controller add required properties to hold animators:

    let presentAnimator: EasyPresentAnimationController = EasyPresentAnimationController()
    let dismissAnimator: EasyDismissAnimationController = EasyDismissAnimationController()    
  • In prepareForSegue, set the transitioningDelegate:

segue.destinationViewController.transitioningDelegate = self


  • Extend your view controller to use the TransEasy transitions:


extension ViewController: UIViewControllerTransitioningDelegate {

    func animationControllerForPresentedController(presented: UIViewController, presentingController presenting: UIViewController, sourceController source: UIViewController) -> UIViewControllerAnimatedTransitioning? {

        guard let secondVC = presented as? SecondViewController else {
            return nil
        }

        presentAnimator.duration = 0.4
        presentAnimator.originalView = qrButton
        presentAnimator.destinationView = secondVC.qrImage
        presentAnimator.blurEffectStyle = .Dark


        return presentAnimator
    }

    func animationControllerForDismissedController(dismissed: UIViewController) -> UIViewControllerAnimatedTransitioning? {

        guard let secondVC = dismissed as? SecondViewController else {
            return nil
        }
        dismissAnimator.duration = 0.4
        dismissAnimator.originalView = secondVC.qrImage
        dismissAnimator.destinationView = qrButton

        return dismissAnimator
    }

}


TODO:

  • ☑ Setup basic Structure for project.
  • ☑ Create demo views and make the relations.
  • ☑ Create Required Classes and Protocols
  • ☑ Add License file.
  • ☑ Add Documentations.
  • ☑ Add screenshots.
  • ☐ Add CI.
  • ☑ Add Pod support.
  • ☐ Make Transitions Interactive.
  • ☐ Match Pop Animation to the original animation.
  • ☐ Add Present transitioning options for Modal presentations.
  • ☐ Add Delegate object and events for transitions.

GitHub

link
Stars: 25
Last commit: 4 weeks ago

Ad: Job Offers

iOS Software Engineer @ Perry Street Software
Perry Street Software is Jack’d and SCRUFF. We are two of the world’s largest gay, bi, trans and queer social dating apps on iOS and Android. Our brands reach more than 20 million members worldwide so members can connect, meet and express themselves on a platform that prioritizes privacy and security. We invest heavily into SwiftUI and using Swift Packages to modularize the codebase.

Submit a free job ad (while I'm testing this). The analytics numbers for this website are here.

Release Notes

Swift 5 Package
4 weeks ago
  • Updates the project to Swift 5.x
  • Adds Swift Package

Swiftpack is being maintained by Petr Pavlik | @ptrpavlik | @swiftpackco | API | Analytics