From b6f30134a42cb4feab1ac2e01acefcafa1c35a1c Mon Sep 17 00:00:00 2001 From: Tim Gymnich Date: Mon, 11 Jan 2021 02:36:03 +0100 Subject: [PATCH] fix calendar colors --- .../Calendar/CalendarEventViewModel.swift | 21 +++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/TUM Campus App/Calendar/CalendarEventViewModel.swift b/TUM Campus App/Calendar/CalendarEventViewModel.swift index 54dc7c2d..9389e20b 100644 --- a/TUM Campus App/Calendar/CalendarEventViewModel.swift +++ b/TUM Campus App/Calendar/CalendarEventViewModel.swift @@ -21,7 +21,20 @@ final class CalendarEventViewModel: EventDescriptor { } } var backgroundColor = UIColor.systemBlue.withAlphaComponent(0.2) - var textColor = UIColor.label + var textColor = UIColor { traitCollection in + switch traitCollection.userInterfaceStyle { + case .dark: return UIColor(red: 28/255, green: 171/255, blue: 246/255, alpha: 1) + default: return UIColor(red: 34/255, green: 126/255, blue: 177/255, alpha: 1) + } + + } + var secondaryTextColor = UIColor { traitCollection in + switch traitCollection.userInterfaceStyle { + case .dark: return UIColor(red: 28/255, green: 171/255, blue: 246/255, alpha: 1) + default: return UIColor(red: 34/255, green: 126/255, blue: 177/255, alpha: 1) + } + + } var font = UIFont.boldSystemFont(ofSize: 12) var userInfo: Any? var lineBreakMode: NSLineBreakMode? = .byWordWrapping @@ -44,14 +57,14 @@ final class CalendarEventViewModel: EventDescriptor { self.startDate = startDate self.endDate = endDate self.text = title - let attributedTitle = NSMutableAttributedString(string: title).font(.systemFont(ofSize: 12, weight: .semibold)).color(.label) + let attributedTitle = NSMutableAttributedString(string: title).font(.systemFont(ofSize: 12, weight: .bold)).color(textColor) if let location = event.location { - let attributedLocation = NSMutableAttributedString(string: location).font(.systemFont(ofSize: 12, weight: .light)).color(.label) + let attributedLocation = NSMutableAttributedString(string: location).font(.systemFont(ofSize: 12, weight: .regular)).color(textColor) attributedTitle.append(NSAttributedString(string: "\n")) attributedTitle.append(attributedLocation) } if let description = event.descriptionText { - let attributedLocation = NSMutableAttributedString(string: description).font(.systemFont(ofSize: 12, weight: .light)).color(.secondaryLabel) + let attributedLocation = NSMutableAttributedString(string: description).font(.systemFont(ofSize: 12, weight: .regular)).color(secondaryTextColor) attributedTitle.append(NSAttributedString(string: "\n\n")) attributedTitle.append(attributedLocation) }