Skip to content

Commit

Permalink
[ios] Add the option to keep/remove the original icon colors if a
Browse files Browse the repository at this point in the history
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 d17328b)

Bug: 1392708
Change-Id: I8909f83dfbc4c2c3b5adf9bec7a6eb260bfab8a6
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4188877
Reviewed-by: Chris Lu <thegreenfrog@chromium.org>
Commit-Queue: Jood Hajeer <jood@google.com>
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: 3ac59a6-refs/heads/main@{#1097615}
  • Loading branch information
Jood Hajeer authored and Chromium LUCI CQ committed Jan 30, 2023
1 parent 608f80a commit 10d9aff
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ @interface InfobarBannerViewController ()
@property(nonatomic, copy) NSString* subtitleText;
@property(nonatomic, copy) NSMutableArray<StyledRange*>* 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;
Expand Down Expand Up @@ -132,6 +133,7 @@ - (instancetype)initWithDelegate:(id<InfobarBannerDelegate>)delegate
[[InfobarMetricsRecorder alloc] initWithType:infobarType];
_presentsModal = presentsModal;
_useIconBackgroundTint = YES;
_ignoreIconColorWithTint = YES;
_restrictSubtitleTextToSingleLine = NO;
_subtitleStyledRanges = [[NSMutableArray alloc] init];
}
Expand Down Expand Up @@ -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];
}
Expand Down Expand Up @@ -446,6 +448,10 @@ - (void)setUseIconBackgroundTint:(BOOL)useIconBackgroundTint {
_useIconBackgroundTint = useIconBackgroundTint;
}

- (void)setIgnoreIconColorWithTint:(BOOL)ignoreIconColorWithTint {
_ignoreIconColorWithTint = ignoreIconColorWithTint;
}

- (void)setIconBackgroundColor:(UIColor*)iconBackgroundColor {
_iconBackgroundColor = iconBackgroundColor;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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];
Expand Down

0 comments on commit 10d9aff

Please sign in to comment.