@@ -7,8 +7,10 @@ import { TabContentItem } from "../tab-navigation-base/tab-content-item";
7
7
import { TabNavigationBase , itemsProperty , selectedIndexProperty , tabStripProperty } from "../tab-navigation-base/tab-navigation-base" ;
8
8
import { CSSType , Color } from "../core/view" ;
9
9
import { Frame } from "../frame" ;
10
- import { RESOURCE_PREFIX , ad , layout } from "../../utils/utils" ;
11
10
import { fromFileOrResource } from "../../image-source" ;
11
+ import { RESOURCE_PREFIX , ad , layout } from "../../utils/utils" ;
12
+ import * as application from "../../application" ;
13
+
12
14
// TODO: Impl trace
13
15
// import { isEnabled as traceEnabled, write as traceWrite } from "../../../trace";
14
16
@@ -99,31 +101,36 @@ function initializeNativeClasses() {
99
101
BottomNavigationBar = BottomNavigationBarImplementation ;
100
102
}
101
103
102
- function createTabItemSpec ( tabStripItem : TabStripItem ) : org . nativescript . widgets . TabItemSpec {
103
- const result = new org . nativescript . widgets . TabItemSpec ( ) ;
104
- result . title = tabStripItem . title ;
104
+ function createTabItemSpec ( item : TabStripItem ) : org . nativescript . widgets . TabItemSpec {
105
+ let iconSource ;
106
+ const tabItemSpec = new org . nativescript . widgets . TabItemSpec ( ) ;
107
+
108
+ // Image and Label children of TabStripItem
109
+ // take priority over its `iconSource` and `title` properties
110
+ iconSource = item . image ? item . image . src : item . iconSource ;
111
+ tabItemSpec . title = item . label ? item . label . text : item . title ;
105
112
106
- if ( tabStripItem . iconSource ) {
107
- if ( tabStripItem . iconSource . indexOf ( RESOURCE_PREFIX ) === 0 ) {
108
- result . iconId = ad . resources . getDrawableId ( tabStripItem . iconSource . substr ( RESOURCE_PREFIX . length ) ) ;
109
- if ( result . iconId === 0 ) {
113
+ if ( iconSource ) {
114
+ if ( iconSource . indexOf ( RESOURCE_PREFIX ) === 0 ) {
115
+ tabItemSpec . iconId = ad . resources . getDrawableId ( iconSource . substr ( RESOURCE_PREFIX . length ) ) ;
116
+ if ( tabItemSpec . iconId === 0 ) {
110
117
// TODO:
111
- // traceMissingIcon(tabStripItem. iconSource);
118
+ // traceMissingIcon(iconSource);
112
119
}
113
120
} else {
114
- const is = fromFileOrResource ( tabStripItem . iconSource ) ;
121
+ const is = fromFileOrResource ( item . iconSource ) ;
115
122
if ( is ) {
116
123
// TODO: Make this native call that accepts string so that we don't load Bitmap in JS.
117
124
// tslint:disable-next-line:deprecation
118
- result . iconDrawable = new android . graphics . drawable . BitmapDrawable ( is . android ) ;
125
+ tabItemSpec . iconDrawable = new android . graphics . drawable . BitmapDrawable ( application . android . context . getResources ( ) , is . android ) ;
119
126
} else {
120
127
// TODO:
121
- // traceMissingIcon(tabStripItem. iconSource);
128
+ // traceMissingIcon(iconSource);
122
129
}
123
130
}
124
131
}
125
132
126
- return result ;
133
+ return tabItemSpec ;
127
134
}
128
135
129
136
function setElevation ( grid : org . nativescript . widgets . GridLayout , bottomNavigationBar : org . nativescript . widgets . BottomNavigationBar ) {
0 commit comments