Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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 @@ -391,7 +391,7 @@ export class BottomNavigation extends TabNavigationBase {
if (this._manager && this._manager.isDestroyed()) {
return;
}

this._attachedToWindow = true;
this.changeTab(this.selectedIndex);
}
Expand Down Expand Up @@ -614,6 +614,9 @@ export class BottomNavigation extends TabNavigationBase {

private getIcon(tabStripItem: TabStripItem): android.graphics.drawable.BitmapDrawable {
const iconSource = tabStripItem.image && tabStripItem.image.src;
if (!iconSource) {
return null;
}

let is: ImageSource;
if (isFontIconURI(iconSource)) {
Expand Down Expand Up @@ -705,7 +708,10 @@ export class BottomNavigation extends TabNavigationBase {
}

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());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,23 +127,23 @@ export class TabStripItem extends View implements TabStripItemDefinition, AddChi
const parent = <TabStrip>this.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._imageFontHandler = this._imageFontHandler || ((args: PropertyChangeData) => {
const parent = <TabStrip>this.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._imageSrcHandler = this._imageSrcHandler || ((args: PropertyChangeData) => {
const parent = <TabStrip>this.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);
}
Expand Down
9 changes: 7 additions & 2 deletions nativescript-core/ui/tabs/tabs.android.ts
Original file line number Diff line number Diff line change
Expand Up @@ -689,6 +689,9 @@ export class Tabs extends TabsBase {

private getIcon(tabStripItem: TabStripItem): android.graphics.drawable.BitmapDrawable {
const iconSource = tabStripItem.image && tabStripItem.image.src;
if (!iconSource) {
return null;
}

let is: ImageSource;
if (isFontIconURI(iconSource)) {
Expand Down Expand Up @@ -814,12 +817,14 @@ export class Tabs extends TabsBase {
const tabBarItem = this._tabsBar.getViewForItemAt(index);
const imgView = <android.widget.ImageView>tabBarItem.getChildAt(0);
const drawable = this.getIcon(tabStripItem);

imgView.setImageDrawable(drawable);
}

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());
}

Expand Down