Browse Source

Fixes large title - #4192 (#4200)

Yogev Ben David 6 years ago
parent
commit
e5cf52f08c
No account linked to committer's email address

+ 3
- 1
lib/ios/RNNNavigationController.m View File

72
 		UIViewController *controller = self.viewControllers[self.viewControllers.count - 2];
72
 		UIViewController *controller = self.viewControllers[self.viewControllers.count - 2];
73
 		if ([controller isKindOfClass:[RNNRootViewController class]]) {
73
 		if ([controller isKindOfClass:[RNNRootViewController class]]) {
74
 			RNNRootViewController *rnnController = (RNNRootViewController *)controller;
74
 			RNNRootViewController *rnnController = (RNNRootViewController *)controller;
75
-			[self.presenter applyOptions:rnnController.options];
75
+			[self setTopBarBackgroundColor:[rnnController.options.topBar.background.color getWithDefaultValue:nil]];
76
 		}
76
 		}
77
 	}
77
 	}
78
 	
78
 	
129
 			self.navigationBar.shadowImage = self.originalTopBarImages[@"shadowImage"] ? self.originalTopBarImages[@"shadowImage"] : self.navigationBar.shadowImage;
129
 			self.navigationBar.shadowImage = self.originalTopBarImages[@"shadowImage"] ? self.originalTopBarImages[@"shadowImage"] : self.navigationBar.shadowImage;
130
 			self.originalTopBarImages = nil;
130
 			self.originalTopBarImages = nil;
131
 		}
131
 		}
132
+		
133
+		self.navigationBar.barTintColor = nil;
132
 	}
134
 	}
133
 }
135
 }
134
 
136
 

+ 1
- 1
lib/ios/RNNSideMenuPresenter.m View File

19
 	[sideMenuController setAnimationVelocityLeft:[options.sideMenu.left.animationVelocity getWithDefaultValue:840.0f]];
19
 	[sideMenuController setAnimationVelocityLeft:[options.sideMenu.left.animationVelocity getWithDefaultValue:840.0f]];
20
 	[sideMenuController setAnimationVelocityRight:[options.sideMenu.right.animationVelocity getWithDefaultValue:840.0f]];
20
 	[sideMenuController setAnimationVelocityRight:[options.sideMenu.right.animationVelocity getWithDefaultValue:840.0f]];
21
 	
21
 	
22
-	[sideMenuController setAnimationType:[options.sideMenu.animationType getWithDefaultValue:@"door"]];
22
+	[sideMenuController setAnimationType:[options.sideMenu.animationType getWithDefaultValue:nil]];
23
 
23
 
24
 	if (options.sideMenu.left.width.hasValue) {
24
 	if (options.sideMenu.left.width.hasValue) {
25
 		[sideMenuController side:MMDrawerSideLeft width:options.sideMenu.left.width.get];
25
 		[sideMenuController side:MMDrawerSideLeft width:options.sideMenu.left.width.get];

+ 2
- 2
lib/ios/RNNViewControllerPresenter.m View File

17
 	
17
 	
18
 	UIViewController* viewController = self.bindedViewController;
18
 	UIViewController* viewController = self.bindedViewController;
19
 	[viewController rnn_setBackgroundImage:[options.backgroundImage getWithDefaultValue:nil]];
19
 	[viewController rnn_setBackgroundImage:[options.backgroundImage getWithDefaultValue:nil]];
20
-	[viewController rnn_setDrawBehindTopBar:[options.topBar.drawBehind getWithDefaultValue:NO]];
21
 	[viewController rnn_setNavigationItemTitle:[options.topBar.title.text getWithDefaultValue:nil]];
20
 	[viewController rnn_setNavigationItemTitle:[options.topBar.title.text getWithDefaultValue:nil]];
22
 	[viewController rnn_setTopBarPrefersLargeTitle:[options.topBar.largeTitle.visible getWithDefaultValue:NO]];
21
 	[viewController rnn_setTopBarPrefersLargeTitle:[options.topBar.largeTitle.visible getWithDefaultValue:NO]];
23
-	[viewController rnn_setDrawBehindTabBar:[options.bottomTabs.drawBehind getWithDefaultValue:NO] || ![options.bottomTabs.visible getWithDefaultValue:YES]];
24
 	[viewController rnn_setTabBarItemBadgeColor:[options.bottomTab.badgeColor getWithDefaultValue:nil]];
22
 	[viewController rnn_setTabBarItemBadgeColor:[options.bottomTab.badgeColor getWithDefaultValue:nil]];
25
 	[viewController rnn_setStatusBarBlur:[options.statusBar.blur getWithDefaultValue:NO]];
23
 	[viewController rnn_setStatusBarBlur:[options.statusBar.blur getWithDefaultValue:NO]];
26
 	[viewController rnn_setStatusBarStyle:[options.statusBar.style getWithDefaultValue:@"default"] animated:[options.statusBar.animate getWithDefaultValue:YES]];
24
 	[viewController rnn_setStatusBarStyle:[options.statusBar.style getWithDefaultValue:@"default"] animated:[options.statusBar.animate getWithDefaultValue:YES]];
47
 	UIViewController* viewController = self.bindedViewController;
45
 	UIViewController* viewController = self.bindedViewController;
48
 	[viewController rnn_setModalPresentationStyle:[RCTConvert UIModalPresentationStyle:[options.modalPresentationStyle getWithDefaultValue:@"fullScreen"]]];
46
 	[viewController rnn_setModalPresentationStyle:[RCTConvert UIModalPresentationStyle:[options.modalPresentationStyle getWithDefaultValue:@"fullScreen"]]];
49
 	[viewController rnn_setModalTransitionStyle:[RCTConvert UIModalTransitionStyle:[options.modalTransitionStyle getWithDefaultValue:@"coverVertical"]]];
47
 	[viewController rnn_setModalTransitionStyle:[RCTConvert UIModalTransitionStyle:[options.modalTransitionStyle getWithDefaultValue:@"coverVertical"]]];
48
+	[viewController rnn_setDrawBehindTopBar:[options.topBar.drawBehind getWithDefaultValue:NO]];
49
+	[viewController rnn_setDrawBehindTabBar:[options.bottomTabs.drawBehind getWithDefaultValue:NO] || ![options.bottomTabs.visible getWithDefaultValue:YES]];
50
 }
50
 }
51
 
51
 
52
 - (void)mergeOptions:(RNNNavigationOptions *)options resolvedOptions:(RNNNavigationOptions *)resolvedOptions {
52
 - (void)mergeOptions:(RNNNavigationOptions *)options resolvedOptions:(RNNNavigationOptions *)resolvedOptions {

+ 0
- 28
lib/ios/ReactNativeNavigationTests/RNNRootViewControllerTest.m View File

546
 //	XCTAssertTrue([[(UIImageView*)self.uut.view.subviews[0] image] isEqual:backgroundImage]);
546
 //	XCTAssertTrue([[(UIImageView*)self.uut.view.subviews[0] image] isEqual:backgroundImage]);
547
 //}
547
 //}
548
 
548
 
549
--(void)testTopBarDrawUnder_true {
550
-	self.options.topBar.drawBehind = [[Bool alloc] initWithValue:@(1)];
551
-	[self.uut viewWillAppear:false];
552
-
553
-	XCTAssertTrue(self.uut.edgesForExtendedLayout & UIRectEdgeTop);
554
-}
555
-
556
--(void)testTopBarDrawUnder_false {
557
-	self.options.topBar.drawBehind = [[Bool alloc] initWithValue:@(0)];
558
-	[self.uut viewWillAppear:false];
559
-
560
-	XCTAssertFalse(self.uut.edgesForExtendedLayout & UIRectEdgeTop);
561
-}
562
-
563
--(void)testBottomTabsDrawUnder_true {
564
-	self.options.bottomTabs.drawBehind = [[Bool alloc] initWithValue:@(1)];
565
-	[self.uut viewWillAppear:false];
566
-
567
-	XCTAssertTrue(self.uut.edgesForExtendedLayout & UIRectEdgeBottom);
568
-}
569
-
570
--(void)testBottomTabsDrawUnder_false {
571
-	self.options.bottomTabs.drawBehind = [[Bool alloc] initWithValue:@(0)];
572
-	[self.uut viewWillAppear:false];
573
-
574
-	XCTAssertFalse(self.uut.edgesForExtendedLayout & UIRectEdgeBottom);
575
-}
576
-
577
 #pragma mark BottomTabs
549
 #pragma mark BottomTabs
578
 
550
 
579
 
551
 

+ 1
- 1
lib/ios/ReactNativeNavigationTests/RNNSideMenuPresenterTest.m View File

30
 	[[self.bindedViewController expect] setAnimationVelocityRight:840.0f];
30
 	[[self.bindedViewController expect] setAnimationVelocityRight:840.0f];
31
 	[[self.bindedViewController reject] side:MMDrawerSideLeft width:0];
31
 	[[self.bindedViewController reject] side:MMDrawerSideLeft width:0];
32
 	[[self.bindedViewController reject] side:MMDrawerSideRight width:0];
32
 	[[self.bindedViewController reject] side:MMDrawerSideRight width:0];
33
-  [[self.bindedViewController expect] setAnimationType:@"door"];
33
+  	[[self.bindedViewController expect] setAnimationType:nil];
34
     
34
     
35
 	[self.uut applyOptions:self.options];
35
 	[self.uut applyOptions:self.options];
36
 
36
 

+ 35
- 3
lib/ios/ReactNativeNavigationTests/RNNViewControllerPresenterTest.m View File

21
 	self.options = [[RNNNavigationOptions alloc] initEmptyOptions];
21
 	self.options = [[RNNNavigationOptions alloc] initEmptyOptions];
22
 }
22
 }
