Browse Source

trying to fix multiple modal dismissal

Daniel Zlotin 7 years ago
parent
commit
853ed4aa17
4 changed files with 34 additions and 28 deletions
  1. 0
    1
      ios/RNNModalManager.m
  2. 0
    4
      ios/RNNReactRootViewCreator.m
  3. 11
    12
      ios/RNNRootViewController.m
  4. 23
    11
      ios/ReactNativeNavigation.m

+ 0
- 1
ios/RNNModalManager.m View File

27
 	[[_store pendingModalIdsToDismiss] removeAllObjects];
27
 	[[_store pendingModalIdsToDismiss] removeAllObjects];
28
 }
28
 }
29
 
29
 
30
-
31
 #pragma mark - private
30
 #pragma mark - private
32
 
31
 
33
 
32
 

+ 0
- 4
ios/RNNReactRootViewCreator.m View File

8
 
8
 
9
 @implementation RNNReactRootView
9
 @implementation RNNReactRootView
10
 
10
 
11
--(void)dealloc {
12
-	
13
-}
14
-
15
 @end
11
 @end
16
 
12
 
17
 @implementation RNNReactRootViewCreator {
13
 @implementation RNNReactRootViewCreator {

+ 11
- 12
ios/RNNRootViewController.m View File

17
 	
17
 	
18
 	self.view = [creator createRootView:self.containerName rootViewId:self.containerId];
18
 	self.view = [creator createRootView:self.containerName rootViewId:self.containerId];
19
 	
19
 	
20
-//	[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(onJsReload) name:RCTJavaScriptWillStartLoadingNotification object:nil];
20
+	[[NSNotificationCenter defaultCenter] addObserver:self
21
+											 selector:@selector(onJsReload)
22
+												 name:RCTJavaScriptWillStartLoadingNotification
23
+											   object:nil];
21
 	
24
 	
22
 	return self;
25
 	return self;
23
 }
26
 }
32
 	[self.eventEmitter sendContainerStop:self.containerId];
35
 	[self.eventEmitter sendContainerStop:self.containerId];
33
 }
36
 }
34
 
37
 
35
-///**
36
-// * fix for 
37
-// */
38
-//-(void)onJsReload {
39
-//	[[NSNotificationCenter defaultCenter] removeObserver:self];
40
-//	[[NSNotificationCenter defaultCenter] removeObserver:self.view];
41
-//	self.view = nil;
42
-//}
43
-
44
--(void)dealloc {
45
-	
38
+/**
39
+ *	fix for #877
40
+ */
41
+-(void)onJsReload {
42
+	[[NSNotificationCenter defaultCenter] removeObserver:self];
43
+	[[NSNotificationCenter defaultCenter] removeObserver:self.view];
44
+	self.view = nil;
46
 }
45
 }
47
 
46
 
48
 @end
47
 @end

+ 23
- 11
ios/ReactNativeNavigation.m View File

17
 @implementation ReactNativeNavigation {
17
 @implementation ReactNativeNavigation {
18
 	NSURL* _jsCodeLocation;
18
 	NSURL* _jsCodeLocation;
19
 	NSDictionary* _launchOptions;
19
 	NSDictionary* _launchOptions;
20
-	RNNStore* _store;
21
 	RCTBridge* _bridge;
20
 	RCTBridge* _bridge;
21
+	
22
+	RNNStore* _store;
23
+	
24
+	RNNCommandsHandler* _commandsHandler;
22
 }
25
 }
23
 
26
 
24
 # pragma mark - public API
27
 # pragma mark - public API
67
 	
70
 	
68
 	id<RNNRootViewCreator> rootViewCreator = [[RNNReactRootViewCreator alloc] initWithBridge:bridge];
71
 	id<RNNRootViewCreator> rootViewCreator = [[RNNReactRootViewCreator alloc] initWithBridge:bridge];
69
 	RNNControllerFactory *controllerFactory = [[RNNControllerFactory alloc] initWithRootViewCreator:rootViewCreator store:_store eventEmitter:eventEmitter];
72
 	RNNControllerFactory *controllerFactory = [[RNNControllerFactory alloc] initWithRootViewCreator:rootViewCreator store:_store eventEmitter:eventEmitter];
70
-	RNNCommandsHandler *commandsHandler = [[RNNCommandsHandler alloc] initWithStore:_store controllerFactory:controllerFactory];
71
-	RNNBridgeModule *bridgeModule = [[RNNBridgeModule alloc] initWithCommandsHandler:commandsHandler];
73
+	_commandsHandler = [[RNNCommandsHandler alloc] initWithStore:_store controllerFactory:controllerFactory];
74
+	RNNBridgeModule *bridgeModule = [[RNNBridgeModule alloc] initWithCommandsHandler:_commandsHandler];
72
 	
75
 	
73
 	return @[bridgeModule,eventEmitter];
76
 	return @[bridgeModule,eventEmitter];
74
 }
77
 }
76
 # pragma mark - js events
79
 # pragma mark - js events
77
 
80
 
78
 -(void)onJavaScriptWillLoad {
81
 -(void)onJavaScriptWillLoad {
79
-	[self resetRootViewControllerOnlyOnJSDevReload];
82
+	[self releaseBeforeJSReload];
80
 	[_store clean];
83
 	[_store clean];
81
 }
84
 }
82
 
85
 
102
 											   object:nil];
105
 											   object:nil];
103
 }
106
 }
104
 
107
 
105
--(void)resetRootViewControllerOnlyOnJSDevReload {
108
+-(void)releaseBeforeJSReload {
106
 #ifdef DEBUG
109
 #ifdef DEBUG
107
-	
108
-	if(![UIApplication.sharedApplication.delegate.window.rootViewController isKindOfClass:[RNNSplashScreen class]]) {
109
-		UIApplication.sharedApplication.delegate.window.rootViewController = nil;
110
-	}
111
-	
110
+//	if(![UIApplication.sharedApplication.delegate.window.rootViewController isKindOfClass:[RNNSplashScreen class]]) {
111
+//		[self releaseBeforeJsReload:UIApplication.sharedApplication.delegate.window.rootViewController];
112
+//	}
112
 #endif
113
 #endif
113
 }
114
 }
114
 
115
 
115
-
116
+//-(void)releaseBeforeJsReload:(UIViewController*)vc {
117
+//	if(!vc) return;
118
+//	
119
+//	for (UIViewController* child in vc.childViewControllers) {
120
+//		[self releaseBeforeJsReload:child];
121
+//	}
122
+//	[self releaseBeforeJsReload:vc.presentedViewController];
123
+//	
124
+//	[NSNotificationCenter.defaultCenter removeObserver:vc];
125
+//	[NSNotificationCenter.defaultCenter removeObserver:vc.view];
126
+//	vc.view = nil;
127
+//}
116
 
128
 
117
 @end
129
 @end