@@ -50,19 +50,19 @@ function initializeNativeClasses() {
50
50
@CSSType ( 'BottomNavigation' )
51
51
export class BottomNavigation extends TabNavigation < com . nativescript . material . core . BottomNavigationBar > {
52
52
tabsPosition = TabsPosition . Bottom ;
53
- protected updateTabsBarItemAt ( position : number , itemSpec : com . nativescript . material . core . TabItemSpec ) {
53
+ protected override updateTabsBarItemAt ( position : number , itemSpec : com . nativescript . material . core . TabItemSpec ) {
54
54
this . mTabsBar . updateItemAt ( position , itemSpec ) ;
55
55
}
56
- protected setTabsBarSelectedIndicatorColors ( colors : number [ ] ) {
56
+ protected override setTabsBarSelectedIndicatorColors ( colors : number [ ] ) {
57
57
// nothing to do
58
58
}
59
- protected getTabBarItemView ( index : number ) {
59
+ protected override getTabBarItemView ( index : number ) {
60
60
return this . mTabsBar . getViewForItemAt ( index ) ;
61
61
}
62
- protected getTabBarItemTextView ( index : number ) {
62
+ protected override getTabBarItemTextView ( index : number ) {
63
63
return this . mTabsBar . getTextViewForItemAt ( index ) ;
64
64
}
65
- protected createNativeTabBar ( context : android . content . Context ) {
65
+ protected override createNativeTabBar ( context : android . content . Context ) {
66
66
initializeNativeClasses ( ) ;
67
67
const tabsBar = new BottomNavigationBar ( context , this ) ;
68
68
const primaryColor = Utils . android . resources . getPaletteColor ( PRIMARY_COLOR , context ) ;
@@ -73,11 +73,11 @@ export class BottomNavigation extends TabNavigation<com.nativescript.material.co
73
73
return tabsBar ;
74
74
}
75
75
76
- protected setTabBarItems ( tabItems : com . nativescript . material . core . TabItemSpec [ ] , viewPager : com . nativescript . material . core . TabViewPager ) {
76
+ protected override setTabBarItems ( tabItems : com . nativescript . material . core . TabItemSpec [ ] , viewPager : com . nativescript . material . core . TabViewPager ) {
77
77
this . mTabsBar . setItems ( tabItems ) ;
78
78
}
79
79
80
- protected selectTabBar ( oldIndex : number , newIndex : number ) {
80
+ protected override selectTabBar ( oldIndex : number , newIndex : number ) {
81
81
this . mTabsBar . setSelectedPosition ( newIndex ) ;
82
82
}
83
83
@@ -99,7 +99,7 @@ export class BottomNavigation extends TabNavigation<com.nativescript.material.co
99
99
// this.changeTab(this.selectedIndex);
100
100
}
101
101
102
- public updateAndroidItemAt ( index : number , spec : com . nativescript . material . core . TabItemSpec ) {
102
+ public override updateAndroidItemAt ( index : number , spec : com . nativescript . material . core . TabItemSpec ) {
103
103
// that try catch is fix for an android NPE error on css change which navigated in (not the current fragment)
104
104
try {
105
105
if ( this . mTabsBar ) {
@@ -108,7 +108,7 @@ export class BottomNavigation extends TabNavigation<com.nativescript.material.co
108
108
} catch ( err ) { }
109
109
}
110
110
111
- public setTabBarBackgroundColor ( value : android . graphics . drawable . Drawable | Color ) : void {
111
+ public override setTabBarBackgroundColor ( value : android . graphics . drawable . Drawable | Color ) : void {
112
112
super . setTabBarBackgroundColor ( value ) ;
113
113
// this.updateTabStripItems();
114
114
}
@@ -130,19 +130,28 @@ export class BottomNavigation extends TabNavigation<com.nativescript.material.co
130
130
} ) ;
131
131
}
132
132
133
- public setTabBarSelectedItemColor ( value : Color ) {
133
+ public override setTabBarSelectedItemColor ( value : Color ) {
134
134
super . setTabBarSelectedItemColor ( value ) ;
135
135
this . _setItemsColors ( this . tabStrip . items ) ;
136
136
}
137
137
138
- public setTabBarUnSelectedItemColor ( value : Color ) {
138
+ public override setTabBarUnSelectedItemColor ( value : Color ) {
139
139
super . setTabBarUnSelectedItemColor ( value ) ;
140
140
this . _setItemsColors ( this . tabStrip . items ) ;
141
141
}
142
142
143
- public onTabsBarSelectedPositionChange ( position : number , prevPosition : number ) {
144
- super . onTabsBarSelectedPositionChange ( position , prevPosition ) ;
143
+ public override onTabsBarSelectedPositionChange ( position : number , prevPosition : number ) : void {
145
144
this . mViewPager . setCurrentItem ( position , true ) ;
145
+ const tabStripItems = this . tabStrip && this . tabStrip . items ;
146
+
147
+ if ( position >= 0 && tabStripItems && tabStripItems [ position ] ) {
148
+ tabStripItems [ position ] . _emit ( TabStripItem . selectEvent ) ;
149
+ }
150
+
151
+ if ( prevPosition >= 0 && tabStripItems && tabStripItems [ prevPosition ] ) {
152
+ tabStripItems [ prevPosition ] . _emit ( TabStripItem . unselectEvent ) ;
153
+ }
154
+
146
155
this . _setItemsColors ( this . tabStrip . items ) ;
147
156
}
148
157
}
0 commit comments