Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix to make disable Left/Right button #254

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
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
3 changes: 2 additions & 1 deletion NavbarButton.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ export default function NavbarButton(props) {
accessible,
accessibilityLabel
} = props;
const disabledStyle = disabled ? { opacity: 0.6 } : {};

return (
<TouchableOpacity
Expand All @@ -28,7 +29,7 @@ export default function NavbarButton(props) {
accessibilityLabel={accessibilityLabel}
>
<View style={style}>
<Text style={[styles.navBarButtonText, { color: tintColor }]}>{title}</Text>
<Text style={[styles.navBarButtonText, { color: tintColor }, disabledStyle]}>{title}</Text>
</View>
</TouchableOpacity>
);
Expand Down
10 changes: 7 additions & 3 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ function getButtonElement(data, style) {
style={[data.style, style]}
tintColor={data.tintColor}
handler={data.handler}
disabled={data.disabled}
accessible={data.accessible}
accessibilityLabel={data.accessibilityLabel}
/>
Expand All @@ -50,9 +51,9 @@ function getButtonElement(data, style) {
);
}

function getTitleElement(data) {
function getTitleElement(data, style) {
if (!data || data.props) {
return <View style={styles.customTitle}>{data}</View>;
return <View style={[styles.customTitle, style]}>{data}</View>;
}

const colorStyle = data.tintColor ? { color: data.tintColor } : null;
Expand Down Expand Up @@ -87,6 +88,7 @@ export default class NavigationBar extends Component {
PropTypes.oneOf([null]),
]),
containerStyle: ViewPropTypes.style,
titleStyle: ViewPropTypes.style
};

static defaultProps = {
Expand All @@ -102,6 +104,7 @@ export default class NavigationBar extends Component {
showAnimation: 'slide',
},
containerStyle: {},
titleStyle: {}
};

componentDidMount() {
Expand Down Expand Up @@ -130,6 +133,7 @@ export default class NavigationBar extends Component {
render() {
const {
containerStyle,
titleStyle,
tintColor,
title,
leftButton,
Expand All @@ -152,7 +156,7 @@ export default class NavigationBar extends Component {
<View style={[styles.navBarContainer, containerStyle, customTintColor]}>
{statusBar}
<View style={[styles.navBar, style]}>
{getTitleElement(title)}
{getTitleElement(title, titleStyle)}
{getButtonElement(leftButton, { marginLeft: 8 })}
{getButtonElement(rightButton, { marginRight: 8 })}
</View>
Expand Down