Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(81)

Unified Diff: ios/chrome/browser/ui/authentication/signin_promo_view.mm

Issue 2901783002: Adding accessibility to the close button in sign-in promo (Closed)
Patch Set: . Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: ios/chrome/browser/ui/authentication/signin_promo_view.mm
diff --git a/ios/chrome/browser/ui/authentication/signin_promo_view.mm b/ios/chrome/browser/ui/authentication/signin_promo_view.mm
index a52cb923ee05f564194f080dbb7e3785e3a56024..3487b8f68e22079aa601ef08c8f4004e0cc7de13 100644
--- a/ios/chrome/browser/ui/authentication/signin_promo_view.mm
+++ b/ios/chrome/browser/ui/authentication/signin_promo_view.mm
@@ -9,6 +9,7 @@
#import "ios/chrome/browser/ui/colors/MDCPalette+CrAdditions.h"
#import "ios/chrome/browser/ui/uikit_ui_util.h"
#include "ios/chrome/grit/ios_chromium_strings.h"
+#include "ios/chrome/grit/ios_strings.h"
#import "ios/third_party/material_components_ios/src/components/Buttons/src/MaterialButtons.h"
#import "ios/third_party/material_components_ios/src/components/Typography/src/MaterialTypography.h"
#include "ui/base/l10n/l10n_util.h"
@@ -42,6 +43,7 @@ const CGFloat kButtonHeight = 36;
@synthesize textLabel = _textLabel;
@synthesize primaryButton = _primaryButton;
@synthesize secondaryButton = _secondaryButton;
+@synthesize closeButton = _closeButton;
- (instancetype)initWithFrame:(CGRect)frame {
self = [super initWithFrame:frame];
@@ -75,6 +77,11 @@ const CGFloat kButtonHeight = 36;
forControlEvents:UIControlEventTouchUpInside];
[self addSubview:_secondaryButton];
+ _closeButton = [[UIButton alloc] init];
+ _closeButton.translatesAutoresizingMaskIntoConstraints = NO;
+ _closeButton.accessibilityIdentifier = @"signin_promo_close_button";
+ [self addSubview:_closeButton];
+
// Adding style.
_imageView.contentMode = UIViewContentModeCenter;
_imageView.layer.masksToBounds = YES;
@@ -93,6 +100,10 @@ const CGFloat kButtonHeight = 36;
_secondaryButton.customTitleColor = [[MDCPalette cr_bluePalette] tint500];
_secondaryButton.uppercaseTitle = NO;
+ [_closeButton setImage:[UIImage imageNamed:@"signin_promo_close_gray"]
+ forState:UIControlStateNormal];
+ _closeButton.hidden = YES;
+
// Adding constraints.
NSDictionary* metrics = @{
@"kButtonHeight" : @(kButtonHeight),
@@ -122,6 +133,10 @@ const CGFloat kButtonHeight = 36;
];
ApplyVisualConstraintsWithMetricsAndOptions(
visualConstraints, views, metrics, NSLayoutFormatAlignAllCenterX);
+ NSArray* buttonVisualConstraints =
+ @[ @"H:[closeButton]-|", @"V:|-[closeButton]" ];
+ ApplyVisualConstraints(buttonVisualConstraints,
+ @{ @"closeButton" : _closeButton });
// Constraints for cold state mode.
NSArray* coldStateVisualConstraints = @[
@@ -201,6 +216,10 @@ const CGFloat kButtonHeight = 36;
[_secondaryButton sendActionsForControlEvents:UIControlEventTouchUpInside];
}
+- (void)accessibilityCloseAction:(id)unused {
+ [_closeButton sendActionsForControlEvents:UIControlEventTouchUpInside];
+}
+
- (CGFloat)horizontalPadding {
return kHorizontalPadding;
}
@@ -223,6 +242,8 @@ const CGFloat kButtonHeight = 36;
#pragma mark - NSObject(Accessibility)
- (NSArray<UIAccessibilityCustomAction*>*)accessibilityCustomActions {
+ NSMutableArray* actions = [NSMutableArray array];
+
NSString* primaryActionName =
[_primaryButton titleForState:UIControlStateNormal];
UIAccessibilityCustomAction* primaryCustomAction =
@@ -230,17 +251,31 @@ const CGFloat kButtonHeight = 36;
initWithName:primaryActionName
target:self
selector:@selector(accessibilityPrimaryAction:)];
- if (_mode == SigninPromoViewModeColdState) {
- return @[ primaryCustomAction ];
+ [actions addObject:primaryCustomAction];
+
+ if (_mode == SigninPromoViewModeWarmState) {
+ NSString* secondaryActionName =
+ [_secondaryButton titleForState:UIControlStateNormal];
+ UIAccessibilityCustomAction* secondaryCustomAction =
+ [[UIAccessibilityCustomAction alloc]
+ initWithName:secondaryActionName
+ target:self
+ selector:@selector(accessibilitySecondaryAction:)];
+ [actions addObject:secondaryCustomAction];
}
- NSString* secondaryActionName =
- [_secondaryButton titleForState:UIControlStateNormal];
- UIAccessibilityCustomAction* secondaryCustomAction =
- [[UIAccessibilityCustomAction alloc]
- initWithName:secondaryActionName
- target:self
- selector:@selector(accessibilitySecondaryAction:)];
- return @[ primaryCustomAction, secondaryCustomAction ];
+
+ if (!_closeButton.hidden) {
+ NSString* closeActionName =
+ l10n_util::GetNSString(IDS_IOS_SIGNIN_PROMO_CLOSE_ACCESSIBILITY);
+ UIAccessibilityCustomAction* closeCustomAction =
+ [[UIAccessibilityCustomAction alloc]
+ initWithName:closeActionName
+ target:self
+ selector:@selector(accessibilityCloseAction:)];
+ [actions addObject:closeCustomAction];
+ }
+
+ return actions;
}
- (NSString*)accessibilityLabel {
« no previous file with comments | « ios/chrome/browser/ui/authentication/signin_promo_view.h ('k') | ios/chrome/browser/ui/bookmarks/bookmark_signin_promo_cell.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698