| Index: ios/chrome/browser/ui/settings/settings_navigation_controller.mm
|
| diff --git a/ios/chrome/browser/ui/settings/settings_navigation_controller.mm b/ios/chrome/browser/ui/settings/settings_navigation_controller.mm
|
| index 8c4e774e626c0a8b367c59b12c4c7f09c0b8a394..7940e977f8ce492e9cfa6840e4b08f7768f7c95f 100644
|
| --- a/ios/chrome/browser/ui/settings/settings_navigation_controller.mm
|
| +++ b/ios/chrome/browser/ui/settings/settings_navigation_controller.mm
|
| @@ -78,6 +78,11 @@
|
| // Closes the settings by calling |closeSettings| on |delegate|.
|
| - (void)closeSettings;
|
|
|
| +// Creates an autoreleased Back button for a UINavigationItem which will pop the
|
| +// top view controller when it is pressed. Should only be called by view
|
| +// controllers owned by SettingsNavigationController.
|
| +- (UIBarButtonItem*)backButton;
|
| +
|
| // Creates an autoreleased "X" button that closes the settings when tapped.
|
| - (UIBarButtonItem*)closeButton;
|
|
|
| @@ -319,6 +324,10 @@ initWithRootViewController:(UIViewController*)rootViewController
|
| [delegate_ closeSettings];
|
| }
|
|
|
| +- (void)back {
|
| + [self popViewControllerAnimated:YES];
|
| +}
|
| +
|
| - (void)popViewControllerOrCloseSettingsAnimated:(BOOL)animated {
|
| if (self.viewControllers.count > 1) {
|
| // Pop the top view controller to reveal the view controller underneath.
|
| @@ -351,6 +360,14 @@ initWithRootViewController:(UIViewController*)rootViewController
|
| [[rightButton title] compare:[doneButton title]] == NSOrderedSame;
|
| }
|
|
|
| +- (UIBarButtonItem*)backButton {
|
| + // Create a custom Back bar button item, as Material Navigation Bar deprecated
|
| + // the back arrow with a shaft.
|
| + return [ChromeIcon templateBarButtonItemWithImage:[ChromeIcon backIcon]
|
| + target:self
|
| + action:@selector(back)];
|
| +}
|
| +
|
| - (UIBarButtonItem*)doneButton {
|
| // Create a custom Done bar button item, as Material Navigation Bar does not
|
| // handle a system UIBarButtonSystemItemDone item.
|
| @@ -408,6 +425,12 @@ initWithRootViewController:(UIViewController*)rootViewController
|
|
|
| - (void)pushViewController:(UIViewController*)viewController
|
| animated:(BOOL)animated {
|
| + // Add a back button if the view controller is not the root view controller
|
| + // and doesn’t already have a left bar button item.
|
| + if (self.viewControllers.count > 0 &&
|
| + viewController.navigationItem.leftBarButtonItems.count == 0) {
|
| + viewController.navigationItem.leftBarButtonItem = [self backButton];
|
| + }
|
| // Wrap the view controller in an MDCAppBarContainerViewController if needed.
|
| [super pushViewController:[self wrappedControllerIfNeeded:viewController]
|
| animated:animated];
|
|
|