1
1
import { themer } from '@nativescript-community/ui-material-core' ;
2
2
import { Application , Color , Screen , Utils , backgroundColorProperty } from '@nativescript/core' ;
3
- import { BottomNavigationBarBase , BottomNavigationTabBase , TitleVisibility , activeColorCssProperty , badgeColorCssProperty , badgeTextColorCssProperty , inactiveColorCssProperty , tabsProperty , titleVisibilityProperty } from './bottomnavigationbar-common' ;
3
+ import {
4
+ BottomNavigationBarBase ,
5
+ BottomNavigationTabBase ,
6
+ TitleVisibility ,
7
+ activeColorCssProperty ,
8
+ badgeColorCssProperty ,
9
+ badgeTextColorCssProperty ,
10
+ inactiveColorCssProperty ,
11
+ tabsProperty ,
12
+ titleVisibilityProperty
13
+ } from './bottomnavigationbar-common' ;
4
14
5
15
@NativeClass
6
16
class BottomNavigationBarDelegate extends NSObject {
@@ -17,21 +27,23 @@ class BottomNavigationBarDelegate extends NSObject {
17
27
if ( ! owner ) {
18
28
return ;
19
29
}
20
- if ( owner . selectedTabIndex === item . tag ) {
21
- owner . _emitTabReselected ( item . tag ) ;
30
+ const tag = item && item . tag ? item . tag : 0 ;
31
+ if ( owner . selectedTabIndex === tag ) {
32
+ owner . _emitTabReselected ( tag ) ;
22
33
return ;
23
34
}
24
- owner . _emitTabSelected ( item . tag ) ;
35
+ owner . _emitTabSelected ( tag ) ;
25
36
}
26
37
27
38
bottomNavigationBarShouldSelectItem ( bottomNavigationBar : MDCBottomNavigationBar , item : UITabBarItem ) : boolean {
28
39
const owner = this . _owner . get ( ) ;
29
40
if ( ! owner ) {
30
41
return true ;
31
42
}
32
- const bottomNavigationTab = owner . items [ item . tag ] ;
43
+ const tag = item && item . tag ? item . tag : 0 ;
44
+ const bottomNavigationTab = owner . items [ tag ] ;
33
45
if ( ! bottomNavigationTab . isSelectable ) {
34
- owner . _emitTabPressed ( item . tag ) ;
46
+ owner . _emitTabPressed ( tag ) ;
35
47
}
36
48
return bottomNavigationTab . isSelectable ;
37
49
}
@@ -140,10 +152,9 @@ export class BottomNavigationBar extends BottomNavigationBarBase {
140
152
return tab ;
141
153
} ) ;
142
154
this . nativeViewProtected . items = new NSArray ( { array : bottomNavigationTabs } ) ;
143
-
144
155
// TODO: this is for he v8 runtime. Should not have to need this setTimeout(), find better way.
145
156
setTimeout ( ( ) => {
146
- this . nativeViewProtected . selectedItem = this . nativeViewProtected . items [ this . selectedTabIndex ] ;
157
+ this . nativeViewProtected . selectedItem = this . nativeViewProtected . items . objectAtIndex ( this . selectedTabIndex ) ;
147
158
} , 0 ) ;
148
159
}
149
160
@@ -174,7 +185,7 @@ declare class MDCBottomNavigationItemView extends UIView {
174
185
export class BottomNavigationTab extends BottomNavigationTabBase {
175
186
nativeViewProtected : UITabBarItem ;
176
187
createNativeView ( ) {
177
- let icon = this . getNativeIcon ( ) ;
188
+ let icon = this . getNativeIcon ( ) ;
178
189
if ( icon ) {
179
190
icon = icon . imageWithRenderingMode ( UIImageRenderingMode . Automatic ) ;
180
191
}
0 commit comments