mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-11-05 13:26:48 +08:00
fix(bottom-navigation): codebehind creation (#7624)
does not show tabstrip
This commit is contained in:
committed by
GitHub
parent
2518655ab3
commit
056d0bf9e4
@@ -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";
|
||||
@@ -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);
|
||||
}
|
||||
@@ -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 {
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user