Browse Source

removed componentLifecycle events and navigationCommands event (#2636)

yogevbd 7 years ago
parent
commit
95f2560414
No account linked to committer's email address

+ 0
- 9
lib/ios/RNNCommandsHandler.m View File

65
 	
65
 	
66
 	UIViewController<RNNRootViewProtocol> *newVc = [_controllerFactory createLayoutAndSaveToStore:layout];
66
 	UIViewController<RNNRootViewProtocol> *newVc = [_controllerFactory createLayoutAndSaveToStore:layout];
67
 	[_navigationStackManager push:newVc onTop:componentId completion:^{
67
 	[_navigationStackManager push:newVc onTop:componentId completion:^{
68
-		[_controllerFactory.eventEmitter sendNavigationEvent:[RNNNavigationEvent create:kPush fromComponent:componentId toComponent:newVc.componentId]];
69
 		completion();
68
 		completion();
70
 	}];
69
 	}];
71
 }
70
 }
74
 	[self assertReady];
73
 	[self assertReady];
75
 	[CATransaction begin];
74
 	[CATransaction begin];
76
 	[CATransaction setCompletionBlock:^{
75
 	[CATransaction setCompletionBlock:^{
77
-		[_controllerFactory.eventEmitter sendNavigationEvent:[RNNNavigationEvent create:kPop fromComponent:nil toComponent:componentId]];
78
 		completion();
76
 		completion();
79
 	}];
77
 	}];
80
 	
78
 	
97
 	[self assertReady];
95
 	[self assertReady];
98
 	[CATransaction begin];
96
 	[CATransaction begin];
99
 	[CATransaction setCompletionBlock:^{
97
 	[CATransaction setCompletionBlock:^{
100
-		[_controllerFactory.eventEmitter sendNavigationEvent:[RNNNavigationEvent create:kPopTo fromComponent:nil toComponent:componentId]];
101
 		completion();
98
 		completion();
102
 	}];
99
 	}];
103
 	
100
 	
110
 	[self assertReady];
107
 	[self assertReady];
111
 	[CATransaction begin];
108
 	[CATransaction begin];
112
 	[CATransaction setCompletionBlock:^{
109
 	[CATransaction setCompletionBlock:^{
113
-		[_controllerFactory.eventEmitter sendNavigationEvent:[RNNNavigationEvent create:kPopToRoot fromComponent:componentId toComponent:nil]];
114
 		completion();
110
 		completion();
115
 	}];
111
 	}];
116
 	
112
 	
124
 	
120
 	
125
 	UIViewController<RNNRootViewProtocol> *newVc = [_controllerFactory createLayoutAndSaveToStore:layout];
121
 	UIViewController<RNNRootViewProtocol> *newVc = [_controllerFactory createLayoutAndSaveToStore:layout];
126
 	[_modalManager showModal:newVc completion:^{
122
 	[_modalManager showModal:newVc completion:^{
127
-		[_controllerFactory.eventEmitter sendNavigationEvent:[RNNNavigationEvent create:kShowModal fromComponent:nil toComponent:newVc.componentId]];
128
 		completion();
123
 		completion();
129
 	}];
124
 	}];
130
 }
125
 }
133
 	[self assertReady];
128
 	[self assertReady];
134
 	[CATransaction begin];
129
 	[CATransaction begin];
135
 	[CATransaction setCompletionBlock:^{
130
 	[CATransaction setCompletionBlock:^{
136
-		[_controllerFactory.eventEmitter sendNavigationEvent:[RNNNavigationEvent create:kDismissModal fromComponent:componentId toComponent:nil]];
137
 		completion();
131
 		completion();
138
 	}];
132
 	}];
139
 	
133
 	
146
 	[self assertReady];
140
 	[self assertReady];
147
 	[CATransaction begin];
141
 	[CATransaction begin];
148
 	[CATransaction setCompletionBlock:^{
142
 	[CATransaction setCompletionBlock:^{
149
-		[_controllerFactory.eventEmitter sendNavigationEvent:[RNNNavigationEvent create:kDismissAllModals fromComponent:nil toComponent:nil]];
150
 		completion();
143
 		completion();
151
 	}];
144
 	}];
152
 	
145
 	
159
 	[self assertReady];
152
 	[self assertReady];
160
 	UIViewController<RNNRootViewProtocol>* overlayVC = [_controllerFactory createOverlay:layout];
153
 	UIViewController<RNNRootViewProtocol>* overlayVC = [_controllerFactory createOverlay:layout];
161
 	[_overlayManager showOverlay:overlayVC completion:^{
154
 	[_overlayManager showOverlay:overlayVC completion:^{
162
-		[_controllerFactory.eventEmitter sendNavigationEvent:[RNNNavigationEvent create:kShowOverlay fromComponent:nil toComponent:overlayVC.componentId]];
163
 		completion();
155
 		completion();
164
 	}];
156
 	}];
165
 }
157
 }
167
 - (void)dismissOverlay:(NSString*)componentId completion:(RNNTransitionCompletionBlock)completion {
159
 - (void)dismissOverlay:(NSString*)componentId completion:(RNNTransitionCompletionBlock)completion {
168
 	[self assertReady];
160
 	[self assertReady];
169
 	[_overlayManager dismissOverlay:componentId completion:^{	
161
 	[_overlayManager dismissOverlay:componentId completion:^{	
170
-		[_controllerFactory.eventEmitter sendNavigationEvent:[RNNNavigationEvent create:kDismissOverlay fromComponent:componentId toComponent:nil]];
171
 		completion();
162
 		completion();
172
 	}];
163
 	}];
173
 }
164
 }

