Skip to content

Commit

Permalink
Merge pull request #15 from rock88/master
Browse files Browse the repository at this point in the history
Another implementation of view factory without storyboard
  • Loading branch information
etolstoy authored Jul 19, 2016
2 parents 21936ba + ad61523 commit e6dc3d3
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
2 changes: 2 additions & 0 deletions Code/IntermoduleDataTransfer/RamblerViperModuleFactory.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
@interface RamblerViperModuleFactory : NSObject<RamblerViperModuleFactoryProtocol>

- (instancetype)initWithStoryboard:(UIStoryboard*)storyboard andRestorationId:(NSString*)restorationId;
- (instancetype)initWithViewHandler:(id<RamblerViperModuleTransitionHandlerProtocol>(^)(void))viewHandler;

@property (nonatomic,strong,readonly) UIStoryboard *storyboard;
@property (nonatomic,strong,readonly) NSString* restorationId;

Expand Down
13 changes: 13 additions & 0 deletions Code/IntermoduleDataTransfer/RamblerViperModuleFactory.m
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ @interface RamblerViperModuleFactory ()

@property (nonatomic,strong) UIStoryboard *storyboard;
@property (nonatomic,strong) NSString* restorationId;
@property (nonatomic,copy) id<RamblerViperModuleTransitionHandlerProtocol>(^viewHandler)(void);

@end

Expand All @@ -26,9 +27,21 @@ - (instancetype)initWithStoryboard:(UIStoryboard*)storyboard andRestorationId:(N
return self;
}

- (instancetype)initWithViewHandler:(id<RamblerViperModuleTransitionHandlerProtocol>(^)(void))viewHandler {
self = [super init];
if (self) {
self.viewHandler = viewHandler;
}
return self;
}

#pragma mark - RDSModuleFactoryProtocol

- (__nullable id<RamblerViperModuleTransitionHandlerProtocol>)instantiateModuleTransitionHandler {
if (self.viewHandler) {
return self.viewHandler();
}

id<RamblerViperModuleTransitionHandlerProtocol> destinationViewController = [self.storyboard instantiateViewControllerWithIdentifier:self.restorationId];
return destinationViewController;
}
Expand Down

0 comments on commit e6dc3d3

Please sign in to comment.