Skip to content

Ability to use custom selected color in shift mode #313

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

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
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
12 changes: 10 additions & 2 deletions bottom-bar/src/main/java/com/roughike/bottombar/BottomBar.java
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@ public class BottomBar extends RelativeLayout implements View.OnClickListener, V
private boolean mShouldUpdateFragmentInitially;

private int mMaxFixedTabCount = 3;
private boolean mForceUseCustomActiveColor = false;

/**
* Bind the BottomBar to your Activity, and inflate your layout here.
Expand Down Expand Up @@ -614,6 +615,13 @@ public void useDarkTheme() {
mIsDarkTheme = true;
}

/**
* Always use custom color for selected tab
*/
public void forceUseCustomColor() {
mForceUseCustomActiveColor = true;
}

/**
* Ignore the automatic Night Mode detection and use a light theme by default,
* even if the Night Mode is on.
Expand Down Expand Up @@ -1398,7 +1406,7 @@ private void selectTab(View tab, boolean animate) {

int tabPosition = findItemPosition(tab);

if (!mIsShiftingMode || mIsTabletMode) {
if (mForceUseCustomActiveColor || (!mIsShiftingMode || mIsTabletMode)) {
int activeColor = mCustomActiveTabColor != 0 ?
mCustomActiveTabColor : mPrimaryColor;
icon.setColorFilter(activeColor);
Expand Down Expand Up @@ -1463,7 +1471,7 @@ private void unselectTab(View tab, boolean animate) {
ImageView icon = (ImageView) tab.findViewById(R.id.bb_bottom_bar_icon);
TextView title = (TextView) tab.findViewById(R.id.bb_bottom_bar_title);

if (!mIsShiftingMode || mIsTabletMode) {
if (mForceUseCustomActiveColor || !mIsShiftingMode || mIsTabletMode) {
int inActiveColor = mIsDarkTheme ? mWhiteColor : mInActiveColor;
icon.setColorFilter(inActiveColor);

Expand Down