mirror of
https://github.com/material-components/material-components-ios.git
synced 2026-02-20 08:27:32 +08:00
[NavigationSuite] Add delegate API that allows users to set a callback block that is called when the layout changed under automatic mode.
PiperOrigin-RevId: 521460143
This commit is contained in:
parent
9d578d398d
commit
cdacd21dfd
@ -238,15 +238,10 @@ static UIViewController *_Nullable DecodeViewController(NSCoder *coder, NSString
|
||||
if (self.layoutMode != MDCBottomNavigationBarLayoutModeAutomatic) {
|
||||
return;
|
||||
}
|
||||
BOOL shouldUseVerticalLayout = [self useVerticalLayoutAfterTransitioningToSize:size];
|
||||
if (shouldUseVerticalLayout == self.enableVerticalLayout) {
|
||||
BOOL enableVerticalLayout = [self useVerticalLayoutAfterTransitioningToSize:size];
|
||||
if (enableVerticalLayout == self.enableVerticalLayout) {
|
||||
return;
|
||||
}
|
||||
[self enableVerticalLayout:shouldUseVerticalLayout withTransitionCoordinator:coordinator];
|
||||
}
|
||||
|
||||
- (void)enableVerticalLayout:(BOOL)enableVerticalLayout
|
||||
withTransitionCoordinator:(id<UIViewControllerTransitionCoordinator>)coordinator {
|
||||
// The setter is not used here since the setter also sets the navigationBar's enableVerticalLayout
|
||||
// flag and we set that here manually to control animations.
|
||||
_enableVerticalLayout = enableVerticalLayout;
|
||||
@ -280,6 +275,11 @@ static UIViewController *_Nullable DecodeViewController(NSCoder *coder, NSString
|
||||
options:UIViewAnimationOptionCurveEaseOut
|
||||
animations:lastAnimations
|
||||
completion:nil];
|
||||
|
||||
if ([self.delegate
|
||||
respondsToSelector:@selector(bottomNavigationBarControllerDidUpdateLayout)]) {
|
||||
[self.delegate bottomNavigationBarControllerDidUpdateLayout];
|
||||
}
|
||||
}];
|
||||
}
|
||||
|
||||
|
||||
@ -16,6 +16,8 @@
|
||||
|
||||
#import "MDCMinimumOS.h" // IWYU pragma: keep
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@class MDCBottomNavigationBarController;
|
||||
|
||||
/**
|
||||
@ -43,4 +45,16 @@
|
||||
(nonnull MDCBottomNavigationBarController *)bottomNavigationBarController
|
||||
shouldSelectViewController:(nonnull UIViewController *)viewController;
|
||||
|
||||
/**
|
||||
Delegates may implement this method if they want to execute some code right
|
||||
after the controller changes layout in @c MDCBottomNavigationBarLayoutModeAutomatic
|
||||
mode.
|
||||
@warning Do not rely on this method when
|
||||
@c MDCBottomNavigationBarLayoutModeVertical or
|
||||
@c MDCBottomNavigationBarLayoutModeHorizontal mode is used.
|
||||
*/
|
||||
- (void)bottomNavigationBarControllerDidUpdateLayout;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user