Browse Source

handle buttonPressed event in rootViewController

yogevbd 6 years ago
parent
commit
26616fc4cc

+ 1
- 5
lib/ios/RNNNavigationButtons.m View File

93
 		return nil;
93
 		return nil;
94
 	}
94
 	}
95
 	
95
 	
96
-	barButtonItem.target = self;
96
+	barButtonItem.target = self.viewController;
97
 	barButtonItem.action = @selector(onButtonPress:);
97
 	barButtonItem.action = @selector(onButtonPress:);
98
 	
98
 	
99
 	NSNumber *enabled = [self getValue:dictionary[@"enabled"] withDefault:defaultStyle.enabled];
99
 	NSNumber *enabled = [self getValue:dictionary[@"enabled"] withDefault:defaultStyle.enabled];
171
 	return value ? value : defaultValue;
171
 	return value ? value : defaultValue;
172
 }
172
 }
173
 
173
 
174
--(void)onButtonPress:(RNNUIBarButtonItem*)barButtonItem {
175
-	[self.viewController.eventEmitter sendOnNavigationButtonPressed:self.viewController.componentId buttonId:barButtonItem.buttonId];
176
-}
177
-
178
 @end
174
 @end

+ 8
- 5
lib/ios/RNNRootViewController.h View File

5
 #import "RNNEventEmitter.h"
5
 #import "RNNEventEmitter.h"
6
 #import "RNNNavigationOptions.h"
6
 #import "RNNNavigationOptions.h"
7
 #import "RNNAnimator.h"
7
 #import "RNNAnimator.h"
8
+#import "RNNUIBarButtonItem.h"
8
 
9
 
9
 typedef void (^RNNReactViewReadyCompletionBlock)(void);
10
 typedef void (^RNNReactViewReadyCompletionBlock)(void);
10
 
11
 
19
 
20
 
20
 
21
 
21
 - (instancetype)initWithName:(NSString*)name
22
 - (instancetype)initWithName:(NSString*)name
22
-				withOptions:(RNNNavigationOptions*)options
23
-			withComponentId:(NSString*)componentId
24
-			rootViewCreator:(id<RNNRootViewCreator>)creator
25
-			   eventEmitter:(RNNEventEmitter*)eventEmitter
26
-		  isExternalComponent:(BOOL)isExternalComponent;
23
+				 withOptions:(RNNNavigationOptions*)options
24
+			 withComponentId:(NSString*)componentId
25
+			 rootViewCreator:(id<RNNRootViewCreator>)creator
26
+				eventEmitter:(RNNEventEmitter*)eventEmitter
27
+		 isExternalComponent:(BOOL)isExternalComponent;
27
 
28
 
28
 - (void)applyTopTabsOptions;
29
 - (void)applyTopTabsOptions;
29
 - (BOOL)isCustomViewController;
30
 - (BOOL)isCustomViewController;
33
 - (void)applyModalOptions;
34
 - (void)applyModalOptions;
34
 - (void)optionsUpdated;
35
 - (void)optionsUpdated;
35
 
36
 
37
+-(void)onButtonPress:(RNNUIBarButtonItem *)barButtonItem;
38
+
36
 @end
39
 @end

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

361
 	return actions;
361
 	return actions;
362
 }
362
 }
363
 
363
 
364
+-(void)onButtonPress:(RNNUIBarButtonItem *)barButtonItem {
365
+	[self.eventEmitter sendOnNavigationButtonPressed:self.componentId buttonId:barButtonItem.buttonId];
366
+}
367
+
364
 /**
368
 /**
365
  *	fix for #877, #878
369
  *	fix for #877, #878
366
  */
370
  */