Slidoo 1.0.4

Slidoo 1.0.4

Maintained by Mitul Manish.



Slidoo 1.0.4

  • By
  • mitul_manish

Slidoo

CI Status Version License Platform

Example

To run the example project, clone the repo, and run pod install from the Example directory first.

Requirements

  • Xcode 10.0+
  • iOS 9.0+
  • Swift 4.2+

Setup

GIF

Left to Right Right to Left
Screenshot Screenshot

Screenshots

Left to Right

Portrait Landscape
Screenshot Screenshot

Right to Left

Portrait Landscape
Screenshot Screenshot

Adding the Transition Delegate

This class provides the custom presentation controller and animator classes responsible for presenting and dismissing the view controller

import UIKit
import Slidoo

class NavigationDrawerTransitionDelegate: NSObject, UIViewControllerTransitioningDelegate {

    private let supportAnimation: Bool

    init(supportAnimation: Bool) {
        self.supportAnimation = supportAnimation
    }

    func presentationController(forPresented presented: UIViewController, presenting: UIViewController?, source: UIViewController) -> UIPresentationController? {
        return NavigationDrawerSwipeController(presentedViewController: presented, presenting: source)
    }

    func animationController(forPresented presented: UIViewController, presenting: UIViewController, source: UIViewController) -> UIViewControllerAnimatedTransitioning? {
        return NavigationDrawerPresentationAnimator(isBeingPresented: true, supportAnimation: supportAnimation)
    }

    func animationController(forDismissed dismissed: UIViewController) -> UIViewControllerAnimatedTransitioning? {
        return NavigationDrawerPresentationAnimator(isBeingPresented: false, supportAnimation: supportAnimation)
    }
}

Using the Transition Delegate

        let presentedVC = DrawerViewController()
        presentedViewControllerTransitionAnimator = nil
        presentedViewControllerTransitionAnimator = NavigationDrawerTransitionDelegate(supportAnimation: supportAnimation)
        presentedVC.transitioningDelegate = presentedViewControllerTransitionAnimator
        presentedVC.modalPresentationStyle = .custom
        present(presentedVC, animated: true)

When user perform a certain action like a button tap, we would like to open the Sliding View or the Drawer with an animation. Use the code above to set the up the transition delegate on the presented view controller.

Open the Sliding View or Drawer on screen swipe

  1. Set up the screen gesture recognizer
        let screenEdgeGesture = UIScreenEdgePanGestureRecognizer(target: self, action: #selector(didPan(panRecognizer:)))
        screenEdgeGesture.edges = view.isRTL ? .right : .left
        view.addGestureRecognizer(screenEdgeGesture)
  1. Detect the swipe
@objc func didPan(panRecognizer: UIPanGestureRecognizer) {
        switch panRecognizer.state {
        case .began:
            presentMenu(supportAnimation: false)
        default:
            forwardPanGesture(panRecognizer)
        }
}
  1. Pass the Gesture Recognizer object to the custom presentation controller
func forwardPanGesture(_ panRecognizer: UIPanGestureRecognizer) {
        if let presentedVC = presentedViewController as? DrawerViewController, let presentationController = presentedVC.presentationController as? NavigationDrawerSwipeController {
            presentationController.didPan(panRecognizer: panRecognizer, screenGestureEnabled: true)
        }
    }

Installation

Slidoo is available through CocoaPods. To install it, simply add the following line to your Podfile:

pod 'Slidoo'

Author

mitul_manish, [email protected]

License

Slidoo is available under the MIT license. See the LICENSE file for more info.