mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-08-16 03:31:45 +08:00
fix(tabs): dynamic styling colors fixed (#8460)
* fix(tabs): dynamic styling colors fixed * test(tabs): adding dynamic color change test
This commit is contained in:
@ -713,6 +713,25 @@ export class BottomNavigation extends TabNavigationBase {
|
||||
} else {
|
||||
this._bottomNavigationBar.setBackground(tryCloneDrawable(value, this.nativeViewProtected.getResources));
|
||||
}
|
||||
|
||||
this.updateTabStripItems();
|
||||
}
|
||||
|
||||
private updateTabStripItems(): void {
|
||||
this.tabStrip.items.forEach((tabStripItem: TabStripItem) => {
|
||||
if (tabStripItem.nativeView) {
|
||||
const tabItemSpec = this.createTabItemSpec(tabStripItem);
|
||||
this.updateAndroidItemAt(tabStripItem._index, tabItemSpec);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private setItemsColors(items: Array<TabStripItem>): void {
|
||||
items.forEach((item) => {
|
||||
if (item.nativeView) {
|
||||
this._setItemColor(item);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public getTabBarSelectedItemColor(): Color {
|
||||
@ -721,6 +740,7 @@ export class BottomNavigation extends TabNavigationBase {
|
||||
|
||||
public setTabBarSelectedItemColor(value: Color) {
|
||||
this._selectedItemColor = value;
|
||||
this.setItemsColors(this.tabStrip.items);
|
||||
}
|
||||
|
||||
public getTabBarUnSelectedItemColor(): Color {
|
||||
@ -729,6 +749,7 @@ export class BottomNavigation extends TabNavigationBase {
|
||||
|
||||
public setTabBarUnSelectedItemColor(value: Color) {
|
||||
this._unSelectedItemColor = value;
|
||||
this.setItemsColors(this.tabStrip.items);
|
||||
}
|
||||
|
||||
public setTabBarItemTitle(tabStripItem: TabStripItem, value: string): void {
|
||||
|
@ -796,6 +796,17 @@ export class Tabs extends TabsBase {
|
||||
} else {
|
||||
this._tabsBar.setBackground(tryCloneDrawable(value, this.nativeViewProtected.getResources));
|
||||
}
|
||||
|
||||
this.updateTabStripItems();
|
||||
}
|
||||
|
||||
private updateTabStripItems(): void {
|
||||
this.tabStrip.items.forEach((tabStripItem: TabStripItem) => {
|
||||
if (tabStripItem.nativeView) {
|
||||
const tabItemSpec = this.createTabItemSpec(tabStripItem);
|
||||
this.updateAndroidItemAt(tabStripItem._index, tabItemSpec);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public getTabBarHighlightColor(): number {
|
||||
@ -807,12 +818,21 @@ export class Tabs extends TabsBase {
|
||||
this._tabsBar.setSelectedIndicatorColors([color]);
|
||||
}
|
||||
|
||||
private setItemsColors(items: Array<TabStripItem>): void {
|
||||
items.forEach((item) => {
|
||||
if (item.nativeView) {
|
||||
this._setItemColor(item);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public getTabBarSelectedItemColor(): Color {
|
||||
return this._selectedItemColor;
|
||||
}
|
||||
|
||||
public setTabBarSelectedItemColor(value: Color) {
|
||||
this._selectedItemColor = value;
|
||||
this.setItemsColors(this.tabStrip.items);
|
||||
}
|
||||
|
||||
public getTabBarUnSelectedItemColor(): Color {
|
||||
@ -821,6 +841,7 @@ export class Tabs extends TabsBase {
|
||||
|
||||
public setTabBarUnSelectedItemColor(value: Color) {
|
||||
this._unSelectedItemColor = value;
|
||||
this.setItemsColors(this.tabStrip.items);
|
||||
}
|
||||
|
||||
public setTabBarItemTitle(tabStripItem: TabStripItem, value: string): void {
|
||||
|
@ -1030,6 +1030,7 @@ export class Tabs extends TabsBase {
|
||||
|
||||
public setTabBarSelectedItemColor(value: Color) {
|
||||
this._selectedItemColor = value;
|
||||
this.setItemColors();
|
||||
}
|
||||
|
||||
public getTabBarUnSelectedItemColor(): Color {
|
||||
@ -1038,6 +1039,7 @@ export class Tabs extends TabsBase {
|
||||
|
||||
public setTabBarUnSelectedItemColor(value: Color) {
|
||||
this._unSelectedItemColor = value;
|
||||
this.setItemColors();
|
||||
}
|
||||
|
||||
private visitFrames(view: ViewBase, operation: (frame: Frame) => {}) {
|
||||
|
Reference in New Issue
Block a user