bogobogo 7 лет назад
Родитель
Сommit
f90a28146a

+ 0
- 1
lib/ios/RNNControllerFactory.m Просмотреть файл

@@ -118,7 +118,6 @@
118 118
 		UIViewController *vc = [self fromTree:child];
119 119
 		[childrenVCs addObject:vc];
120 120
 	}
121
-	
122 121
 	RNNSideMenuController *sideMenu = [[RNNSideMenuController alloc] initWithControllers:childrenVCs];
123 122
 	return sideMenu;
124 123
 }

+ 1
- 0
lib/ios/RNNNavigationOptions.h Просмотреть файл

@@ -7,6 +7,7 @@
7 7
 @property (nonatomic, strong) NSNumber* topBarTextColor;
8 8
 @property (nonatomic, strong) NSNumber* statusBarHidden;
9 9
 @property (nonatomic, strong) NSString* title;
10
+@property (nonatomic, strong) NSNumber* screenBackgroundColor;
10 11
 @property (nonatomic, strong) NSString* setTabBadge;
11 12
 
12 13
 -(instancetype)init;

+ 15
- 10
lib/ios/RNNNavigationOptions.m Просмотреть файл

@@ -9,13 +9,13 @@
9 9
 }
10 10
 
11 11
 -(instancetype)initWithDict:(NSDictionary *)navigationOptions {
12
-	if(self = [super init]) {
13
-		self.topBarBackgroundColor = [navigationOptions objectForKey:@"topBarBackgroundColor"];
14
-		self.statusBarHidden = [navigationOptions objectForKey:@"statusBarHidden"];
15
-		self.title = [navigationOptions objectForKey:@"title"];
16
-		self.topBarTextColor = [navigationOptions objectForKey:@"topBarTextColor"];
17
-		self.setTabBadge = [navigationOptions objectForKey:@"setTabBadge"];
18
-	}
12
+	self = [super init];
13
+	self.topBarBackgroundColor = [navigationOptions objectForKey:@"topBarBackgroundColor"];
14
+	self.statusBarHidden = [navigationOptions objectForKey:@"statusBarHidden"];
15
+	self.title = [navigationOptions objectForKey:@"title"];
16
+	self.topBarTextColor = [navigationOptions objectForKey:@"topBarTextColor"];
17
+	self.screenBackgroundColor = [navigationOptions objectForKey:@"screenBackgroundColor"];
18
+	self.setTabBadge = [navigationOptions objectForKey:@"setTabBadge"];
19 19
 	return self;
20 20
 }
21 21
 
@@ -25,10 +25,12 @@
25 25
 	}
26 26
 }
27 27
 
28
--(void)applyOn:(UIViewController*)viewController{
28
+-(void)applyOn:(UIViewController*)viewController {
29 29
 	if (self.topBarBackgroundColor) {
30 30
 		UIColor* backgroundColor = [RCTConvert UIColor:self.topBarBackgroundColor];
31 31
 		viewController.navigationController.navigationBar.barTintColor = backgroundColor;
32
+	} else {
33
+		viewController.navigationController.navigationBar.barTintColor = nil;
32 34
 	}
33 35
 	if (self.title) {
34 36
 		viewController.navigationItem.title = self.title;
@@ -37,12 +39,15 @@
37 39
 		UIColor* textColor = [RCTConvert UIColor:self.topBarTextColor];
38 40
 		viewController.navigationController.navigationBar.titleTextAttributes = @{NSForegroundColorAttributeName:textColor};
39 41
 	}
42
+	if (self.screenBackgroundColor) {
43
+		UIColor* screenColor = [RCTConvert UIColor:self.screenBackgroundColor];
44
+		viewController.view.backgroundColor = screenColor;
45
+  }
40 46
 	if (self.setTabBadge) {
41 47
 		NSString *badge = [RCTConvert NSString:self.setTabBadge];
42 48
 		if (viewController.navigationController) {
43 49
 			viewController.navigationController.tabBarItem.badgeValue = badge;
44
-		}
45
-		else {
50
+    } else {
46 51
 			viewController.tabBarItem.badgeValue = badge;
47 52
 		}
48 53
 	}

+ 9
- 0
lib/ios/ReactNativeNavigationTests/RNNRootViewControllerTest.m Просмотреть файл

@@ -92,5 +92,14 @@
92 92
 	XCTAssertTrue([self.uut.navigationController.navigationBar.titleTextAttributes[@"NSColor"] isEqual:expectedColor]);
93 93
 }
94 94
 
95
+-(void)testScreenBackgroundColor_validColor{
96
+	NSNumber* inputColor = @(0xFFFF0000);
97
+	self.options.screenBackgroundColor = inputColor;
98
+	[self.uut viewWillAppear:false];
99
+	UIColor* expectedColor = [UIColor colorWithRed:1 green:0 blue:0 alpha:1];
100
+	XCTAssertTrue([self.uut.view.backgroundColor isEqual:expectedColor]);
101
+}
102
+
103
+
95 104
 
96 105
 @end

+ 2
- 4
playground/src/containers/OptionsScreen.js Просмотреть файл

@@ -12,8 +12,7 @@ import Navigation from 'react-native-navigation';
12 12
 class OptionsScreen extends Component {
13 13
   static navigationOptions = {
14 14
     title: 'Static Title',
15
-    topBarBackgroundColor: "red",
16
-    statusBarHidden: true
15
+    topBarBackgroundColor: "red"
17 16
   }
18 17
 
19 18
   constructor(props) {
@@ -44,8 +43,7 @@ const styles = {
44 43
   root: {
45 44
     flexGrow: 1,
46 45
     justifyContent: 'center',
47
-    alignItems: 'center',
48
-    backgroundColor: '#f5fcff'
46
+    alignItems: 'center'
49 47
   },
50 48
   h1: {
51 49
     fontSize: 24,

+ 1
- 2
playground/src/containers/WelcomeScreen.js Просмотреть файл

@@ -138,8 +138,7 @@ const styles = {
138 138
   root: {
139 139
     flexGrow: 1,
140 140
     justifyContent: 'center',
141
-    alignItems: 'center',
142
-    backgroundColor: '#f5fcff'
141
+    alignItems: 'center'
143 142
   },
144 143
   h1: {
145 144
     fontSize: 24,