Commit 5b12c493 authored by Robbie Gibson's avatar Robbie Gibson Committed by Commit Bot

[iOS] Fix dark mode visual bug on signin screen

The root cause is that, because CALayer uses CGColors, which don't
support the whole dynamic color infrastructure, we have to manually
set these colors to the correct version in -traitCollectionDidChange.
However, CALayer automatically animates any change to these properties.

This means that when the color mode changes, the rest of the colors
update immediately, but the layer's colors animate to the correct color
over the next ~0.5 seconds.

To fix this, we can use CATransaction and setDisableActions to disable
the automatic animation.

Fixed: 1028091
Change-Id: Id217c5387bffc77a5a971aac0e43198a1ffa8200
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1940328Reviewed-by: default avatarJérôme Lebel <jlebel@chromium.org>
Commit-Queue: Robbie Gibson <rkgibson@google.com>
Cr-Commit-Position: refs/heads/master@{#719585}
parent e4c89540
...@@ -452,6 +452,11 @@ enum AuthenticationState { ...@@ -452,6 +452,11 @@ enum AuthenticationState {
} }
- (void)updateGradientColors { - (void)updateGradientColors {
[CATransaction begin];
// If this isn't set, the changes here are automatically animated. The other
// color changes for dark mode don't animate, however, so there ends up being
// visual desyncing.
[CATransaction setDisableActions:YES];
UIColor* backgroundColor = self.backgroundColor; UIColor* backgroundColor = self.backgroundColor;
if (@available(iOS 13, *)) { if (@available(iOS 13, *)) {
...@@ -463,6 +468,7 @@ enum AuthenticationState { ...@@ -463,6 +468,7 @@ enum AuthenticationState {
(id)[backgroundColor colorWithAlphaComponent:0].CGColor, (id)[backgroundColor colorWithAlphaComponent:0].CGColor,
(id)backgroundColor.CGColor (id)backgroundColor.CGColor
]; ];
[CATransaction commit];
} }
#pragma mark - UIAdaptivePresentationController #pragma mark - UIAdaptivePresentationController
......
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