Skip to content
Snippets Groups Projects
Commit 54858910 authored by Claudio Cambra's avatar Claudio Cambra Committed by Steve Lhomme
Browse files

macosx: Use effectiveAppearance received from KVO in...

macosx: Use effectiveAppearance received from KVO in VLCMediaSourceCollectionViewItem, fixing bad label text colour update

Signed-off-by: default avatarClaudio Cambra <developer@claudiocambra.com>
parent 442e98e4
No related branches found
No related tags found
1 merge request!3190macosx: Fix views dependent on NSView extension shouldShowDarkAppearance not updating colours correctly
......@@ -81,11 +81,11 @@ NSString *VLCMediaSourceCellIdentifier = @"VLCLibraryCellIdentifier";
if (@available(macOS 10.14, *)) {
[[NSApplication sharedApplication] addObserver:self
forKeyPath:@"effectiveAppearance"
options:0
options:NSKeyValueObservingOptionNew
context:nil];
}
[self updateColoredAppearance];
[self updateColoredAppearance:self.view.effectiveAppearance];
[self updateFontBasedOnSetting:nil];
[self prepareForReuse];
}
......@@ -97,12 +97,21 @@ NSString *VLCMediaSourceCellIdentifier = @"VLCLibraryCellIdentifier";
change:(NSDictionary<NSKeyValueChangeKey,id> *)change
context:(void *)context
{
[self updateColoredAppearance];
if ([keyPath isEqualToString:@"effectiveAppearance"]) {
NSAppearance *effectiveAppearance = change[NSKeyValueChangeNewKey];
[self updateColoredAppearance:effectiveAppearance];
}
}
- (void)updateColoredAppearance
- (void)updateColoredAppearance:(NSAppearance*)appearance
{
self.mediaTitleTextField.textColor = self.view.shouldShowDarkAppearance ? [NSColor VLClibraryDarkTitleColor] : [NSColor VLClibraryLightTitleColor];
NSParameterAssert(appearance);
BOOL isDark = NO;
if (@available(macOS 10.14, *)) {
isDark = [appearance.name isEqualToString:NSAppearanceNameDarkAqua] || [appearance.name isEqualToString:NSAppearanceNameVibrantDark];
}
self.mediaTitleTextField.textColor = isDark ? [NSColor VLClibraryDarkTitleColor] : [NSColor VLClibraryLightTitleColor];
}
- (void)updateFontBasedOnSetting:(NSNotification *)aNotification
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment