Commit 74cca096 authored by Robbie Gibson's avatar Robbie Gibson Committed by Commit Bot

[iOS][Dark mode] Fix improper ordering of iOS 13 compile guards

Before, when compiling with iOS 12, but running with iOS 13, nothing
ended up running in these cases. Now, in this case, we fall back to the
iOS 12 logic.

Bug: 976681, 976666
Change-Id: If659155521ff2d8a13320aa2174e78e35476593a
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1712875
Commit-Queue: Robbie Gibson <rkgibson@google.com>
Reviewed-by: default avatarJavier Ernesto Flores Robles <javierrobles@chromium.org>
Reviewed-by: default avatarRohit Rao <rohitrao@chromium.org>
Cr-Commit-Position: refs/heads/master@{#679991}
parent d92cf59a
...@@ -281,15 +281,16 @@ constexpr NSUInteger kUIViewAnimationCurveToOptionsShift = 16; ...@@ -281,15 +281,16 @@ constexpr NSUInteger kUIViewAnimationCurveToOptionsShift = 16;
// fields. // fields.
UIView* stackHolder = [[UIView alloc] init]; UIView* stackHolder = [[UIView alloc] init];
stackHolder.layer.cornerRadius = kTextFieldCornerRadius; stackHolder.layer.cornerRadius = kTextFieldCornerRadius;
if (@available(iOS 13, *)) { stackHolder.layer.borderColor = UIColor.cr_separatorColor.CGColor;
#if defined(__IPHONE_13_0) && (__IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_13_0) #if defined(__IPHONE_13_0) && (__IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_13_0)
if (@available(iOS 13, *)) {
// Use performAsCurrentTraitCollection to get the correct CGColor for the
// given dynamic color and current userInterfaceStyle.
[self.traitCollection performAsCurrentTraitCollection:^{ [self.traitCollection performAsCurrentTraitCollection:^{
stackHolder.layer.borderColor = UIColor.cr_separatorColor.CGColor; stackHolder.layer.borderColor = UIColor.cr_separatorColor.CGColor;
}]; }];
#endif
} else {
stackHolder.layer.borderColor = UIColor.cr_separatorColor.CGColor;
} }
#endif
stackHolder.layer.borderWidth = 1.0 / [UIScreen mainScreen].scale; stackHolder.layer.borderWidth = 1.0 / [UIScreen mainScreen].scale;
stackHolder.clipsToBounds = YES; stackHolder.clipsToBounds = YES;
stackHolder.backgroundColor = UIColor.cr_secondarySystemBackgroundColor; stackHolder.backgroundColor = UIColor.cr_secondarySystemBackgroundColor;
......
...@@ -657,27 +657,8 @@ NSUInteger GetPageIndexFromPage(TabGridPage page) { ...@@ -657,27 +657,8 @@ NSUInteger GetPageIndexFromPage(TabGridPage page) {
styler.tableViewBackgroundColor = UIColorFromRGB(kGridBackgroundColor); styler.tableViewBackgroundColor = UIColorFromRGB(kGridBackgroundColor);
styler.cellHighlightColor = styler.cellHighlightColor =
[UIColor colorWithWhite:0 alpha:kGridDarkThemeCellHighlightColorAlpha]; [UIColor colorWithWhite:0 alpha:kGridDarkThemeCellHighlightColorAlpha];
// For iOS 13, setting the overrideUserInterfaceStyle to dark forces the use // To make using the compile guards easier, use a separate method.
// of dark mode colors for all the colors in this view. However, this [self setupRemoteTabsViewControllerForDarkModeWithStyler:styler];
// override is not available on pre-iOS 13 devices, so the dark mode colors
// must be provided manually.
if (@available(iOS 13, *)) {
#if defined(__IPHONE_13_0) && (__IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_13_0)
self.remoteTabsViewController.overrideUserInterfaceStyle =
UIUserInterfaceStyleDark;
#endif
} else {
styler.cellTitleColor = UIColorFromRGB(kGridDarkThemeCellTitleColor);
styler.headerFooterTitleColor =
UIColorFromRGB(kGridDarkThemeCellTitleColor);
styler.cellDetailColor = UIColorFromRGB(kGridDarkThemeCellDetailColor,
kGridDarkThemeCellDetailAlpha);
styler.headerFooterDetailColor = UIColorFromRGB(
kGridDarkThemeCellDetailColor, kGridDarkThemeCellDetailAlpha);
styler.tintColor = UIColorFromRGB(kGridDarkThemeCellTintColor);
styler.solidButtonTextColor =
UIColorFromRGB(kGridDarkThemeCellSolidButtonTextColor);
}
self.remoteTabsViewController.styler = styler; self.remoteTabsViewController.styler = styler;
UIView* contentView = self.scrollContentView; UIView* contentView = self.scrollContentView;
...@@ -702,6 +683,32 @@ NSUInteger GetPageIndexFromPage(TabGridPage page) { ...@@ -702,6 +683,32 @@ NSUInteger GetPageIndexFromPage(TabGridPage page) {
[NSLayoutConstraint activateConstraints:constraints]; [NSLayoutConstraint activateConstraints:constraints];
} }
// The iOS 13 compile guards are much easier to use in a separate function that
// can be returned from.
- (void)setupRemoteTabsViewControllerForDarkModeWithStyler:
(ChromeTableViewStyler*)styler {
// For iOS 13, setting the overrideUserInterfaceStyle to dark forces the use
// of dark mode colors for all the colors in this view. However, this
// override is not available on pre-iOS 13 devices, so the dark mode colors
// must be provided manually.
#if defined(__IPHONE_13_0) && (__IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_13_0)
if (@available(iOS 13, *)) {
self.remoteTabsViewController.overrideUserInterfaceStyle =
UIUserInterfaceStyleDark;
return;
}
#endif
styler.cellTitleColor = UIColorFromRGB(kGridDarkThemeCellTitleColor);
styler.headerFooterTitleColor = UIColorFromRGB(kGridDarkThemeCellTitleColor);
styler.cellDetailColor = UIColorFromRGB(kGridDarkThemeCellDetailColor,
kGridDarkThemeCellDetailAlpha);
styler.headerFooterDetailColor = UIColorFromRGB(
kGridDarkThemeCellDetailColor, kGridDarkThemeCellDetailAlpha);
styler.tintColor = UIColorFromRGB(kGridDarkThemeCellTintColor);
styler.solidButtonTextColor =
UIColorFromRGB(kGridDarkThemeCellSolidButtonTextColor);
}
// Adds the top toolbar and sets constraints. // Adds the top toolbar and sets constraints.
- (void)setupTopToolbar { - (void)setupTopToolbar {
TabGridTopToolbar* topToolbar = [[TabGridTopToolbar alloc] init]; TabGridTopToolbar* topToolbar = [[TabGridTopToolbar alloc] init];
......
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