Commit 6d2a3250 authored by Javier Ernesto Flores Robles's avatar Javier Ernesto Flores Robles Committed by Commit Bot

[iOS][DarkMode] Support dark mode in collection view controller cells

Updates the background of the cells from a default white color to a
dynamic color.

Bug: 976675, 991209
Change-Id: I5df54407fc53ade588de5a6d28f537fe140e3bab
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1745479
Commit-Queue: Javier Ernesto Flores Robles <javierrobles@chromium.org>
Reviewed-by: default avatarRohit Rao <rohitrao@chromium.org>
Cr-Commit-Position: refs/heads/master@{#686371}
parent 66dbfadc
......@@ -65,6 +65,8 @@
// Suport dark mode.
self.collectionView.backgroundColor = UIColor.cr_systemGroupedBackgroundColor;
self.styler.cellBackgroundColor =
UIColor.cr_secondarySystemGroupedBackgroundColor;
}
- (void)contentSizeCategoryDidChange:(id)sender {
......@@ -99,6 +101,25 @@
}
}
- (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]) {
// MDCCollectionView doesn't support dynamic colors, so they have to be
// resolved now.
// TODO(crbug.com/984928): Clean up once dynamic color support is added.
self.styler.cellBackgroundColor =
[UIColor.cr_secondarySystemGroupedBackgroundColor
resolvedColorWithTraitCollection:self.traitCollection];
[self.collectionViewLayout invalidateLayout];
}
}
#endif
}
#pragma mark MDCCollectionViewEditingDelegate
- (void)collectionView:(UICollectionView*)collectionView
......
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