11/* @flow */
22
33import * as React from 'react' ;
4- import { View , StyleSheet , Platform } from 'react-native' ;
4+ import {
5+ View ,
6+ StyleSheet ,
7+ Platform ,
8+ TouchableWithoutFeedback ,
9+ } from 'react-native' ;
510import color from 'color' ;
611
712import Text from '../Typography/Text' ;
@@ -32,6 +37,10 @@ type Props = $RemoveChildren<typeof View> & {|
3237 * Style for the subtitle.
3338 */
3439 subtitleStyle ? : any ,
40+ /**
41+ * Function to execute on press.
42+ */
43+ onPress ? : ( ) => mixed ,
3544 style ? : any ,
3645 /**
3746 * @optional
@@ -50,6 +59,7 @@ class AppbarContent extends React.Component<Props> {
5059 color : titleColor = black ,
5160 subtitle,
5261 subtitleStyle,
62+ onPress,
5363 style,
5464 titleStyle,
5565 theme,
@@ -64,31 +74,34 @@ class AppbarContent extends React.Component<Props> {
6474 . string ( ) ;
6575
6676 return (
67- < View style = { [ styles . container , style ] } { ...rest } >
68- < Text
69- style = { [
70- {
71- color : titleColor ,
72- fontFamily : Platform . OS === 'ios' ? fonts . regular : fonts . medium ,
73- } ,
74- styles . title ,
75- titleStyle ,
76- ] }
77- numberOfLines = { 1 }
78- accessibilityTraits = "header"
79- accessibilityRole = "header"
80- >
81- { title }
82- </ Text >
83- { subtitle ? (
77+ < TouchableWithoutFeedback onPress = { onPress } >
78+ < View style = { [ styles . container , style ] } { ...rest } >
8479 < Text
85- style = { [ styles . subtitle , { color : subtitleColor } , subtitleStyle ] }
80+ style = { [
81+ {
82+ color : titleColor ,
83+ fontFamily :
84+ Platform . OS === 'ios' ? fonts . regular : fonts . medium ,
85+ } ,
86+ styles . title ,
87+ titleStyle ,
88+ ] }
8689 numberOfLines = { 1 }
90+ accessibilityTraits = "header"
91+ accessibilityRole = "header"
8792 >
88- { subtitle }
93+ { title }
8994 </ Text >
90- ) : null }
91- </ View >
95+ { subtitle ? (
96+ < Text
97+ style = { [ styles . subtitle , { color : subtitleColor } , subtitleStyle ] }
98+ numberOfLines = { 1 }
99+ >
100+ { subtitle }
101+ </ Text >
102+ ) : null }
103+ </ View >
104+ </ TouchableWithoutFeedback >
92105 ) ;
93106 }
94107}
0 commit comments