4 Commits

Author SHA1 Message Date
Jeff Verkoeyen
b78737be48 [AppBar] Inject AppBars after view controllers have been added to the navigation controller.
Before this change, it was never possible to interact with the navigationController property in a pushed view controller's viewDidLoad property when using MDCAppBarNavigationController. This behavior is surprising for folks using UINavigationController, which does allow you to access navigationController from within viewDidLoad.

This expectation is an anti-pattern (e.g. viewDidLoad is never guaranteed to be invoked after a view controller has been pushed onto a navigationController stack), but the goal of MDCAppBarNavigationController is to provide a drop-in replacement for UINavigationController so our intent is to align behaviors, even if they're not necessarily for the right reasons.

All that being said, the change introduced in this CL simply swaps the ordering of pushing the view controller and injecting the AppBar, such that the injection now happens after the super implementation of pushViewController has been invoked. This allows the viewDidLoad logic to be invoked after navigationController has been initialized on the view controller.

The reason we were doing it the other way before was so that the AppBar could intercept the relevant status bar appearance events. We work around that requirement in this change by invoking setNeedsStatusBarAppearanceUpdate and setNeedsUpdateOfHomeIndicatorAutoHidden immediately after injecting the AppBar.

PiperOrigin-RevId: 313410464
2020-05-27 10:06:04 -07:00
Jeff Verkoeyen
e479b366e7 [AppBar] Roll-back "inject AppBars after view controllers have been added to the navigation controller."
PiperOrigin-RevId: 311550067
2020-05-14 09:47:14 -07:00
Jeff Verkoeyen
c0b4ff9cb3 [AppBar] Inject AppBars after view controllers have been added to the navigation controller.
Before this change, it was never possible to interact with the navigationController property in a pushed view controller's viewDidLoad property when using MDCAppBarNavigationController. This behavior is surprising for folks using UINavigationController, which does allow you to access navigationController from within viewDidLoad.

This expectation is an anti-pattern (e.g. viewDidLoad is never guaranteed to be invoked after a view controller has been pushed onto a navigationController stack), but the goal of MDCAppBarNavigationController is to provide a drop-in replacement for UINavigationController so our intent is to align behaviors, even if they're not necessarily for the right reasons.

All that being said, the change introduced in this CL simply swaps the ordering of pushing the view controller and injecting the AppBar, such that the injection now happens after the super implementation of pushViewController has been invoked. This allows the viewDidLoad logic to be invoked after navigationController has been initialized on the view controller.

The reason we were doing it the other way before was so that the AppBar could intercept the relevant status bar appearance events. We work around that requirement in this change by invoking setNeedsStatusBarAppearanceUpdate and setNeedsUpdateOfHomeIndicatorAutoHidden immediately after injecting the AppBar.

PiperOrigin-RevId: 311342757
2020-05-13 09:29:59 -07:00
Jeff Verkoeyen
dbb9ab1170 [AppBar] Add NavigationController example with AppBar initially hidden.
Note that this new example demonstrates a bug in which the AppBar is not, in fact, hidden when presented.

PiperOrigin-RevId: 311104930
2020-05-13 14:41:30 +00:00