Преглед изворни кода

Fix sending dismissed modal event when dismissing modal by swiping gesture (#5747)

* Fix dismissed modal event by swiping down gesture

* Fix typescript
Yogev Ben David пре 5 година
родитељ
комит
4cb0e98a67
No account linked to committer's email address

+ 1
- 0
lib/ios/RNNModalManager.m Прегледај датотеку

@@ -124,6 +124,7 @@
124 124
 
125 125
 - (void)presentationControllerDidDismiss:(UIPresentationController *)presentationController {
126 126
 	[_presentedModals removeObject:presentationController.presentedViewController];
127
+    [_delegate dismissedModal:presentationController.presentedViewController];
127 128
 }
128 129
 
129 130
 -(UIViewController*)topPresentedVC {

+ 2
- 2
lib/src/events/ComponentEventsObserver.test.tsx Прегледај датотеку

@@ -175,9 +175,9 @@ describe('ComponentEventsObserver', () => {
175 175
     expect(navigationButtonPressedFn).toHaveBeenCalledTimes(1);
176 176
     expect(navigationButtonPressedFn).toHaveBeenCalledWith({ buttonId: 'myButtonId', componentId: 'myCompId' });
177 177
 
178
-    uut.notifyModalDismissed({ componentId: 'myCompId' });
178
+    uut.notifyModalDismissed({ componentId: 'myCompId', modalsDismissed: 1 });
179 179
     expect(modalDismissedFn).toHaveBeenCalledTimes(1);
180
-    expect(modalDismissedFn).toHaveBeenLastCalledWith({ componentId: 'myCompId' })
180
+    expect(modalDismissedFn).toHaveBeenLastCalledWith({ componentId: 'myCompId', modalsDismissed: 1 })
181 181
 
182 182
     uut.notifySearchBarUpdated({ componentId: 'myCompId', text: 'theText', isFocused: true });
183 183
     expect(searchBarUpdatedFn).toHaveBeenCalledTimes(1);

+ 22
- 0
playground/ios/NavigationTests/RNNModalManagerTest.m Прегледај датотеку

@@ -1,4 +1,5 @@
1 1
 #import <XCTest/XCTest.h>
2
+#import <OCMock/OCMock.h>
2 3
 #import "RNNModalManager.h"
3 4
 #import "RNNComponentViewController.h"
4 5
 
@@ -107,6 +108,27 @@
107 108
 	XCTAssertTrue(_modalManager.topPresentedVC.presentViewControllerCalls == 1);
108 109
 }
109 110
 
111
+- (void)testDismissModal_ShouldInvokeDelegateDismissedModal {
112
+	id mockDelegate = [OCMockObject mockForProtocol:@protocol(RNNModalManagerDelegate)];
113
+	_modalManager.delegate = mockDelegate;
114
+	[_modalManager showModal:_vc1 animated:NO completion:nil];
115
+	
116
+	[[mockDelegate expect] dismissedModal:_vc1];
117
+	[_modalManager dismissModal:_vc1 completion:nil];
118
+	[mockDelegate verify];
119
+}
120
+
121
+- (void)testPresentationControllerDidDismiss_ShouldInvokeDelegateDismissedModal {
122
+	id mockDelegate = [OCMockObject mockForProtocol:@protocol(RNNModalManagerDelegate)];
123
+	_modalManager.delegate = mockDelegate;
124
+	
125
+	UIPresentationController* presentationController = [[UIPresentationController alloc] initWithPresentedViewController:_vc2 presentingViewController:_vc1];
126
+	
127
+	[[mockDelegate expect] dismissedModal:_vc2];
128
+	[_modalManager presentationControllerDidDismiss:presentationController];
129
+	[mockDelegate verify];
130
+}
131
+
110 132
 #pragma mark RNNModalManagerDelegate
111 133
 
112 134
 - (void)dismissedMultipleModals:(NSArray *)viewControllers {