From 10d9aff0cc990d9000a9ed1b381caf370e4bcc3f Mon Sep 17 00:00:00 2001 From: Jood Hajeer Date: Mon, 30 Jan 2023 17:41:42 +0000 Subject: [PATCH] [ios] Add the option to keep/remove the original icon colors if a background tint is applied. This CL introduces a new property ignoreIconColorWithTint in the infobar banner consumer. It is used to keep/remove the original icon colors when a background tint color is applied. Default behaviour is to ignore the icon colors when a background tint is applied. No behaviour change for default cases in this CL. Setting it to keep the icon colors only for the new Save/Update password messages design in the mediator. Screenshots in crbug.com/1392708#c26. (cherry picked from commit d17328bc02778053eb458bd594e62e52b01731e9) Bug: 1392708 Change-Id: I8909f83dfbc4c2c3b5adf9bec7a6eb260bfab8a6 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4188877 Reviewed-by: Chris Lu Commit-Queue: Jood Hajeer Cr-Original-Commit-Position: refs/heads/main@{#1097616} Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4203248 Cr-Commit-Position: refs/branch-heads/5563@{#20} Cr-Branched-From: 3ac59a6729cdb287a7ee629a0004c907ec1b06dc-refs/heads/main@{#1097615} --- .../browser/ui/infobars/banners/infobar_banner_consumer.h | 4 ++++ .../ui/infobars/banners/infobar_banner_view_controller.mm | 8 +++++++- .../infobars/banners/test/fake_infobar_banner_consumer.h | 1 + .../passwords/password_infobar_banner_overlay_mediator.mm | 2 +- 4 files changed, 13 insertions(+), 2 deletions(-) diff --git a/ios/chrome/browser/ui/infobars/banners/infobar_banner_consumer.h b/ios/chrome/browser/ui/infobars/banners/infobar_banner_consumer.h index 5ba4abeae7aa08..30ecafc6796d4b 100644 --- a/ios/chrome/browser/ui/infobars/banners/infobar_banner_consumer.h +++ b/ios/chrome/browser/ui/infobars/banners/infobar_banner_consumer.h @@ -25,6 +25,10 @@ // YES if the icon image should have a default tint applied to its background. - (void)setUseIconBackgroundTint:(BOOL)useIconBackgroundTint; +// NO if the icon image colors should not be ignored when a background tint is +// applied. Default is YES. +- (void)setIgnoreIconColorWithTint:(BOOL)ignoreIconColorWithTint; + // The background color of the icon, only applied when // [setUseIconBackgroundTint:YES] is called. - (void)setIconBackgroundColor:(UIColor*)iconBackgroundColor; diff --git a/ios/chrome/browser/ui/infobars/banners/infobar_banner_view_controller.mm b/ios/chrome/browser/ui/infobars/banners/infobar_banner_view_controller.mm index a1a27e6787ea75..1fece01b7c828d 100644 --- a/ios/chrome/browser/ui/infobars/banners/infobar_banner_view_controller.mm +++ b/ios/chrome/browser/ui/infobars/banners/infobar_banner_view_controller.mm @@ -84,6 +84,7 @@ @interface InfobarBannerViewController () @property(nonatomic, copy) NSString* subtitleText; @property(nonatomic, copy) NSMutableArray* subtitleStyledRanges; @property(nonatomic, assign) BOOL useIconBackgroundTint; +@property(nonatomic, assign) BOOL ignoreIconColorWithTint; @property(nonatomic, strong) UIColor* iconImageTintColor; @property(nonatomic, strong) UIColor* iconBackgroundColor; @property(nonatomic, assign) BOOL restrictSubtitleTextToSingleLine; @@ -132,6 +133,7 @@ - (instancetype)initWithDelegate:(id)delegate [[InfobarMetricsRecorder alloc] initWithType:infobarType]; _presentsModal = presentsModal; _useIconBackgroundTint = YES; + _ignoreIconColorWithTint = YES; _restrictSubtitleTextToSingleLine = NO; _subtitleStyledRanges = [[NSMutableArray alloc] init]; } @@ -165,7 +167,7 @@ - (void)viewDidLoad { if (self.iconImage) { // If the icon image requires a background tint, ignore the original color // information and draw the image as a template image. - if (self.useIconBackgroundTint) { + if (self.useIconBackgroundTint && self.ignoreIconColorWithTint) { self.iconImage = [self.iconImage imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate]; } @@ -446,6 +448,10 @@ - (void)setUseIconBackgroundTint:(BOOL)useIconBackgroundTint { _useIconBackgroundTint = useIconBackgroundTint; } +- (void)setIgnoreIconColorWithTint:(BOOL)ignoreIconColorWithTint { + _ignoreIconColorWithTint = ignoreIconColorWithTint; +} + - (void)setIconBackgroundColor:(UIColor*)iconBackgroundColor { _iconBackgroundColor = iconBackgroundColor; } diff --git a/ios/chrome/browser/ui/infobars/banners/test/fake_infobar_banner_consumer.h b/ios/chrome/browser/ui/infobars/banners/test/fake_infobar_banner_consumer.h index fe56d4b3d58582..ad55a50931a485 100644 --- a/ios/chrome/browser/ui/infobars/banners/test/fake_infobar_banner_consumer.h +++ b/ios/chrome/browser/ui/infobars/banners/test/fake_infobar_banner_consumer.h @@ -19,6 +19,7 @@ @property(nonatomic, strong) UIColor* iconBackgroundColor; @property(nonatomic, strong) UIColor* iconImageTintColor; @property(nonatomic, assign) BOOL useIconBackgroundTint; +@property(nonatomic, assign) BOOL ignoreIconColorWithTint; @property(nonatomic, assign) BOOL restrictSubtitleTextToSingleLine; @end diff --git a/ios/chrome/browser/ui/overlays/infobar_banner/passwords/password_infobar_banner_overlay_mediator.mm b/ios/chrome/browser/ui/overlays/infobar_banner/passwords/password_infobar_banner_overlay_mediator.mm index 78a35d722ec3a3..360b5265e10a23 100644 --- a/ios/chrome/browser/ui/overlays/infobar_banner/passwords/password_infobar_banner_overlay_mediator.mm +++ b/ios/chrome/browser/ui/overlays/infobar_banner/passwords/password_infobar_banner_overlay_mediator.mm @@ -80,7 +80,7 @@ - (void)configureConsumer { [self.consumer setIconImage:[self iconImageWithConfig:config]]; if (base::FeatureList::IsEnabled( password_manager::features::kIOSShowPasswordStorageInSaveInfobar)) { - [self.consumer setUseIconBackgroundTint:NO]; + [self.consumer setIgnoreIconColorWithTint:NO]; } [self.consumer setPresentsModal:YES]; [self.consumer setTitleText:title];