Browse Source

fix navBarSubtitleColor - now it will set the navigation subtitle color properly without any effect on the title (#1847)

Ran Greenberg 7 years ago
parent
commit
3f377f65df
2 changed files with 19 additions and 1 deletions
  1. 10
    0
      example/src/screens/Actions.js
  2. 9
    1
      ios/Helpers/RCCTitleViewHelper.m

+ 10
- 0
example/src/screens/Actions.js View File

27
     });
27
     });
28
   };
28
   };
29
 
29
 
30
+  setSubtitle = () => {
31
+    this.props.navigator.setSubTitle({
32
+      subtitle: 'New SubTitle!',
33
+      navigatorStyle: {
34
+        navBarSubtitleColor: 'red'
35
+      }
36
+    });
37
+  };
38
+
30
   toggleTabs = () => {
39
   toggleTabs = () => {
31
     const to = this._toggleTabs === 'shown' ? 'hidden' : 'shown';
40
     const to = this._toggleTabs === 'shown' ? 'hidden' : 'shown';
32
 
41
 
142
     return (
151
     return (
143
       <ScrollView style={styles.container}>
152
       <ScrollView style={styles.container}>
144
         <Row title={'Set Title'} onPress={this.setTitle} />
153
         <Row title={'Set Title'} onPress={this.setTitle} />
154
+        <Row title={'Set Subtitle'} onPress={this.setSubtitle} />
145
         <Row title={'Toggle Tabs'} onPress={this.toggleTabs} />
155
         <Row title={'Toggle Tabs'} onPress={this.toggleTabs} />
146
         <Row title={'Set Tab Badge'} onPress={this.setTabBadge} />
156
         <Row title={'Set Tab Badge'} onPress={this.setTabBadge} />
147
         <Row title={'Switch To Tab 0'} onPress={this.switchToTab} />
157
         <Row title={'Switch To Tab 0'} onPress={this.switchToTab} />

+ 9
- 1
ios/Helpers/RCCTitleViewHelper.m View File

8
 
8
 
9
 #import "RCCTitleViewHelper.h"
9
 #import "RCCTitleViewHelper.h"
10
 #import <React/RCTConvert.h>
10
 #import <React/RCTConvert.h>
11
+#import "RCCViewController.h"
11
 #import "RCTHelpers.h"
12
 #import "RCTHelpers.h"
12
 
13
 
13
 @implementation RCCTitleView
14
 @implementation RCCTitleView
69
         return;
70
         return;
70
     }
71
     }
71
     
72
     
73
+    if ([self.viewController isKindOfClass:[RCCViewController class]]) {
74
+        NSMutableDictionary *mergedStyle = [NSMutableDictionary dictionaryWithDictionary:((RCCViewController*)self.viewController).navigatorStyle];
75
+        [mergedStyle addEntriesFromDictionary:style];
76
+        
77
+        style = mergedStyle;
78
+    }
79
+    
72
     CGRect navigationBarBounds = self.navigationController.navigationBar.bounds;
80
     CGRect navigationBarBounds = self.navigationController.navigationBar.bounds;
73
     
81
     
74
     self.titleView = [[RCCTitleView alloc] initWithFrame:navigationBarBounds];
82
     self.titleView = [[RCCTitleView alloc] initWithFrame:navigationBarBounds];
164
     labelframe.size = labelSize;
172
     labelframe.size = labelSize;
165
     subtitleLabel.frame = labelframe;
173
     subtitleLabel.frame = labelframe;
166
     [subtitleLabel sizeToFit];
174
     [subtitleLabel sizeToFit];
167
-
175
+    
168
     [self.titleView addSubview:subtitleLabel];
176
     [self.titleView addSubview:subtitleLabel];
169
     
177
     
170
     return subtitleLabel;
178
     return subtitleLabel;