Commit 304fcb07 authored by Robbie Gibson's avatar Robbie Gibson Committed by Commit Bot

[iOS] Add dark mode colors to saved password views

This mostly consists of replacing the old blue and red with our new
blue/red semantic colors.

Bug: 976668
Change-Id: I25f5bdc99140d4fa2ea7a6d4a09ffebecacb7996
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1713635Reviewed-by: default avatarMark Cogan <marq@chromium.org>
Reviewed-by: default avatarSergio Collazos <sczs@chromium.org>
Commit-Queue: Robbie Gibson <rkgibson@google.com>
Cr-Commit-Position: refs/heads/master@{#680549}
parent 1fa69c08
...@@ -10,6 +10,7 @@ source_set("appearance") { ...@@ -10,6 +10,7 @@ source_set("appearance") {
"appearance_customization.mm", "appearance_customization.mm",
] ]
deps = [ deps = [
"//ios/chrome/browser/ui/settings:settings_root",
"//ios/chrome/browser/ui/table_view", "//ios/chrome/browser/ui/table_view",
"//ios/chrome/common/colors", "//ios/chrome/common/colors",
] ]
......
...@@ -4,6 +4,7 @@ ...@@ -4,6 +4,7 @@
#import "ios/chrome/browser/ui/appearance/appearance_customization.h" #import "ios/chrome/browser/ui/appearance/appearance_customization.h"
#import "ios/chrome/browser/ui/settings/settings_navigation_controller.h"
#import "ios/chrome/browser/ui/table_view/table_view_navigation_controller.h" #import "ios/chrome/browser/ui/table_view/table_view_navigation_controller.h"
#import "ios/chrome/common/colors/semantic_color_names.h" #import "ios/chrome/common/colors/semantic_color_names.h"
...@@ -13,7 +14,12 @@ ...@@ -13,7 +14,12 @@
void CustomizeUIAppearance() { void CustomizeUIAppearance() {
Class containerClass = [TableViewNavigationController class]; Class containerClass = [TableViewNavigationController class];
UIBarButtonItem* barbuttonItemAppearance = [UIBarButtonItem UIBarButtonItem* barButtonItemAppearance = [UIBarButtonItem
appearanceWhenContainedInInstancesOfClasses:@[ containerClass ]]; appearanceWhenContainedInInstancesOfClasses:@[ containerClass ]];
barbuttonItemAppearance.tintColor = [UIColor colorNamed:kTintColor]; barButtonItemAppearance.tintColor = [UIColor colorNamed:kTintColor];
Class navigationBarClass = [SettingsNavigationController class];
UINavigationBar* navigationBarAppearance = [UINavigationBar
appearanceWhenContainedInInstancesOfClasses:@[ navigationBarClass ]];
navigationBarAppearance.tintColor = [UIColor colorNamed:kTintColor];
} }
...@@ -8,6 +8,7 @@ ...@@ -8,6 +8,7 @@
#include "ios/chrome/browser/ui/table_view/cells/table_view_cells_constants.h" #include "ios/chrome/browser/ui/table_view/cells/table_view_cells_constants.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/UIColor+cr_semantic_colors.h" #import "ios/chrome/common/colors/UIColor+cr_semantic_colors.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"
#include "ios/chrome/grit/ios_strings.h" #include "ios/chrome/grit/ios_strings.h"
#include "ui/base/l10n/l10n_util_mac.h" #include "ui/base/l10n/l10n_util_mac.h"
...@@ -80,7 +81,7 @@ const CGFloat kIconImageSize = 28; ...@@ -80,7 +81,7 @@ const CGFloat kIconImageSize = 28;
_switchView = [[UISwitch alloc] initWithFrame:CGRectZero]; _switchView = [[UISwitch alloc] initWithFrame:CGRectZero];
_switchView.translatesAutoresizingMaskIntoConstraints = NO; _switchView.translatesAutoresizingMaskIntoConstraints = NO;
_switchView.onTintColor = UIColorFromRGB(kTableViewSwitchTintColor); _switchView.onTintColor = [UIColor colorNamed:kTintColor];
[_switchView [_switchView
setContentCompressionResistancePriority:UILayoutPriorityDefaultHigh + 1 setContentCompressionResistancePriority:UILayoutPriorityDefaultHigh + 1
forAxis: forAxis:
......
...@@ -24,6 +24,7 @@ ...@@ -24,6 +24,7 @@
#import "ios/chrome/browser/ui/table_view/cells/table_view_text_item.h" #import "ios/chrome/browser/ui/table_view/cells/table_view_text_item.h"
#include "ios/chrome/browser/ui/ui_feature_flags.h" #include "ios/chrome/browser/ui/ui_feature_flags.h"
#include "ios/chrome/browser/ui/util/uikit_ui_util.h" #include "ios/chrome/browser/ui/util/uikit_ui_util.h"
#import "ios/chrome/common/colors/semantic_color_names.h"
#include "ios/chrome/grit/ios_strings.h" #include "ios/chrome/grit/ios_strings.h"
#import "ios/third_party/material_components_ios/src/components/Snackbar/src/MaterialSnackbar.h" #import "ios/third_party/material_components_ios/src/components/Snackbar/src/MaterialSnackbar.h"
#include "ui/base/l10n/l10n_util_mac.h" #include "ui/base/l10n/l10n_util_mac.h"
...@@ -225,7 +226,7 @@ typedef NS_ENUM(NSInteger, ItemType) { ...@@ -225,7 +226,7 @@ typedef NS_ENUM(NSInteger, ItemType) {
TableViewTextItem* item = TableViewTextItem* item =
[[TableViewTextItem alloc] initWithType:ItemTypeCopySite]; [[TableViewTextItem alloc] initWithType:ItemTypeCopySite];
item.text = l10n_util::GetNSString(IDS_IOS_SETTINGS_SITE_COPY_BUTTON); item.text = l10n_util::GetNSString(IDS_IOS_SETTINGS_SITE_COPY_BUTTON);
item.textColor = UIColorFromRGB(kTableViewTextLabelColorBlue); item.textColor = [UIColor colorNamed:kTintColor];
// Accessibility label adds the header to the text, so that accessibility // Accessibility label adds the header to the text, so that accessibility
// users do not have to rely on the visual grouping to understand which part // users do not have to rely on the visual grouping to understand which part
// of the credential is being copied. // of the credential is being copied.
...@@ -243,7 +244,7 @@ typedef NS_ENUM(NSInteger, ItemType) { ...@@ -243,7 +244,7 @@ typedef NS_ENUM(NSInteger, ItemType) {
TableViewTextItem* item = TableViewTextItem* item =
[[TableViewTextItem alloc] initWithType:ItemTypeCopyUsername]; [[TableViewTextItem alloc] initWithType:ItemTypeCopyUsername];
item.text = l10n_util::GetNSString(IDS_IOS_SETTINGS_USERNAME_COPY_BUTTON); item.text = l10n_util::GetNSString(IDS_IOS_SETTINGS_USERNAME_COPY_BUTTON);
item.textColor = UIColorFromRGB(kTableViewTextLabelColorBlue); item.textColor = [UIColor colorNamed:kTintColor];
// Accessibility label adds the header to the text, so that accessibility // Accessibility label adds the header to the text, so that accessibility
// users do not have to rely on the visual grouping to understand which part // users do not have to rely on the visual grouping to understand which part
// of the credential is being copied. // of the credential is being copied.
...@@ -262,7 +263,7 @@ typedef NS_ENUM(NSInteger, ItemType) { ...@@ -262,7 +263,7 @@ typedef NS_ENUM(NSInteger, ItemType) {
TableViewTextItem* item = TableViewTextItem* item =
[[TableViewTextItem alloc] initWithType:ItemTypeCopyPassword]; [[TableViewTextItem alloc] initWithType:ItemTypeCopyPassword];
item.text = l10n_util::GetNSString(IDS_IOS_SETTINGS_PASSWORD_COPY_BUTTON); item.text = l10n_util::GetNSString(IDS_IOS_SETTINGS_PASSWORD_COPY_BUTTON);
item.textColor = UIColorFromRGB(kTableViewTextLabelColorBlue); item.textColor = [UIColor colorNamed:kTintColor];
// Accessibility label adds the header to the text, so that accessibility // Accessibility label adds the header to the text, so that accessibility
// users do not have to rely on the visual grouping to understand which part // users do not have to rely on the visual grouping to understand which part
// of the credential is being copied. // of the credential is being copied.
...@@ -281,7 +282,7 @@ typedef NS_ENUM(NSInteger, ItemType) { ...@@ -281,7 +282,7 @@ typedef NS_ENUM(NSInteger, ItemType) {
TableViewTextItem* item = TableViewTextItem* item =
[[TableViewTextItem alloc] initWithType:ItemTypeShowHide]; [[TableViewTextItem alloc] initWithType:ItemTypeShowHide];
item.text = [self showHideButtonText]; item.text = [self showHideButtonText];
item.textColor = UIColorFromRGB(kTableViewTextLabelColorBlue); item.textColor = [UIColor colorNamed:kTintColor];
item.accessibilityTraits |= UIAccessibilityTraitButton; item.accessibilityTraits |= UIAccessibilityTraitButton;
return item; return item;
} }
...@@ -291,7 +292,7 @@ typedef NS_ENUM(NSInteger, ItemType) { ...@@ -291,7 +292,7 @@ typedef NS_ENUM(NSInteger, ItemType) {
TableViewTextItem* item = TableViewTextItem* item =
[[TableViewTextItem alloc] initWithType:ItemTypeDelete]; [[TableViewTextItem alloc] initWithType:ItemTypeDelete];
item.text = l10n_util::GetNSString(IDS_IOS_SETTINGS_PASSWORD_DELETE_BUTTON); item.text = l10n_util::GetNSString(IDS_IOS_SETTINGS_PASSWORD_DELETE_BUTTON);
item.textColor = [UIColor redColor]; item.textColor = [UIColor colorNamed:kDestructiveTintColor];
item.accessibilityTraits |= UIAccessibilityTraitButton; item.accessibilityTraits |= UIAccessibilityTraitButton;
return item; return item;
} }
......
...@@ -48,6 +48,7 @@ ...@@ -48,6 +48,7 @@
#include "ios/chrome/browser/ui/ui_feature_flags.h" #include "ios/chrome/browser/ui/ui_feature_flags.h"
#include "ios/chrome/browser/ui/util/ui_util.h" #include "ios/chrome/browser/ui/util/ui_util.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/UIColor+cr_semantic_colors.h"
#import "ios/chrome/common/colors/semantic_color_names.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"
#include "ios/chrome/grit/ios_strings.h" #include "ios/chrome/grit/ios_strings.h"
...@@ -264,7 +265,7 @@ std::vector<std::unique_ptr<autofill::PasswordForm>> CopyOf( ...@@ -264,7 +265,7 @@ std::vector<std::unique_ptr<autofill::PasswordForm>> CopyOf(
searchController.obscuresBackgroundDuringPresentation = NO; searchController.obscuresBackgroundDuringPresentation = NO;
searchController.delegate = self; searchController.delegate = self;
searchController.searchBar.delegate = self; searchController.searchBar.delegate = self;
searchController.searchBar.backgroundColor = [UIColor clearColor]; searchController.searchBar.backgroundColor = UIColor.clearColor;
searchController.searchBar.accessibilityIdentifier = kPasswordsSearchBarId; searchController.searchBar.accessibilityIdentifier = kPasswordsSearchBarId;
// Center search bar and cancel button vertically so it looks centered // Center search bar and cancel button vertically so it looks centered
// in the header when searching. // in the header when searching.
...@@ -437,7 +438,7 @@ std::vector<std::unique_ptr<autofill::PasswordForm>> CopyOf( ...@@ -437,7 +438,7 @@ std::vector<std::unique_ptr<autofill::PasswordForm>> CopyOf(
TableViewTextItem* exportPasswordsItem = TableViewTextItem* exportPasswordsItem =
[[TableViewTextItem alloc] initWithType:ItemTypeExportPasswordsButton]; [[TableViewTextItem alloc] initWithType:ItemTypeExportPasswordsButton];
exportPasswordsItem.text = l10n_util::GetNSString(IDS_IOS_EXPORT_PASSWORDS); exportPasswordsItem.text = l10n_util::GetNSString(IDS_IOS_EXPORT_PASSWORDS);
exportPasswordsItem.textColor = UIColorFromRGB(kTableViewTextLabelColorBlue); exportPasswordsItem.textColor = [UIColor colorNamed:kTintColor];
exportPasswordsItem.accessibilityIdentifier = @"exportPasswordsItem_button"; exportPasswordsItem.accessibilityIdentifier = @"exportPasswordsItem_button";
exportPasswordsItem.accessibilityTraits = UIAccessibilityTraitButton; exportPasswordsItem.accessibilityTraits = UIAccessibilityTraitButton;
return exportPasswordsItem; return exportPasswordsItem;
...@@ -733,12 +734,10 @@ std::vector<std::unique_ptr<autofill::PasswordForm>> CopyOf( ...@@ -733,12 +734,10 @@ std::vector<std::unique_ptr<autofill::PasswordForm>> CopyOf(
- (void)setExportPasswordsButtonEnabled:(BOOL)enabled { - (void)setExportPasswordsButtonEnabled:(BOOL)enabled {
if (enabled) { if (enabled) {
DCHECK(exportReady_ && !self.editing); DCHECK(exportReady_ && !self.editing);
exportPasswordsItem_.textColor = exportPasswordsItem_.textColor = [UIColor colorNamed:kTintColor];
UIColorFromRGB(kTableViewTextLabelColorBlue);
exportPasswordsItem_.accessibilityTraits &= ~UIAccessibilityTraitNotEnabled; exportPasswordsItem_.accessibilityTraits &= ~UIAccessibilityTraitNotEnabled;
} else { } else {
exportPasswordsItem_.textColor = exportPasswordsItem_.textColor = UIColor.cr_labelColor;
UIColorFromRGB(kTableViewTextLabelColorLightGrey);
exportPasswordsItem_.accessibilityTraits |= UIAccessibilityTraitNotEnabled; exportPasswordsItem_.accessibilityTraits |= UIAccessibilityTraitNotEnabled;
} }
[self reconfigureCellsForItems:@[ exportPasswordsItem_ ]]; [self reconfigureCellsForItems:@[ exportPasswordsItem_ ]];
......
...@@ -21,6 +21,8 @@ ...@@ -21,6 +21,8 @@
#import "ios/chrome/browser/ui/table_view/cells/table_view_detail_text_item.h" #import "ios/chrome/browser/ui/table_view/cells/table_view_detail_text_item.h"
#include "ios/chrome/browser/ui/table_view/chrome_table_view_controller_test.h" #include "ios/chrome/browser/ui/table_view/chrome_table_view_controller_test.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/UIColor+cr_semantic_colors.h"
#import "ios/chrome/common/colors/semantic_color_names.h"
#include "ios/chrome/grit/ios_strings.h" #include "ios/chrome/grit/ios_strings.h"
#include "ios/web/public/test/test_web_thread_bundle.h" #include "ios/web/public/test/test_web_thread_bundle.h"
#include "testing/gmock/include/gmock/gmock.h" #include "testing/gmock/include/gmock/gmock.h"
...@@ -308,8 +310,7 @@ TEST_F(PasswordsTableViewControllerTest, ...@@ -308,8 +310,7 @@ TEST_F(PasswordsTableViewControllerTest,
TableViewDetailTextItem* exportButton = GetTableViewItem(1, 0); TableViewDetailTextItem* exportButton = GetTableViewItem(1, 0);
CheckTextCellTextWithId(IDS_IOS_EXPORT_PASSWORDS, 1, 0); CheckTextCellTextWithId(IDS_IOS_EXPORT_PASSWORDS, 1, 0);
EXPECT_NSEQ(UIColorFromRGB(kTableViewTextLabelColorLightGrey), EXPECT_NSEQ(UIColor.cr_labelColor, exportButton.textColor);
exportButton.textColor);
EXPECT_TRUE(exportButton.accessibilityTraits & EXPECT_TRUE(exportButton.accessibilityTraits &
UIAccessibilityTraitNotEnabled); UIAccessibilityTraitNotEnabled);
...@@ -317,8 +318,7 @@ TEST_F(PasswordsTableViewControllerTest, ...@@ -317,8 +318,7 @@ TEST_F(PasswordsTableViewControllerTest,
AddBlacklistedForm1(); AddBlacklistedForm1();
// The export button should still be disabled as exporting blacklisted forms // The export button should still be disabled as exporting blacklisted forms
// is not currently supported. // is not currently supported.
EXPECT_NSEQ(UIColorFromRGB(kTableViewTextLabelColorLightGrey), EXPECT_NSEQ(UIColor.cr_labelColor, exportButton.textColor);
exportButton.textColor);
EXPECT_TRUE(exportButton.accessibilityTraits & EXPECT_TRUE(exportButton.accessibilityTraits &
UIAccessibilityTraitNotEnabled); UIAccessibilityTraitNotEnabled);
} }
...@@ -334,8 +334,7 @@ TEST_F(PasswordsTableViewControllerTest, ...@@ -334,8 +334,7 @@ TEST_F(PasswordsTableViewControllerTest,
CheckTextCellTextWithId(IDS_IOS_EXPORT_PASSWORDS, 2, 0); CheckTextCellTextWithId(IDS_IOS_EXPORT_PASSWORDS, 2, 0);
EXPECT_NSEQ(UIColorFromRGB(kTableViewTextLabelColorBlue), EXPECT_NSEQ([UIColor colorNamed:kTintColor], exportButton.textColor);
exportButton.textColor);
EXPECT_FALSE(exportButton.accessibilityTraits & EXPECT_FALSE(exportButton.accessibilityTraits &
UIAccessibilityTraitNotEnabled); UIAccessibilityTraitNotEnabled);
} }
...@@ -352,8 +351,7 @@ TEST_F(PasswordsTableViewControllerTest, TestExportButtonDisabledEditMode) { ...@@ -352,8 +351,7 @@ TEST_F(PasswordsTableViewControllerTest, TestExportButtonDisabledEditMode) {
[passwords_controller setEditing:YES animated:NO]; [passwords_controller setEditing:YES animated:NO];
EXPECT_NSEQ(UIColorFromRGB(kTableViewTextLabelColorLightGrey), EXPECT_NSEQ(UIColor.cr_labelColor, exportButton.textColor);
exportButton.textColor);
EXPECT_TRUE(exportButton.accessibilityTraits & EXPECT_TRUE(exportButton.accessibilityTraits &
UIAccessibilityTraitNotEnabled); UIAccessibilityTraitNotEnabled);
} }
...@@ -373,8 +371,7 @@ TEST_F(PasswordsTableViewControllerTest, ...@@ -373,8 +371,7 @@ TEST_F(PasswordsTableViewControllerTest,
[passwords_controller setEditing:YES animated:NO]; [passwords_controller setEditing:YES animated:NO];
[passwords_controller setEditing:NO animated:NO]; [passwords_controller setEditing:NO animated:NO];
EXPECT_NSEQ(UIColorFromRGB(kTableViewTextLabelColorBlue), EXPECT_NSEQ([UIColor colorNamed:kTintColor], exportButton.textColor);
exportButton.textColor);
EXPECT_FALSE(exportButton.accessibilityTraits & EXPECT_FALSE(exportButton.accessibilityTraits &
UIAccessibilityTraitNotEnabled); UIAccessibilityTraitNotEnabled);
} }
......
...@@ -57,9 +57,6 @@ extern const int kTableViewTextLabelColorLightGrey; ...@@ -57,9 +57,6 @@ extern const int kTableViewTextLabelColorLightGrey;
// metadata...). // metadata...).
extern const int kTableViewSecondaryLabelLightGrayTextColor; extern const int kTableViewSecondaryLabelLightGrayTextColor;
// Hex Value for the tint color for switches.
extern const int kTableViewSwitchTintColor;
// A masked password string(e.g. "••••••••"). // A masked password string(e.g. "••••••••").
extern NSString* const kMaskedPassword; extern NSString* const kMaskedPassword;
......
...@@ -25,6 +25,5 @@ const CGFloat kTableViewAccessoryWidth = 40; ...@@ -25,6 +25,5 @@ const CGFloat kTableViewAccessoryWidth = 40;
const int kTableViewTextLabelColorBlue = 0x1A73E8; const int kTableViewTextLabelColorBlue = 0x1A73E8;
const int kTableViewTextLabelColorLightGrey = 0x6D6D72; const int kTableViewTextLabelColorLightGrey = 0x6D6D72;
const int kTableViewSecondaryLabelLightGrayTextColor = 0x5F6368; const int kTableViewSecondaryLabelLightGrayTextColor = 0x5F6368;
const int kTableViewSwitchTintColor = 0x1A73E8;
NSString* const kMaskedPassword = @"••••••••"; NSString* const kMaskedPassword = @"••••••••";
...@@ -7,6 +7,7 @@ ...@@ -7,6 +7,7 @@
#import "ios/chrome/browser/ui/table_view/cells/table_view_cells_constants.h" #import "ios/chrome/browser/ui/table_view/cells/table_view_cells_constants.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/UIColor+cr_semantic_colors.h" #import "ios/chrome/common/colors/UIColor+cr_semantic_colors.h"
#import "ios/chrome/common/colors/semantic_color_names.h"
#import "ios/chrome/common/string_util.h" #import "ios/chrome/common/string_util.h"
#import "net/base/mac/url_conversions.h" #import "net/base/mac/url_conversions.h"
...@@ -70,6 +71,8 @@ const CGFloat kVerticalPadding = 8; ...@@ -70,6 +71,8 @@ const CGFloat kVerticalPadding = 8;
[UIFont preferredFontForTextStyle:kTableViewSublabelFontStyle]; [UIFont preferredFontForTextStyle:kTableViewSublabelFontStyle];
_textView.adjustsFontForContentSizeCategory = YES; _textView.adjustsFontForContentSizeCategory = YES;
_textView.translatesAutoresizingMaskIntoConstraints = NO; _textView.translatesAutoresizingMaskIntoConstraints = NO;
_textView.linkTextAttributes =
@{NSForegroundColorAttributeName : [UIColor colorNamed:kTintColor]};
[self.contentView addSubview:_textView]; [self.contentView addSubview:_textView];
......
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