@@ -50,19 +50,19 @@ function initializeNativeClasses() {
5050@CSSType ( 'BottomNavigation' )
5151export class BottomNavigation extends TabNavigation < com . nativescript . material . core . BottomNavigationBar > {
5252 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 ) {
5454 this . mTabsBar . updateItemAt ( position , itemSpec ) ;
5555 }
56- protected setTabsBarSelectedIndicatorColors ( colors : number [ ] ) {
56+ protected override setTabsBarSelectedIndicatorColors ( colors : number [ ] ) {
5757 // nothing to do
5858 }
59- protected getTabBarItemView ( index : number ) {
59+ protected override getTabBarItemView ( index : number ) {
6060 return this . mTabsBar . getViewForItemAt ( index ) ;
6161 }
62- protected getTabBarItemTextView ( index : number ) {
62+ protected override getTabBarItemTextView ( index : number ) {
6363 return this . mTabsBar . getTextViewForItemAt ( index ) ;
6464 }
65- protected createNativeTabBar ( context : android . content . Context ) {
65+ protected override createNativeTabBar ( context : android . content . Context ) {
6666 initializeNativeClasses ( ) ;
6767 const tabsBar = new BottomNavigationBar ( context , this ) ;
6868 const primaryColor = Utils . android . resources . getPaletteColor ( PRIMARY_COLOR , context ) ;
@@ -73,11 +73,11 @@ export class BottomNavigation extends TabNavigation<com.nativescript.material.co
7373 return tabsBar ;
7474 }
7575
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 ) {
7777 this . mTabsBar . setItems ( tabItems ) ;
7878 }
7979
80- protected selectTabBar ( oldIndex : number , newIndex : number ) {
80+ protected override selectTabBar ( oldIndex : number , newIndex : number ) {
8181 this . mTabsBar . setSelectedPosition ( newIndex ) ;
8282 }
8383
@@ -99,7 +99,7 @@ export class BottomNavigation extends TabNavigation<com.nativescript.material.co
9999 // this.changeTab(this.selectedIndex);
100100 }
101101
102- public updateAndroidItemAt ( index : number , spec : com . nativescript . material . core . TabItemSpec ) {
102+ public override updateAndroidItemAt ( index : number , spec : com . nativescript . material . core . TabItemSpec ) {
103103 // that try catch is fix for an android NPE error on css change which navigated in (not the current fragment)
104104 try {
105105 if ( this . mTabsBar ) {
@@ -108,7 +108,7 @@ export class BottomNavigation extends TabNavigation<com.nativescript.material.co
108108 } catch ( err ) { }
109109 }
110110
111- public setTabBarBackgroundColor ( value : android . graphics . drawable . Drawable | Color ) : void {
111+ public override setTabBarBackgroundColor ( value : android . graphics . drawable . Drawable | Color ) : void {
112112 super . setTabBarBackgroundColor ( value ) ;
113113 // this.updateTabStripItems();
114114 }
@@ -130,19 +130,28 @@ export class BottomNavigation extends TabNavigation<com.nativescript.material.co
130130 } ) ;
131131 }
132132
133- public setTabBarSelectedItemColor ( value : Color ) {
133+ public override setTabBarSelectedItemColor ( value : Color ) {
134134 super . setTabBarSelectedItemColor ( value ) ;
135135 this . _setItemsColors ( this . tabStrip . items ) ;
136136 }
137137
138- public setTabBarUnSelectedItemColor ( value : Color ) {
138+ public override setTabBarUnSelectedItemColor ( value : Color ) {
139139 super . setTabBarUnSelectedItemColor ( value ) ;
140140 this . _setItemsColors ( this . tabStrip . items ) ;
141141 }
142142
143- public onTabsBarSelectedPositionChange ( position : number , prevPosition : number ) {
144- super . onTabsBarSelectedPositionChange ( position , prevPosition ) ;
143+ public override onTabsBarSelectedPositionChange ( position : number , prevPosition : number ) : void {
145144 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+
146155 this . _setItemsColors ( this . tabStrip . items ) ;
147156 }
148157}
0 commit comments