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
|
// Types
|
||||||
|
import { TabStrip } from "../tab-navigation-base/tab-strip";
|
||||||
import { TabContentItem } from "../tab-navigation-base/tab-content-item";
|
import { TabContentItem } from "../tab-navigation-base/tab-content-item";
|
||||||
import { TabStripItem } from "../tab-navigation-base/tab-strip-item";
|
import { TabStripItem } from "../tab-navigation-base/tab-strip-item";
|
||||||
import { TextTransform } from "../text-base";
|
import { TextTransform } from "../text-base";
|
||||||
|
|
||||||
//Requires
|
//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 { Font } from "../styling/font";
|
||||||
import { getTransformedText } from "../text-base";
|
import { getTransformedText } from "../text-base";
|
||||||
import { Frame } from "../frame";
|
import { Frame } from "../frame";
|
||||||
@@ -137,7 +138,7 @@ class UITabBarControllerDelegateImpl extends NSObject implements UITabBarControl
|
|||||||
if (tabStripItems[position]) {
|
if (tabStripItems[position]) {
|
||||||
tabStripItems[position]._emit(TabStripItem.selectEvent);
|
tabStripItems[position]._emit(TabStripItem.selectEvent);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (tabStripItems[prevPosition]) {
|
if (tabStripItems[prevPosition]) {
|
||||||
tabStripItems[prevPosition]._emit(TabStripItem.unselectEvent);
|
tabStripItems[prevPosition]._emit(TabStripItem.unselectEvent);
|
||||||
}
|
}
|
||||||
@@ -610,6 +611,15 @@ export class BottomNavigation extends TabNavigationBase {
|
|||||||
this.setViewControllers(value);
|
this.setViewControllers(value);
|
||||||
selectedIndexProperty.coerce(this);
|
selectedIndexProperty.coerce(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[tabStripProperty.getDefault](): TabStrip {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
[tabStripProperty.setNative](value: TabStrip) {
|
||||||
|
this.setViewControllers(this.items);
|
||||||
|
selectedIndexProperty.coerce(this);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
interface TabStates {
|
interface TabStates {
|
||||||
|
|||||||
@@ -37,8 +37,8 @@ export class TabNavigationBase extends View implements TabNavigationBaseDefiniti
|
|||||||
this._addView(value);
|
this._addView(value);
|
||||||
// selectedIndexProperty.coerce(this);
|
// selectedIndexProperty.coerce(this);
|
||||||
} else if (name === "TabStrip") {
|
} else if (name === "TabStrip") {
|
||||||
|
// Setting tabStrip will trigger onTabStripChanged
|
||||||
this.tabStrip = value;
|
this.tabStrip = value;
|
||||||
this._addView(value);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -94,14 +94,12 @@ export class TabNavigationBase extends View implements TabNavigationBaseDefiniti
|
|||||||
}
|
}
|
||||||
|
|
||||||
public onTabStripChanged(oldTabStrip: TabStrip, newTabStrip: TabStrip) {
|
public onTabStripChanged(oldTabStrip: TabStrip, newTabStrip: TabStrip) {
|
||||||
if (oldTabStrip && oldTabStrip.items && oldTabStrip.items.length) {
|
if (oldTabStrip && oldTabStrip.parent) {
|
||||||
oldTabStrip.items.forEach(item => this._removeView(item));
|
this._removeView(oldTabStrip);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (newTabStrip && newTabStrip.items && newTabStrip.items.length) {
|
if (newTabStrip) {
|
||||||
newTabStrip.items.forEach(item => {
|
this._addView(newTabStrip);
|
||||||
this._addView(item);
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user