@@ -12,6 +12,8 @@ import { CSSType, Color } from "../core/view";
12
12
import { Frame , View } from "../frame" ;
13
13
import { RESOURCE_PREFIX , ad , layout } from "../../utils/utils" ;
14
14
import { fromFileOrResource } from "../../image-source" ;
15
+ import * as application from "../../application" ;
16
+
15
17
// TODO: Impl trace
16
18
// import { isEnabled as traceEnabled, write as traceWrite } from "../../../trace";
17
19
@@ -159,34 +161,35 @@ function initializeNativeClasses() {
159
161
}
160
162
161
163
function 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 ) {
173
176
// TODO:
174
- // traceMissingIcon(tabStripItem. iconSource);
177
+ // traceMissingIcon(iconSource);
175
178
}
176
179
} else {
177
180
const is = fromFileOrResource ( tabStripItem . iconSource ) ;
178
181
if ( is ) {
179
182
// TODO: Make this native call that accepts string so that we don't load Bitmap in JS.
180
183
// 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 ) ;
182
185
} else {
183
186
// TODO:
184
- // traceMissingIcon(tabStripItem. iconSource);
187
+ // traceMissingIcon(iconSource);
185
188
}
186
189
}
187
190
}
188
191
189
- return result ;
192
+ return tabItemSpec ;
190
193
}
191
194
192
195
function setElevation ( grid : org . nativescript . widgets . GridLayout , bottomNavigationBar : org . nativescript . widgets . BottomNavigationBar ) {
@@ -471,7 +474,7 @@ export class BottomNavigation extends TabNavigationBase {
471
474
}
472
475
473
476
this . _currentFragment = fragment ;
474
-
477
+
475
478
const tabItems = this . items ;
476
479
const tabItem = tabItems ? tabItems [ position ] : null ;
477
480
if ( tabItem ) {
0 commit comments