From ad61523999d608f6377a8ef04d57edc18e746195 Mon Sep 17 00:00:00 2001 From: Andrey Date: Thu, 16 Jun 2016 11:49:16 +0600 Subject: [PATCH] add -initWithViewHandler: initializer & viewHandler property --- .../RamblerViperModuleFactory.h | 2 ++ .../RamblerViperModuleFactory.m | 13 +++++++++++++ 2 files changed, 15 insertions(+) diff --git a/Code/IntermoduleDataTransfer/RamblerViperModuleFactory.h b/Code/IntermoduleDataTransfer/RamblerViperModuleFactory.h index c7d8a55..a8a7c86 100644 --- a/Code/IntermoduleDataTransfer/RamblerViperModuleFactory.h +++ b/Code/IntermoduleDataTransfer/RamblerViperModuleFactory.h @@ -14,6 +14,8 @@ @interface RamblerViperModuleFactory : NSObject - (instancetype)initWithStoryboard:(UIStoryboard*)storyboard andRestorationId:(NSString*)restorationId; +- (instancetype)initWithViewHandler:(id(^)(void))viewHandler; + @property (nonatomic,strong,readonly) UIStoryboard *storyboard; @property (nonatomic,strong,readonly) NSString* restorationId; diff --git a/Code/IntermoduleDataTransfer/RamblerViperModuleFactory.m b/Code/IntermoduleDataTransfer/RamblerViperModuleFactory.m index 22e64e4..d3d3fb6 100644 --- a/Code/IntermoduleDataTransfer/RamblerViperModuleFactory.m +++ b/Code/IntermoduleDataTransfer/RamblerViperModuleFactory.m @@ -12,6 +12,7 @@ @interface RamblerViperModuleFactory () @property (nonatomic,strong) UIStoryboard *storyboard; @property (nonatomic,strong) NSString* restorationId; +@property (nonatomic,copy) id(^viewHandler)(void); @end @@ -26,9 +27,21 @@ - (instancetype)initWithStoryboard:(UIStoryboard*)storyboard andRestorationId:(N return self; } +- (instancetype)initWithViewHandler:(id(^)(void))viewHandler { + self = [super init]; + if (self) { + self.viewHandler = viewHandler; + } + return self; +} + #pragma mark - RDSModuleFactoryProtocol - (__nullable id)instantiateModuleTransitionHandler { + if (self.viewHandler) { + return self.viewHandler(); + } + id destinationViewController = [self.storyboard instantiateViewControllerWithIdentifier:self.restorationId]; return destinationViewController; }