Skip to content
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ public String toString() {
public int titleBarTitleFontSize;
public boolean titleBarTitleFontBold;
public boolean titleBarTitleTextCentered;
public boolean titleBarSubTitleTextCentered;
public int titleBarHeight;
public boolean backButtonHidden;
public Font titleBarButtonFontFamily;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ public StyleParams parse() {
result.titleBarTitleFontSize = getInt("titleBarTitleFontSize", getDefaultTitleTextFontSize());
result.titleBarTitleFontBold = getBoolean("titleBarTitleFontBold", getDefaultTitleTextFontBold());
result.titleBarTitleTextCentered = getBoolean("titleBarTitleTextCentered", getDefaultTitleBarTextCentered());
result.titleBarSubTitleTextCentered = getBoolean("titleBarSubTitleTextCentered", getDefaultTitleBarTextCentered());
result.titleBarHeight = getInt("titleBarHeight", getDefaultTitleBarHeight());
result.backButtonHidden = getBoolean("backButtonHidden", getDefaultBackButtonHidden());
result.topTabsHidden = getBoolean("topTabsHidden", getDefaultTopTabsHidden());
Expand Down Expand Up @@ -326,6 +327,10 @@ private boolean getDefaultTitleBarTextCentered() {
return AppStyle.appStyle != null && AppStyle.appStyle.titleBarTitleTextCentered;
}

private boolean getDefaultSubTitleBarTextCentered() {
return AppStyle.appStyle != null && AppStyle.appStyle.titleBarSubTitleTextCentered;
}

private int getDefaultTitleBarHeight() {
return AppStyle.appStyle == null ? -1 : AppStyle.appStyle.titleBarHeight;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ public void setStyle(StyleParams params) {
setSubtitleFont(params);
colorOverflowButton(params);
setBackground(params);
centerTitle(params);
centerTopBarContent(params);
setTopPadding(params);
}

Expand All @@ -102,6 +102,7 @@ public void setSubtitle(CharSequence subtitle, StyleParams styleParams) {
super.setSubtitle(subtitle);
setSubtitleFontSize(styleParams);
setSubtitleFont(styleParams);
centerSubTitle(styleParams);
}

private void setSubtitleFontSize(StyleParams params) {
Expand All @@ -120,6 +121,11 @@ private void setSubtitleFont(StyleParams params) {
}
}

private void centerTopBarContent(final StyleParams params) {
centerTitle(params);
centerSubTitle(params);
}

private void centerTitle(final StyleParams params) {
final View titleView = getTitleView();
if (titleView == null) {
Expand All @@ -135,6 +141,21 @@ public void run() {
});
}

private void centerSubTitle(final StyleParams params) {
final TextView subTitleView = getSubtitleView();
if (subTitleView == null) {
return;
}
ViewUtils.runOnPreDraw(subTitleView, new Runnable() {
@Override
public void run() {
if (params.titleBarSubTitleTextCentered) {
subTitleView.setX(ViewUtils.getWindowWidth((Activity) getContext()) / 2 - subTitleView.getWidth() / 2);
}
}
});
}

private void setTopPadding(final StyleParams params) {
setPadding(0, (int) ViewUtils.convertDpToPixel(params.titleBarTopPadding), 0,0);
}
Expand Down
1 change: 1 addition & 0 deletions docs/styling-the-navigator.md
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ this.props.navigator.setStyle({
// Android only
navigationBarColor: '#000000', // change the background color of the bottom native navigation bar.
navBarTitleTextCentered: true, // default: false. centers the title.
navBarSubTitleTextCentered: true, // (Android - default: false, iOS - default: depending on navBarTitleTextCentered). centers the subTitle.
navBarButtonFontFamily: 'sans-serif-thin', // Change the font family of textual buttons
statusBarColor: '#000000', // change the color of the status bar.
drawUnderStatusBar: false, // default: false, will draw the screen underneath the statusbar. Useful togheter with statusBarColor: transparent
Expand Down
1 change: 1 addition & 0 deletions src/deprecated/platformSpecificDeprecated.android.js
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,7 @@ function convertStyleParams(originalStyleObject) {
titleBarTitleFontSize: originalStyleObject.navBarTextFontSize,
titleBarTitleFontBold: originalStyleObject.navBarTextFontBold,
titleBarTitleTextCentered: originalStyleObject.navBarTitleTextCentered,
titleBarSubTitleTextCentered: originalStyleObject.navBarSubTitleTextCentered,
titleBarHeight: originalStyleObject.navBarHeight,
titleBarTopPadding: originalStyleObject.navBarTopPadding,
backButtonHidden: originalStyleObject.backButtonHidden,
Expand Down