Commit 2111c653 authored by Javier Ernesto Flores Robles's avatar Javier Ernesto Flores Robles Committed by Commit Bot

[iOS][Alert] Make the alert bigger for a11y

I noticed UIAlertController is wider on accessibility category sizes.
With this change the alert view behaves similar to UIAlertController
with one difference: instead of having 3 sizes (270, 350 and 402) it
it will only have 270 and 402, if the screen is not big enough for 402
it will be as big as it can, respecting the margins.

Bug: 951300
Change-Id: I6cbb7d4ed60aa042567c2ee0d715cb5a267cabb0
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1583703
Commit-Queue: Javier Ernesto Flores Robles <javierrobles@chromium.org>
Reviewed-by: default avatarKurt Horimoto <kkhorimoto@chromium.org>
Cr-Commit-Position: refs/heads/master@{#654812}
parent 3a259d63
......@@ -26,6 +26,7 @@ constexpr float kShadowOpacity = 0.12;
// Properties of the alert view.
constexpr CGFloat kCornerRadius = 14;
constexpr CGFloat kAlertWidth = 270;
constexpr CGFloat kAlertWidthAccessibilty = 402;
constexpr CGFloat kMinimumHeight = 30;
constexpr CGFloat kMinimumMargin = 4;
......@@ -132,16 +133,25 @@ constexpr int kButtonTextDestructiveColor = 0xdf322f;
self.contentView.layer.shadowOpacity = kShadowOpacity;
self.contentView.translatesAutoresizingMaskIntoConstraints = NO;
[self.view addSubview:self.contentView];
BOOL isAccessibilityContentSize =
UIContentSizeCategoryIsAccessibilityCategory(
[UIApplication sharedApplication].preferredContentSizeCategory);
const CGFloat alertWidth =
isAccessibilityContentSize ? kAlertWidthAccessibilty : kAlertWidth;
NSLayoutConstraint* widthConstraint =
[self.contentView.widthAnchor constraintEqualToConstant:alertWidth];
widthConstraint.priority = 999;
[NSLayoutConstraint activateConstraints:@[
widthConstraint,
// Centering
[self.contentView.centerXAnchor
constraintEqualToAnchor:self.view.centerXAnchor],
[self.contentView.centerYAnchor
constraintEqualToAnchor:self.view.centerYAnchor],
// Width
[self.contentView.widthAnchor constraintEqualToConstant:kAlertWidth],
// Minimum Size
[self.contentView.heightAnchor
constraintGreaterThanOrEqualToConstant:kMinimumHeight],
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment