Browse Source

V2 topBarTransparent (#2252)

yogevbd 7 years ago
parent
commit
4f9a5c6fed

+ 7
- 0
lib/ios/RNNNavigationOptions.m View File

110
 			viewController.navigationController.navigationBar.translucent = [self.topBar.translucent boolValue];
110
 			viewController.navigationController.navigationBar.translucent = [self.topBar.translucent boolValue];
111
 		}
111
 		}
112
 		
112
 		
113
+		if (self.topBar.transparent) {
114
+			[viewController.navigationController.navigationBar setBackgroundImage:[UIImage new] forBarMetrics:UIBarMetricsDefault];
115
+			viewController.navigationController.navigationBar.shadowImage = [UIImage new];
116
+			UIView *transparentView = [[UIView alloc] initWithFrame:CGRectZero];
117
+			[viewController.navigationController.navigationBar insertSubview:transparentView atIndex:0];
118
+		}
119
+		
113
 		if (self.topBar.noBorder) {
120
 		if (self.topBar.noBorder) {
114
 			if ([self.topBar.noBorder boolValue]) {
121
 			if ([self.topBar.noBorder boolValue]) {
115
 				viewController.navigationController.navigationBar
122
 				viewController.navigationController.navigationBar

+ 1
- 0
lib/ios/RNNTopBarOptions.h View File

12
 @property (nonatomic, strong) NSNumber* hideOnScroll;
12
 @property (nonatomic, strong) NSNumber* hideOnScroll;
13
 @property (nonatomic, strong) NSNumber* buttonColor;
13
 @property (nonatomic, strong) NSNumber* buttonColor;
14
 @property (nonatomic, strong) NSNumber* translucent;
14
 @property (nonatomic, strong) NSNumber* translucent;
15
+@property (nonatomic, strong) NSNumber* transparent;
15
 @property (nonatomic, strong) NSNumber* textFontSize;
16
 @property (nonatomic, strong) NSNumber* textFontSize;
16
 @property (nonatomic, strong) NSNumber* noBorder;
17
 @property (nonatomic, strong) NSNumber* noBorder;
17
 @property (nonatomic, strong) NSNumber* blur;
18
 @property (nonatomic, strong) NSNumber* blur;

+ 1
- 0
lib/ios/RNNTopBarOptions.m View File

19
 	self.buttonColor = [topBarOptions valueForKey:@"buttonColor"];
19
 	self.buttonColor = [topBarOptions valueForKey:@"buttonColor"];
20
 	self.blur = [topBarOptions valueForKey:@"blur"];
20
 	self.blur = [topBarOptions valueForKey:@"blur"];
21
 	self.translucent = [topBarOptions valueForKey:@"translucent"];
21
 	self.translucent = [topBarOptions valueForKey:@"translucent"];
22
+	self.transparent = [topBarOptions valueForKey:@"transparent"];
22
 	self.noBorder = [topBarOptions valueForKey:@"noBorder"];
23
 	self.noBorder = [topBarOptions valueForKey:@"noBorder"];
23
 	self.animateHide =[topBarOptions valueForKey:@"animateHide"];
24
 	self.animateHide =[topBarOptions valueForKey:@"animateHide"];
24
 	
25
 	

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

156
 	XCTAssertFalse(self.uut.navigationController.navigationBar.translucent);
156
 	XCTAssertFalse(self.uut.navigationController.navigationBar.translucent);
157
 }
157
 }
158
 
158
 
159
+-(void)testTopBarTransparent {
160
+	NSNumber* topBarTransparentInput = @(0);
161
+	self.options.topBar.transparent = topBarTransparentInput;
162
+	__unused RNNNavigationController* nav = [[RNNNavigationController alloc] initWithRootViewController:self.uut];
163
+	[self.uut viewWillAppear:false];
164
+	XCTAssertNotNil(self.uut.navigationController.navigationBar.shadowImage);
165
+	XCTAssertNotNil([self.uut.navigationController.navigationBar backgroundImageForBarMetrics:UIBarMetricsDefault]);
166
+	XCTAssertTrue(CGRectEqualToRect(self.uut.navigationController.navigationBar.subviews.firstObject.frame, CGRectZero));
167
+}
168
+
159
 -(void)testTabBadge {
169
 -(void)testTabBadge {
160
 	NSString* tabBadgeInput = @"5";
170
 	NSString* tabBadgeInput = @"5";
161
 	self.options.tabBar.tabBadge = tabBadgeInput;
171
 	self.options.tabBar.tabBadge = tabBadgeInput;