Selaa lähdekoodia

Apply button options on viewController init

yogevbd 6 vuotta sitten
vanhempi
commit
be2933f913

+ 4
- 4
lib/ios/RNNViewControllerPresenter.m Näytä tiedosto

@@ -31,10 +31,6 @@
31 31
 	if (options.topBar.searchBar.hasValue) {
32 32
 		[viewController rnn_setSearchBarWithPlaceholder:[options.topBar.searchBarPlaceholder getWithDefaultValue:@""]];
33 33
 	}
34
-	
35
-	if ((options.topBar.leftButtons || options.topBar.rightButtons)) {
36
-		[_navigationButtons applyLeftButtons:options.topBar.leftButtons rightButtons:options.topBar.rightButtons defaultLeftButtonStyle:options.topBar.leftButtonStyle defaultRightButtonStyle:options.topBar.rightButtonStyle];
37
-	}
38 34
 }
39 35
 
40 36
 - (void)applyOptionsOnInit:(RNNNavigationOptions *)options {
@@ -45,6 +41,10 @@
45 41
 	[viewController rnn_setModalTransitionStyle:[RCTConvert UIModalTransitionStyle:[options.modalTransitionStyle getWithDefaultValue:@"coverVertical"]]];
46 42
 	[viewController rnn_setDrawBehindTopBar:[options.topBar.drawBehind getWithDefaultValue:NO]];
47 43
 	[viewController rnn_setDrawBehindTabBar:[options.bottomTabs.drawBehind getWithDefaultValue:NO] || ![options.bottomTabs.visible getWithDefaultValue:YES]];
44
+	
45
+	if ((options.topBar.leftButtons || options.topBar.rightButtons)) {
46
+		[_navigationButtons applyLeftButtons:options.topBar.leftButtons rightButtons:options.topBar.rightButtons defaultLeftButtonStyle:options.topBar.leftButtonStyle defaultRightButtonStyle:options.topBar.rightButtonStyle];
47
+	}
48 48
 }
49 49
 
50 50
 - (void)mergeOptions:(RNNNavigationOptions *)newOptions currentOptions:(RNNNavigationOptions *)currentOptions defaultOptions:(RNNNavigationOptions *)defaultOptions {

+ 8
- 9
lib/ios/ReactNativeNavigationTests/RNNRootViewControllerTest.m Näytä tiedosto

@@ -414,8 +414,8 @@
414 414
 
415 415
 -(void)testRightButtonsWithTitle_withoutStyle {
416 416
 	self.options.topBar.rightButtons = @[@{@"id": @"testId", @"text": @"test"}];
417
-	__unused RNNNavigationController* nav = [self createNavigationController];
418
-	[self.uut viewWillAppear:false];
417
+	self.uut = [[RNNRootViewController alloc] initWithLayoutInfo:nil rootViewCreator:nil eventEmitter:nil presenter:[RNNViewControllerPresenter new] options:self.options defaultOptions:nil];
418
+	RNNNavigationController* nav = [[RNNNavigationController alloc] initWithLayoutInfo:nil childViewControllers:@[self.uut] options:nil defaultOptions:nil presenter:nil];
419 419
 
420 420
 	RNNUIBarButtonItem* button = (RNNUIBarButtonItem*)[nav.topViewController.navigationItem.rightBarButtonItems objectAtIndex:0];
421 421
 	NSString* expectedButtonId = @"testId";
@@ -429,8 +429,8 @@
429 429
 	NSNumber* inputColor = @(0xFFFF0000);
430 430
 
431 431
 	self.options.topBar.rightButtons = @[@{@"id": @"testId", @"text": @"test", @"enabled": @false, @"buttonColor": inputColor, @"buttonFontSize": @22, @"buttonFontWeight": @"800"}];
432
-	__unused RNNNavigationController* nav = [self createNavigationController];
433
-	[self.uut viewWillAppear:false];
432
+	self.uut = [[RNNRootViewController alloc] initWithLayoutInfo:nil rootViewCreator:nil eventEmitter:nil presenter:[RNNViewControllerPresenter new] options:self.options defaultOptions:nil];
433
+	RNNNavigationController* nav = [[RNNNavigationController alloc] initWithLayoutInfo:nil childViewControllers:@[self.uut] options:nil defaultOptions:nil presenter:nil];
434 434
 
435 435
 	RNNUIBarButtonItem* button = (RNNUIBarButtonItem*)[nav.topViewController.navigationItem.rightBarButtonItems objectAtIndex:0];
436 436
 	NSString* expectedButtonId = @"testId";
@@ -445,8 +445,8 @@
445 445
 
446 446
 -(void)testLeftButtonsWithTitle_withoutStyle {
447 447
 	self.options.topBar.leftButtons = @[@{@"id": @"testId", @"text": @"test"}];
448
-	__unused RNNNavigationController* nav = [self createNavigationController];
449
-	[self.uut viewWillAppear:false];
448
+	self.uut = [[RNNRootViewController alloc] initWithLayoutInfo:nil rootViewCreator:nil eventEmitter:nil presenter:[RNNViewControllerPresenter new] options:self.options defaultOptions:nil];
449
+	RNNNavigationController* nav = [[RNNNavigationController alloc] initWithLayoutInfo:nil childViewControllers:@[self.uut] options:nil defaultOptions:nil presenter:nil];
450 450
 
451 451
 	RNNUIBarButtonItem* button = (RNNUIBarButtonItem*)[nav.topViewController.navigationItem.leftBarButtonItems objectAtIndex:0];
452 452
 	NSString* expectedButtonId = @"testId";
@@ -460,9 +460,8 @@
460 460
 	NSNumber* inputColor = @(0xFFFF0000);
461 461
 
462 462
 	self.options.topBar.leftButtons = @[@{@"id": @"testId", @"text": @"test", @"enabled": @false, @"buttonColor": inputColor, @"buttonFontSize": @22, @"buttonFontWeight": @"800"}];
463
-	__unused RNNNavigationController* nav = [self createNavigationController];
464
-
465
-	[self.uut viewWillAppear:false];
463
+	self.uut = [[RNNRootViewController alloc] initWithLayoutInfo:nil rootViewCreator:nil eventEmitter:nil presenter:[RNNViewControllerPresenter new] options:self.options defaultOptions:nil];
464
+	RNNNavigationController* nav = [[RNNNavigationController alloc] initWithLayoutInfo:nil childViewControllers:@[self.uut] options:nil defaultOptions:nil presenter:nil];
466 465
 
467 466
 	RNNUIBarButtonItem* button = (RNNUIBarButtonItem*)[nav.topViewController.navigationItem.leftBarButtonItems objectAtIndex:0];
468 467
 	NSString* expectedButtonId = @"testId";