mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-11-05 13:26:48 +08:00
fix: tab navigations don't work with lowercase xml (#8016)
This commit is contained in:
@@ -1,12 +1,12 @@
|
||||
// Types
|
||||
import { TabNavigationBase as TabNavigationBaseDefinition, SelectedIndexChangedEventData } from ".";
|
||||
import { TabContentItem } from "../tab-content-item";
|
||||
import { TabStrip } from "../tab-strip";
|
||||
import { TabStripItem } from "../tab-strip-item";
|
||||
import { ViewBase, AddArrayFromBuilder, AddChildFromBuilder, EventData } from "../../core/view";
|
||||
|
||||
// Requires
|
||||
import { View, Property, CoercibleProperty, isIOS, Color } from "../../core/view";
|
||||
import { View, Property, CoercibleProperty, isIOS } from "../../core/view";
|
||||
import { TabContentItem } from "../tab-content-item";
|
||||
import { TabStrip } from "../tab-strip";
|
||||
|
||||
// TODO: Impl trace
|
||||
// export const traceCategory = "TabView";
|
||||
@@ -29,14 +29,14 @@ export class TabNavigationBase extends View implements TabNavigationBaseDefiniti
|
||||
}
|
||||
|
||||
public _addChildFromBuilder(name: string, value: any): void {
|
||||
if (name === "TabContentItem") {
|
||||
if (value instanceof TabContentItem) {
|
||||
if (!this.items) {
|
||||
this.items = new Array<TabContentItem>();
|
||||
}
|
||||
this.items.push(<TabContentItem>value);
|
||||
this._addView(value);
|
||||
// selectedIndexProperty.coerce(this);
|
||||
} else if (name === "TabStrip") {
|
||||
} else if (value instanceof TabStrip) {
|
||||
// Setting tabStrip will trigger onTabStripChanged
|
||||
this.tabStrip = value;
|
||||
}
|
||||
|
||||
@@ -3,8 +3,6 @@ import { TabStripItem as TabStripItemDefinition } from ".";
|
||||
import { PropertyChangeData } from "../../../data/observable";
|
||||
import { TabNavigationBase } from "../tab-navigation-base";
|
||||
import { TabStrip } from "../tab-strip";
|
||||
import { Image } from "../../image/image";
|
||||
import { Label } from "../../label/label";
|
||||
import { Color } from "../../../color";
|
||||
import { AddChildFromBuilder } from "../../core/view";
|
||||
|
||||
@@ -12,8 +10,9 @@ import { AddChildFromBuilder } from "../../core/view";
|
||||
import {
|
||||
View, ViewBase, CSSType, backgroundColorProperty, backgroundInternalProperty, PseudoClassHandler
|
||||
} from "../../core/view";
|
||||
import { Tabs } from "../../tabs";
|
||||
import { isIOS } from "../../../platform";
|
||||
import { Image } from "../../image/image";
|
||||
import { Label } from "../../label/label";
|
||||
|
||||
export * from "../../core/view";
|
||||
export const traceCategory = "TabView";
|
||||
@@ -173,14 +172,14 @@ export class TabStripItem extends View implements TabStripItemDefinition, AddChi
|
||||
}
|
||||
|
||||
public _addChildFromBuilder(name: string, value: any): void {
|
||||
if (name === "Image") {
|
||||
if (value instanceof Image) {
|
||||
this.image = <Image>value;
|
||||
this.iconSource = (<Image>value).src;
|
||||
this._addView(value);
|
||||
// selectedIndexProperty.coerce(this);
|
||||
}
|
||||
|
||||
if (name === "Label") {
|
||||
if (value instanceof Label) {
|
||||
this.label = <Label>value;
|
||||
this.title = (<Label>value).text;
|
||||
this._addView(value);
|
||||
@@ -213,7 +212,9 @@ export class TabStripItem extends View implements TabStripItemDefinition, AddChi
|
||||
const parent = <TabStrip>this.parent;
|
||||
const tabStripParent = parent && <TabNavigationBase>parent.parent;
|
||||
if (this._index === tabStripParent.selectedIndex &&
|
||||
!(isIOS && tabStripParent instanceof Tabs)) {
|
||||
!(isIOS && tabStripParent.cssType.toLowerCase() === "tabs")) {
|
||||
// HACK: tabStripParent instanceof Tabs creates a circular dependency
|
||||
// HACK: tabStripParent.cssType === "Tabs" is a hacky workaround
|
||||
this._goToVisualState("highlighted");
|
||||
}
|
||||
} else {
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
import { Color } from "../../../color";
|
||||
import { AddArrayFromBuilder, AddChildFromBuilder, EventData, ViewBase } from "../../core/view";
|
||||
import { TabNavigationBase } from "../tab-navigation-base";
|
||||
import { TabStripItem } from "../tab-strip-item";
|
||||
import { TabStripItemEventData, TabStrip as TabStripDefinition } from "./";
|
||||
|
||||
// Requires
|
||||
@@ -10,6 +9,7 @@ import {
|
||||
backgroundColorProperty, backgroundInternalProperty, booleanConverter,
|
||||
colorProperty, CSSType, fontInternalProperty, Property, View
|
||||
} from "../../core/view";
|
||||
import { TabStripItem } from "../tab-strip-item";
|
||||
import { textTransformProperty } from "../../text-base";
|
||||
|
||||
export const traceCategory = "TabView";
|
||||
@@ -44,7 +44,7 @@ export class TabStrip extends View implements TabStripDefinition, AddChildFromBu
|
||||
}
|
||||
|
||||
public _addChildFromBuilder(name: string, value: any): void {
|
||||
if (name === "TabStripItem") {
|
||||
if (value instanceof TabStripItem) {
|
||||
if (!this.items) {
|
||||
this.items = new Array<TabStripItem>();
|
||||
}
|
||||
|
||||
@@ -140,7 +140,7 @@ export class TabViewBase extends View implements TabViewDefinition, AddChildFrom
|
||||
}
|
||||
|
||||
public _addChildFromBuilder(name: string, value: any): void {
|
||||
if (name === "TabViewItem") {
|
||||
if (value instanceof TabViewItemBase) {
|
||||
if (!this.items) {
|
||||
this.items = new Array<TabViewItemBase>();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user