diff --git a/Signal/src/ViewControllers/ContactViewController.swift b/Signal/src/ViewControllers/ContactViewController.swift index 987842473..9c4ca4231 100644 --- a/Signal/src/ViewControllers/ContactViewController.swift +++ b/Signal/src/ViewControllers/ContactViewController.swift @@ -197,7 +197,7 @@ class ContactViewController: OWSViewController, ContactShareViewHelperDelegate { } private func heroBackgroundColor() -> UIColor { - return (Theme.isDarkThemeEnabled() + return (Theme.isDarkThemeEnabled ? UIColor(rgbHex: 0x272727) : UIColor(rgbHex: 0xefeff4)) } diff --git a/Signal/src/ViewControllers/ExperienceUpgradesPageViewController.swift b/Signal/src/ViewControllers/ExperienceUpgradesPageViewController.swift index d7df42e52..1f9610b75 100644 --- a/Signal/src/ViewControllers/ExperienceUpgradesPageViewController.swift +++ b/Signal/src/ViewControllers/ExperienceUpgradesPageViewController.swift @@ -30,7 +30,7 @@ private class IntroducingCustomNotificationAudioExperienceUpgradeViewController: view.addSubview(bodyLabel) bodyLabel.text = body bodyLabel.font = UIFont.ows_lightFont(withSize: ScaleFromIPhone5To7Plus(17, 22)) - bodyLabel.textColor = UIColor.black + bodyLabel.textColor = Theme.primaryColor bodyLabel.numberOfLines = 0 bodyLabel.lineBreakMode = .byWordWrapping bodyLabel.textAlignment = .center @@ -140,7 +140,7 @@ private class IntroductingReadReceiptsExperienceUpgradeViewController: Experienc view.addSubview(bodyLabel) bodyLabel.text = body bodyLabel.font = UIFont.ows_lightFont(withSize: ScaleFromIPhone5To7Plus(17, 22)) - bodyLabel.textColor = UIColor.black + bodyLabel.textColor = Theme.primaryColor bodyLabel.numberOfLines = 0 bodyLabel.lineBreakMode = .byWordWrapping bodyLabel.textAlignment = .center @@ -292,7 +292,7 @@ private class IntroductingProfilesExperienceUpgradeViewController: ExperienceUpg view.addSubview(bodyLabel) bodyLabel.text = body bodyLabel.font = UIFont.ows_lightFont(withSize: ScaleFromIPhone5To7Plus(17, 22)) - bodyLabel.textColor = UIColor.black + bodyLabel.textColor = Theme.primaryColor bodyLabel.numberOfLines = 0 bodyLabel.lineBreakMode = .byWordWrapping bodyLabel.textAlignment = .center @@ -443,7 +443,7 @@ private class ExperienceUpgradeViewController: OWSViewController { view.addSubview(bodyLabel) bodyLabel.text = body bodyLabel.font = UIFont.ows_lightFont(withSize: ScaleFromIPhone5To7Plus(17, 22)) - bodyLabel.textColor = UIColor.black + bodyLabel.textColor = Theme.primaryColor bodyLabel.numberOfLines = 0 bodyLabel.lineBreakMode = .byWordWrapping bodyLabel.textAlignment = .center @@ -529,7 +529,7 @@ public class ExperienceUpgradesPageViewController: OWSViewController, UIPageView @objc public override func loadView() { self.view = UIView.container() - view.backgroundColor = UIColor.white + view.backgroundColor = Theme.backgroundColor //// Create Views diff --git a/Signal/src/ViewControllers/GifPicker/GifPickerCell.swift b/Signal/src/ViewControllers/GifPicker/GifPickerCell.swift index 6f2e44ae3..89285fe98 100644 --- a/Signal/src/ViewControllers/GifPicker/GifPickerCell.swift +++ b/Signal/src/ViewControllers/GifPicker/GifPickerCell.swift @@ -267,7 +267,9 @@ class GifPickerCell: UICollectionViewCell { private func clearViewState() { imageView?.image = nil - self.backgroundColor = UIColor(white: 0.95, alpha: 1.0) + self.backgroundColor = (Theme.isDarkThemeEnabled + ? UIColor(white: 0.25, alpha: 1.0) + : UIColor(white: 0.95, alpha: 1.0)) } private func pickBestAsset() -> GiphyAsset? { diff --git a/Signal/src/ViewControllers/GifPicker/GifPickerViewController.swift b/Signal/src/ViewControllers/GifPicker/GifPickerViewController.swift index 2b9218456..66e8a91b8 100644 --- a/Signal/src/ViewControllers/GifPicker/GifPickerViewController.swift +++ b/Signal/src/ViewControllers/GifPicker/GifPickerViewController.swift @@ -150,7 +150,7 @@ class GifPickerViewController: OWSViewController, UISearchBarDelegate, UICollect private func createViews() { - let backgroundColor = (Theme.isDarkThemeEnabled() + let backgroundColor = (Theme.isDarkThemeEnabled ? UIColor(white: 0.08, alpha: 1.0) : Theme.backgroundColor) self.view.backgroundColor = backgroundColor diff --git a/Signal/src/ViewControllers/LongTextViewController.swift b/Signal/src/ViewControllers/LongTextViewController.swift index 11104e4b8..5c15bb2d9 100644 --- a/Signal/src/ViewControllers/LongTextViewController.swift +++ b/Signal/src/ViewControllers/LongTextViewController.swift @@ -58,12 +58,12 @@ public class LongTextViewController: OWSViewController { // MARK: - Create Views private func createViews() { - view.backgroundColor = UIColor.white + view.backgroundColor = Theme.backgroundColor let messageTextView = UITextView() self.messageTextView = messageTextView messageTextView.font = UIFont.ows_dynamicTypeBody - messageTextView.backgroundColor = UIColor.white + messageTextView.backgroundColor = Theme.backgroundColor messageTextView.isOpaque = true messageTextView.isEditable = false messageTextView.isSelectable = true @@ -71,7 +71,7 @@ public class LongTextViewController: OWSViewController { messageTextView.showsHorizontalScrollIndicator = false messageTextView.showsVerticalScrollIndicator = true messageTextView.isUserInteractionEnabled = true - messageTextView.textColor = UIColor.black + messageTextView.textColor = Theme.primaryColor messageTextView.text = messageBody view.addSubview(messageTextView) diff --git a/Signal/src/ViewControllers/MediaGalleryViewController.swift b/Signal/src/ViewControllers/MediaGalleryViewController.swift index 6da116e85..523bdc526 100644 --- a/Signal/src/ViewControllers/MediaGalleryViewController.swift +++ b/Signal/src/ViewControllers/MediaGalleryViewController.swift @@ -139,7 +139,7 @@ public struct GalleryDate: Hashable, Comparable, Equatable { return month.hashValue ^ year.hashValue } - // Mark: Comparable + // MARK: Comparable public static func < (lhs: GalleryDate, rhs: GalleryDate) -> Bool { if lhs.year != rhs.year { @@ -368,7 +368,7 @@ class MediaGalleryViewController: OWSNavigationController, MediaGalleryDataSourc // fade out content behind the pageViewController // and behind the presentation view - self.view.backgroundColor = .white + self.view.backgroundColor = Theme.backgroundColor }, completion: { (_: Bool) in // At this point our presentation view should be overlayed perfectly @@ -512,7 +512,7 @@ class MediaGalleryViewController: OWSNavigationController, MediaGalleryDataSourc // In case user has hidden bars, which changes background to black. // We don't want to change this while detailView is visible, lest // we obscure out the presentationView - detailView.backgroundColor = .white + detailView.backgroundColor = Theme.backgroundColor }) // This intentionally overlaps the previous animation a bit diff --git a/Signal/src/ViewControllers/MediaPageViewController.swift b/Signal/src/ViewControllers/MediaPageViewController.swift index 086f67904..31cb8c491 100644 --- a/Signal/src/ViewControllers/MediaPageViewController.swift +++ b/Signal/src/ViewControllers/MediaPageViewController.swift @@ -170,7 +170,7 @@ class MediaPageViewController: UIPageViewController, UIPageViewControllerDataSou let kFooterHeight: CGFloat = 44 - view.backgroundColor = UIColor.white + view.backgroundColor = Theme.backgroundColor let footerBar = UIToolbar() self.footerBar = footerBar @@ -245,7 +245,7 @@ class MediaPageViewController: UIPageViewController, UIPageViewControllerDataSou // We don't animate the background color change because the old color shows through momentarily // behind where the status bar "used to be". - self.view.backgroundColor = shouldHideToolbars ? UIColor.black : UIColor.white + self.view.backgroundColor = (shouldHideToolbars ? UIColor.black : Theme.backgroundColor) UIView.animate(withDuration: 0.1) { self.currentViewController.setShouldHideToolbars(self.shouldHideToolbars) @@ -474,7 +474,7 @@ class MediaPageViewController: UIPageViewController, UIPageViewControllerDataSou } Logger.debug("\(logTag) in \(#function) cache miss.") - var fetchedItem: ConversationViewItem? = nil + var fetchedItem: ConversationViewItem? self.uiDatabaseConnection.read { transaction in let message = galleryItem.message let thread = message.thread(with: transaction) diff --git a/Signal/src/ViewControllers/MediaTileViewController.swift b/Signal/src/ViewControllers/MediaTileViewController.swift index 2f5d03f67..0a6366e53 100644 --- a/Signal/src/ViewControllers/MediaTileViewController.swift +++ b/Signal/src/ViewControllers/MediaTileViewController.swift @@ -80,7 +80,7 @@ public class MediaTileViewController: UICollectionViewController, MediaGalleryDa return } - collectionView.backgroundColor = UIColor.white + collectionView.backgroundColor = Theme.backgroundColor collectionView.register(MediaGalleryCell.self, forCellWithReuseIdentifier: MediaGalleryCell.reuseIdentifier) collectionView.register(MediaGallerySectionHeader.self, forSupplementaryViewOfKind: UICollectionElementKindSectionHeader, withReuseIdentifier: MediaGallerySectionHeader.reuseIdentifier) @@ -877,12 +877,12 @@ private class MediaGalleryCell: UICollectionViewCell { self.highlightedView = UIView() highlightedView.alpha = 0.2 - highlightedView.backgroundColor = .black + highlightedView.backgroundColor = Theme.primaryColor highlightedView.isHidden = true self.selectedView = UIView() selectedView.alpha = 0.3 - selectedView.backgroundColor = .white + selectedView.backgroundColor = Theme.backgroundColor selectedView.isHidden = true super.init(frame: frame) diff --git a/Signal/src/ViewControllers/MenuActionsViewController.swift b/Signal/src/ViewControllers/MenuActionsViewController.swift index cf9f22813..ebccfd23f 100644 --- a/Signal/src/ViewControllers/MenuActionsViewController.swift +++ b/Signal/src/ViewControllers/MenuActionsViewController.swift @@ -288,7 +288,9 @@ class MenuActionSheetView: UIView, MenuActionViewDelegate { super.init(frame: frame) - backgroundColor = UIColor.ows_light10 + backgroundColor = (Theme.isDarkThemeEnabled + ? UIColor.ows_dark85 + : UIColor.ows_light10) addSubview(actionStackView) actionStackView.autoPinEdgesToSuperviewEdges() @@ -410,7 +412,9 @@ class MenuActionView: UIButton { super.init(frame: CGRect.zero) isUserInteractionEnabled = true - backgroundColor = .white + backgroundColor = (Theme.isDarkThemeEnabled + ? UIColor.ows_dark60 + : UIColor.white) let imageView = UIImageView(image: action.image) let imageWidth: CGFloat = 24 @@ -419,13 +423,15 @@ class MenuActionView: UIButton { let titleLabel = UILabel() titleLabel.font = UIFont.ows_dynamicTypeBody - titleLabel.textColor = UIColor.ows_light90 + titleLabel.textColor = Theme.primaryColor titleLabel.text = action.title titleLabel.isUserInteractionEnabled = false let subtitleLabel = UILabel() subtitleLabel.font = UIFont.ows_dynamicTypeSubheadline - subtitleLabel.textColor = UIColor.ows_light60 + subtitleLabel.textColor = (Theme.isDarkThemeEnabled + ? UIColor.ows_dark30 + : Theme.secondaryColor) subtitleLabel.text = action.subtitle subtitleLabel.isUserInteractionEnabled = false @@ -451,7 +457,7 @@ class MenuActionView: UIButton { override var isHighlighted: Bool { didSet { - self.backgroundColor = isHighlighted ? UIColor.ows_light10 : UIColor.white + self.backgroundColor = isHighlighted ? Theme.backgroundColor.withAlphaComponent(0.9) : Theme.backgroundColor } } diff --git a/Signal/src/views/ReminderView.swift b/Signal/src/views/ReminderView.swift index 7909aa4ce..e376e4059 100644 --- a/Signal/src/views/ReminderView.swift +++ b/Signal/src/views/ReminderView.swift @@ -67,7 +67,7 @@ class ReminderView: UIView { self.backgroundColor = UIColor.ows_reminderYellow case .explanation: // TODO: Theme, review with design. - self.backgroundColor = (Theme.isDarkThemeEnabled() + self.backgroundColor = (Theme.isDarkThemeEnabled ? UIColor(rgbHex: 0x202020) : UIColor(rgbHex: 0xf5f5f5)) } diff --git a/SignalMessaging/categories/Theme.h b/SignalMessaging/categories/Theme.h index f21483638..7dbe2956a 100644 --- a/SignalMessaging/categories/Theme.h +++ b/SignalMessaging/categories/Theme.h @@ -16,7 +16,8 @@ extern NSString *const ThemeDidChangeNotification; - (instancetype)init NS_UNAVAILABLE; -+ (BOOL)isDarkThemeEnabled; +@property (class, readonly, nonatomic) BOOL isDarkThemeEnabled; + #ifdef THEME_ENABLED + (void)setIsDarkThemeEnabled:(BOOL)value; #endif