mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-11-05 13:26:48 +08:00
Merge pull request #8315 from NativeScript/tab-styles-fixes
fix(android): Bugs in tab strip items when changing styles dynamically
This commit is contained in:
@@ -391,7 +391,7 @@ export class BottomNavigation extends TabNavigationBase {
|
|||||||
if (this._manager && this._manager.isDestroyed()) {
|
if (this._manager && this._manager.isDestroyed()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
this._attachedToWindow = true;
|
this._attachedToWindow = true;
|
||||||
this.changeTab(this.selectedIndex);
|
this.changeTab(this.selectedIndex);
|
||||||
}
|
}
|
||||||
@@ -614,6 +614,9 @@ export class BottomNavigation extends TabNavigationBase {
|
|||||||
|
|
||||||
private getIcon(tabStripItem: TabStripItem): android.graphics.drawable.BitmapDrawable {
|
private getIcon(tabStripItem: TabStripItem): android.graphics.drawable.BitmapDrawable {
|
||||||
const iconSource = tabStripItem.image && tabStripItem.image.src;
|
const iconSource = tabStripItem.image && tabStripItem.image.src;
|
||||||
|
if (!iconSource) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
let is: ImageSource;
|
let is: ImageSource;
|
||||||
if (isFontIconURI(iconSource)) {
|
if (isFontIconURI(iconSource)) {
|
||||||
@@ -705,7 +708,10 @@ export class BottomNavigation extends TabNavigationBase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public setTabBarItemFontInternal(tabStripItem: TabStripItem, value: Font): void {
|
public setTabBarItemFontInternal(tabStripItem: TabStripItem, value: Font): void {
|
||||||
tabStripItem.nativeViewProtected.setTextSize(value.fontSize);
|
if (value.fontSize) {
|
||||||
|
tabStripItem.nativeViewProtected.setTextSize(value.fontSize);
|
||||||
|
}
|
||||||
|
|
||||||
tabStripItem.nativeViewProtected.setTypeface(value.getAndroidTypeface());
|
tabStripItem.nativeViewProtected.setTypeface(value.getAndroidTypeface());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -127,7 +127,7 @@ export class TabStripItem extends View implements TabStripItemDefinition, AddChi
|
|||||||
const parent = <TabStrip>this.parent;
|
const parent = <TabStrip>this.parent;
|
||||||
const tabStripParent = parent && <TabNavigationBase>parent.parent;
|
const tabStripParent = parent && <TabNavigationBase>parent.parent;
|
||||||
|
|
||||||
return tabStripParent && (<any>tabStripParent).setTabBarIconColor(this, args.value);
|
return tabStripParent && tabStripParent.setTabBarIconColor(this, args.value);
|
||||||
});
|
});
|
||||||
this.image.style.on("colorChange", this._imageColorHandler);
|
this.image.style.on("colorChange", this._imageColorHandler);
|
||||||
|
|
||||||
@@ -135,7 +135,7 @@ export class TabStripItem extends View implements TabStripItemDefinition, AddChi
|
|||||||
const parent = <TabStrip>this.parent;
|
const parent = <TabStrip>this.parent;
|
||||||
const tabStripParent = parent && <TabNavigationBase>parent.parent;
|
const tabStripParent = parent && <TabNavigationBase>parent.parent;
|
||||||
|
|
||||||
return tabStripParent && (<any>tabStripParent).setTabBarIconColor(this, args.value);
|
return tabStripParent && tabStripParent.setTabBarIconColor(this, args.value);
|
||||||
});
|
});
|
||||||
this.image.style.on("fontInternalChange", this._imageFontHandler);
|
this.image.style.on("fontInternalChange", this._imageFontHandler);
|
||||||
|
|
||||||
@@ -143,7 +143,7 @@ export class TabStripItem extends View implements TabStripItemDefinition, AddChi
|
|||||||
const parent = <TabStrip>this.parent;
|
const parent = <TabStrip>this.parent;
|
||||||
const tabStripParent = parent && <TabNavigationBase>parent.parent;
|
const tabStripParent = parent && <TabNavigationBase>parent.parent;
|
||||||
|
|
||||||
return tabStripParent && (<any>tabStripParent).setTabBarIconColor(this, args.value);
|
return tabStripParent && tabStripParent.setTabBarIconColor(this, args.value);
|
||||||
});
|
});
|
||||||
this.image.on("srcChange", this._imageSrcHandler);
|
this.image.on("srcChange", this._imageSrcHandler);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -689,6 +689,9 @@ export class Tabs extends TabsBase {
|
|||||||
|
|
||||||
private getIcon(tabStripItem: TabStripItem): android.graphics.drawable.BitmapDrawable {
|
private getIcon(tabStripItem: TabStripItem): android.graphics.drawable.BitmapDrawable {
|
||||||
const iconSource = tabStripItem.image && tabStripItem.image.src;
|
const iconSource = tabStripItem.image && tabStripItem.image.src;
|
||||||
|
if (!iconSource) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
let is: ImageSource;
|
let is: ImageSource;
|
||||||
if (isFontIconURI(iconSource)) {
|
if (isFontIconURI(iconSource)) {
|
||||||
@@ -814,12 +817,14 @@ export class Tabs extends TabsBase {
|
|||||||
const tabBarItem = this._tabsBar.getViewForItemAt(index);
|
const tabBarItem = this._tabsBar.getViewForItemAt(index);
|
||||||
const imgView = <android.widget.ImageView>tabBarItem.getChildAt(0);
|
const imgView = <android.widget.ImageView>tabBarItem.getChildAt(0);
|
||||||
const drawable = this.getIcon(tabStripItem);
|
const drawable = this.getIcon(tabStripItem);
|
||||||
|
|
||||||
imgView.setImageDrawable(drawable);
|
imgView.setImageDrawable(drawable);
|
||||||
}
|
}
|
||||||
|
|
||||||
public setTabBarItemFontInternal(tabStripItem: TabStripItem, value: Font): void {
|
public setTabBarItemFontInternal(tabStripItem: TabStripItem, value: Font): void {
|
||||||
tabStripItem.nativeViewProtected.setTextSize(value.fontSize);
|
if (value.fontSize) {
|
||||||
|
tabStripItem.nativeViewProtected.setTextSize(value.fontSize);
|
||||||
|
}
|
||||||
tabStripItem.nativeViewProtected.setTypeface(value.getAndroidTypeface());
|
tabStripItem.nativeViewProtected.setTypeface(value.getAndroidTypeface());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user