@@ -12,6 +12,8 @@ import { CSSType, Color } from "../core/view";
1212import { Frame , View } from "../frame" ;
1313import { RESOURCE_PREFIX , ad , layout } from "../../utils/utils" ;
1414import { fromFileOrResource } from "../../image-source" ;
15+ import * as application from "../../application" ;
16+
1517// TODO: Impl trace
1618// import { isEnabled as traceEnabled, write as traceWrite } from "../../../trace";
1719
@@ -159,34 +161,35 @@ function initializeNativeClasses() {
159161}
160162
161163function createTabItemSpec ( tabStripItem : TabStripItem ) : org . nativescript . widgets . TabItemSpec {
162- const result = new org . nativescript . widgets . TabItemSpec ( ) ;
163- result . title = tabStripItem . title ;
164-
165- if ( tabStripItem . backgroundColor instanceof Color ) {
166- result . backgroundColor = tabStripItem . backgroundColor . android ;
167- }
168-
169- if ( tabStripItem . iconSource ) {
170- if ( tabStripItem . iconSource . indexOf ( RESOURCE_PREFIX ) === 0 ) {
171- result . iconId = ad . resources . getDrawableId ( tabStripItem . iconSource . substr ( RESOURCE_PREFIX . length ) ) ;
172- if ( result . iconId === 0 ) {
164+ let iconSource ;
165+ const tabItemSpec = new org . nativescript . widgets . TabItemSpec ( ) ;
166+
167+ // Image and Label children of TabStripItem
168+ // take priority over its `iconSource` and `title` properties
169+ iconSource = tabStripItem . image ? tabStripItem . image . src : tabStripItem . iconSource ;
170+ tabItemSpec . title = tabStripItem . label ? tabStripItem . label . text : tabStripItem . title ;
171+
172+ if ( iconSource ) {
173+ if ( iconSource . indexOf ( RESOURCE_PREFIX ) === 0 ) {
174+ tabItemSpec . iconId = ad . resources . getDrawableId ( iconSource . substr ( RESOURCE_PREFIX . length ) ) ;
175+ if ( tabItemSpec . iconId === 0 ) {
173176 // TODO:
174- // traceMissingIcon(tabStripItem. iconSource);
177+ // traceMissingIcon(iconSource);
175178 }
176179 } else {
177180 const is = fromFileOrResource ( tabStripItem . iconSource ) ;
178181 if ( is ) {
179182 // TODO: Make this native call that accepts string so that we don't load Bitmap in JS.
180183 // tslint:disable-next-line:deprecation
181- result . iconDrawable = new android . graphics . drawable . BitmapDrawable ( is . android ) ;
184+ tabItemSpec . iconDrawable = new android . graphics . drawable . BitmapDrawable ( application . android . context . getResources ( ) , is . android ) ;
182185 } else {
183186 // TODO:
184- // traceMissingIcon(tabStripItem. iconSource);
187+ // traceMissingIcon(iconSource);
185188 }
186189 }
187190 }
188191
189- return result ;
192+ return tabItemSpec ;
190193}
191194
192195function setElevation ( grid : org . nativescript . widgets . GridLayout , bottomNavigationBar : org . nativescript . widgets . BottomNavigationBar ) {
@@ -471,7 +474,7 @@ export class BottomNavigation extends TabNavigationBase {
471474 }
472475
473476 this . _currentFragment = fragment ;
474-
477+
475478 const tabItems = this . items ;
476479 const tabItem = tabItems ? tabItems [ position ] : null ;
477480 if ( tabItem ) {
0 commit comments