mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-08-16 11:42:04 +08:00
fix(ios/bottom-navigation): move TabStrip items event emitting to selectedIndex changed handler (#8160)
This commit is contained in:

committed by
Vasil Trifonov

parent
d65a2db83a
commit
8550c3293d
@ -157,23 +157,6 @@ class UITabBarControllerDelegateImpl extends NSObject implements UITabBarControl
|
||||
|
||||
const owner = this._owner.get();
|
||||
if (owner) {
|
||||
if (tabBarController.viewControllers) {
|
||||
const position = tabBarController.viewControllers.indexOfObject(viewController);
|
||||
if (position !== NSNotFound) {
|
||||
const prevPosition = owner.selectedIndex;
|
||||
const tabStripItems = owner.tabStrip && owner.tabStrip.items;
|
||||
if (tabStripItems) {
|
||||
if (tabStripItems[position]) {
|
||||
tabStripItems[position]._emit(TabStripItem.selectEvent);
|
||||
}
|
||||
|
||||
if (tabStripItems[prevPosition]) {
|
||||
tabStripItems[prevPosition]._emit(TabStripItem.unselectEvent);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
owner._onViewControllerShown(viewController);
|
||||
}
|
||||
|
||||
@ -358,6 +341,17 @@ export class BottomNavigation extends TabNavigationBase {
|
||||
newItem.loadView(newItem.content);
|
||||
}
|
||||
|
||||
const tabStripItems = this.tabStrip && this.tabStrip.items;
|
||||
if (tabStripItems) {
|
||||
if (tabStripItems[newIndex]) {
|
||||
tabStripItems[newIndex]._emit(TabStripItem.selectEvent);
|
||||
}
|
||||
|
||||
if (tabStripItems[oldIndex]) {
|
||||
tabStripItems[oldIndex]._emit(TabStripItem.unselectEvent);
|
||||
}
|
||||
}
|
||||
|
||||
super.onSelectedIndexChanged(oldIndex, newIndex);
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user