Skip to content

Commit

Permalink
[Dialogs] Fix title icon resize on orientation change
Browse files Browse the repository at this point in the history
The title icon image view size is updated after each orientation transition, causing the image to get smaller after each transition.
To fix this, we're using the original size of the titleIcon image, instead of the current size of the titleImageView to determine the actual size of the image.

PiperOrigin-RevId: 319127689
  • Loading branch information
galiak11 authored and material-automation committed Jul 1, 2020
1 parent d220234 commit 74cf720
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion components/Dialogs/src/private/MDCAlertControllerView+Private.m
Original file line number Diff line number Diff line change
Expand Up @@ -594,6 +594,7 @@ - (CGFloat)accessoryVerticalInset {
return ([self hasMessage] && [self hasAccessoryView]) ? self.accessoryViewVerticalInset : 0.0f;
}

// Returns the size of the title view or the current size of the title icon imageView.
- (CGSize)titleIconViewSize {
if (self.titleIconView != nil) {
return self.titleIconView.frame.size;
Expand All @@ -603,6 +604,16 @@ - (CGSize)titleIconViewSize {
return CGSizeZero;
}

// Returns the size of the title view or the original size of the title icon image.
- (CGSize)titleIconImageSize {
if (self.titleIconView != nil) {
return self.titleIconView.frame.size;
} else if (self.titleIcon != nil) {
return self.titleIcon.size;
}
return CGSizeZero;
}

- (CGRect)titleFrameWithTitleSize:(CGSize)titleSize {
CGFloat leftInset = self.titleInsets.left;
CGFloat titleTop =
Expand All @@ -622,7 +633,7 @@ - (CGRect)messageFrameWithSize:(CGSize)messageSize {
@param boundsSize is the total bounds without any internal margins or padding.
*/
- (CGRect)titleIconFrameWithTitleSize:(CGSize)titleSize boundsSize:(CGSize)boundsSize {
CGSize titleIconViewSize = [self titleIconViewSize];
CGSize titleIconViewSize = [self titleIconImageSize];
CGFloat leftInset = self.titleIconInsets.left;
CGFloat topInset = self.titleIconInsets.top;
CGFloat titleIconHeight = titleIconViewSize.height;
Expand Down

0 comments on commit 74cf720

Please sign in to comment.