Popularity
0.7
Growing
Activity
0.0
Stable
14
3
1

Code Quality Rank: L5
Programming language: Swift
License: MIT License
Tags: UI     Modal Transition    
Latest version: v1.2.6

Presenter alternatives and similar libraries

Based on the "Modal Transition" category.
Alternatively, view Presenter alternatives based on common mentions on social networks and blogs.

Do you think we are missing an alternative of Presenter or a related project?

Add another 'Modal Transition' Library

README

Presenter

CI Status Version License Platform Carthage compatible

Screen transition with safe and clean code.

With Presenter, you can…

  • Assure that the ViewController's requirements are met, such as a ViewModel to be injected.
  • Constrain transition types (push or present modal or both)

This library is recommended to be used together with Instantiatable.

Usage

Clean Screen Transition

MyViewController.Presenter(userID: "muukii").push(self.navigationController)
MyViewController.Presenter(userID: "muukii").present(self)

Advanced

MyViewController.Presenter(userID: "muukii").push(self.navigationController) { (transaction: PushTransaction<MyViewController> in

    // Pop    
    transaction.pop()

    // Get
    transaction.viewController
}

MyViewController.Presenter(userID: "muukii").present(self) { (transaction: ModalTransaction<MyViewController>) in

    // Pop    
    transaction.dismiss()

    // Get
    transaction.viewController
}

Create Presenter

Push

extension MyViewController {

    final class Presenter: PushPresenter {

        let userID: String

        init(userID: String) {
            self.userID = userID
        }

        func createViewController() -> MyViewController {
            let controller = MessagesViewController() // Init from Stroyboard or XIB
            controller.userID = userID
            return controller
        }  

        // Optional:

        public func willPush(viewController: MyViewController) {

        }

        public func didPush(viewController: MyViewController) {

        }
    }
}

Present

extension MyViewController {

    final class Presenter: ModalPresenter {

        let userID: String

        init(userID: String) {
            self.userID = userID
        }

        func parentController(viewController: UIViewController) -> UIViewController? {
            return UINavigationController(rootViewController: viewController)
        }

        func createViewController() -> MyViewController {
            let controller = MessagesViewController() // Init from Stroyboard or XIB
            controller.userID = userID
            return controller
        }   

        // Optional

        public func willPresent(viewController: MyViewController) {

        }

        public func didPresent(viewController: MyViewController) {

        }
    }
}

Present or Push

extension MyViewController {

    final class Presenter: PushPresenter, ModalPresenter {

        let userID: String

        init(userID: String) {
            self.userID = userID
        }

        func parentController(viewController: UIViewController) -> UIViewController? {
            // Call Present() only
            return UINavigationController(rootViewController: viewController)
        }

        func createViewController() -> MyViewController {
            let controller = MessagesViewController() // Init from Stroyboard or XIB
            controller.userID = userID
            return controller
        }    

        // Optional

        public func willPresent(viewController: MyViewController) {

        }

        public func didPresent(viewController: MyViewController) {

        }

        public func willPush(viewController: MyViewController) {

        }

        public func didPush(viewController: MyViewController) {

        }
    }
}

Requirements

Installation

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

pod "Presenter"

Author

muukii, [email protected]

License

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


*Note that all licence references and agreements mentioned in the Presenter README section above are relevant to that project's source code only.