Commit 5ba833f0 authored by Javier Ernesto Flores Robles's avatar Javier Ernesto Flores Robles Committed by Commit Bot

[iOS][DarkMode] Update colors in Sync Screen

Bug: 976640
Change-Id: I973711f79529998b33626b0af9e146271e8b1a80
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1695411
Commit-Queue: Javier Ernesto Flores Robles <javierrobles@chromium.org>
Reviewed-by: default avatarJérôme Lebel <jlebel@chromium.org>
Reviewed-by: default avatarJavier Ernesto Flores Robles <javierrobles@chromium.org>
Cr-Commit-Position: refs/heads/master@{#676008}
parent c5bcdc96
......@@ -63,6 +63,7 @@ source_set("authentication") {
"//ios/chrome/browser/ui/util",
"//ios/chrome/browser/unified_consent",
"//ios/chrome/common",
"//ios/chrome/common/colors",
"//ios/chrome/common/ui_util",
"//ios/public/provider/chrome/browser",
"//ios/public/provider/chrome/browser/images",
......
......@@ -19,19 +19,11 @@ extern const CGFloat kAuthenticationHorizontalMargin;
// Vertical margin between the header image and the main title.
extern const CGFloat kAuthenticationHeaderTitleMargin;
// Alpha for the title color.
extern const CGFloat kAuthenticationTitleColorAlpha;
// Alpha for the text color.
extern const CGFloat kAuthenticationTextColorAlpha;
// Alpha for the separator color.
extern const CGFloat kAuthenticationSeparatorColorAlpha;
// Height of the separator.
extern const CGFloat kAuthenticationSeparatorHeight;
// Color of the checkmark.
extern const int kAuthenticationCheckmarkColor;
// Header image name.
extern NSString* const kAuthenticationHeaderImageName;
......
......@@ -16,12 +16,7 @@ const UIFontTextStyle kAuthenticationTextFontStyle = UIFontTextStyleSubheadline;
const CGFloat kAuthenticationHorizontalMargin = 16.;
const CGFloat kAuthenticationHeaderTitleMargin = 19.;
const CGFloat kAuthenticationTitleColorAlpha = 0.87;
const CGFloat kAuthenticationTextColorAlpha = 0.54;
const CGFloat kAuthenticationSeparatorColorAlpha = 0.12;
const CGFloat kAuthenticationSeparatorHeight = 1;
const int kAuthenticationCheckmarkColor = 0x1A73E8;
NSString* const kAuthenticationHeaderImageName = @"unified_consent_header";
......@@ -102,8 +102,6 @@ using TimerGeneratorBlock = std::unique_ptr<base::OneShotTimer> (^)();
@property(nonatomic, readonly) ios::ChromeBrowserState* browserState;
@property(nonatomic, readonly) UIColor* backgroundColor;
// Vertical padding used underneath buttons. Default value is 18.
@property(nonatomic, assign) CGFloat buttonVerticalPadding;
......
......@@ -39,13 +39,14 @@
#include "ios/chrome/browser/ui/authentication/signin_account_selector_view_controller.h"
#include "ios/chrome/browser/ui/authentication/signin_confirmation_view_controller.h"
#include "ios/chrome/browser/ui/authentication/unified_consent/unified_consent_coordinator.h"
#import "ios/chrome/browser/ui/colors/MDCPalette+CrAdditions.h"
#import "ios/chrome/browser/ui/commands/application_commands.h"
#import "ios/chrome/browser/ui/util/label_link_controller.h"
#import "ios/chrome/browser/ui/util/rtl_geometry.h"
#import "ios/chrome/browser/ui/util/ui_util.h"
#import "ios/chrome/browser/ui/util/uikit_ui_util.h"
#include "ios/chrome/browser/unified_consent/unified_consent_service_factory.h"
#import "ios/chrome/common/colors/UIColor+cr_semantic_colors.h"
#import "ios/chrome/common/colors/semantic_color_names.h"
#include "ios/chrome/common/string_util.h"
#include "ios/chrome/grit/ios_chromium_strings.h"
#include "ios/chrome/grit/ios_strings.h"
......@@ -144,7 +145,6 @@ enum AuthenticationState {
SigninAccountSelectorViewControllerDelegate,
UnifiedConsentCoordinatorDelegate>
@property(nonatomic, strong) ChromeIdentity* selectedIdentity;
@end
@implementation ChromeSigninViewController {
......@@ -340,20 +340,21 @@ enum AuthenticationState {
}
- (void)setPrimaryButtonStyling:(MDCButton*)button {
[button setBackgroundColor:[[MDCPalette cr_bluePalette] tint500]
[button setBackgroundColor:[UIColor colorNamed:kTintColor]
forState:UIControlStateNormal];
[button setImage:nil forState:UIControlStateNormal];
[button setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
[button setUnderlyingColorHint:[UIColor blackColor]];
[button setTitleColor:[UIColor colorNamed:kSolidButtonTextColor]
forState:UIControlStateNormal];
[button setUnderlyingColorHint:UIColor.cr_systemBackgroundColor];
[button setInkColor:[UIColor colorWithWhite:1 alpha:0.2f]];
}
- (void)setSecondaryButtonStyling:(MDCButton*)button {
[button setBackgroundColor:self.backgroundColor
[button setBackgroundColor:UIColor.cr_systemBackgroundColor
forState:UIControlStateNormal];
[button setTitleColor:[[MDCPalette cr_bluePalette] tint500]
[button setTitleColor:[UIColor colorNamed:kTintColor]
forState:UIControlStateNormal];
[button setUnderlyingColorHint:[UIColor whiteColor]];
[button setUnderlyingColorHint:UIColor.cr_systemBackgroundColor];
[button setInkColor:[UIColor colorWithWhite:0 alpha:0.06f]];
}
......@@ -461,6 +462,13 @@ enum AuthenticationState {
setCenter:CGPointMake(CGRectGetMidX(bounds), CGRectGetMidY(bounds))];
}
- (void)updateGradientColors {
_gradientLayer.colors = @[
(id)[UIColor.cr_systemBackgroundColor colorWithAlphaComponent:0].CGColor,
(id)UIColor.cr_systemBackgroundColor.CGColor
];
}
#pragma mark - Accessibility
- (BOOL)accessibilityPerformEscape {
......@@ -479,11 +487,6 @@ enum AuthenticationState {
return _delegate;
}
- (UIColor*)backgroundColor {
return _unifiedConsentEnabled ? [UIColor whiteColor]
: [[MDCPalette greyPalette] tint50];
}
- (NSString*)identityPickerTitle {
return l10n_util::GetNSString(IDS_IOS_ACCOUNT_CONSISTENCY_SETUP_TITLE);
}
......@@ -923,7 +926,7 @@ enum AuthenticationState {
- (void)viewDidLoad {
[super viewDidLoad];
self.view.backgroundColor = self.backgroundColor;
self.view.backgroundColor = UIColor.cr_systemBackgroundColor;
_primaryButton = [[MDCFlatButton alloc] init];
[self setPrimaryButtonStyling:_primaryButton];
......@@ -947,17 +950,14 @@ enum AuthenticationState {
[[MDCActivityIndicator alloc] initWithFrame:CGRectZero];
[_activityIndicator setDelegate:self];
[_activityIndicator setStrokeWidth:3];
[_activityIndicator
setCycleColors:@[ [[MDCPalette cr_bluePalette] tint500] ]];
[_activityIndicator setCycleColors:@[ [UIColor colorNamed:kTintColor] ]];
[self.view addSubview:_activityIndicator];
}
_gradientView = [[UIView alloc] initWithFrame:CGRectZero];
_gradientLayer = [CAGradientLayer layer];
[_gradientView setUserInteractionEnabled:NO];
_gradientLayer.colors = [NSArray
arrayWithObjects:(id)[[UIColor colorWithWhite:1 alpha:0] CGColor],
(id)[self.backgroundColor CGColor], nil];
[self updateGradientColors];
[[_gradientView layer] insertSublayer:_gradientLayer atIndex:0];
[self.view addSubview:_gradientView];
}
......@@ -980,6 +980,23 @@ enum AuthenticationState {
[self updateLayout];
}
- (void)traitCollectionDidChange:(UITraitCollection*)previousTraitCollection {
[super traitCollectionDidChange:previousTraitCollection];
#if defined(__IPHONE_13_0) && (__IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_13_0)
if (@available(iOS 13, *)) {
if ([self.traitCollection
hasDifferentColorAppearanceComparedToTraitCollection:
previousTraitCollection]) {
[self updateGradientColors];
// As of iOS 13 Beta 3, MDCFlatButton doesn't update it's colors
// automatically. These lines do it instead.
[self updatePrimaryButtonForIdentityPickerState];
[self setSecondaryButtonStyling:_secondaryButton];
}
}
#endif
}
#pragma mark - Events
- (void)onPrimaryButtonPressed:(id)sender {
......
......@@ -42,7 +42,6 @@ source_set("unified_consent_ui") {
"//ios/chrome/browser/ui/authentication/unified_consent/identity_chooser:identity_chooser_ui",
"//ios/chrome/browser/ui/colors",
"//ios/chrome/browser/ui/util",
"//ios/chrome/browser/ui/util",
"//ios/chrome/common",
"//ios/chrome/common/colors",
"//ios/chrome/common/ui_util",
......
......@@ -13,6 +13,7 @@
#import "ios/chrome/browser/ui/colors/MDCPalette+CrAdditions.h"
#import "ios/chrome/browser/ui/util/label_link_controller.h"
#import "ios/chrome/browser/ui/util/uikit_ui_util.h"
#import "ios/chrome/common/colors/UIColor+cr_semantic_colors.h"
#include "ios/chrome/common/string_util.h"
#import "ios/chrome/common/ui_util/constraints_ui_util.h"
#include "ios/chrome/grit/ios_chromium_strings.h"
......@@ -168,7 +169,7 @@ const char* const kSettingsSyncURL = "internal://settings-sync";
UILabel* title =
[self addLabelWithStringId:IDS_IOS_ACCOUNT_UNIFIED_CONSENT_TITLE
fontStyle:kAuthenticationTitleFontStyle
textColorAlpha:kAuthenticationTitleColorAlpha
textColor:UIColor.cr_labelColor
parentView:container];
// Identity picker view.
......@@ -184,20 +185,19 @@ const char* const kSettingsSyncURL = "internal://settings-sync";
UILabel* syncTitleLabel =
[self addLabelWithStringId:IDS_IOS_ACCOUNT_UNIFIED_CONSENT_SYNC_TITLE
fontStyle:kAuthenticationTextFontStyle
textColorAlpha:kAuthenticationTitleColorAlpha
textColor:UIColor.cr_labelColor
parentView:container];
UILabel* syncSubtitleLabel =
[self addLabelWithStringId:IDS_IOS_ACCOUNT_UNIFIED_CONSENT_SYNC_SUBTITLE
fontStyle:kAuthenticationTextFontStyle
textColorAlpha:kAuthenticationTextColorAlpha
textColor:UIColor.cr_secondaryLabelColor
parentView:container];
// Separator.
UIView* separator = [[UIView alloc] initWithFrame:CGRectZero];
separator.translatesAutoresizingMaskIntoConstraints = NO;
separator.backgroundColor =
[UIColor colorWithWhite:0 alpha:kAuthenticationSeparatorColorAlpha];
separator.backgroundColor = UIColor.cr_secondarySystemBackgroundColor;
[container addSubview:separator];
// Customize label.
......@@ -205,7 +205,7 @@ const char* const kSettingsSyncURL = "internal://settings-sync";
self.customizeSyncLabel =
[self addLabelWithStringId:self.openSettingsStringId
fontStyle:kAuthenticationTextFontStyle
textColorAlpha:kAuthenticationTextColorAlpha
textColor:UIColor.cr_secondaryLabelColor
parentView:container];
// Layouts
......@@ -356,14 +356,14 @@ const char* const kSettingsSyncURL = "internal://settings-sync";
// Adds label with title |stringId| into |parentView|.
- (UILabel*)addLabelWithStringId:(int)stringId
fontStyle:(UIFontTextStyle)fontStyle
textColorAlpha:(CGFloat)textColorAlpha
textColor:(UIColor*)textColor
parentView:(UIView*)parentView {
DCHECK(stringId);
DCHECK(parentView);
UILabel* label = [[UILabel alloc] initWithFrame:CGRectZero];
label.translatesAutoresizingMaskIntoConstraints = NO;
label.font = [UIFont preferredFontForTextStyle:fontStyle];
label.textColor = [UIColor colorWithWhite:0 alpha:textColorAlpha];
label.textColor = textColor;
label.text = l10n_util::GetNSString(stringId);
_consentStringIds.push_back(stringId);
label.numberOfLines = 0;
......
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