mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2026-03-13 10:22:08 +08:00
tabs back btn updates
This commit is contained in:
@@ -55,15 +55,31 @@ export class Tabs extends ViewController {
|
||||
injector: Injector
|
||||
) {
|
||||
super(parentViewCtrl, compiler, elementRef, loader, injector);
|
||||
this.item = viewItem;
|
||||
|
||||
this.item.navbarView = () => {
|
||||
let activeTab = this.getActive();
|
||||
if (activeTab && activeTab.instance) {
|
||||
return activeTab.instance.navbarView();
|
||||
}
|
||||
return {};
|
||||
};
|
||||
// Tabs may also be an actual ViewItem which was navigated to
|
||||
// if Tabs is static and not navigated to within a ViewController
|
||||
// then skip this and don't treat it as it's own ViewItem
|
||||
if (viewItem) {
|
||||
this.item = viewItem;
|
||||
|
||||
// special overrides for the Tabs ViewItem
|
||||
// the Tabs ViewItem does not have it's own navbar
|
||||
// so find the navbar it should use within it's active Tab
|
||||
viewItem.navbarView = () => {
|
||||
let activeTab = this.getActive();
|
||||
if (activeTab && activeTab.instance) {
|
||||
return activeTab.instance.navbarView();
|
||||
}
|
||||
return {};
|
||||
};
|
||||
|
||||
// a Tabs ViewItem should not have a back button
|
||||
// enableBack back button should be determined by the
|
||||
// the active ViewItem with a navbar
|
||||
viewItem.enableBack = () => {
|
||||
return false;
|
||||
};
|
||||
}
|
||||
|
||||
this.childNavbar(true);
|
||||
|
||||
|
||||
@@ -276,11 +276,9 @@ export class ViewController {
|
||||
}
|
||||
|
||||
swipeBackEnabled() {
|
||||
if (this.items.length > 1) {
|
||||
let activeItem = this.getActive();
|
||||
if (activeItem) {
|
||||
return activeItem.enableBack;
|
||||
}
|
||||
let activeItem = this.getActive();
|
||||
if (activeItem) {
|
||||
return activeItem.enableBack();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -17,9 +17,6 @@ export class ViewItem {
|
||||
this.state = 0;
|
||||
this.disposals = [];
|
||||
|
||||
// if it's possible to go back from this nav item
|
||||
this.enableBack = false;
|
||||
|
||||
this.protos = {};
|
||||
this._nbItms = [];
|
||||
this._promises = [];
|
||||
@@ -32,9 +29,6 @@ export class ViewItem {
|
||||
stage(callback) {
|
||||
let viewCtrl = this.viewCtrl;
|
||||
|
||||
// update if it's possible to go back from this nav item
|
||||
this.enableBack = viewCtrl && !!viewCtrl.getPrevious(this);
|
||||
|
||||
if (this.instance || !viewCtrl) {
|
||||
// already compiled this view
|
||||
return callback();
|
||||
@@ -152,6 +146,14 @@ export class ViewItem {
|
||||
};
|
||||
}
|
||||
|
||||
enableBack() {
|
||||
// update if it's possible to go back from this nav item
|
||||
if (this.viewCtrl) {
|
||||
return !!this.viewCtrl.getPrevious(this);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
setInstance(instance) {
|
||||
this.instance = instance;
|
||||
}
|
||||
|
||||
@@ -26,7 +26,7 @@ export class Transition extends Animation {
|
||||
let enteringNavbar = this.enteringNavbar = new Animation(enteringItem.navbarElement());
|
||||
enteringNavbar.before.addClass(SHOW_NAVBAR_CSS);
|
||||
|
||||
if (enteringItem.enableBack) {
|
||||
if (enteringItem.enableBack()) {
|
||||
// only animate in the back button if the entering view has it enabled
|
||||
let enteringBackButton = this.enteringBackButton = new Animation(enteringItem.backButtonElement());
|
||||
enteringBackButton
|
||||
|
||||
Reference in New Issue
Block a user