Browse Source

Fixes broken modals animations, Closes #5036 (#5098)

Yogev Ben David 5 years ago
parent
commit
42e26d77b8
No account linked to committer's email address

+ 1
- 1
lib/ios/RNNCommandsHandler.m View File

@@ -250,7 +250,7 @@ static NSString* const setDefaultOptions	= @"setDefaultOptions";
250 250
 	UIViewController *newVc = [_controllerFactory createLayout:layout];
251 251
 	
252 252
 	[newVc renderTreeAndWait:[newVc.resolveOptions.animations.showModal.waitForRender getWithDefaultValue:NO] perform:^{
253
-		[_modalManager showModal:newVc animated:[newVc.getCurrentChild.resolveOptions.animations.showModal.enable getWithDefaultValue:YES] hasCustomAnimation:newVc.getCurrentChild.resolveOptions.animations.showModal.hasCustomAnimation completion:^(NSString *componentId) {
253
+		[_modalManager showModal:newVc animated:[newVc.resolveOptions.animations.showModal.enable getWithDefaultValue:YES] hasCustomAnimation:newVc.resolveOptions.animations.showModal.hasCustomAnimation completion:^(NSString *componentId) {
254 254
 			[_eventEmitter sendOnNavigationCommandCompletion:showModal commandId:commandId params:@{@"layout": layout}];
255 255
 			completion(newVc.layoutInfo.componentId);
256 256
 		}];

+ 19
- 1
lib/ios/ReactNativeNavigationTests/RNNCommandsHandlerTest.m View File

@@ -42,6 +42,7 @@
42 42
 @interface RNNCommandsHandlerTest : XCTestCase
43 43
 
44 44
 @property (nonatomic, strong) RNNCommandsHandler* uut;
45
+@property (nonatomic, strong) id modalManager;
45 46
 @property (nonatomic, strong) RNNRootViewController* vc1;
46 47
 @property (nonatomic, strong) RNNRootViewController* vc2;
47 48
 @property (nonatomic, strong) RNNRootViewController* vc3;
@@ -61,8 +62,9 @@
61 62
 	self.mainWindow = [OCMockObject partialMockForObject:[UIWindow new]];
62 63
 	self.eventEmmiter = [OCMockObject partialMockForObject:[RNNEventEmitter new]];
63 64
 	self.overlayManager = [OCMockObject partialMockForObject:[RNNOverlayManager new]];
65
+	self.modalManager = [OCMockObject partialMockForObject:[RNNModalManager new]];
64 66
 	self.controllerFactory = [OCMockObject partialMockForObject:[[RNNControllerFactory alloc] initWithRootViewCreator:nil eventEmitter:self.eventEmmiter store:nil componentRegistry:nil andBridge:nil]];
65
-	self.uut = [[RNNCommandsHandler alloc] initWithControllerFactory:self.controllerFactory eventEmitter:self.eventEmmiter stackManager:[RNNNavigationStackManager new] modalManager:[RNNModalManager new] overlayManager:self.overlayManager mainWindow:_mainWindow];
67
+	self.uut = [[RNNCommandsHandler alloc] initWithControllerFactory:self.controllerFactory eventEmitter:self.eventEmmiter stackManager:[RNNNavigationStackManager new] modalManager:self.modalManager overlayManager:self.overlayManager mainWindow:_mainWindow];
66 68
 	self.vc1 = [RNNRootViewController new];
67 69
 	self.vc2 = [RNNRootViewController new];
68 70
 	self.vc3 = [RNNRootViewController new];
@@ -313,4 +315,20 @@
313 315
 	[mockedVC verify];
314 316
 }
315 317
 
318
+- (void)testShowModal_shouldShowAnimated {
319
+	[self.uut setReadyToReceiveCommands:true];
320
+	self.vc1.options = [[RNNNavigationOptions alloc] initEmptyOptions];
321
+	self.vc1.options.animations.showModal.enable = [[Bool alloc] initWithBOOL:YES];
322
+	
323
+	id mockedVC = [OCMockObject partialMockForObject:self.vc1];
324
+	OCMStub([self.controllerFactory createLayout:[OCMArg any]]).andReturn(mockedVC);
325
+	
326
+	[[self.modalManager expect] showModal:mockedVC animated:YES hasCustomAnimation:NO completion:[OCMArg any]];
327
+	[self.uut showModal:@{} commandId:@"showModal" completion:^(NSString *componentId) {
328
+		
329
+	}];
330
+	[self.modalManager verify];
331
+}
332
+
333
+
316 334
 @end