Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 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 @@ -10,6 +10,7 @@
import android.content.Context;
import android.content.res.Configuration;
import android.graphics.Color;
import android.graphics.PorterDuff;
import android.graphics.drawable.Drawable;
import android.view.MenuItem;
import androidx.annotation.ColorInt;
Expand Down Expand Up @@ -133,9 +134,14 @@ protected void onLayout(boolean changed, int l, int t, int r, int b)
// no selected color specified but a text color -> use that
selectedTextColor = textColor;
}

this.tabLayout.setTabTextColors(textColor, selectedTextColor);
}
if (this.tabLayout.getTabAt(0).getIcon() != null
&& getProxy().hasPropertyAndNotNull(TiC.PROPERTY_ACTIVE_TINT_COLOR)) {
this.tabLayout.getTabAt(0).getIcon().setColorFilter(
TiConvert.toColor(proxy.getProperty(TiC.PROPERTY_ACTIVE_TINT_COLOR),
TiApplication.getAppCurrentActivity()), PorterDuff.Mode.SRC_IN);
}
setNativeView(this.tabLayout);
}

Expand Down Expand Up @@ -261,6 +267,11 @@ private void addItem(Object value)
if (value instanceof Drawable) {
tab.setIcon(((Drawable) value));
TiUITabLayoutTabGroup.scaleIconToFit(tab);

if (tab.getIcon() != null && proxy.hasPropertyAndNotNull(TiC.PROPERTY_TINT_COLOR)) {
tab.getIcon().setColorFilter(TiConvert.toColor(proxy.getProperty(TiC.PROPERTY_TINT_COLOR),
TiApplication.getAppCurrentActivity()), PorterDuff.Mode.SRC_IN);
}
} else {
tab.setText(value.toString());
}
Expand Down Expand Up @@ -394,6 +405,13 @@ private void onTabIndexChangedTo(int index)
// First, update the proxy's "index" property.
proxy.setProperty(TiC.PROPERTY_INDEX, index);

if (this.tabLayout.getTabAt(index).getIcon() != null
&& proxy.hasPropertyAndNotNull(TiC.PROPERTY_ACTIVE_TINT_COLOR)) {
this.tabLayout.getTabAt(index).getIcon().setColorFilter(
TiConvert.toColor(proxy.getProperty(TiC.PROPERTY_ACTIVE_TINT_COLOR),
TiApplication.getAppCurrentActivity()), PorterDuff.Mode.SRC_IN);
}

// Last, fire a "click" event.
if (!skipClickEvent) {
KrollDict data = new KrollDict();
Expand All @@ -406,7 +424,12 @@ private void onTabIndexChangedTo(int index)
@Override
public void onTabUnselected(TabLayout.Tab tab)
{
// No override
// set old tint color again
if (tab.getIcon() != null && proxy.hasPropertyAndNotNull(TiC.PROPERTY_TINT_COLOR)) {
tab.getIcon().setColorFilter(
TiConvert.toColor(proxy.getProperty(TiC.PROPERTY_TINT_COLOR), TiApplication.getAppCurrentActivity()),
PorterDuff.Mode.SRC_IN);
}
}

@Override
Expand Down
8 changes: 7 additions & 1 deletion apidoc/Titanium/UI/TabbedBar.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,12 @@ properties:
availability: creation
platforms: [iphone, ipad, android, macos]
since: {iphone: "9.0.0", ipad: "9.0.0", android: "12.0.0"}
- name: activeTintColor
summary: Icon tint color of the selected tab
type: [ String, Titanium.UI.Color ]
availability: creation
platforms: [android]
since: {android: "12.5.0"}
- name: style
summary: Style of the tabbed bar.
description: |
Expand All @@ -66,7 +72,7 @@ properties:

The `BAR` style specifies a more compact style and allows the bar's background
color or gradient to show through.

For Android use [Titanium.UI.TABS_STYLE_DEFAULT](Titanium.UI.TABS_STYLE_DEFAULT) or
[Titanium.UI.TABS_STYLE_BOTTOM_NAVIGATION](Titanium.UI.TABS_STYLE_BOTTOM_NAVIGATION) and
it is only supported in the creation dictionary of the proxy.
Expand Down