Browse Source

V2 top bar text font family (#1634)

* screen Background Color iOS

* ios v2 topBarTextFontFamily
bogobogo 7 years ago
parent
commit
7b6148a0e4

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

9
 @property (nonatomic, strong) NSString* title;
9
 @property (nonatomic, strong) NSString* title;
10
 @property (nonatomic, strong) NSNumber* screenBackgroundColor;
10
 @property (nonatomic, strong) NSNumber* screenBackgroundColor;
11
 @property (nonatomic, strong) NSString* setTabBadge;
11
 @property (nonatomic, strong) NSString* setTabBadge;
12
+@property (nonatomic, strong) NSString* topBarTextFontFamily;
12
 
13
 
13
 -(instancetype)init;
14
 -(instancetype)init;
14
 -(instancetype)initWithDict:(NSDictionary *)navigationOptions;
15
 -(instancetype)initWithDict:(NSDictionary *)navigationOptions;

+ 8
- 3
lib/ios/RNNNavigationOptions.m View File

13
 	self.topBarBackgroundColor = [navigationOptions objectForKey:@"topBarBackgroundColor"];
13
 	self.topBarBackgroundColor = [navigationOptions objectForKey:@"topBarBackgroundColor"];
14
 	self.statusBarHidden = [navigationOptions objectForKey:@"statusBarHidden"];
14
 	self.statusBarHidden = [navigationOptions objectForKey:@"statusBarHidden"];
15
 	self.title = [navigationOptions objectForKey:@"title"];
15
 	self.title = [navigationOptions objectForKey:@"title"];
16
-	self.topBarTextColor = [navigationOptions objectForKey:@"topBarTextColor"];
17
 	self.screenBackgroundColor = [navigationOptions objectForKey:@"screenBackgroundColor"];
16
 	self.screenBackgroundColor = [navigationOptions objectForKey:@"screenBackgroundColor"];
18
 	self.setTabBadge = [navigationOptions objectForKey:@"setTabBadge"];
17
 	self.setTabBadge = [navigationOptions objectForKey:@"setTabBadge"];
18
+	self.topBarTextFontFamily = [navigationOptions objectForKey:@"topBarTextFontFamily"];
19
 	return self;
19
 	return self;
20
 }
20
 }
21
 
21
 
37
 	}
37
 	}
38
 	if (self.topBarTextColor) {
38
 	if (self.topBarTextColor) {
39
 		UIColor* textColor = [RCTConvert UIColor:self.topBarTextColor];
39
 		UIColor* textColor = [RCTConvert UIColor:self.topBarTextColor];
40
-		viewController.navigationController.navigationBar.titleTextAttributes = @{NSForegroundColorAttributeName:textColor};
40
+		NSMutableDictionary* navigationBarTitleTextAttributes = [NSMutableDictionary dictionaryWithDictionary:@{NSForegroundColorAttributeName: textColor}];
41
+		if (self.topBarTextFontFamily) {
42
+			[navigationBarTitleTextAttributes addEntriesFromDictionary:@{NSFontAttributeName: [UIFont fontWithName:self.topBarTextFontFamily size:20]}];
43
+		}
44
+		viewController.navigationController.navigationBar.titleTextAttributes = navigationBarTitleTextAttributes;
45
+	} else if (self.topBarTextFontFamily){
46
+		viewController.navigationController.navigationBar.titleTextAttributes = @{NSFontAttributeName: [UIFont fontWithName:self.topBarTextFontFamily size:20]};
41
 	}
47
 	}
42
 	if (self.screenBackgroundColor) {
48
 	if (self.screenBackgroundColor) {
43
 		UIColor* screenColor = [RCTConvert UIColor:self.screenBackgroundColor];
49
 		UIColor* screenColor = [RCTConvert UIColor:self.screenBackgroundColor];
55
 
61
 
56
 
62
 
57
 
63
 
58
-
59
 @end
64
 @end

+ 4
- 2
playground/src/containers/OptionsScreen.js View File

12
 class OptionsScreen extends Component {
12
 class OptionsScreen extends Component {
13
   static navigationOptions = {
13
   static navigationOptions = {
14
     title: 'Static Title',
14
     title: 'Static Title',
15
-    topBarBackgroundColor: "red"
15
+    topBarBackgroundColor: "red",
16
+    topBarTextFontFamily: "HelveticaNeue-Italic"
16
   }
17
   }
17
 
18
 
18
   constructor(props) {
19
   constructor(props) {
34
     Navigation.setOptions(this.props.containerId, {
35
     Navigation.setOptions(this.props.containerId, {
35
       title: 'Dynamic Title',
36
       title: 'Dynamic Title',
36
       topBarTextColor: '#00FFFF',
37
       topBarTextColor: '#00FFFF',
37
-      topBarBackgroundColor: 'green'
38
+      topBarBackgroundColor: 'green',
39
+      topBarTextFontFamily: "HelveticaNeue-CondensedBold"
38
     });
40
     });
39
   }
41
   }
40
 }
42
 }