Skip to content

Commit

Permalink
fix(bottom-navigation): codebehind creation (#7624)
Browse files Browse the repository at this point in the history
does not show tabstrip
  • Loading branch information
ADjenkov committed Aug 2, 2019
1 parent 2518655 commit 056d0bf
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 9 deletions.
14 changes: 12 additions & 2 deletions tns-core-modules/ui/bottom-navigation/bottom-navigation.ios.ts
@@ -1,10 +1,11 @@
// Types
import { TabStrip } from "../tab-navigation-base/tab-strip";
import { TabContentItem } from "../tab-navigation-base/tab-content-item";
import { TabStripItem } from "../tab-navigation-base/tab-strip-item";
import { TextTransform } from "../text-base";

//Requires
import { TabNavigationBase, itemsProperty, selectedIndexProperty } from "../tab-navigation-base/tab-navigation-base";
import { TabNavigationBase, itemsProperty, selectedIndexProperty, tabStripProperty } from "../tab-navigation-base/tab-navigation-base";
import { Font } from "../styling/font";
import { getTransformedText } from "../text-base";
import { Frame } from "../frame";
Expand Down Expand Up @@ -137,7 +138,7 @@ class UITabBarControllerDelegateImpl extends NSObject implements UITabBarControl
if (tabStripItems[position]) {
tabStripItems[position]._emit(TabStripItem.selectEvent);
}

if (tabStripItems[prevPosition]) {
tabStripItems[prevPosition]._emit(TabStripItem.unselectEvent);
}
Expand Down Expand Up @@ -610,6 +611,15 @@ export class BottomNavigation extends TabNavigationBase {
this.setViewControllers(value);
selectedIndexProperty.coerce(this);
}

[tabStripProperty.getDefault](): TabStrip {
return null;
}

[tabStripProperty.setNative](value: TabStrip) {
this.setViewControllers(this.items);
selectedIndexProperty.coerce(this);
}
}

interface TabStates {
Expand Down
Expand Up @@ -37,8 +37,8 @@ export class TabNavigationBase extends View implements TabNavigationBaseDefiniti
this._addView(value);
// selectedIndexProperty.coerce(this);
} else if (name === "TabStrip") {
// Setting tabStrip will trigger onTabStripChanged
this.tabStrip = value;
this._addView(value);
}
}

Expand Down Expand Up @@ -94,14 +94,12 @@ export class TabNavigationBase extends View implements TabNavigationBaseDefiniti
}

public onTabStripChanged(oldTabStrip: TabStrip, newTabStrip: TabStrip) {
if (oldTabStrip && oldTabStrip.items && oldTabStrip.items.length) {
oldTabStrip.items.forEach(item => this._removeView(item));
if (oldTabStrip && oldTabStrip.parent) {
this._removeView(oldTabStrip);
}

if (newTabStrip && newTabStrip.items && newTabStrip.items.length) {
newTabStrip.items.forEach(item => {
this._addView(item);
});
if (newTabStrip) {
this._addView(newTabStrip);
}
}

Expand Down

0 comments on commit 056d0bf

Please sign in to comment.