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
 	UIViewController *newVc = [_controllerFactory createLayout:layout];
250
 	UIViewController *newVc = [_controllerFactory createLayout:layout];
251
 	
251
 	
252
 	[newVc renderTreeAndWait:[newVc.resolveOptions.animations.showModal.waitForRender getWithDefaultValue:NO] perform:^{
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
 			[_eventEmitter sendOnNavigationCommandCompletion:showModal commandId:commandId params:@{@"layout": layout}];
254
 			[_eventEmitter sendOnNavigationCommandCompletion:showModal commandId:commandId params:@{@"layout": layout}];
255
 			completion(newVc.layoutInfo.componentId);
255
 			completion(newVc.layoutInfo.componentId);
256
 		}];
256
 		}];

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

42
 @interface RNNCommandsHandlerTest : XCTestCase
42
 @interface RNNCommandsHandlerTest : XCTestCase
43
 
43
 
44
 @property (nonatomic, strong) RNNCommandsHandler* uut;
44
 @property (nonatomic, strong) RNNCommandsHandler* uut;
45
+@property (nonatomic, strong) id modalManager;
45
 @property (nonatomic, strong) RNNRootViewController* vc1;
46
 @property (nonatomic, strong) RNNRootViewController* vc1;
46
 @property (nonatomic, strong) RNNRootViewController* vc2;
47
 @property (nonatomic, strong) RNNRootViewController* vc2;
47
 @property (nonatomic, strong) RNNRootViewController* vc3;
48
 @property (nonatomic, strong) RNNRootViewController* vc3;
61
 	self.mainWindow = [OCMockObject partialMockForObject:[UIWindow new]];
62
 	self.mainWindow = [OCMockObject partialMockForObject:[UIWindow new]];
62
 	self.eventEmmiter = [OCMockObject partialMockForObject:[RNNEventEmitter new]];
63
 	self.eventEmmiter = [OCMockObject partialMockForObject:[RNNEventEmitter new]];
63
 	self.overlayManager = [OCMockObject partialMockForObject:[RNNOverlayManager new]];
64
 	self.overlayManager = [OCMockObject partialMockForObject:[RNNOverlayManager new]];
65
+	self.modalManager = [OCMockObject partialMockForObject:[RNNModalManager new]];
64
 	self.controllerFactory = [OCMockObject partialMockForObject:[[RNNControllerFactory alloc] initWithRootViewCreator:nil eventEmitter:self.eventEmmiter store:nil componentRegistry:nil andBridge:nil]];
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
 	self.vc1 = [RNNRootViewController new];
68
 	self.vc1 = [RNNRootViewController new];
67
 	self.vc2 = [RNNRootViewController new];
69
 	self.vc2 = [RNNRootViewController new];
68
 	self.vc3 = [RNNRootViewController new];
70
 	self.vc3 = [RNNRootViewController new];
313
 	[mockedVC verify];
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
 @end
334
 @end