Skip to content

Commit 2bf6601

Browse files
committed
fix(bottomnavigationbar): ios dont depend on tag as the native side changes it
1 parent f0ce481 commit 2bf6601

File tree

1 file changed

+9
-10
lines changed

1 file changed

+9
-10
lines changed

src/bottomnavigationbar/bottomnavigationbar.ios.ts

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -27,23 +27,23 @@ class BottomNavigationBarDelegate extends NSObject {
2727
if (!owner) {
2828
return;
2929
}
30-
const tag = item && item.tag ? item.tag : 0;
31-
if (owner.selectedTabIndex === tag) {
32-
owner._emitTabReselected(tag);
30+
const barIndex = item && (item as any).barIndex ? (item as any).barIndex : 0;
31+
if (owner.selectedTabIndex === barIndex) {
32+
owner._emitTabReselected(barIndex);
3333
return;
3434
}
35-
owner._emitTabSelected(tag);
35+
owner._emitTabSelected(barIndex);
3636
}
3737

3838
bottomNavigationBarShouldSelectItem(bottomNavigationBar: MDCBottomNavigationBar, item: UITabBarItem): boolean {
3939
const owner = this._owner.get();
4040
if (!owner) {
4141
return true;
4242
}
43-
const tag = item && item.tag ? item.tag : 0;
44-
const bottomNavigationTab = owner.items[tag];
43+
const barIndex = item && (item as any).barIndex ? (item as any).barIndex : 0;
44+
const bottomNavigationTab = owner.items[barIndex];
4545
if (!bottomNavigationTab.isSelectable) {
46-
owner._emitTabPressed(tag);
46+
owner._emitTabPressed(barIndex);
4747
}
4848
return bottomNavigationTab.isSelectable;
4949
}
@@ -144,15 +144,14 @@ export class BottomNavigationBar extends BottomNavigationBarBase {
144144
if (tabs) {
145145
this._items = tabs;
146146
}
147-
148147
const bottomNavigationTabs = this._items.map((item, index) => {
149148
this._addView(item);
150149
const tab = item.nativeViewProtected;
151-
tab.tag = index;
150+
(tab as any).barIndex = index;
152151
return tab;
153152
});
154153
this.nativeViewProtected.items = new NSArray({ array: bottomNavigationTabs });
155-
154+
156155
// TODO: this is for he v8 runtime. Should not have to need this setTimeout(), find better way.
157156
setTimeout(() => {
158157
this.nativeViewProtected.selectedItem = this.nativeViewProtected.items[this.selectedTabIndex];

0 commit comments

Comments
 (0)