diff --git a/components/Dialogs/src/MDCAlertControllerView.h b/components/Dialogs/src/MDCAlertControllerView.h index b52a1587dd1..9159e571bda 100644 --- a/components/Dialogs/src/MDCAlertControllerView.h +++ b/components/Dialogs/src/MDCAlertControllerView.h @@ -54,6 +54,16 @@ */ @property(nonatomic, assign) UIEdgeInsets contentInsets; +/** + The edge insets around the content view (which includes the message, and the accessory view if it + is set) against the dialog edges or its neighbor elements, the title and the actions. + + In GM3, the bottom content inset is not needed due to the top action inset provding 24 spacing. + + Default value is UIEdgeInsets(top: 24, leading: 24, bottom: 0, trailing: 24). + */ +@property(nonatomic, assign) UIEdgeInsets M3CDialogContentInsets; + /** The edge insets around the actions against the dialog edges and its neighbor, which could be any of the other elements: the message, accessory view, title, title icon or title icon view. diff --git a/components/Dialogs/src/private/MDCAlertControllerView+Private.m b/components/Dialogs/src/private/MDCAlertControllerView+Private.m index 359f0f84d5d..a20f632d6c5 100644 --- a/components/Dialogs/src/private/MDCAlertControllerView+Private.m +++ b/components/Dialogs/src/private/MDCAlertControllerView+Private.m @@ -43,8 +43,6 @@ static const CGFloat MDCDialogMessageOpacity = 0.54f; -static const UIEdgeInsets M3CDialogContentInsets = (UIEdgeInsets){24.0f, 24.0f, 0.0f, 24.0f}; - /** KVO context for this file. */ static char *const kKVOContextMDCAlertControllerViewPrivate = "kKVOContextMDCAlertControllerViewPrivate"; @@ -117,6 +115,7 @@ - (instancetype)initWithFrame:(CGRect)frame { self.titleInsets = UIEdgeInsetsMake(24.0f, 24.0f, 20.0f, 24.0f); self.contentInsets = UIEdgeInsetsMake(24.0f, 24.0f, 24.0f, 24.0f); self.actionsInsets = UIEdgeInsetsMake(8.0f, 8.0f, 8.0f, 8.0f); + self.M3CDialogContentInsets = UIEdgeInsetsMake(24.0f, 24.0f, 0.0f, 24.0f); self.M3CButtonActionsInsets = UIEdgeInsetsMake(24.0f, 24.0f, 24.0f, 24.0f); self.actionsHorizontalMargin = 8.0f; self.M3CButtonActionsVerticalMargin = 8.0f; @@ -178,6 +177,13 @@ - (instancetype)initWithFrame:(CGRect)frame { return self; } +- (UIEdgeInsets)contentInsets { + if (self.M3CButtonEnabled) { + return self.M3CDialogContentInsets; + } + return _contentInsets; +} + - (NSString *)title { return self.titleLabel.text; } @@ -188,14 +194,6 @@ - (void)setTitle:(NSString *)title { [self setNeedsLayout]; } -- (void)setM3CButtonEnabled:(BOOL)M3CButtonEnabled { - if (M3CButtonEnabled) { - // Bottom content inset is not needed due to the top action inset. - self.contentInsets = M3CDialogContentInsets; - } - _M3CButtonEnabled = M3CButtonEnabled; -} - - (void)setBackgroundColor:(UIColor *_Nullable)backgroundColor { super.backgroundColor = backgroundColor; self.titleView.backgroundColor = backgroundColor;