Browse Source

V2 top bar no border (#1688)

* topBarNoBorder for ios

* Unit tests for topBarNoBorder
Graham Chance 7 years ago
parent
commit
b2105f2347

+ 1
- 1
lib/ios/RNNNavigationOptions.h View File

@@ -15,7 +15,7 @@
15 15
 @property (nonatomic, strong) NSNumber* topBarTranslucent;
16 16
 @property (nonatomic, strong) NSString* tabBadge;
17 17
 @property (nonatomic, strong) NSNumber* topBarTextFontSize;
18
-
18
+@property (nonatomic, strong) NSNumber* topBarNoBorder;
19 19
 
20 20
 
21 21
 

+ 12
- 1
lib/ios/RNNNavigationOptions.m View File

@@ -22,7 +22,8 @@
22 22
 	self.topBarTranslucent = [navigationOptions objectForKey:@"topBarTranslucent"];
23 23
 	self.tabBadge = [navigationOptions objectForKey:@"tabBadge"];
24 24
 	self.topBarTextFontSize = [navigationOptions objectForKey:@"topBarTextFontSize"];
25
-  
25
+	self.topBarNoBorder = [navigationOptions objectForKey:@"topBarNoBorder"];
26
+
26 27
 	return self;
27 28
 }
28 29
 
@@ -107,5 +108,15 @@
107 108
 		}		
108 109
 	}
109 110
 
111
+	if (self.topBarNoBorder) {
112
+		if ([self.topBarNoBorder boolValue]) {
113
+			viewController.navigationController.navigationBar
114
+			.shadowImage = [[UIImage alloc] init];
115
+		} else {
116
+			viewController.navigationController.navigationBar
117
+			.shadowImage = nil;
118
+		}
119
+	}
120
+
110 121
 }
111 122
 @end

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

@@ -205,4 +205,20 @@
205 205
 	//	XCTAssertThrows([self.uut viewWillAppear:false]);
206 206
 }
207 207
 
208
+-(void)testTopBarNoBorderOn {
209
+	NSNumber* topBarNoBorderInput = @(1);
210
+	self.options.topBarNoBorder = topBarNoBorderInput;
211
+	__unused UINavigationController* nav = [[UINavigationController alloc] initWithRootViewController:self.uut];
212
+	[self.uut viewWillAppear:false];
213
+	XCTAssertNotNil(self.uut.navigationController.navigationBar.shadowImage);
214
+}
215
+
216
+-(void)testTopBarNoBorderOff {
217
+	NSNumber* topBarNoBorderInput = @(0);
218
+	self.options.topBarNoBorder = topBarNoBorderInput;
219
+	__unused UINavigationController* nav = [[UINavigationController alloc] initWithRootViewController:self.uut];
220
+	[self.uut viewWillAppear:false];
221
+	XCTAssertNil(self.uut.navigationController.navigationBar.shadowImage);
222
+}
223
+
208 224
 @end