Skip to content

Commit

Permalink
Fixes broken modals animations, Closes #5036 (#5098)
Browse files Browse the repository at this point in the history
  • Loading branch information
yogevbd authored May 12, 2019
1 parent 42fd86d commit 42e26d7
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 2 deletions.
2 changes: 1 addition & 1 deletion lib/ios/RNNCommandsHandler.m
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@ - (void)showModal:(NSDictionary*)layout commandId:(NSString *)commandId completi
UIViewController *newVc = [_controllerFactory createLayout:layout];

[newVc renderTreeAndWait:[newVc.resolveOptions.animations.showModal.waitForRender getWithDefaultValue:NO] perform:^{
[_modalManager showModal:newVc animated:[newVc.getCurrentChild.resolveOptions.animations.showModal.enable getWithDefaultValue:YES] hasCustomAnimation:newVc.getCurrentChild.resolveOptions.animations.showModal.hasCustomAnimation completion:^(NSString *componentId) {
[_modalManager showModal:newVc animated:[newVc.resolveOptions.animations.showModal.enable getWithDefaultValue:YES] hasCustomAnimation:newVc.resolveOptions.animations.showModal.hasCustomAnimation completion:^(NSString *componentId) {
[_eventEmitter sendOnNavigationCommandCompletion:showModal commandId:commandId params:@{@"layout": layout}];
completion(newVc.layoutInfo.componentId);
}];
Expand Down
20 changes: 19 additions & 1 deletion lib/ios/ReactNativeNavigationTests/RNNCommandsHandlerTest.m
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ @implementation MockUINavigationController
@interface RNNCommandsHandlerTest : XCTestCase

@property (nonatomic, strong) RNNCommandsHandler* uut;
@property (nonatomic, strong) id modalManager;
@property (nonatomic, strong) RNNRootViewController* vc1;
@property (nonatomic, strong) RNNRootViewController* vc2;
@property (nonatomic, strong) RNNRootViewController* vc3;
Expand All @@ -61,8 +62,9 @@ - (void)setUp {
self.mainWindow = [OCMockObject partialMockForObject:[UIWindow new]];
self.eventEmmiter = [OCMockObject partialMockForObject:[RNNEventEmitter new]];
self.overlayManager = [OCMockObject partialMockForObject:[RNNOverlayManager new]];
self.modalManager = [OCMockObject partialMockForObject:[RNNModalManager new]];
self.controllerFactory = [OCMockObject partialMockForObject:[[RNNControllerFactory alloc] initWithRootViewCreator:nil eventEmitter:self.eventEmmiter store:nil componentRegistry:nil andBridge:nil]];
self.uut = [[RNNCommandsHandler alloc] initWithControllerFactory:self.controllerFactory eventEmitter:self.eventEmmiter stackManager:[RNNNavigationStackManager new] modalManager:[RNNModalManager new] overlayManager:self.overlayManager mainWindow:_mainWindow];
self.uut = [[RNNCommandsHandler alloc] initWithControllerFactory:self.controllerFactory eventEmitter:self.eventEmmiter stackManager:[RNNNavigationStackManager new] modalManager:self.modalManager overlayManager:self.overlayManager mainWindow:_mainWindow];
self.vc1 = [RNNRootViewController new];
self.vc2 = [RNNRootViewController new];
self.vc3 = [RNNRootViewController new];
Expand Down Expand Up @@ -313,4 +315,20 @@ - (void)testSetRoot_waitForRenderFalse {
[mockedVC verify];
}

- (void)testShowModal_shouldShowAnimated {
[self.uut setReadyToReceiveCommands:true];
self.vc1.options = [[RNNNavigationOptions alloc] initEmptyOptions];
self.vc1.options.animations.showModal.enable = [[Bool alloc] initWithBOOL:YES];

id mockedVC = [OCMockObject partialMockForObject:self.vc1];
OCMStub([self.controllerFactory createLayout:[OCMArg any]]).andReturn(mockedVC);

[[self.modalManager expect] showModal:mockedVC animated:YES hasCustomAnimation:NO completion:[OCMArg any]];
[self.uut showModal:@{} commandId:@"showModal" completion:^(NSString *componentId) {

}];
[self.modalManager verify];
}


@end

0 comments on commit 42e26d7

Please sign in to comment.