Commit 8b680a65 authored by Robbie Gibson's avatar Robbie Gibson Committed by Commit Bot

[iOS][Dark Mode] Fix splash screen not supporting dark mode, first-run

For the launch screen, I think there may be an Apple bug with xibs and
system colors. In my custom project, when the deployment target was 13,
the launch screen supported dark mode fine, but when I switched to 12,
it didn't any more.

To fix this, I instead used our named color "background_color" in the
xib. This sidesteps the issue because named colors are supported on
both iOS 12 and 13 and it's actually a better experience than having
the background be solid black. This color doesn't show up in Interface
Builder in Xcode because the color isn't defined in an xcassets
collection, but it does work.

The other changes are changing the first-run experience to also use
this background color instead of systemBackgroundColor/black. The
ChromeSigninViewController remains black by default because it is also
presented from settings, which uses the standard Apple color palette.

Bug: 997170
Change-Id: Icd71fa2aedf1f3828fa2cefb5382deacc964cae3
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1795905
Commit-Queue: Robbie Gibson <rkgibson@google.com>
Reviewed-by: default avatarMark Cogan <marq@chromium.org>
Reviewed-by: default avatarJérôme Lebel <jlebel@chromium.org>
Cr-Commit-Position: refs/heads/master@{#695597}
parent 5e556dd8
...@@ -118,6 +118,7 @@ group("launchscreen_assets") { ...@@ -118,6 +118,7 @@ group("launchscreen_assets") {
public_deps = [ public_deps = [
":launchscreen_app_logo", ":launchscreen_app_logo",
":launchscreen_brand_name", ":launchscreen_brand_name",
"//ios/chrome/common/colors/resources:background_color",
] ]
} }
......
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="14845" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" launchScreen="YES" useTraitCollections="YES" colorMatched="YES"> <document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="14865.1" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" launchScreen="YES" useTraitCollections="YES" colorMatched="YES">
<device id="retina6_1" orientation="portrait" appearance="light"/> <device id="retina6_1" orientation="portrait" appearance="light"/>
<dependencies> <dependencies>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="14799.2"/> <plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="14819.2"/>
<capability name="Named colors" minToolsVersion="9.0"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/> <capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies> </dependencies>
<objects> <objects>
...@@ -26,14 +27,14 @@ ...@@ -26,14 +27,14 @@
</constraints> </constraints>
</imageView> </imageView>
<imageView userInteractionEnabled="NO" contentMode="scaleToFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="launchscreen_brand_name" translatesAutoresizingMaskIntoConstraints="NO" id="bAU-qs-X5w"> <imageView userInteractionEnabled="NO" contentMode="scaleToFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="launchscreen_brand_name" translatesAutoresizingMaskIntoConstraints="NO" id="bAU-qs-X5w">
<rect key="frame" x="153.5" y="807" width="107.00000000000003" height="35"/> <rect key="frame" x="153.5" y="807" width="107" height="35"/>
<constraints> <constraints>
<constraint firstAttribute="width" constant="107" id="0Mf-i7-mvo"/> <constraint firstAttribute="width" constant="107" id="0Mf-i7-mvo"/>
<constraint firstAttribute="height" constant="35" id="7Gs-G7-OR2"/> <constraint firstAttribute="height" constant="35" id="7Gs-G7-OR2"/>
</constraints> </constraints>
</imageView> </imageView>
</subviews> </subviews>
<color key="backgroundColor" xcode11CocoaTouchSystemColor="systemBackgroundColor" cocoaTouchSystemColor="whiteColor"/> <color key="backgroundColor" name="background_color"/>
<constraints> <constraints>
<constraint firstItem="K7H-Iv-QNk" firstAttribute="width" secondItem="tRS-Cx-RH3" secondAttribute="width" multiplier="0.381966" id="3hJ-Yo-1Tg"/> <constraint firstItem="K7H-Iv-QNk" firstAttribute="width" secondItem="tRS-Cx-RH3" secondAttribute="width" multiplier="0.381966" id="3hJ-Yo-1Tg"/>
<constraint firstItem="K7H-Iv-QNk" firstAttribute="height" secondItem="tRS-Cx-RH3" secondAttribute="height" multiplier="0.381966" id="962-tL-cOd"/> <constraint firstItem="K7H-Iv-QNk" firstAttribute="height" secondItem="tRS-Cx-RH3" secondAttribute="height" multiplier="0.381966" id="962-tL-cOd"/>
...@@ -67,5 +68,8 @@ ...@@ -67,5 +68,8 @@
<resources> <resources>
<image name="launchscreen_app_logo" width="192" height="192"/> <image name="launchscreen_app_logo" width="192" height="192"/>
<image name="launchscreen_brand_name" width="107" height="35"/> <image name="launchscreen_brand_name" width="107" height="35"/>
<namedColor name="background_color">
<color red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
</namedColor>
</resources> </resources>
</document> </document>
...@@ -113,6 +113,7 @@ using TimerGeneratorBlock = std::unique_ptr<base::OneShotTimer> (^)(); ...@@ -113,6 +113,7 @@ using TimerGeneratorBlock = std::unique_ptr<base::OneShotTimer> (^)();
// Secondary button title used to skip the sign-in. // Secondary button title used to skip the sign-in.
@property(nonatomic, readonly) NSString* skipSigninButtonTitle; @property(nonatomic, readonly) NSString* skipSigninButtonTitle;
@property(nonatomic, readonly) UIColor* backgroundColor;
@property(nonatomic, readonly) UIButton* primaryButton; @property(nonatomic, readonly) UIButton* primaryButton;
@property(nonatomic, readonly) UIButton* secondaryButton; @property(nonatomic, readonly) UIButton* secondaryButton;
......
...@@ -308,7 +308,7 @@ enum AuthenticationState { ...@@ -308,7 +308,7 @@ enum AuthenticationState {
} }
- (void)setPrimaryButtonStyling:(MDCButton*)button { - (void)setPrimaryButtonStyling:(MDCButton*)button {
UIColor* hintColor = UIColor.cr_systemBackgroundColor; UIColor* hintColor = self.backgroundColor;
UIColor* backgroundColor = [UIColor colorNamed:kBlueColor]; UIColor* backgroundColor = [UIColor colorNamed:kBlueColor];
UIColor* titleColor = [UIColor colorNamed:kSolidButtonTextColor]; UIColor* titleColor = [UIColor colorNamed:kSolidButtonTextColor];
...@@ -331,8 +331,8 @@ enum AuthenticationState { ...@@ -331,8 +331,8 @@ enum AuthenticationState {
} }
- (void)setSecondaryButtonStyling:(MDCButton*)button { - (void)setSecondaryButtonStyling:(MDCButton*)button {
UIColor* hintColor = UIColor.cr_systemBackgroundColor; UIColor* hintColor = self.backgroundColor;
UIColor* backgroundColor = UIColor.cr_systemBackgroundColor; UIColor* backgroundColor = self.backgroundColor;
UIColor* titleColor = [UIColor colorNamed:kBlueColor]; UIColor* titleColor = [UIColor colorNamed:kBlueColor];
if (@available(iOS 13, *)) { if (@available(iOS 13, *)) {
...@@ -451,7 +451,7 @@ enum AuthenticationState { ...@@ -451,7 +451,7 @@ enum AuthenticationState {
} }
- (void)updateGradientColors { - (void)updateGradientColors {
UIColor* backgroundColor = UIColor.cr_systemBackgroundColor; UIColor* backgroundColor = self.backgroundColor;
if (@available(iOS 13, *)) { if (@available(iOS 13, *)) {
backgroundColor = backgroundColor =
...@@ -505,6 +505,10 @@ enum AuthenticationState { ...@@ -505,6 +505,10 @@ enum AuthenticationState {
return l10n_util::GetNSString(IDS_IOS_ACCOUNT_CONSISTENCY_SETUP_SKIP_BUTTON); return l10n_util::GetNSString(IDS_IOS_ACCOUNT_CONSISTENCY_SETUP_SKIP_BUTTON);
} }
- (UIColor*)backgroundColor {
return UIColor.cr_systemBackgroundColor;
}
- (UIButton*)primaryButton { - (UIButton*)primaryButton {
return _primaryButton; return _primaryButton;
} }
...@@ -815,7 +819,7 @@ enum AuthenticationState { ...@@ -815,7 +819,7 @@ enum AuthenticationState {
- (void)viewDidLoad { - (void)viewDidLoad {
[super viewDidLoad]; [super viewDidLoad];
self.view.backgroundColor = UIColor.cr_systemBackgroundColor; self.view.backgroundColor = self.backgroundColor;
_primaryButton = [[MDCFlatButton alloc] init]; _primaryButton = [[MDCFlatButton alloc] init];
[self setPrimaryButtonStyling:_primaryButton]; [self setPrimaryButtonStyling:_primaryButton];
......
...@@ -16,6 +16,7 @@ ...@@ -16,6 +16,7 @@
#import "ios/chrome/browser/ui/promos/signin_promo_view_controller.h" #import "ios/chrome/browser/ui/promos/signin_promo_view_controller.h"
#include "ios/chrome/browser/ui/util/ui_util.h" #include "ios/chrome/browser/ui/util/ui_util.h"
#import "ios/chrome/browser/web_state_list/web_state_list.h" #import "ios/chrome/browser/web_state_list/web_state_list.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/public/provider/chrome/browser/chrome_browser_provider.h" #import "ios/public/provider/chrome/browser/chrome_browser_provider.h"
#import "ios/public/provider/chrome/browser/signin/chrome_identity.h" #import "ios/public/provider/chrome/browser/signin/chrome_identity.h"
...@@ -120,6 +121,12 @@ NSString* const kSignInSkipButtonAccessibilityIdentifier = ...@@ -120,6 +121,12 @@ NSString* const kSignInSkipButtonAccessibilityIdentifier =
}]; }];
} }
#pragma mark Superclass overrides
- (UIColor*)backgroundColor {
return [UIColor colorNamed:kBackgroundColor];
}
#pragma mark ChromeSigninViewControllerDelegate #pragma mark ChromeSigninViewControllerDelegate
- (void)willStartSignIn:(ChromeSigninViewController*)controller { - (void)willStartSignIn:(ChromeSigninViewController*)controller {
......
...@@ -14,7 +14,6 @@ ...@@ -14,7 +14,6 @@
#import "ios/chrome/browser/ui/util/label_observer.h" #import "ios/chrome/browser/ui/util/label_observer.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"
#include "ios/chrome/common/string_util.h" #include "ios/chrome/common/string_util.h"
#include "ios/chrome/grit/ios_chromium_strings.h" #include "ios/chrome/grit/ios_chromium_strings.h"
...@@ -165,7 +164,7 @@ const char kPrivacyNoticeUrl[] = "internal://privacy-notice"; ...@@ -165,7 +164,7 @@ const char kPrivacyNoticeUrl[] = "internal://privacy-notice";
- (instancetype)initWithFrame:(CGRect)frame { - (instancetype)initWithFrame:(CGRect)frame {
self = [super initWithFrame:frame]; self = [super initWithFrame:frame];
if (self) { if (self) {
self.backgroundColor = UIColor.cr_systemBackgroundColor; self.backgroundColor = [UIColor colorNamed:kBackgroundColor];
self.autoresizingMask = self.autoresizingMask =
UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight; UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
} }
...@@ -224,7 +223,6 @@ const char kPrivacyNoticeUrl[] = "internal://privacy-notice"; ...@@ -224,7 +223,6 @@ const char kPrivacyNoticeUrl[] = "internal://privacy-notice";
- (UIView*)containerView { - (UIView*)containerView {
if (!_containerView) { if (!_containerView) {
_containerView = [[UIView alloc] initWithFrame:CGRectZero]; _containerView = [[UIView alloc] initWithFrame:CGRectZero];
[_containerView setBackgroundColor:UIColor.cr_systemBackgroundColor];
} }
return _containerView; return _containerView;
} }
...@@ -232,7 +230,6 @@ const char kPrivacyNoticeUrl[] = "internal://privacy-notice"; ...@@ -232,7 +230,6 @@ const char kPrivacyNoticeUrl[] = "internal://privacy-notice";
- (UILabel*)titleLabel { - (UILabel*)titleLabel {
if (!_titleLabel) { if (!_titleLabel) {
_titleLabel = [[UILabel alloc] initWithFrame:CGRectZero]; _titleLabel = [[UILabel alloc] initWithFrame:CGRectZero];
[_titleLabel setBackgroundColor:UIColor.cr_systemBackgroundColor];
[_titleLabel setNumberOfLines:0]; [_titleLabel setNumberOfLines:0];
[_titleLabel setLineBreakMode:NSLineBreakByWordWrapping]; [_titleLabel setLineBreakMode:NSLineBreakByWordWrapping];
[_titleLabel setBaselineAdjustment:UIBaselineAdjustmentAlignBaselines]; [_titleLabel setBaselineAdjustment:UIBaselineAdjustmentAlignBaselines];
...@@ -246,7 +243,6 @@ const char kPrivacyNoticeUrl[] = "internal://privacy-notice"; ...@@ -246,7 +243,6 @@ const char kPrivacyNoticeUrl[] = "internal://privacy-notice";
if (!_imageView) { if (!_imageView) {
UIImage* image = [UIImage imageNamed:kAppLogoImageName]; UIImage* image = [UIImage imageNamed:kAppLogoImageName];
_imageView = [[UIImageView alloc] initWithImage:image]; _imageView = [[UIImageView alloc] initWithImage:image];
[_imageView setBackgroundColor:UIColor.cr_systemBackgroundColor];
} }
return _imageView; return _imageView;
} }
......
...@@ -18,6 +18,7 @@ source_set("promos") { ...@@ -18,6 +18,7 @@ source_set("promos") {
"//ios/chrome/browser/browser_state", "//ios/chrome/browser/browser_state",
"//ios/chrome/browser/signin", "//ios/chrome/browser/signin",
"//ios/chrome/browser/ui/commands", "//ios/chrome/browser/ui/commands",
"//ios/chrome/common/colors",
"//ios/public/provider/chrome/browser", "//ios/public/provider/chrome/browser",
"//ios/public/provider/chrome/browser/signin", "//ios/public/provider/chrome/browser/signin",
"//net", "//net",
......
...@@ -15,6 +15,7 @@ ...@@ -15,6 +15,7 @@
#include "ios/chrome/browser/signin/authentication_service.h" #include "ios/chrome/browser/signin/authentication_service.h"
#include "ios/chrome/browser/signin/authentication_service_factory.h" #include "ios/chrome/browser/signin/authentication_service_factory.h"
#import "ios/chrome/browser/ui/commands/application_commands.h" #import "ios/chrome/browser/ui/commands/application_commands.h"
#import "ios/chrome/common/colors/semantic_color_names.h"
#include "ios/public/provider/chrome/browser/chrome_browser_provider.h" #include "ios/public/provider/chrome/browser/chrome_browser_provider.h"
#import "ios/public/provider/chrome/browser/signin/chrome_identity.h" #import "ios/public/provider/chrome/browser/signin/chrome_identity.h"
#import "ios/public/provider/chrome/browser/signin/chrome_identity_service.h" #import "ios/public/provider/chrome/browser/signin/chrome_identity_service.h"
...@@ -167,6 +168,12 @@ NSSet* GaiaIdSetWithIdentities(NSArray* identities) { ...@@ -167,6 +168,12 @@ NSSet* GaiaIdSetWithIdentities(NSArray* identities) {
return currentVersion; return currentVersion;
} }
#pragma mark Superclass overrides
- (UIColor*)backgroundColor {
return [UIColor colorNamed:kBackgroundColor];
}
#pragma mark - PromoViewController #pragma mark - PromoViewController
+ (BOOL)shouldBePresentedForBrowserState: + (BOOL)shouldBePresentedForBrowserState:
......
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