yogevbd 6 years ago
parent
commit
3cb50f9a88
2 changed files with 12 additions and 3 deletions
  1. 10
    1
      lib/ios/RNNNavigationButtons.m
  2. 2
    2
      playground/src/screens/OptionsScreen.js

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

35
 
35
 
36
 -(void)setButtons:(NSArray*)buttons side:(NSString*)side animated:(BOOL)animated {
36
 -(void)setButtons:(NSArray*)buttons side:(NSString*)side animated:(BOOL)animated {
37
 	NSMutableArray *barButtonItems = [NSMutableArray new];
37
 	NSMutableArray *barButtonItems = [NSMutableArray new];
38
-	for (NSDictionary *button in buttons) {
38
+	NSArray* resolvedButtons = [self resolveButtons:buttons];
39
+	for (NSDictionary *button in resolvedButtons) {
39
 		RNNUIBarButtonItem* barButtonItem = [self buildButton:button];
40
 		RNNUIBarButtonItem* barButtonItem = [self buildButton:button];
40
 		if(barButtonItem) {
41
 		if(barButtonItem) {
41
 			[barButtonItems addObject:barButtonItem];
42
 			[barButtonItems addObject:barButtonItem];
53
 	}
54
 	}
54
 }
55
 }
55
 
56
 
57
+- (NSArray *)resolveButtons:(id)buttons {
58
+	if ([buttons isKindOfClass:[NSArray class]]) {
59
+		return buttons;
60
+	} else {
61
+		return @[buttons];
62
+	}
63
+}
64
+
56
 -(RNNUIBarButtonItem*)buildButton: (NSDictionary*)dictionary {
65
 -(RNNUIBarButtonItem*)buildButton: (NSDictionary*)dictionary {
57
 	NSString* buttonId = dictionary[@"id"];
66
 	NSString* buttonId = dictionary[@"id"];
58
 	NSString* title = dictionary[@"title"];
67
 	NSString* title = dictionary[@"title"];

+ 2
- 2
playground/src/screens/OptionsScreen.js View File

81
             color: 'red'
81
             color: 'red'
82
           }
82
           }
83
         ],
83
         ],
84
-        leftButtons: [{
84
+        leftButtons: {
85
           id: BUTTON_LEFT,
85
           id: BUTTON_LEFT,
86
           testID: BUTTON_LEFT,
86
           testID: BUTTON_LEFT,
87
           icon: require('../../img/navicon_add.png'),
87
           icon: require('../../img/navicon_add.png'),
88
           title: 'Left',
88
           title: 'Left',
89
           color: 'purple'
89
           color: 'purple'
90
-        }]
90
+        }
91
       },
91
       },
92
       fab: {
92
       fab: {
93
         id: FAB,
93
         id: FAB,