Commit 4810fa67 authored by Chris Lu's avatar Chris Lu Committed by Commit Bot

[ios] Create BadgeTypeTranslate

Creates a new BadgeType for the Save Credit Card Infobar. Adds support
for the badge in BadgePopupMenuItem and BadgeButtonFactory.

Bug: 1014959
Change-Id: I3052c0a17ea4e5f68db3a16ead997605b58aaacf
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1872014
Commit-Queue: Chris Lu <thegreenfrog@chromium.org>
Reviewed-by: default avatarPeter Lee <pkl@chromium.org>
Reviewed-by: default avatarSergio Collazos <sczs@chromium.org>
Cr-Commit-Position: refs/heads/master@{#708882}
parent 6f9a2349
......@@ -46,6 +46,8 @@
return BadgeType::kBadgeTypePasswordUpdate;
case InfobarType::kInfobarTypeSaveCard:
return BadgeType::kBadgeTypeSaveCard;
case InfobarType::kInfobarTypeTranslate:
return BadgeType::kBadgeTypeTranslate;
default:
NOTREACHED() << "This infobar should not have a badge";
return BadgeType::kBadgeTypeNone;
......
......@@ -28,6 +28,8 @@
return [self passwordsUpdateBadgeButton];
case BadgeType::kBadgeTypeSaveCard:
return [self saveCardBadgeButton];
case BadgeType::kBadgeTypeTranslate:
return [self translateBadgeButton];
case BadgeType::kBadgeTypeIncognito:
return [self incognitoBadgeButton];
case BadgeType::kBadgeTypeOverflow:
......@@ -83,6 +85,19 @@
return button;
}
- (BadgeButton*)translateBadgeButton {
BadgeButton* button =
[self createButtonForType:BadgeType::kBadgeTypeTranslate
imageNamed:@"infobar_translate_icon"
renderingMode:UIImageRenderingModeAlwaysTemplate];
[button addTarget:self.delegate
action:@selector(translateBadgeButtonTapped:)
forControlEvents:UIControlEventTouchUpInside];
button.accessibilityIdentifier = kBadgeButtonTranslateAccessibilityIdentifier;
// TODO(crbug.com/1014959): Create a11y label hint.
return button;
}
- (BadgeButton*)incognitoBadgeButton {
BadgeButton* button =
[self createButtonForType:BadgeType::kBadgeTypeIncognito
......
......@@ -13,6 +13,7 @@ extern NSString* const kBadgeButtonUpdatePasswordAccessibilityIdentifier;
extern NSString* const kBadgeButtonIncognitoAccessibilityIdentifier;
extern NSString* const kBadgeButtonOverflowAccessibilityIdentifier;
extern NSString* const kBadgeButtonSaveCardAccessibilityIdentifier;
extern NSString* const kBadgeButtonTranslateAccessibilityIdentifier;
// A11y identifier for the Badge Popup Menu Table View.
extern NSString* const kBadgePopupMenuTableViewAccessibilityIdentifier;
......
......@@ -23,6 +23,9 @@ NSString* const kBadgeButtonOverflowAccessibilityIdentifier =
NSString* const kBadgeButtonSaveCardAccessibilityIdentifier =
@"badgeButtonSaveCardAXID";
NSString* const kBadgeButtonTranslateAccessibilityIdentifier =
@"badgeButtonTranslateAXID";
NSString* const kBadgePopupMenuTableViewAccessibilityIdentifier =
@"badgePopupMenuOverflowAXID";
......
......@@ -13,6 +13,9 @@
// Action when a Save Card badge is tapped.
- (void)saveCardBadgeButtonTapped:(id)sender;
// Action when a Translate badge is tapped.
- (void)translateBadgeButtonTapped:(id)sender;
// Action when the overflow badge is tapped.
- (void)overflowBadgeButtonTapped:(id)sender;
@end
......
......@@ -140,6 +140,10 @@ const int kMinimumNonFullScreenBadgesForOverflow = 2;
infobarType:InfobarType::kInfobarTypeSaveCard];
}
- (void)translateBadgeButtonTapped:(id)sender {
// TODO(crbug.com/1014959): Implement.
}
- (void)overflowBadgeButtonTapped:(id)sender {
NSMutableArray<id<BadgeItem>>* popupMenuBadges =
[[NSMutableArray alloc] init];
......
......@@ -65,6 +65,11 @@ const CGFloat kBadgeCornerRadius = 5.0;
// "Save Card" on the delegate and "Save Credit Card on mocks.
_title = @"Save Credit Card";
break;
case BadgeType::kBadgeTypeTranslate:
_actionIdentifier = PopupMenuActionShowTranslateOptions;
// TODO(crbug.com/1014959): use l10n to translate string.
_title = @"Translate Page";
break;
case BadgeType::kBadgeTypeIncognito:
NOTREACHED() << "A BadgePopupMenuItem should not be an Incognito badge";
break;
......@@ -95,6 +100,10 @@ const CGFloat kBadgeCornerRadius = 5.0;
badgeImage = [[UIImage imageNamed:@"infobar_save_card_icon"]
imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate];
break;
case BadgeType::kBadgeTypeTranslate:
badgeImage = [[UIImage imageNamed:@"infobar_translate_icon"]
imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate];
break;
case BadgeType::kBadgeTypeIncognito:
NOTREACHED()
<< "A popup menu item should not be of type kBadgeTypeIncognito";
......
......@@ -21,6 +21,8 @@ enum class BadgeType {
kBadgeTypeOverflow = 4,
// Badge type for Save Credit Card Infobar.
kBadgeTypeSaveCard = 5,
// Badge type for the Translate Infobar.
kBadgeTypeTranslate = 6,
};
#endif // IOS_CHROME_BROWSER_UI_BADGES_BADGE_TYPE_H_
......@@ -52,6 +52,7 @@ typedef NS_ENUM(NSInteger, PopupMenuAction) {
PopupMenuActionShowSavePasswordOptions,
PopupMenuActionShowUpdatePasswordOptions,
PopupMenuActionShowSaveCardOptions,
PopupMenuActionShowTranslateOptions,
};
// Protocol defining a popup item.
......
......@@ -118,6 +118,9 @@ NSString* const kSCDisplayedBadgeToggleButton =
- (void)saveCardBadgeButtonTapped:(id)sender {
}
- (void)translateBadgeButtonTapped:(id)sender {
}
- (void)overflowBadgeButtonTapped:(id)sender {
self.badgePopupMenuCoordinator = [[BadgePopupMenuCoordinator alloc]
initWithBaseViewController:self.containerViewController];
......
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