Skip to content

Commit

Permalink
fix: return default tab background color when the background color is…
Browse files Browse the repository at this point in the history
… not explicitely set through css (#8240)

* fix: return default tab background color

when the background color is not explicitely set through css

* chore: update NativeScript.api.md

* fix: do not cast return getTabBarBackgroundColor to ColorDrawable

* chore: added comment and method check

Co-authored-by: Alexander Vakrilov <alexander.vakrilov@gmail.com>
  • Loading branch information
vtrifonov and vakrilov authored Jan 14, 2020
1 parent 4e48e68 commit 8569b51
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 6 deletions.
2 changes: 2 additions & 0 deletions api-reports/NativeScript.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -2197,6 +2197,8 @@ export class TabContentItem extends ContentView {
export class TabNavigationBase extends View {
android: any /* android.view.View */;

getTabBarBackgroundArgbColor(): any

getTabBarBackgroundColor(): any

getTabBarColor(): any
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -578,9 +578,7 @@ export class BottomNavigation extends TabNavigationBase {

// BACKGROUND-COLOR
const backgroundColor = tabStripItem.style.backgroundColor;
if (backgroundColor) {
tabItemSpec.backgroundColor = backgroundColor.android;
}
tabItemSpec.backgroundColor = backgroundColor ? backgroundColor.android : this.getTabBarBackgroundArgbColor();

// COLOR
const color = titleLabel.style.color;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,12 @@ export class TabNavigationBase extends View {
*/
getTabBarBackgroundColor(): any

/**
* @private
* Method is intended to be overridden by inheritors and used as "protected"
*/
getTabBarBackgroundArgbColor(): any

/**
* @private
* Method is intended to be overridden by inheritors and used as "protected"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,13 @@ export class TabNavigationBase extends View implements TabNavigationBaseDefiniti
return null;
}

public getTabBarBackgroundArgbColor(): any {
// This method is implemented only for Android
const colorDrawable = this.getTabBarBackgroundColor();

return colorDrawable && colorDrawable.getColor && colorDrawable.getColor();
}

public setTabBarBackgroundColor(value: any): void {
// overridden by inheritors
}
Expand Down
4 changes: 1 addition & 3 deletions nativescript-core/ui/tabs/tabs.android.ts
Original file line number Diff line number Diff line change
Expand Up @@ -653,9 +653,7 @@ export class Tabs extends TabsBase {

// BACKGROUND-COLOR
const backgroundColor = tabStripItem.style.backgroundColor;
if (backgroundColor) {
tabItemSpec.backgroundColor = backgroundColor.android;
}
tabItemSpec.backgroundColor = backgroundColor ? backgroundColor.android : this.getTabBarBackgroundArgbColor();

// COLOR
const color = nestedLabel.style.color;
Expand Down

0 comments on commit 8569b51

Please sign in to comment.