23
 
23
 
24
-- (void)testApplyOptions_backgroundImageDefaultNil {
24
+- (void)testApplyOptions_backgroundImageDefaultNilShouldNotAddSubview {
25
 	[self.uut applyOptions:self.options];
25
 	[self.uut applyOptions:self.options];
26
-	XCTAssertNil(((UIImageView *)self.bindedViewController.view.subviews[0]).image);
26
+	XCTAssertTrue((self.bindedViewController.view.subviews.count) == 0);
27
 }
27
 }
28
 
28
 
29
 - (void)testApplyOptions_topBarPrefersLargeTitleDefaultFalse {
29
 - (void)testApplyOptions_topBarPrefersLargeTitleDefaultFalse {
55
 - (void)testApplyOptions_drawBehindTabBarTrueWhenVisibleFalse {
55
 - (void)testApplyOptions_drawBehindTabBarTrueWhenVisibleFalse {
56
 	self.options.bottomTabs.visible = [[Bool alloc] initWithValue:@(0)];
56
 	self.options.bottomTabs.visible = [[Bool alloc] initWithValue:@(0)];
57
 	[[(id)self.bindedViewController expect] rnn_setDrawBehindTabBar:YES];
57
 	[[(id)self.bindedViewController expect] rnn_setDrawBehindTabBar:YES];
58
-	[self.uut applyOptions:self.options];
58
+	[self.uut applyOptionsOnInit:self.options];
59
 	[(id)self.bindedViewController verify];
59
 	[(id)self.bindedViewController verify];
60
 }
60
 }
61
 
61
 
85
 	[(id)self.bindedViewController verify];
85
 	[(id)self.bindedViewController verify];
86
 }
86
 }
87
 
87
 
88
+-(void)testApplyOptionsOnInit_TopBarDrawUnder_true {
89
+    self.options.topBar.drawBehind = [[Bool alloc] initWithValue:@(1)];
90
+    
91
+    [[(id)self.bindedViewController expect] rnn_setDrawBehindTopBar:YES];
92
+    [self.uut applyOptionsOnInit:self.options];
93
+    [(id)self.bindedViewController verify];
94
+}
95
+
96
+-(void)testApplyOptionsOnInit_TopBarDrawUnder_false {
97
+    self.options.topBar.drawBehind = [[Bool alloc] initWithValue:@(0)];
98
+    
99
+    [[(id)self.bindedViewController expect] rnn_setDrawBehindTopBar:NO];
100
+    [self.uut applyOptionsOnInit:self.options];
101
+    [(id)self.bindedViewController verify];
102
+}
103
+
104
+-(void)testApplyOptionsOnInit_BottomTabsDrawUnder_true {
105
+    self.options.bottomTabs.drawBehind = [[Bool alloc] initWithValue:@(1)];
106
+    
107
+    [[(id)self.bindedViewController expect] rnn_setDrawBehindTabBar:YES];
108
+    [self.uut applyOptionsOnInit:self.options];
109
+    [(id)self.bindedViewController verify];
110
+}
111
+
112
+-(void)testApplyOptionsOnInit_BottomTabsDrawUnder_false {
113
+    self.options.bottomTabs.drawBehind = [[Bool alloc] initWithValue:@(0)];
114
+    
115
+    [[(id)self.bindedViewController expect] rnn_setDrawBehindTabBar:NO];
116
+    [self.uut applyOptionsOnInit:self.options];
117
+    [(id)self.bindedViewController verify];
118
+}
119
+
88
 @end
120
 @end

+ 17
- 0
lib/ios/ReactNativeNavigationTests/UIViewController+RNNOptionsTest.m View File

71
 	XCTAssertEqual([self.uut edgesForExtendedLayout], expectedRectEdge);
71
 	XCTAssertEqual([self.uut edgesForExtendedLayout], expectedRectEdge);
72
 }
72
 }
73
 
73
 
74
+- (void)testSetBackgroundImageShouldNotAddViewIfImageNil {
75
+	NSUInteger subviewsCount = [[[self.uut view] subviews] count];
76
+	[self.uut rnn_setBackgroundImage:nil];
77
+	XCTAssertEqual([[[self.uut view] subviews] count], subviewsCount);
78
+}
79
+
80
+- (void)testSetBackgroundImageShouldAddUIImageViewSubview {
81
+	NSUInteger subviewsCount = [[[self.uut view] subviews] count];
82
+	[self.uut rnn_setBackgroundImage:[UIImage new]];
83
+	XCTAssertEqual([[[self.uut view] subviews] count], subviewsCount+1);
84
+}
74
 
85
 
86
+- (void)testSetBackgroundImageShouldAddUIImageViewSubviewWithImage {
87
+	UIImage* image = [UIImage new];
88
+	[self.uut rnn_setBackgroundImage:image];
89
+	UIImageView* imageView = [[[self.uut view] subviews] firstObject];
90
+	XCTAssertEqual(imageView.image, image);
91
+}
75
 
92
 
76
 @end
93
 @end

+ 10
- 8
lib/ios/UIViewController+RNNOptions.m View File

5
 @implementation UIViewController (RNNOptions)
5
 @implementation UIViewController (RNNOptions)
6
 
6
 
7
 - (void)rnn_setBackgroundImage:(UIImage *)backgroundImage {
7
 - (void)rnn_setBackgroundImage:(UIImage *)backgroundImage {
8
-	UIImageView* backgroundImageView = (self.view.subviews.count > 0) ? self.view.subviews[0] : nil;
9
-	if (![backgroundImageView isKindOfClass:[UIImageView class]]) {
10
-		backgroundImageView = [[UIImageView alloc] initWithFrame:self.view.bounds];
11
-		[self.view insertSubview:backgroundImageView atIndex:0];
8
+	if (backgroundImage) {
9
+		UIImageView* backgroundImageView = (self.view.subviews.count > 0) ? self.view.subviews[0] : nil;
10
+		if (![backgroundImageView isKindOfClass:[UIImageView class]]) {
11
+			backgroundImageView = [[UIImageView alloc] initWithFrame:self.view.bounds];
12
+			[self.view insertSubview:backgroundImageView atIndex:0];
13
+		}
14
+		
15
+		backgroundImageView.layer.masksToBounds = YES;
16
+		backgroundImageView.image = backgroundImage;
17
+		[backgroundImageView setContentMode:UIViewContentModeScaleAspectFill];
12
 	}
18
 	}
13
-	
14
-	backgroundImageView.layer.masksToBounds = YES;
15
-	backgroundImageView.image = backgroundImage;
16
-	[backgroundImageView setContentMode:UIViewContentModeScaleAspectFill];
17
 }
19
 }
18
 
20
 
19
 - (void)rnn_setModalPresentationStyle:(UIModalPresentationStyle)modalPresentationStyle {
21
 - (void)rnn_setModalPresentationStyle:(UIModalPresentationStyle)modalPresentationStyle {