Screen transition with safe and clean code.

Overview

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.

You might also like...
Code Swift iOS app showcasing basic movies list from Orange TV API.

iOS Code Test - Optiva Media Code Swift iOS app showcasing basic movies list from Orange TV API. Built using XCode 13.0 (Swift 5) How to run the examp

Some projects written in Swift 5 code designed using the MVVM design pattern.
Some projects written in Swift 5 code designed using the MVVM design pattern.

MVVM Design Pattern Demo This repository has contained some simple demo projects written in Swift code designed using the MVVM design pattern. Project

A Swift sample code to reads ISO 10303-21 exchange structures (STEP P21 files for AP242) split into multiple files using external references approach.

multipleP21ReadsSample A Swift sample code to reads ISO 10303-21 exchange structures (STEP P21 files for AP242) split into multiple files using extern

Starter project for the iOS code challenge

iOS Base Project for Podium Take-Home Challenge Introduction We have provided two version of this base project: one using UIKit, one using SwiftUI. Th

Code challenge iOS - Movies app

Code challenge iOS - Movies app Project structure The Common folder contains sha

Third Prize for Uber Hackathon China 2016. Source code for iOS client of UberGuide Project.
Third Prize for Uber Hackathon China 2016. Source code for iOS client of UberGuide Project.

Smart Traveller Intro It's the project we did for Uber Hackathon China 2016. This is the repo for iOS client. Using swift and Objective-C. The project

Example app source code developed by swift language from apple
Example app source code developed by swift language from apple

AboutMe Example app source code developed by swift language from apple. Display data from a central source in multiple views. Welcome to the About Me

🎉 WWDC 2021 Swift Student Challenge Winner 🎉 Dance Party allows users to record choreography and play against other users to try and match the key poses!
🎉 WWDC 2021 Swift Student Challenge Winner 🎉 Dance Party allows users to record choreography and play against other users to try and match the key poses!

💃 Dance Party 🕺 🍎 WWDC 2021 Swift Student Challenge Winner 🎉 Installation Steps (Works on iPad Only) Clone or Download Unzip the .playgroundbook.z

Releases(1.2.1)
Owner
Muukii
Swift & iOS - Working on creating apps and open-sourced libraries. I'm interested in Creating smooth and fancy UI, State-Management, Image Processing.
Muukii
A sample iOS app built using the Clean Swift architecture

Main Purpose is to create a simple project for Clean-Swift This project wrote with using Clean-Swift and MVP Design Pattern

Eyup Cimen 8 Oct 24, 2022
Challenge-vip-delivery - Project for VIP (Clean Swift) Architecture Dev Sprints on Devpass

VIP (Clean Swift) - Delivery App ?? Neste desafio, aplicaremos conceitos da arquitetura VIP para finalizar a implementação de um aplicativo. Desenvolv

Devpass 5 Oct 24, 2022
IOS-Application-3 - A basic calculator app for iOS compatible to any layout and screen size

Calculator It is a basic calculator app for iOS compatible to any layout and scr

Kushal Shingote 1 Feb 2, 2022
The "Ask Me" is simple iOS application which shows answer on the screen everytime when the user press the ask button

The "Ask Me" is simple iOS application which shows answer on the screen everytime when the user press the ask button. This application is build and design by Chetan Parate using Xcode and Swift.

Chetan Parate 0 Oct 27, 2021
Sample app to demonstrate the integration code and working of Dyte SDK for iOS, using Swift

docs-template by dyte ADD_DESCRIPTION_HERE Explore the docs » View Demo · Report Bug · Request Feature Table of Contents About the Project Built With

Dyte 8 Nov 26, 2021
Code Challenge - Using Alamofire is a Swift-based, HTTP networking library, also Codable for Data Model and Combine Framework .

Code Challenge ##Using Alamofire is a Swift-based, HTTP networking library, also Codable for Data Model and Combine Framework . Alamofire is one of th

Eng Angelo Saber 0 Nov 24, 2021
The source code of the EU Digital COVID Certificate App Core for iOS

This repository contains the source code of the EU Digital COVID Certificate App Core for iOS.

null 35 Apr 5, 2022
Sample Code for WWDC21

WWDC21 Sample Code Accessibility Create Accessible Experiences for watchOS Creating Accessible Views WWDC21 Challenge: Large Text Challenge WWDC21 Cha

Artem Novichkov 84 Dec 27, 2022
Demonstration code for a simple Swift property-wrapper, keypath-based dependency injection system. The keypaths ensure compile-time safety for all injectable services.

Injectable Demo Preliminary musings and demonstration code for a simple Swift property-wrapper, keypath-based dependency injection system. The keypath

Michael Long 12 Aug 5, 2022
GoodAsOldPhones is the demo app of Swift tutorial on code school.

GoodAsOldPhones GoodAsOldPhones is the demo app of Swift tutorial on code school. This app demonstates basic use and implementation of tab bar control

Kushal Shingote 5 May 24, 2022