Skip to content

Commit

Permalink
[Snackbar] Add messageAnimationEnabled to control the animation behav…
Browse files Browse the repository at this point in the history
…ior of snackbar.

PiperOrigin-RevId: 591368769
  • Loading branch information
Wenyu Zhang authored and material-automation committed Dec 15, 2023
1 parent 7fd4094 commit c4c73b5
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
7 changes: 7 additions & 0 deletions components/Snackbar/src/MDCSnackbarManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -369,6 +369,13 @@ NS_ASSUME_NONNULL_END
*/
@property(nonatomic, assign) BOOL shouldShowMessageWhenVoiceOverIsRunning;

/**
If disabled, @c MDCSnackbarManager will not show or dismiss snackbar messages with animation.
Default is set to YES.
*/
@property(nonatomic, assign, getter=isMessageAnimationEnabled) BOOL messageAnimationEnabled;

/**
The delegate for MDCSnackbarManager.defaultManager through which it may inform of snackbar
presentation updates.
Expand Down
5 changes: 3 additions & 2 deletions components/Snackbar/src/MDCSnackbarManager.m
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@ - (void)displaySnackbarViewForMessage:(MDCSnackbarMessage *)message {
// only if the user isn't running VoiceOver.
[self.overlayView
showSnackbarView:snackbarView
animated:YES
animated:self.manager.isMessageAnimationEnabled
completion:^{
if ([self snackbarAllowsFocus:snackbarView]) {
UIAccessibilityPostNotification(self.manager.focusAccessibilityNotification,
Expand Down Expand Up @@ -336,7 +336,7 @@ - (void)hideSnackbarViewReally:(MDCSnackbarMessageView *)snackbarView
}

[self.overlayView
dismissSnackbarViewAnimated:YES
dismissSnackbarViewAnimated:self.manager.isMessageAnimationEnabled
completion:^{
self.overlayView.hidden = YES;
[self deactivateOverlay:self.overlayView];
Expand Down Expand Up @@ -634,6 +634,7 @@ - (instancetype)initWithWindowScene:(nullable UIWindowScene *)windowScene {
_mdc_overrideBaseElevation = -1;
_focusAccessibilityNotification = UIAccessibilityLayoutChangedNotification;
_shouldShowMessageWhenVoiceOverIsRunning = YES;
_messageAnimationEnabled = YES;
_enableDismissalAccessibilityAffordance = NO;
_usesGM3Shapes = NO;
}
Expand Down

0 comments on commit c4c73b5

Please sign in to comment.