Bladeren bron

add subtitle support to navigation bar

Ran Greenberg 7 jaren geleden
bovenliggende
commit
a425e9077a
3 gewijzigde bestanden met toevoegingen van 37 en 1 verwijderingen
  1. 1
    0
      example/src/app.js
  2. 28
    0
      example/src/screens/StyledScreen.js
  3. 8
    1
      src/deprecated/platformSpecificDeprecated.ios.js

+ 1
- 0
example/src/app.js Bestand weergeven

@@ -17,6 +17,7 @@ Navigation.startSingleScreenApp({
17 17
     navigatorStyle: {
18 18
       navBarBackgroundColor: '#4dbce9',
19 19
       navBarTextColor: '#ffff00',
20
+      navBarSubtitleTextColor: '#ff0000',
20 21
       navBarButtonColor: '#ffffff',
21 22
       statusBarTextColorScheme: 'light'
22 23
     }

+ 28
- 0
example/src/screens/StyledScreen.js Bestand weergeven

@@ -46,6 +46,14 @@ export default class StyledScreen extends Component {
46 46
           <TouchableOpacity onPress={ this.onPopPress.bind(this) }>
47 47
             <Text style={styles.button}>Pop Screen</Text>
48 48
           </TouchableOpacity>
49
+  
50
+          <TouchableOpacity onPress={ this.onSetSubtitlePress.bind(this) }>
51
+            <Text style={styles.button}>Set Subtitle</Text>
52
+          </TouchableOpacity>
53
+  
54
+          <TouchableOpacity onPress={ this.onSetTitleImagePress.bind(this) }>
55
+            <Text style={styles.button}>Set Title Image</Text>
56
+          </TouchableOpacity>
49 57
 
50 58
         </View>
51 59
 
@@ -72,6 +80,26 @@ export default class StyledScreen extends Component {
72 80
   onPopPress() {
73 81
     this.props.navigator.pop();
74 82
   }
83
+  
84
+  onSetSubtitlePress() {
85
+    this.props.navigator.setTitle({
86
+      title: 'title',
87
+      subtitle: 'subtitle',
88
+      navigatorStyle: {
89
+        navBarSubtitleTextColor: '#ff00ff',
90
+        navBarTextColor: '#ffff00'
91
+        
92
+      }
93
+    })
94
+  }
95
+  
96
+  onSetTitleImagePress() {
97
+    this.props.navigator.setTitle({
98
+      title: 'title',
99
+      titleImage: require('../../img/one.png'),
100
+    })
101
+  }
102
+  
75 103
 }
76 104
 
77 105
 const styles = StyleSheet.create({

+ 8
- 1
src/deprecated/platformSpecificDeprecated.ios.js Bestand weergeven

@@ -151,6 +151,7 @@ function startSingleScreenApp(params) {
151 151
         <NavigationControllerIOS
152 152
           id={navigatorID}
153 153
           title={screen.title}
154
+          subtitle={params.subtitle}
154 155
           titleImage={screen.titleImage}
155 156
           component={screen.screen}
156 157
           passProps={{
@@ -228,6 +229,7 @@ function navigatorPush(navigator, params) {
228 229
 
229 230
   Controllers.NavigationControllerIOS(navigator.navigatorID).push({
230 231
     title: params.title,
232
+    subtitle:params.subtitle,
231 233
     titleImage: params.titleImage,
232 234
     component: params.screen,
233 235
     animated: params.animated,
@@ -280,6 +282,7 @@ function navigatorResetTo(navigator, params) {
280 282
 
281 283
   Controllers.NavigationControllerIOS(navigator.navigatorID).resetTo({
282 284
     title: params.title,
285
+    subtitle: params.subtitle,
283 286
     titleImage: params.titleImage,
284 287
     component: params.screen,
285 288
     animated: params.animated,
@@ -292,7 +295,10 @@ function navigatorResetTo(navigator, params) {
292 295
 
293 296
 function navigatorSetTitle(navigator, params) {
294 297
   Controllers.NavigationControllerIOS(navigator.navigatorID).setTitle({
295
-    title: params.title
298
+    title: params.title,
299
+    subtitle: params.subtitle,
300
+    titleImage: params.titleImage,
301
+    style: params.navigatorStyle
296 302
   });
297 303
 }
298 304
 
@@ -416,6 +422,7 @@ function showModal(params) {
416 422
         <NavigationControllerIOS
417 423
           id={navigatorID}
418 424
           title={params.title}
425
+          subtitle={params.title}
419 426
           titleImage={params.titleImage}
420 427
           component={params.screen}
421 428
           passProps={passProps}