From 4f8dbf39b54d30be3988d7c6023f7c0b6e256f88 Mon Sep 17 00:00:00 2001 From: Matthew Chen Date: Tue, 7 Aug 2018 17:12:16 -0400 Subject: [PATCH] Refine theme. --- Signal/src/ViewControllers/ContactsPicker.swift | 2 +- .../GifPicker/GifPickerViewController.swift | 12 ++++++++---- .../HomeView/ConversationSearchViewController.swift | 5 ++++- SignalMessaging/ViewControllers/OWSViewController.m | 2 +- SignalMessaging/categories/Theme.h | 2 +- SignalMessaging/categories/Theme.m | 5 +++++ 6 files changed, 20 insertions(+), 8 deletions(-) diff --git a/Signal/src/ViewControllers/ContactsPicker.swift b/Signal/src/ViewControllers/ContactsPicker.swift index 19767ca39..d9f204854 100644 --- a/Signal/src/ViewControllers/ContactsPicker.swift +++ b/Signal/src/ViewControllers/ContactsPicker.swift @@ -119,7 +119,7 @@ public class ContactsPicker: OWSViewController, UITableViewDelegate, UITableView self.tableView.backgroundColor = Theme.backgroundColor self.searchBar.backgroundColor = Theme.backgroundColor - self.searchBar.barStyle = Theme.barStyle() + self.searchBar.barStyle = Theme.barStyle searchBar.placeholder = NSLocalizedString("INVITE_FRIENDS_PICKER_SEARCHBAR_PLACEHOLDER", comment: "Search") // Auto size cells for dynamic type diff --git a/Signal/src/ViewControllers/GifPicker/GifPickerViewController.swift b/Signal/src/ViewControllers/GifPicker/GifPickerViewController.swift index b4bbf8f4c..2b9218456 100644 --- a/Signal/src/ViewControllers/GifPicker/GifPickerViewController.swift +++ b/Signal/src/ViewControllers/GifPicker/GifPickerViewController.swift @@ -150,7 +150,10 @@ class GifPickerViewController: OWSViewController, UISearchBarDelegate, UICollect private func createViews() { - view.backgroundColor = UIColor.white + let backgroundColor = (Theme.isDarkThemeEnabled() + ? UIColor(white: 0.08, alpha: 1.0) + : Theme.backgroundColor) + self.view.backgroundColor = backgroundColor // Block UIKit from adjust insets of collection view which screws up // min/max scroll positions. @@ -161,7 +164,8 @@ class GifPickerViewController: OWSViewController, UISearchBarDelegate, UICollect searchBar.delegate = self searchBar.placeholder = NSLocalizedString("GIF_VIEW_SEARCH_PLACEHOLDER_TEXT", comment: "Placeholder text for the search field in GIF view") - searchBar.backgroundColor = UIColor.white + searchBar.backgroundColor = Theme.backgroundColor + searchBar.barStyle = Theme.barStyle self.view.addSubview(searchBar) searchBar.autoPinWidthToSuperview() @@ -169,7 +173,7 @@ class GifPickerViewController: OWSViewController, UISearchBarDelegate, UICollect self.collectionView.delegate = self self.collectionView.dataSource = self - self.collectionView.backgroundColor = UIColor.white + self.collectionView.backgroundColor = backgroundColor self.collectionView.register(GifPickerCell.self, forCellWithReuseIdentifier: kCellReuseIdentifier) // Inserted below searchbar because we later occlude the collectionview // by inserting a masking layer between the search bar and collectionview @@ -228,7 +232,7 @@ class GifPickerViewController: OWSViewController, UISearchBarDelegate, UICollect private func createErrorLabel(text: String) -> UILabel { let label = UILabel() label.text = text - label.textColor = UIColor.black + label.textColor = Theme.primaryColor label.font = UIFont.ows_mediumFont(withSize: 20) label.textAlignment = .center label.numberOfLines = 0 diff --git a/Signal/src/ViewControllers/HomeView/ConversationSearchViewController.swift b/Signal/src/ViewControllers/HomeView/ConversationSearchViewController.swift index b0d1941d9..d8bca82f6 100644 --- a/Signal/src/ViewControllers/HomeView/ConversationSearchViewController.swift +++ b/Signal/src/ViewControllers/HomeView/ConversationSearchViewController.swift @@ -253,7 +253,10 @@ class ConversationSearchViewController: UITableViewController { // a snippet for conversations that reflects the latest // contents. if let messageSnippet = searchResult.snippet { - overrideSnippet = NSAttributedString(string: messageSnippet) + overrideSnippet = NSAttributedString(string: messageSnippet, + attributes: [ + NSAttributedStringKey.foregroundColor: Theme.primaryColor + ]) } else { owsFail("\(ConversationSearchViewController.logTag) message search result is missing message snippet") } diff --git a/SignalMessaging/ViewControllers/OWSViewController.m b/SignalMessaging/ViewControllers/OWSViewController.m index 231569c6b..904c71897 100644 --- a/SignalMessaging/ViewControllers/OWSViewController.m +++ b/SignalMessaging/ViewControllers/OWSViewController.m @@ -93,7 +93,7 @@ NS_ASSUME_NONNULL_BEGIN object:nil]; self.bottomLayoutView = view; - self.bottomLayoutConstraint = [view autoPinEdge:ALEdgeBottom toEdge:ALEdgeBottom ofView:self.view]; + self.bottomLayoutConstraint = [view autoPinToBottomLayoutGuideOfViewController:self withInset:0.f]; } - (void)observeActivation diff --git a/SignalMessaging/categories/Theme.h b/SignalMessaging/categories/Theme.h index ca0e76eae..f21483638 100644 --- a/SignalMessaging/categories/Theme.h +++ b/SignalMessaging/categories/Theme.h @@ -40,7 +40,7 @@ extern NSString *const ThemeDidChangeNotification; #pragma mark - -+ (UIBarStyle)barStyle; +@property (class, readonly, nonatomic) UIBarStyle barStyle; @end diff --git a/SignalMessaging/categories/Theme.m b/SignalMessaging/categories/Theme.m index 551fec985..247b41f3b 100644 --- a/SignalMessaging/categories/Theme.m +++ b/SignalMessaging/categories/Theme.m @@ -25,6 +25,11 @@ NSString *const ThemeKeyThemeEnabled = @"ThemeKeyThemeEnabled"; #ifndef THEME_ENABLED return NO; #else + if (!CurrentAppContext().isMainApp) { + // Ignore theme in app extensions. + return NO; + } + return [OWSPrimaryStorage.sharedManager.dbReadConnection boolForKey:ThemeKeyThemeEnabled inCollection:ThemeCollection defaultValue:NO];