refactor(backButton): separate show/enable logic

Previously the showBack property was setting if the back button should
or should not be enabled, and it was also used if the back button
should be hidden or not for the view. Changed it so there are now two
concepts, where showBack is visual only, and enableBack determines if
it should show according to $ionicHistory and navigation info.
This commit is contained in:
Adam Bradley
2014-11-19 11:38:14 -06:00
parent 387b1eef79
commit b4e4055a06
11 changed files with 68 additions and 42 deletions

View File

@@ -89,7 +89,7 @@ function($scope, $element, $attrs, $ionicNavBarDelegate, $ionicHistory, $ionicVi
// the view is now compiled, in the dom and linked, now lets transition the views.
// this uses a callback incase THIS nav-view has a nested nav-view, and after the NESTED
// nav-view links, the NESTED nav-view would update which direction THIS nav-view should use
switcher.transition(self.direction(), registerData.showBack);
switcher.transition(self.direction(), registerData.enableBack);
});
};
@@ -111,9 +111,15 @@ function($scope, $element, $attrs, $ionicNavBarDelegate, $ionicHistory, $ionicVi
};
self.showBackButton = function(val) {
self.enableBackButton = function(shouldEnable) {
var associatedNavBarCtrl = getAssociatedNavBarCtrl();
associatedNavBarCtrl && associatedNavBarCtrl.showBackButton(val);
associatedNavBarCtrl && associatedNavBarCtrl.enableBackButton(shouldEnable);
};
self.showBackButton = function(shouldShow) {
var associatedNavBarCtrl = getAssociatedNavBarCtrl();
associatedNavBarCtrl && associatedNavBarCtrl.showBackButton(shouldShow);
};