Commit 4507d294 authored by Robbie Gibson's avatar Robbie Gibson Committed by Commit Bot

[iOS][Dark Mode] Add dark mode colors to save card infobar

Bug: 991539
Change-Id: Ibd47e2d2ef209fa86400136af8d135f82898c1c1
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1760225
Commit-Queue: Robbie Gibson <rkgibson@google.com>
Reviewed-by: default avatarRohit Rao <rohitrao@chromium.org>
Cr-Commit-Position: refs/heads/master@{#688259}
parent 111a1549
...@@ -117,12 +117,14 @@ source_set("autofill_ui") { ...@@ -117,12 +117,14 @@ source_set("autofill_ui") {
"//ios/chrome/browser/ui/colors", "//ios/chrome/browser/ui/colors",
"//ios/chrome/browser/ui/image_util", "//ios/chrome/browser/ui/image_util",
"//ios/chrome/browser/ui/infobars:infobars_ui", "//ios/chrome/browser/ui/infobars:infobars_ui",
"//ios/chrome/browser/ui/toolbar/public",
"//ios/chrome/browser/ui/util", "//ios/chrome/browser/ui/util",
"//ios/chrome/common", "//ios/chrome/common",
"//ios/chrome/common/colors",
"//ios/chrome/common/ui_util", "//ios/chrome/common/ui_util",
"//ios/third_party/material_components_ios", "//ios/third_party/material_components_ios",
"//ios/third_party/material_roboto_font_loader_ios", "//ios/third_party/material_roboto_font_loader_ios",
"//ui/base:base", "//ui/base",
"//url:url", "//url:url",
] ]
libs = [ "UIKit.framework" ] libs = [ "UIKit.framework" ]
......
...@@ -82,10 +82,13 @@ base::string16 GetTitleForButton(ConfirmInfoBarDelegate* delegate, ...@@ -82,10 +82,13 @@ base::string16 GetTitleForButton(ConfirmInfoBarDelegate* delegate,
// Icon. // Icon.
gfx::Image icon = self.infoBarDelegate->GetIcon(); gfx::Image icon = self.infoBarDelegate->GetIcon();
DCHECK(!icon.IsEmpty()); DCHECK(!icon.IsEmpty());
if (self.infoBarDelegate->IsGooglePayBrandingEnabled()) if (self.infoBarDelegate->IsGooglePayBrandingEnabled()) {
[self.infoBarView setGooglePayIcon:icon.ToUIImage()]; [self.infoBarView setGooglePayIcon:icon.ToUIImage()];
else } else {
[self.infoBarView setIcon:icon.ToUIImage()]; UIImage* iconImage = [icon.ToUIImage()
imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate];
[self.infoBarView setIcon:iconImage];
}
// Message, if any. // Message, if any.
base::string16 messageText = self.infoBarDelegate->GetMessageText(); base::string16 messageText = self.infoBarDelegate->GetMessageText();
......
...@@ -10,13 +10,16 @@ ...@@ -10,13 +10,16 @@
#import "ios/chrome/browser/ui/autofill/save_card_infobar_view_delegate.h" #import "ios/chrome/browser/ui/autofill/save_card_infobar_view_delegate.h"
#import "ios/chrome/browser/ui/colors/MDCPalette+CrAdditions.h" #import "ios/chrome/browser/ui/colors/MDCPalette+CrAdditions.h"
#import "ios/chrome/browser/ui/infobars/infobar_constants.h" #import "ios/chrome/browser/ui/infobars/infobar_constants.h"
#import "ios/chrome/browser/ui/toolbar/public/toolbar_constants.h"
#import "ios/chrome/browser/ui/util/label_link_controller.h" #import "ios/chrome/browser/ui/util/label_link_controller.h"
#import "ios/chrome/browser/ui/util/named_guide.h" #import "ios/chrome/browser/ui/util/named_guide.h"
#import "ios/chrome/browser/ui/util/uikit_ui_util.h" #import "ios/chrome/browser/ui/util/uikit_ui_util.h"
#import "ios/chrome/common/colors/semantic_color_names.h"
#import "ios/chrome/common/ui_util/constraints_ui_util.h" #import "ios/chrome/common/ui_util/constraints_ui_util.h"
#import "ios/third_party/material_components_ios/src/components/Buttons/src/MaterialButtons.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" #import "ios/third_party/material_components_ios/src/components/Typography/src/MaterialTypography.h"
#include "ui/base/l10n/l10n_util.h" #include "ui/base/l10n/l10n_util.h"
#import "ui/gfx/ios/uikit_util.h"
#include "url/gurl.h" #include "url/gurl.h"
#if !defined(__has_feature) || !__has_feature(objc_arc) #if !defined(__has_feature) || !__has_feature(objc_arc)
...@@ -38,9 +41,6 @@ const CGFloat kDescriptionLineHeight = 20; ...@@ -38,9 +41,6 @@ const CGFloat kDescriptionLineHeight = 20;
// to the close button icon's intrinsic padding equals kPadding. // to the close button icon's intrinsic padding equals kPadding.
const CGFloat kCloseButtonPadding = 12; const CGFloat kCloseButtonPadding = 12;
// Color in RGB to be used as tint color on the icon.
const CGFloat kIconTintColor = 0x1A73E8;
// Padding used on the bottom edge of the title. // Padding used on the bottom edge of the title.
const CGFloat kTitleBottomPadding = 24; const CGFloat kTitleBottomPadding = 24;
...@@ -53,9 +53,6 @@ const CGFloat kHorizontalSpacing = 8; ...@@ -53,9 +53,6 @@ const CGFloat kHorizontalSpacing = 8;
// Padding used on the top edge of the action buttons' container. // Padding used on the top edge of the action buttons' container.
const CGFloat kButtonsTopPadding = 32; const CGFloat kButtonsTopPadding = 32;
// Color in RGB used as background of the action buttons.
const int kButtonTitleColorBlue = 0x4285f4;
// Corner radius for action buttons. // Corner radius for action buttons.
const CGFloat kButtonCornerRadius = 8.0; const CGFloat kButtonCornerRadius = 8.0;
...@@ -173,9 +170,22 @@ NSString* const kTitleViewAccessibilityIdentifier = @"titleView"; ...@@ -173,9 +170,22 @@ NSString* const kTitleViewAccessibilityIdentifier = @"titleView";
// Creates and adds subviews. // Creates and adds subviews.
- (void)setupSubviews { - (void)setupSubviews {
[self setAccessibilityViewIsModal:YES]; [self setAccessibilityViewIsModal:YES];
self.backgroundColor = UIColorFromRGB(kInfobarBackgroundColor); self.backgroundColor = [UIColor colorNamed:kBackgroundColor];
id<LayoutGuideProvider> safeAreaLayoutGuide = self.safeAreaLayoutGuide; id<LayoutGuideProvider> safeAreaLayoutGuide = self.safeAreaLayoutGuide;
// Add thin separator to separate infobar from the web content.
UIView* separator = [[UIView alloc] initWithFrame:CGRectZero];
separator.translatesAutoresizingMaskIntoConstraints = NO;
separator.backgroundColor = [UIColor colorNamed:kToolbarShadowColor];
[self addSubview:separator];
CGFloat separatorHeight = ui::AlignValueToUpperPixel(kToolbarSeparatorHeight);
[NSLayoutConstraint activateConstraints:@[
[separator.heightAnchor constraintEqualToConstant:separatorHeight],
[self.leadingAnchor constraintEqualToAnchor:separator.leadingAnchor],
[self.trailingAnchor constraintEqualToAnchor:separator.trailingAnchor],
[self.topAnchor constraintEqualToAnchor:separator.bottomAnchor],
]];
// Add the icon. The icon is fixed to the top leading corner of the infobar. // Add the icon. The icon is fixed to the top leading corner of the infobar.
// |iconContainerView| is used here because the AutoLayout constraints for // |iconContainerView| is used here because the AutoLayout constraints for
// UIImageView would get ignored otherwise. // UIImageView would get ignored otherwise.
...@@ -191,7 +201,7 @@ NSString* const kTitleViewAccessibilityIdentifier = @"titleView"; ...@@ -191,7 +201,7 @@ NSString* const kTitleViewAccessibilityIdentifier = @"titleView";
iconImageView.translatesAutoresizingMaskIntoConstraints = NO; iconImageView.translatesAutoresizingMaskIntoConstraints = NO;
iconImageView.accessibilityIdentifier = iconImageView.accessibilityIdentifier =
kIconImageViewAccessibilityIdentifier; kIconImageViewAccessibilityIdentifier;
iconImageView.tintColor = UIColorFromRGB(kIconTintColor); iconImageView.tintColor = [UIColor colorNamed:kBlueColor];
// Prevent the icon from shrinking horizontally. This is needed when the // Prevent the icon from shrinking horizontally. This is needed when the
// title is long and needs to wrap. // title is long and needs to wrap.
[iconImageView [iconImageView
...@@ -266,8 +276,7 @@ NSString* const kTitleViewAccessibilityIdentifier = @"titleView"; ...@@ -266,8 +276,7 @@ NSString* const kTitleViewAccessibilityIdentifier = @"titleView";
action:@selector(didTapClose) action:@selector(didTapClose)
forControlEvents:UIControlEventTouchUpInside]; forControlEvents:UIControlEventTouchUpInside];
[closeButton setAccessibilityLabel:l10n_util::GetNSString(IDS_CLOSE)]; [closeButton setAccessibilityLabel:l10n_util::GetNSString(IDS_CLOSE)];
closeButton.tintColor = [UIColor blackColor]; closeButton.tintColor = [UIColor colorNamed:kToolbarButtonColor];
closeButton.alpha = 0.20;
// Prevent the button from shrinking horizontally. This is needed when the // Prevent the button from shrinking horizontally. This is needed when the
// title is long and needs to wrap. // title is long and needs to wrap.
[closeButton [closeButton
...@@ -337,8 +346,8 @@ NSString* const kTitleViewAccessibilityIdentifier = @"titleView"; ...@@ -337,8 +346,8 @@ NSString* const kTitleViewAccessibilityIdentifier = @"titleView";
if (self.cancelButtonTitle.length > 0UL) { if (self.cancelButtonTitle.length > 0UL) {
UIButton* cancelButton = UIButton* cancelButton =
[self actionButtonWithTitle:self.cancelButtonTitle [self actionButtonWithTitle:self.cancelButtonTitle
palette:nil backgroundColor:nil
titleColor:UIColorFromRGB(kButtonTitleColorBlue) titleColor:[UIColor colorNamed:kBlueColor]
target:self target:self
action:@selector(didTapCancel)]; action:@selector(didTapCancel)];
...@@ -348,8 +357,8 @@ NSString* const kTitleViewAccessibilityIdentifier = @"titleView"; ...@@ -348,8 +357,8 @@ NSString* const kTitleViewAccessibilityIdentifier = @"titleView";
if (self.confirmButtonTitle.length > 0UL) { if (self.confirmButtonTitle.length > 0UL) {
UIButton* confirmButton = UIButton* confirmButton =
[self actionButtonWithTitle:self.confirmButtonTitle [self actionButtonWithTitle:self.confirmButtonTitle
palette:[MDCPalette cr_bluePalette] backgroundColor:[UIColor colorNamed:kBlueColor]
titleColor:[UIColor whiteColor] titleColor:[UIColor colorNamed:kSolidButtonTextColor]
target:self target:self
action:@selector(didTapConfirm)]; action:@selector(didTapConfirm)];
...@@ -404,9 +413,8 @@ NSString* const kTitleViewAccessibilityIdentifier = @"titleView"; ...@@ -404,9 +413,8 @@ NSString* const kTitleViewAccessibilityIdentifier = @"titleView";
label.accessibilityIdentifier = kTitleLabelAccessibilityIdentifier; label.accessibilityIdentifier = kTitleLabelAccessibilityIdentifier;
label.translatesAutoresizingMaskIntoConstraints = NO; label.translatesAutoresizingMaskIntoConstraints = NO;
label.clipsToBounds = YES; label.clipsToBounds = YES;
label.textColor = [[MDCPalette greyPalette] tint900]; label.textColor = [UIColor colorNamed:kTextPrimaryColor];
label.numberOfLines = 0; label.numberOfLines = 0;
label.backgroundColor = [UIColor clearColor];
NSMutableParagraphStyle* paragraphStyle = NSMutableParagraphStyle* paragraphStyle =
[[NSMutableParagraphStyle alloc] init]; [[NSMutableParagraphStyle alloc] init];
paragraphStyle.lineBreakMode = NSLineBreakByWordWrapping; paragraphStyle.lineBreakMode = NSLineBreakByWordWrapping;
...@@ -475,9 +483,8 @@ NSString* const kTitleViewAccessibilityIdentifier = @"titleView"; ...@@ -475,9 +483,8 @@ NSString* const kTitleViewAccessibilityIdentifier = @"titleView";
if (self.description.length > 0UL) { if (self.description.length > 0UL) {
UILabel* label = [[UILabel alloc] initWithFrame:CGRectZero]; UILabel* label = [[UILabel alloc] initWithFrame:CGRectZero];
label.accessibilityIdentifier = kDescriptionLabelAccessibilityIdentifier; label.accessibilityIdentifier = kDescriptionLabelAccessibilityIdentifier;
label.textColor = [[MDCPalette greyPalette] tint700]; label.textColor = [UIColor colorNamed:kTextSecondaryColor];
label.numberOfLines = 0; label.numberOfLines = 0;
label.backgroundColor = [UIColor clearColor];
NSMutableParagraphStyle* paragraphStyle = NSMutableParagraphStyle* paragraphStyle =
[[NSMutableParagraphStyle alloc] init]; [[NSMutableParagraphStyle alloc] init];
paragraphStyle.lineBreakMode = NSLineBreakByWordWrapping; paragraphStyle.lineBreakMode = NSLineBreakByWordWrapping;
...@@ -519,16 +526,14 @@ NSString* const kTitleViewAccessibilityIdentifier = @"titleView"; ...@@ -519,16 +526,14 @@ NSString* const kTitleViewAccessibilityIdentifier = @"titleView";
cardLabel.accessibilityIdentifier = kCardLabelAccessibilityIdentifier; cardLabel.accessibilityIdentifier = kCardLabelAccessibilityIdentifier;
cardLabel.text = self.cardLabel; cardLabel.text = self.cardLabel;
cardLabel.font = [MDCTypography body1Font]; cardLabel.font = [MDCTypography body1Font];
cardLabel.textColor = [[MDCPalette greyPalette] tint900]; cardLabel.textColor = [UIColor colorNamed:kTextPrimaryColor];
cardLabel.backgroundColor = [UIColor clearColor];
[cardDetailsContainerView addArrangedSubview:cardLabel]; [cardDetailsContainerView addArrangedSubview:cardLabel];
UILabel* cardSublabel = [[UILabel alloc] initWithFrame:CGRectZero]; UILabel* cardSublabel = [[UILabel alloc] initWithFrame:CGRectZero];
cardSublabel.accessibilityIdentifier = kCardSublabelAccessibilityIdentifier; cardSublabel.accessibilityIdentifier = kCardSublabelAccessibilityIdentifier;
cardSublabel.text = self.cardSublabel; cardSublabel.text = self.cardSublabel;
cardSublabel.font = [MDCTypography body1Font]; cardSublabel.font = [MDCTypography body1Font];
cardSublabel.textColor = [[MDCPalette greyPalette] tint700]; cardSublabel.textColor = [UIColor colorNamed:kTextSecondaryColor];
cardSublabel.backgroundColor = [UIColor clearColor];
[cardDetailsContainerView addArrangedSubview:cardSublabel]; [cardDetailsContainerView addArrangedSubview:cardSublabel];
// Dummy view that expands so that the card details are aligned to the leading // Dummy view that expands so that the card details are aligned to the leading
...@@ -547,7 +552,6 @@ NSString* const kTitleViewAccessibilityIdentifier = @"titleView"; ...@@ -547,7 +552,6 @@ NSString* const kTitleViewAccessibilityIdentifier = @"titleView";
label.accessibilityIdentifier = kLegalMessageLabelAccessibilityIdentifier; label.accessibilityIdentifier = kLegalMessageLabelAccessibilityIdentifier;
label.textColor = [[MDCPalette greyPalette] tint700]; label.textColor = [[MDCPalette greyPalette] tint700];
label.numberOfLines = 0; label.numberOfLines = 0;
label.backgroundColor = [UIColor clearColor];
NSMutableParagraphStyle* paragraphStyle = NSMutableParagraphStyle* paragraphStyle =
[[NSMutableParagraphStyle alloc] init]; [[NSMutableParagraphStyle alloc] init];
paragraphStyle.lineBreakMode = NSLineBreakByWordWrapping; paragraphStyle.lineBreakMode = NSLineBreakByWordWrapping;
...@@ -592,14 +596,14 @@ NSString* const kTitleViewAccessibilityIdentifier = @"titleView"; ...@@ -592,14 +596,14 @@ NSString* const kTitleViewAccessibilityIdentifier = @"titleView";
action { action {
LabelLinkController* labelLinkController = LabelLinkController* labelLinkController =
[[LabelLinkController alloc] initWithLabel:label action:action]; [[LabelLinkController alloc] initWithLabel:label action:action];
[labelLinkController setLinkColor:[[MDCPalette cr_bluePalette] tint500]]; [labelLinkController setLinkColor:[UIColor colorNamed:kBlueColor]];
return labelLinkController; return labelLinkController;
} }
// Creates and returns an infobar action button initialized with the given // Creates and returns an infobar action button initialized with the given
// title, colors, and action. // title, colors, and action.
- (UIButton*)actionButtonWithTitle:(NSString*)title - (UIButton*)actionButtonWithTitle:(NSString*)title
palette:(MDCPalette*)palette backgroundColor:(UIColor*)backgroundColor
titleColor:(UIColor*)titleColor titleColor:(UIColor*)titleColor
target:(id)target target:(id)target
action:(SEL)action { action:(SEL)action {
...@@ -610,17 +614,17 @@ NSString* const kTitleViewAccessibilityIdentifier = @"titleView"; ...@@ -610,17 +614,17 @@ NSString* const kTitleViewAccessibilityIdentifier = @"titleView";
[button addTarget:target [button addTarget:target
action:action action:action
forControlEvents:UIControlEventTouchUpInside]; forControlEvents:UIControlEventTouchUpInside];
[button setUnderlyingColorHint:[UIColor blackColor]]; [button setUnderlyingColorHint:[UIColor colorNamed:kBackgroundColor]];
button.uppercaseTitle = NO; button.uppercaseTitle = NO;
button.layer.cornerRadius = kButtonCornerRadius; button.layer.cornerRadius = kButtonCornerRadius;
[button [button
setTitleFont:[UIFont preferredFontForTextStyle:UIFontTextStyleHeadline] setTitleFont:[UIFont preferredFontForTextStyle:UIFontTextStyleHeadline]
forState:UIControlStateNormal]; forState:UIControlStateNormal];
if (palette) { if (backgroundColor) {
button.hasOpaqueBackground = YES; button.hasOpaqueBackground = YES;
button.inkColor = [[palette tint300] colorWithAlphaComponent:0.5f]; button.inkColor = [UIColor colorNamed:kMDCInkColor];
[button setBackgroundColor:[palette tint500] forState:UIControlStateNormal]; [button setBackgroundColor:backgroundColor forState:UIControlStateNormal];
} }
if (titleColor) { if (titleColor) {
......
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