Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
57 changes: 35 additions & 22 deletions src/components/Appbar/AppbarContent.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
/* @flow */

import * as React from 'react';
import { View, StyleSheet, Platform } from 'react-native';
import {
View,
StyleSheet,
Platform,
TouchableWithoutFeedback,
} from 'react-native';
import color from 'color';

import Text from '../Typography/Text';
Expand Down Expand Up @@ -32,6 +37,10 @@ type Props = $RemoveChildren<typeof View> & {|
* Style for the subtitle.
*/
subtitleStyle?: any,
/**
* Function to execute on press.
*/
onPress?: () => mixed,
style?: any,
/**
* @optional
Expand All @@ -50,6 +59,7 @@ class AppbarContent extends React.Component<Props> {
color: titleColor = black,
subtitle,
subtitleStyle,
onPress,
style,
titleStyle,
theme,
Expand All @@ -64,31 +74,34 @@ class AppbarContent extends React.Component<Props> {
.string();

return (
<View style={[styles.container, style]} {...rest}>
<Text
style={[
{
color: titleColor,
fontFamily: Platform.OS === 'ios' ? fonts.regular : fonts.medium,
},
styles.title,
titleStyle,
]}
numberOfLines={1}
accessibilityTraits="header"
accessibilityRole="header"
>
{title}
</Text>
{subtitle ? (
<TouchableWithoutFeedback onPress={onPress}>
<View style={[styles.container, style]} {...rest}>
<Text
style={[styles.subtitle, { color: subtitleColor }, subtitleStyle]}
style={[
{
color: titleColor,
fontFamily:
Platform.OS === 'ios' ? fonts.regular : fonts.medium,
},
styles.title,
titleStyle,
]}
numberOfLines={1}
accessibilityTraits="header"
accessibilityRole="header"
>
{subtitle}
{title}
</Text>
) : null}
</View>
{subtitle ? (
<Text
style={[styles.subtitle, { color: subtitleColor }, subtitleStyle]}
numberOfLines={1}
>
{subtitle}
</Text>
) : null}
</View>
</TouchableWithoutFeedback>
);
}
}
Expand Down