yogevbd 6 anos atrás
pai
commit
3cb50f9a88

+ 10
- 1
lib/ios/RNNNavigationButtons.m Ver arquivo

@@ -35,7 +35,8 @@
35 35
 
36 36
 -(void)setButtons:(NSArray*)buttons side:(NSString*)side animated:(BOOL)animated {
37 37
 	NSMutableArray *barButtonItems = [NSMutableArray new];
38
-	for (NSDictionary *button in buttons) {
38
+	NSArray* resolvedButtons = [self resolveButtons:buttons];
39
+	for (NSDictionary *button in resolvedButtons) {
39 40
 		RNNUIBarButtonItem* barButtonItem = [self buildButton:button];
40 41
 		if(barButtonItem) {
41 42
 			[barButtonItems addObject:barButtonItem];
@@ -53,6 +54,14 @@
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 65
 -(RNNUIBarButtonItem*)buildButton: (NSDictionary*)dictionary {
57 66
 	NSString* buttonId = dictionary[@"id"];
58 67
 	NSString* title = dictionary[@"title"];

+ 2
- 2
playground/src/screens/OptionsScreen.js Ver arquivo

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