+ 0
- 3
lib/ios/RNNEventEmitter.h View File

5
 #import <React/RCTBridgeModule.h>
5
 #import <React/RCTBridgeModule.h>
6
 
6
 
7
 #import "RNNNavigationEvent.h"
7
 #import "RNNNavigationEvent.h"
8
-#import "RNNComponentLifecycleEvent.h"
9
 
8
 
10
 @interface RNNEventEmitter : RCTEventEmitter <RCTBridgeModule>
9
 @interface RNNEventEmitter : RCTEventEmitter <RCTBridgeModule>
11
 
10
 
19
 
18
 
20
 -(void)sendNavigationEvent:(RNNNavigationEvent*)navigationEvent;
19
 -(void)sendNavigationEvent:(RNNNavigationEvent*)navigationEvent;
21
 
20
 
22
--(void)sendLifecycleEvent:(RNNComponentLifecycleEvent *)navigationEvent;
23
-
24
 @end
21
 @end

+ 1
- 6
lib/ios/RNNEventEmitter.m View File

12
 static NSString* const componentDidDisappear	= @"RNN.componentDidDisappear";
12
 static NSString* const componentDidDisappear	= @"RNN.componentDidDisappear";
13
 static NSString* const onNavigationButtonPressed	= @"RNN.navigationButtonPressed";
13
 static NSString* const onNavigationButtonPressed	= @"RNN.navigationButtonPressed";
14
 static NSString* const navigationCommands	= @"RNN.navigationCommands";
14
 static NSString* const navigationCommands	= @"RNN.navigationCommands";
15
-static NSString* const componentLifecycle	= @"RNN.componentLifecycle";
16
 
15
 
17
 -(NSArray<NSString *> *)supportedEvents {
16
 -(NSArray<NSString *> *)supportedEvents {
18
-	return @[onAppLaunched, componentDidAppear, componentDidDisappear, onNavigationButtonPressed, navigationCommands, componentLifecycle];
17
+	return @[onAppLaunched, componentDidAppear, componentDidDisappear, onNavigationButtonPressed, navigationCommands];
19
 }
18
 }
20
 
19
 
21
 # pragma mark public
20
 # pragma mark public
32
 	[self send:navigationCommands body:navigationEvent.body];
31
 	[self send:navigationCommands body:navigationEvent.body];
33
 }
32
 }
34
 
33
 
35
--(void)sendLifecycleEvent:(RNNComponentLifecycleEvent *)navigationEvent {
36
-	[self send:componentLifecycle body:navigationEvent.body];
37
-}
38
-
39
 -(void)sendComponentDidAppear:(NSString *)componentId {
34
 -(void)sendComponentDidAppear:(NSString *)componentId {
40
 	[self send:componentDidAppear body:componentId];
35
 	[self send:componentDidAppear body:componentId];
41
 }
36
 }

+ 0
- 8
lib/ios/RNNRootViewController.m View File

37
 -(void)viewWillAppear:(BOOL)animated{
37
 -(void)viewWillAppear:(BOOL)animated{
38
 	[super viewWillAppear:animated];
38
 	[super viewWillAppear:animated];
39
 	[self.options applyOn:self];
39
 	[self.options applyOn:self];
40
-	[self sendLifecycleEvent:kDidMount];
41
 }
40
 }
42
 
41
 
43
 -(void)viewDidAppear:(BOOL)animated {
42
 -(void)viewDidAppear:(BOOL)animated {
44
 	[super viewDidAppear:animated];
43
 	[super viewDidAppear:animated];
45
 	[self.eventEmitter sendComponentDidAppear:self.componentId];
44
 	[self.eventEmitter sendComponentDidAppear:self.componentId];
46
-	[self sendLifecycleEvent:kDidAppear];
47
 }
45
 }
48
 
46
 
49
 - (void)viewWillDisappear:(BOOL)animated {
47
 - (void)viewWillDisappear:(BOOL)animated {
50
 	[super viewWillDisappear:animated];
48
 	[super viewWillDisappear:animated];
51
-	[self sendLifecycleEvent:kWillUnmount];
52
 }
49
 }
53
 
50
 
54
 -(void)viewDidDisappear:(BOOL)animated {
51
 -(void)viewDidDisappear:(BOOL)animated {
55
 	[super viewDidDisappear:animated];
52
 	[super viewDidDisappear:animated];
56
 	[self.eventEmitter sendComponentDidDisappear:self.componentId];
53
 	[self.eventEmitter sendComponentDidDisappear:self.componentId];
57
-	[self sendLifecycleEvent:kDidDisappear];
58
 }
54
 }
59
 
55
 
60
 - (void)viewDidLoad {
56
 - (void)viewDidLoad {
61
 	[super viewDidLoad];
57
 	[super viewDidLoad];
62
 }
58
 }
63
 
59
 
64
-- (void)sendLifecycleEvent:(LifecycleEvent)event {
65
-	[self.eventEmitter sendLifecycleEvent:[RNNComponentLifecycleEvent create:event componentName:self.componentName componentId:self.componentId]];
66
-}
67
-
68
 -(BOOL)isCustomTransitioned {
60
 -(BOOL)isCustomTransitioned {
69
 	return self.options.customTransition != nil;
61
 	return self.options.customTransition != nil;
70
 }
62
 }