Skip to content

Commit

Permalink
fix(android): tintColor on bottom navigation (#12242)
Browse files Browse the repository at this point in the history
Fixes TIMOB-28220
  • Loading branch information
garymathews committed Nov 6, 2020
1 parent 599b82d commit f640850
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -485,32 +485,27 @@ public Drawable updateIconTint(TiViewProxy tabProxy, Drawable drawable, boolean
return null;
}

// Clone existing drawable so color filter applies correctly.
drawable = drawable.getConstantState().newDrawable();

final KrollDict tabProperties = tabProxy.getProperties();
final KrollDict properties = getProxy().getProperties();

int color = this.textColorInt;
if (selected) {
if (tabProperties.containsKeyAndNotNull(TiC.PROPERTY_ACTIVE_TINT_COLOR)
|| properties.containsKeyAndNotNull(TiC.PROPERTY_ACTIVE_TINT_COLOR)
|| tabProperties.containsKeyAndNotNull(TiC.PROPERTY_ACTIVE_TITLE_COLOR)
|| properties.containsKeyAndNotNull(TiC.PROPERTY_ACTIVE_TITLE_COLOR)) {
|| properties.containsKeyAndNotNull(TiC.PROPERTY_ACTIVE_TINT_COLOR)) {
final String colorString = tabProperties.optString(TiC.PROPERTY_ACTIVE_TINT_COLOR,
properties.optString(TiC.PROPERTY_ACTIVE_TINT_COLOR,
tabProperties.optString(TiC.PROPERTY_ACTIVE_TITLE_COLOR,
properties.getString(TiC.PROPERTY_ACTIVE_TITLE_COLOR))));
properties.getString(TiC.PROPERTY_ACTIVE_TINT_COLOR));
color = TiColorHelper.parseColor(colorString);
}
drawable.setColorFilter(color, PorterDuff.Mode.SRC_IN);
} else {
color = this.unselectedTextColorInt;
if (tabProperties.containsKeyAndNotNull(TiC.PROPERTY_TINT_COLOR)
|| properties.containsKeyAndNotNull(TiC.PROPERTY_TINT_COLOR)
|| tabProperties.containsKeyAndNotNull(TiC.PROPERTY_TITLE_COLOR)
|| properties.containsKeyAndNotNull(TiC.PROPERTY_TITLE_COLOR)) {
|| properties.containsKeyAndNotNull(TiC.PROPERTY_TINT_COLOR)) {
final String colorString = tabProperties.optString(TiC.PROPERTY_TINT_COLOR,
properties.optString(TiC.PROPERTY_TINT_COLOR,
tabProperties.optString(TiC.PROPERTY_TITLE_COLOR,
properties.getString(TiC.PROPERTY_TITLE_COLOR))));
properties.getString(TiC.PROPERTY_TINT_COLOR));
color = TiColorHelper.parseColor(colorString);
}
drawable.setColorFilter(color, PorterDuff.Mode.SRC_IN);
Expand Down
8 changes: 4 additions & 4 deletions apidoc/Titanium/UI/Tab.yml
Original file line number Diff line number Diff line change
Expand Up @@ -267,13 +267,13 @@ properties:
platforms: [iphone,ipad, macos]

- name: tintColor
summary: Defines the color of the tab icon. Will fallback to titleColor when not defined.
summary: Defines the color of the tab icon.
type: String
since: {iphone: "3.1.3", ipad: "3.1.3", android: "9.0.3"}
platforms: [iphone, ipad, android, macos]

- name: activeTintColor
summary: Defines the color of the tab icon when it is active. Will fallback to activeTitleColor when not defined.
summary: Defines the color of the tab icon when it is active.
type: String
since: {android: "9.0.3"}
platforms: [iphone, ipad, android, macos]
Expand All @@ -289,7 +289,7 @@ properties:
- name: titleColor
summary: Defines the color of the title of tab when it's inactive.
description: |
The color of the title of the tab when it's inactive. If not defined, it will use the default tint color.
The color of the title of the tab when it's inactive.
type: [String, Titanium.UI.Color]
since: {iphone: "4.1.0", ipad: "4.1.0", android: "8.0.0"}
osver: {ios: {min: "5.0"}}
Expand All @@ -298,7 +298,7 @@ properties:
- name: activeTitleColor
summary: Defines the color of the title of tab when it's active.
description: |
The color of the title of the tab when it's active. If not defined, it will use the default tint color.
The color of the title of the tab when it's active.
type: [String, Titanium.UI.Color]
since: {iphone: "4.1.0", ipad: "4.1.0", android: "8.0.0"}
osver: {ios: {min: "5.0"}}
Expand Down
8 changes: 4 additions & 4 deletions apidoc/Titanium/UI/TabGroup.yml
Original file line number Diff line number Diff line change
Expand Up @@ -340,15 +340,15 @@ properties:
- name: titleColor
summary: Defines the color of the title of tab when it's inactive.
description: |
The color of the title of the tab when it's inactive. If not defined, it will use the default tint color.
The color of the title of the tab when it's inactive.
type: [String, Titanium.UI.Color]
since: {iphone: "9.0.3", ipad: "9.0.3", android: "9.0.3"}
platforms: [iphone, ipad, android, macos]

- name: activeTitleColor
summary: Defines the color of the title of tab when it's active.
description: |
The color of the title of the tab when it's active. If not defined, it will use the default tint color.
The color of the title of the tab when it's active.
type: [String, Titanium.UI.Color]
since: {iphone: "9.0.3", ipad: "9.0.3", android: "9.0.3"}
platforms: [iphone, ipad, android, macos]
Expand Down Expand Up @@ -504,7 +504,7 @@ properties:
- name: activeTintColor
summary: The activeTintColor to apply to tabs.
description: |
This property affects the tint of selected tab icons. Will fallback to activeTitleColor when not defined.
This property affects the tint of selected tab icons.
type: String
since: "9.0.3"
default: null
Expand All @@ -513,7 +513,7 @@ properties:
- name: tintColor
summary: The tintColor to apply to tabs.
description: |
This property affects the tint of unselected tab icons. Will fallback to titleColor when not defined.
This property affects the tint of unselected tab icons.
type: String
since: "9.0.3"
default: null
Expand Down

0 comments on commit f640850

Please sign in to comment.