Latest1.7.4
Homepagehttps://github.com/ladeiko/ViperMcFlurryX
LicenseMIT
Platformsios 9.0, requires ARC
DependenciesViperMcFlurrySwiftFix
Authors

Overview

Pod version

NOTE: It is a fork of Rambler VIPER McFlurry

VIPER McFlurry is a modern framework for implementing VIPER architecture in iOS application. It offers several tools and components that help either start new projects with VIPER or move from MVC.

McFlurry

Changes

v1.7.3, v1.7.4

  • Remove some compilation warnings

v1.7.2

  • Update parentTransitionHandler logic

v1.7.1

  • Add more closeModule variations to
    RamblerViperModuleTransitionHandlerProtocol
- (void)closeModulesUntil:(id<RamblerViperModuleTransitionHandlerProtocol>)transitionHandler animated:(BOOL)animated completion:(ModuleCloseCompletionBlock)completion;

- (void)closeTopModules:(BOOL)animated completion:(ModuleCloseCompletionBlock)completion;
  • Add
- (_Nullable id<RamblerViperModuleTransitionHandlerProtocol>)parentTransitionHandler;

v1.6.2

  • openModuleUsingSegue will be called synchronously if thenChainUsingBlock was called on promise just after main call. In another case segue will be executed on next runloop cycle. Sync version ensures that after call to openModuleUsingSegue segue was executed.
  • Updated code of – (void)closeCurrentModule:(BOOL)animated completion:(ModuleCloseCompletionBlock)completion for navigation controller case when completion call is required. Also added [self willMoveToParentViewController:nil] before removeFromParentViewController.

Key Features

  • The framework itself pushes you to implement a proper VIPER architecture,
  • It provides an extremely nice and easy way to implement intermodule data transfer,
  • Used in default Generamba template.

Usage

This example works only for Module with UIViewController as View. However, it’s possible to use this approach even with UIView and UITableViewCell acting as View.

  • Create Module input protocol for target module inherited from RamblerViperModuleInput:
@protocol SomeModuleInput <RamblerViperModuleInput>

- (void)moduleConfigurationMethod;

@end
  • Make Presenter of target module conform to this protocol.
  • Inject Presenter as moduleInput property of the view. You can skip this step if presenter is a view property with name "output".
  • Add Segue from source module ViewController to target module ViewController.
  • Inject Source ViewController into Source Router as property "transition handler".
  • In Router method call transition handler to open target module with configuration during segue.
[[self.transitionHandler openModuleUsingSegue:SegueIdentifier]
    thenChainUsingBlock:^id<RamblerViperModuleOutput>(id<SomeModuleInput> moduleInput) {
        [moduleInput moduleConfigurationMethod];
        return nil;
    }];

Working with Module output

  • Create Module output protocol for target module inherited from RamblerViperModuleOutput:
@protocol SomeModuleOutput <RamblerViperModuleOutput>

- (void)moduleConfigurationMethod;

@end
  • Make source module presenter to conform to this protocol.
  • Add to target module presenter method:
- (void)setModuleOutput:(id<RamblerViperModuleOutput>)moduleOutput;
  • Return source module presenter from configuration block in router:
[[self.transitionHandler openModuleUsingSegue:SegueIdentifier]
    thenChainUsingBlock:^id<RamblerViperModuleOutput>(id<SomeModuleInput> moduleInput) {
        [moduleInput moduleConfigurationMethod];
        return sourceRouterPresenter; // Return of module output
    }];

Working with Module Factory

Module factory can be replaced with segues for most cases. Except you need to create complex module or nontrivial module instantiation logic.

  • Use RamblerViperModuleFactory object as module fabric with Typhoon.
  • Set definition Initializer to initWithViewControllerLoader:andViewControllerIdentifier:
    • First parameter is the object which loads the view controller, e.g. UIStoryboard or TyphoonNibLoader instance,
    • Second parameter is view controller’s identifier, e.g. RestorationID or NibName of ViewController.
  • Typhoon will initialize module from ViewController.
  • Inject this Factory into router.
  • Call Transition Handler’s method - openModuleUsingFactory:withTransitionBlock:.
  • Second block is place where transition from one to another viewController/transitionHandler should be performed:

    [[self.transitionHandler openModuleUsingFactory:self.betaModuleFactory
                                withTransitionBlock:^(id <RamblerViperModuleTransitionHandlerProtocol> sourceModuleTransitionHandler,
                                        id <RamblerViperModuleTransitionHandlerProtocol> destinationModuleTransitionHandler) {
    
                                    UIViewController *sourceViewController = (id) sourceModuleTransitionHandler;
                                    UIViewController *destinationViewController = (id) destinationModuleTransitionHandler;
    
                                    [sourceViewController.navigationController pushViewController:destinationViewController
                                                                                         animated:YES];
    
                                }] thenChainUsingBlock:^id<RamblerViperModuleOutput>(id<RamblerModuleBetaInput> moduleInput) {
                                   [moduleInput configureWithExampleString:exampleString];
                                   return nil;
                               }];
  • In example above one module is pushed to navigation stack of another module.
  • Modules are linked with intermodule data transfer block.

Installation

Add to podfile

pod "ViperMcFlurryX"

License

MIT

Authors

Rambler&Co team:

ViperMcFlurryX fork:

Latest podspec

{
    "name": "ViperMcFlurryX",
    "version": "1.7.4",
    "summary": "ViperMcFlurryX - Fork of Rambler ViperMcFlurry framework.",
    "homepage": "https://github.com/ladeiko/ViperMcFlurryX",
    "license": "MIT",
    "authors": {
        "Siarhei Ladzeika": "[email protected]"
    },
    "source": {
        "git": "https://github.com/ladeiko/ViperMcFlurryX.git",
        "tag": "1.7.4"
    },
    "platforms": {
        "ios": "9.0"
    },
    "requires_arc": true,
    "source_files": "Source/*.{h,m}",
    "dependencies": {
        "ViperMcFlurrySwiftFix": []
    }
}

Pin It on Pinterest

Share This