Skip to content
Merged
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ export class BottomNavigationViewModel extends Observable {
const gridlayout = new GridLayout();
label.text = "Content Item " + index;
gridlayout.addChild(label);
contentItem.view = gridlayout;
contentItem.content = gridlayout;

return contentItem;
}
Expand Down
2 changes: 1 addition & 1 deletion e2e/ui-tests-app/app/tabs/tabs-binding-view-model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ export class TabsBindingNavigationViewModel extends Observable {
const gridlayout = new GridLayout();
label.text = "Content Item " + index;
gridlayout.addChild(label);
contentItem.view = gridlayout;
contentItem.content = gridlayout;

return contentItem;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ function _createContentItems(count: number): Array<TabContentItem> {
const label = new Label();
label.text = "Tab " + i;
const tabEntry = new TabContentItem();
tabEntry.view = label;
tabEntry.content = label;
items.push(tabEntry);
}

Expand Down Expand Up @@ -101,12 +101,12 @@ export function testBackNavigationToTabViewWithNestedFramesShouldWork() {
let items = Array<TabContentItem>();
let tabViewitem = new TabContentItem();
// tabViewitem.title = "Item1";
tabViewitem.view = _createFrameView();
tabViewitem.content = _createFrameView();
items.push(tabViewitem);

let tabViewitem2 = new TabContentItem();
// tabViewitem2.title = "Item2";
tabViewitem2.view = _createFrameView();
tabViewitem2.content = _createFrameView();
items.push(tabViewitem2);

tabView.items = items;
Expand Down Expand Up @@ -145,7 +145,7 @@ export function testWhenNavigatingBackToANonCachedPageContainingATabViewWithALis
let items = Array<TabContentItem>();
let tabViewitem = new TabContentItem();
// tabViewitem.title = "List";
tabViewitem.view = _createListView();
tabViewitem.content = _createListView();
items.push(tabViewitem);

let label = new Label();
Expand All @@ -155,7 +155,7 @@ export function testWhenNavigatingBackToANonCachedPageContainingATabViewWithALis
aboutLayout.addChild(label);
tabViewitem = new TabContentItem();
// tabViewitem.title = "About";
tabViewitem.view = aboutLayout;
tabViewitem.content = aboutLayout;
items.push(tabViewitem);

tabView.items = items;
Expand Down Expand Up @@ -184,7 +184,7 @@ export function testWhenNavigatingBackToANonCachedPageContainingATabViewWithALis

TKUnit.waitUntilReady(() => topFrame.currentPage === rootPage);

TKUnit.assert(tabView.items[0].view instanceof ListView, "ListView should be created when navigating back to the main page.");
TKUnit.assert(tabView.items[0].content instanceof ListView, "ListView should be created when navigating back to the main page.");
}

function tabViewIsFullyLoaded(tabView: BottomNavigation): boolean {
Expand Down Expand Up @@ -232,8 +232,8 @@ export function testLoadedAndUnloadedAreFired_WhenNavigatingAwayAndBack() {
}

tabView.items.forEach((item, i) => {
item.view.on("loaded", createLoadedFor(i));
item.view.on("unloaded", createUnloadedFor(i));
item.content.on("loaded", createLoadedFor(i));
item.content.on("unloaded", createUnloadedFor(i));
});

const tabViewPage = new Page();
Expand All @@ -252,8 +252,8 @@ export function testLoadedAndUnloadedAreFired_WhenNavigatingAwayAndBack() {
TKUnit.assertEqual(topFrame.currentPage, tabViewPage);

for (let i = 0; i < itemCount; i++) {
tabView.items[i].view.off("loaded");
tabView.items[i].view.off("unloaded");
tabView.items[i].content.off("loaded");
tabView.items[i].content.off("unloaded");
}

helper.goBack();
Expand All @@ -267,7 +267,7 @@ export function testLoadedAndUnloadedAreFired_WhenNavigatingAwayAndBack() {

function _clickTheFirstButtonInTheListViewNatively(tabView: BottomNavigation) {
if (tabView.android) {
const androidListView = <android.widget.ListView>tabView.items[0].view.nativeView;
const androidListView = <android.widget.ListView>tabView.items[0].content.nativeView;
// var viewPager: android.support.v4.view.ViewPager = (<any>tabView)._viewPager;
// var androidListView = <android.widget.ListView>viewPager.getChildAt(0);
var stackLayout = <org.nativescript.widgets.StackLayout>androidListView.getChildAt(0);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ function createFrame(i: number, page: Page) {
function createTabItem(i: number, frame: Frame) {
const tabEntry = new TabContentItem();
// tabEntry.title = "Tab " + i;
tabEntry.view = frame;
tabEntry.content = frame;
tabEntry["index"] = i;

return tabEntry;
Expand Down
6 changes: 3 additions & 3 deletions tests/app/ui/bottom-navigation/bottom-navigation-tests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export class BottomNavigationTest extends UITest<BottomNavigation> {
const label = new Label();
label.text = "Tab " + i;
const tabEntry = new TabContentItem();
tabEntry.view = label;
tabEntry.content = label;
items.push(tabEntry);
}

Expand Down Expand Up @@ -208,7 +208,7 @@ export class BottomNavigationTest extends UITest<BottomNavigation> {
TKUnit.assertThrows(() => {
let item = new TabContentItem();
// item.title = "Tab 0";
item.view = undefined;
item.content = undefined;
tabView.items = [item];

}, "Binding TabNavigation to a TabItem with undefined view should throw.");
Expand All @@ -221,7 +221,7 @@ export class BottomNavigationTest extends UITest<BottomNavigation> {
TKUnit.assertThrows(() => {
let item = new TabContentItem();
// item.title = "Tab 0";
item.view = null;
item.content = null;
tabView.items = [item];

}, "Binding TabNavigation to a TabItem with null view should throw.");
Expand Down
22 changes: 11 additions & 11 deletions tests/app/ui/tabs/tabs-navigation-tests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ function _createContentItems(count: number): Array<TabContentItem> {
const label = new Label();
label.text = "Tab " + i;
const tabEntry = new TabContentItem();
tabEntry.view = label;
tabEntry.content = label;
items.push(tabEntry);
}

Expand Down Expand Up @@ -101,12 +101,12 @@ export function testBackNavigationToTabViewWithNestedFramesShouldWork() {
let items = Array<TabContentItem>();
let tabViewitem = new TabContentItem();
// tabViewitem.title = "Item1";
tabViewitem.view = _createFrameView();
tabViewitem.content = _createFrameView();
items.push(tabViewitem);

let tabViewitem2 = new TabContentItem();
// tabViewitem2.title = "Item2";
tabViewitem2.view = _createFrameView();
tabViewitem2.content = _createFrameView();
items.push(tabViewitem2);

tabView.items = items;
Expand Down Expand Up @@ -145,7 +145,7 @@ export function testWhenNavigatingBackToANonCachedPageContainingATabViewWithALis
let items = Array<TabContentItem>();
let tabViewitem = new TabContentItem();
// tabViewitem.title = "List";
tabViewitem.view = _createListView();
tabViewitem.content = _createListView();
items.push(tabViewitem);

let label = new Label();
Expand All @@ -155,7 +155,7 @@ export function testWhenNavigatingBackToANonCachedPageContainingATabViewWithALis
aboutLayout.addChild(label);
tabViewitem = new TabContentItem();
// tabViewitem.title = "About";
tabViewitem.view = aboutLayout;
tabViewitem.content = aboutLayout;
items.push(tabViewitem);

tabView.items = items;
Expand Down Expand Up @@ -184,7 +184,7 @@ export function testWhenNavigatingBackToANonCachedPageContainingATabViewWithALis

TKUnit.waitUntilReady(() => topFrame.currentPage === rootPage);

TKUnit.assert(tabView.items[0].view instanceof ListView, "ListView should be created when navigating back to the main page.");
TKUnit.assert(tabView.items[0].content instanceof ListView, "ListView should be created when navigating back to the main page.");
}

function tabViewIsFullyLoaded(tabView: Tabs): boolean {
Expand Down Expand Up @@ -232,8 +232,8 @@ export function testLoadedAndUnloadedAreFired_WhenNavigatingAwayAndBack() {
}

tabView.items.forEach((item, i) => {
item.view.on("loaded", createLoadedFor(i));
item.view.on("unloaded", createUnloadedFor(i));
item.content.on("loaded", createLoadedFor(i));
item.content.on("unloaded", createUnloadedFor(i));
});

const tabViewPage = new Page();
Expand All @@ -252,8 +252,8 @@ export function testLoadedAndUnloadedAreFired_WhenNavigatingAwayAndBack() {
TKUnit.assertEqual(topFrame.currentPage, tabViewPage);

for (let i = 0; i < itemCount; i++) {
tabView.items[i].view.off("loaded");
tabView.items[i].view.off("unloaded");
tabView.items[i].content.off("loaded");
tabView.items[i].content.off("unloaded");
}

helper.goBack();
Expand All @@ -267,7 +267,7 @@ export function testLoadedAndUnloadedAreFired_WhenNavigatingAwayAndBack() {

function _clickTheFirstButtonInTheListViewNatively(tabView: Tabs) {
if (tabView.android) {
const androidListView = <android.widget.ListView>tabView.items[0].view.nativeView;
const androidListView = <android.widget.ListView>tabView.items[0].content.nativeView;
// var viewPager: android.support.v4.view.ViewPager = (<any>tabView)._viewPager;
// var androidListView = <android.widget.ListView>viewPager.getChildAt(0);
var stackLayout = <org.nativescript.widgets.StackLayout>androidListView.getChildAt(0);
Expand Down
2 changes: 1 addition & 1 deletion tests/app/ui/tabs/tabs-root-tests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ function createFrame(i: number, page: Page) {
function createTabItem(i: number, frame: Frame) {
const tabEntry = new TabContentItem();
// tabEntry.title = "Tab " + i;
tabEntry.view = frame;
tabEntry.content = frame;
tabEntry["index"] = i;

return tabEntry;
Expand Down
6 changes: 3 additions & 3 deletions tests/app/ui/tabs/tabs-tests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export class TabsTest extends UITest<Tabs> {
const label = new Label();
label.text = "Tab " + i;
const tabEntry = new TabContentItem();
tabEntry.view = label;
tabEntry.content = label;
items.push(tabEntry);
}

Expand Down Expand Up @@ -210,7 +210,7 @@ export class TabsTest extends UITest<Tabs> {
TKUnit.assertThrows(() => {
let item = new TabContentItem();
// item.title = "Tab 0";
item.view = undefined;
item.content = undefined;
tabView.items = [item];

}, "Binding TabNavigation to a TabItem with undefined view should throw.");
Expand All @@ -223,7 +223,7 @@ export class TabsTest extends UITest<Tabs> {
TKUnit.assertThrows(() => {
let item = new TabContentItem();
// item.title = "Tab 0";
item.view = null;
item.content = null;
tabView.items = [item];

}, "Binding TabNavigation to a TabItem with null view should throw.");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ function initializeNativeClasses() {
public onCreateView(inflater: android.view.LayoutInflater, container: android.view.ViewGroup, savedInstanceState: android.os.Bundle): android.view.View {
const tabItem = this.tab.items[this.index];

return tabItem.view.nativeViewProtected;
return tabItem.nativeViewProtected;
}
}

Expand Down Expand Up @@ -211,11 +211,10 @@ function createTabItemSpec(tabStripItem: TabStripItem): org.nativescript.widgets
return tabItemSpec;
}

function setElevation(grid: org.nativescript.widgets.GridLayout, bottomNavigationBar: org.nativescript.widgets.BottomNavigationBar) {
function setElevation(bottomNavigationBar: org.nativescript.widgets.BottomNavigationBar) {
const compat = <any>androidx.core.view.ViewCompat;
if (compat.setElevation) {
const val = DEFAULT_ELEVATION * layout.getDisplayDensity();
compat.setElevation(grid, val);
compat.setElevation(bottomNavigationBar, val);
}
}
Expand Down Expand Up @@ -288,7 +287,7 @@ export class BottomNavigation extends TabNavigationBase {
nativeView.addView(bottomNavigationBar);
(<any>nativeView).bottomNavigationBar = bottomNavigationBar;

setElevation(nativeView, bottomNavigationBar);
setElevation(bottomNavigationBar);

const primaryColor = ad.resources.getPaletteColor(PRIMARY_COLOR, context);
if (primaryColor) {
Expand Down Expand Up @@ -341,20 +340,20 @@ export class BottomNavigation extends TabNavigationBase {
toUnload.forEach(index => {
const item = items[index];
if (items[index]) {
item.unloadView(item.view);
item.unloadView(item.content);
}
});

const newItem = items[newIndex];
const selectedView = newItem && newItem.view;
const selectedView = newItem && newItem.content;
if (selectedView instanceof Frame) {
selectedView._pushInFrameStackRecursive();
}

toLoad.forEach(index => {
const item = items[index];
if (this.isLoaded && items[index]) {
item.loadView(item.view);
item.loadView(item.content);
}
});
}
Expand Down
26 changes: 13 additions & 13 deletions tns-core-modules/ui/bottom-navigation/bottom-navigation.ios.ts
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,7 @@ export class BottomNavigation extends TabNavigationBase {
super.onLoaded();

const selectedIndex = this.selectedIndex;
const selectedView = this.items && this.items[selectedIndex] && this.items[selectedIndex].view;
const selectedView = this.items && this.items[selectedIndex] && this.items[selectedIndex].content;
if (selectedView instanceof Frame) {
selectedView._pushInFrameStackRecursive();
}
Expand Down Expand Up @@ -295,18 +295,18 @@ export class BottomNavigation extends TabNavigationBase {
const oldItem = items[oldIndex];
if (oldItem) {
oldItem.canBeLoaded = false;
oldItem.unloadView(oldItem.view);
oldItem.unloadView(oldItem.content);
}

const newItem = items[newIndex];
if (newItem && this.isLoaded) {
const selectedView = items[newIndex].view;
const selectedView = items[newIndex].content;
if (selectedView instanceof Frame) {
selectedView._pushInFrameStackRecursive();
}

newItem.canBeLoaded = true;
newItem.loadView(newItem.view);
newItem.loadView(newItem.content);
}

super.onSelectedIndexChanged(oldIndex, newIndex);
Expand Down Expand Up @@ -463,25 +463,25 @@ export class BottomNavigation extends TabNavigationBase {
}

private getViewController(item: TabContentItem): UIViewController {
let newController: UIViewController = item.view ? item.view.viewController : null;
let newController: UIViewController = item.content ? item.content.viewController : null;

if (newController) {
(<any>item).setViewController(newController, newController.view);

return newController;
}

if (item.view.ios instanceof UIViewController) {
newController = item.view.ios;
if (item.content.ios instanceof UIViewController) {
newController = item.content.ios;
(<any>item).setViewController(newController, newController.view);
} else if (item.view.ios && item.view.ios.controller instanceof UIViewController) {
newController = item.view.ios.controller;
} else if (item.content.ios && item.content.ios.controller instanceof UIViewController) {
newController = item.content.ios.controller;
(<any>item).setViewController(newController, newController.view);
} else {
newController = iosView.UILayoutViewController.initWithOwner(new WeakRef(item.view)) as UIViewController;
newController.view.addSubview(item.view.nativeViewProtected);
item.view.viewController = newController;
(<any>item).setViewController(newController, item.view.nativeViewProtected);
newController = iosView.UILayoutViewController.initWithOwner(new WeakRef(item.content)) as UIViewController;
newController.view.addSubview(item.content.nativeViewProtected);
item.content.viewController = newController;
(<any>item).setViewController(newController, item.content.nativeViewProtected);
}

return newController;
Expand Down
Loading