From f795b12a86e92403ebbad418d561f04b80aa9d4e Mon Sep 17 00:00:00 2001 From: Matthew Chen Date: Mon, 23 Jul 2018 15:03:07 -0400 Subject: [PATCH 1/5] Refine theme. --- .../ViewControllers/CallViewController.swift | 2 + .../ConversationSearchViewController.swift | 46 +++++++++++++++++++ .../ViewControllers/HomeView/HomeViewCell.m | 5 -- .../HomeView/HomeViewController.m | 35 +++++++++++--- .../NewContactThreadViewController.m | 3 +- .../CodeVerificationViewController.m | 2 + .../Registration/RegistrationViewController.m | 2 + .../ViewControllers/OWSTableViewController.m | 2 +- .../ViewControllers/OWSViewController.h | 2 + .../ViewControllers/OWSViewController.m | 12 +++++ SignalMessaging/categories/Theme.h | 2 +- SignalMessaging/categories/Theme.m | 6 +-- .../contacts/CountryCodeViewController.m | 2 + 13 files changed, 102 insertions(+), 19 deletions(-) diff --git a/Signal/src/ViewControllers/CallViewController.swift b/Signal/src/ViewControllers/CallViewController.swift index b64b9786f..9401f0a55 100644 --- a/Signal/src/ViewControllers/CallViewController.swift +++ b/Signal/src/ViewControllers/CallViewController.swift @@ -148,6 +148,8 @@ class CallViewController: OWSViewController, CallObserver, CallServiceObserver, super.init(nibName: nil, bundle: nil) allAudioSources = Set(callUIAdapter.audioService.availableInputs) + + self.shouldUseTheme = false } deinit { diff --git a/Signal/src/ViewControllers/HomeView/ConversationSearchViewController.swift b/Signal/src/ViewControllers/HomeView/ConversationSearchViewController.swift index c0f88a133..525114c76 100644 --- a/Signal/src/ViewControllers/HomeView/ConversationSearchViewController.swift +++ b/Signal/src/ViewControllers/HomeView/ConversationSearchViewController.swift @@ -48,6 +48,8 @@ class ConversationSearchViewController: UITableViewController { var blockedPhoneNumberSet = Set() + private var hasThemeChanged = false + // MARK: View Lifecycle override func viewDidLoad() { @@ -67,6 +69,28 @@ class ConversationSearchViewController: UITableViewController { selector: #selector(yapDatabaseModified), name: NSNotification.Name.YapDatabaseModified, object: OWSPrimaryStorage.shared().dbNotificationObject) + NotificationCenter.default.addObserver(self, + selector: #selector(themeDidChange), + name: NSNotification.Name.ThemeDidChange, + object: nil) + + applyTheme() + } + + override func viewDidAppear(_ animated: Bool) { + super.viewDidAppear(animated) + + guard hasThemeChanged else { + return + } + hasThemeChanged = false + + applyTheme() + self.tableView.reloadData() + } + + deinit { + NotificationCenter.default.removeObserver(self) } @objc internal func yapDatabaseModified(notification: NSNotification) { @@ -75,6 +99,22 @@ class ConversationSearchViewController: UITableViewController { refreshSearchResults() } + @objc internal func themeDidChange(notification: NSNotification) { + SwiftAssertIsOnMainThread(#function) + + applyTheme() + self.tableView.reloadData() + + hasThemeChanged = true + } + + private func applyTheme() { + SwiftAssertIsOnMainThread(#function) + + self.view.backgroundColor = Theme.backgroundColor + self.tableView.backgroundColor = Theme.backgroundColor + } + // MARK: UITableViewDelegate override func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) { @@ -159,6 +199,8 @@ class ConversationSearchViewController: UITableViewController { return UITableViewCell() } + OWSTableItem.configureCell(cell) + let searchText = self.searchResultSet.searchText cell.configure(searchText: searchText) return cell @@ -172,6 +214,7 @@ class ConversationSearchViewController: UITableViewController { owsFail("searchResult was unexpectedly nil") return UITableViewCell() } + OWSTableItem.configureCell(cell) cell.configure(withThread: searchResult.thread, contactsManager: contactsManager, blockedPhoneNumber: self.blockedPhoneNumberSet) return cell case .contacts: @@ -184,6 +227,7 @@ class ConversationSearchViewController: UITableViewController { owsFail("searchResult was unexpectedly nil") return UITableViewCell() } + OWSTableItem.configureCell(cell) cell.configure(with: searchResult.signalAccount, contactsManager: contactsManager) return cell case .messages: @@ -197,6 +241,8 @@ class ConversationSearchViewController: UITableViewController { return UITableViewCell() } + OWSTableItem.configureCell(cell) + var overrideSnippet = NSAttributedString() var overrideDate: Date? if searchResult.messageId != nil { diff --git a/Signal/src/ViewControllers/HomeView/HomeViewCell.m b/Signal/src/ViewControllers/HomeView/HomeViewCell.m index bde7dd8ba..0b1abe0e6 100644 --- a/Signal/src/ViewControllers/HomeView/HomeViewCell.m +++ b/Signal/src/ViewControllers/HomeView/HomeViewCell.m @@ -65,11 +65,6 @@ NS_ASSUME_NONNULL_BEGIN _viewConstraints = [NSMutableArray new]; - UIView *selectedBackgroundView = [UIView new]; - selectedBackgroundView.backgroundColor = [Theme.cellSelectedColor colorWithAlphaComponent:0.08f]; - - self.selectedBackgroundView = selectedBackgroundView; - self.avatarView = [[AvatarImageView alloc] init]; [self.contentView addSubview:self.avatarView]; [self.avatarView autoSetDimension:ALDimensionWidth toSize:self.avatarSize]; diff --git a/Signal/src/ViewControllers/HomeView/HomeViewController.m b/Signal/src/ViewControllers/HomeView/HomeViewController.m index 81719972c..f5fe3d0bf 100644 --- a/Signal/src/ViewControllers/HomeView/HomeViewController.m +++ b/Signal/src/ViewControllers/HomeView/HomeViewController.m @@ -84,6 +84,7 @@ NSString *const kArchivedConversationsReuseIdentifier = @"kArchivedConversations @property (nonatomic) TSThread *lastThread; @property (nonatomic) BOOL hasArchivedThreadsRow; +@property (nonatomic) BOOL hasThemeChanged; @end @@ -174,7 +175,7 @@ NSString *const kArchivedConversationsReuseIdentifier = @"kArchivedConversations object:nil]; [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(themeDidChange:) - name:NSNotificationNameThemeDidChange + name:ThemeDidChangeNotification object:nil]; } @@ -223,14 +224,20 @@ NSString *const kArchivedConversationsReuseIdentifier = @"kArchivedConversations [self applyTheme]; [self.tableView reloadData]; + + self.hasThemeChanged = YES; } - (void)applyTheme { OWSAssertIsOnMainThread(); + OWSAssert(self.tableView); + OWSAssert(self.searchBar); self.view.backgroundColor = Theme.backgroundColor; self.tableView.backgroundColor = Theme.backgroundColor; + self.searchBar.backgroundColor = Theme.backgroundColor; + self.searchBar.barStyle = Theme.barStyle; } #pragma mark - View Life Cycle @@ -328,8 +335,6 @@ NSString *const kArchivedConversationsReuseIdentifier = @"kArchivedConversations [self.tableView insertSubview:pullToRefreshView atIndex:0]; [self updateReminderViews]; - - [self applyTheme]; } - (void)updateReminderViews @@ -383,9 +388,6 @@ NSString *const kArchivedConversationsReuseIdentifier = @"kArchivedConversations searchBar.searchBarStyle = UISearchBarStyleMinimal; searchBar.placeholder = NSLocalizedString(@"HOME_VIEW_CONVERSATION_SEARCHBAR_PLACEHOLDER", @"Placeholder text for search bar which filters conversations."); - searchBar.backgroundColor = Theme.backgroundColor; - searchBar.barStyle = Theme.barStyle; - searchBar.delegate = self; [searchBar sizeToFit]; @@ -404,6 +406,8 @@ NSString *const kArchivedConversationsReuseIdentifier = @"kArchivedConversations searchResultsController.view.hidden = YES; [self updateBarButtonItems]; + + [self applyTheme]; } - (void)applyDefaultBackButton @@ -435,6 +439,20 @@ NSString *const kArchivedConversationsReuseIdentifier = @"kArchivedConversations [self displayAnyUnseenUpgradeExperience]; [self applyDefaultBackButton]; + + if (self.hasThemeChanged) { + [self.tableView reloadData]; + self.hasThemeChanged = NO; + } + + [self.searchResultsController viewDidAppear:animated]; +} + +- (void)viewDidDisappear:(BOOL)animated +{ + [super viewDidDisappear:animated]; + + [self.searchResultsController viewDidDisappear:animated]; } - (void)updateBarButtonItems @@ -567,6 +585,8 @@ NSString *const kArchivedConversationsReuseIdentifier = @"kArchivedConversations if ([self updateHasArchivedThreadsRow]) { [self.tableView reloadData]; } + + [self.searchResultsController viewWillAppear:animated]; } - (void)viewWillDisappear:(BOOL)animated @@ -574,6 +594,8 @@ NSString *const kArchivedConversationsReuseIdentifier = @"kArchivedConversations [super viewWillDisappear:animated]; self.isViewVisible = NO; + + [self.searchResultsController viewWillDisappear:animated]; } - (void)setIsViewVisible:(BOOL)isViewVisible @@ -784,6 +806,7 @@ NSString *const kArchivedConversationsReuseIdentifier = @"kArchivedConversations { HomeViewCell *cell = [self.tableView dequeueReusableCellWithIdentifier:HomeViewCell.cellReuseIdentifier]; OWSAssert(cell); + [OWSTableItem configureCell:cell]; ThreadViewModel *thread = [self threadViewModelForIndexPath:indexPath]; [cell configureWithThread:thread diff --git a/Signal/src/ViewControllers/NewContactThreadViewController.m b/Signal/src/ViewControllers/NewContactThreadViewController.m index d7c53557f..ab3e77a23 100644 --- a/Signal/src/ViewControllers/NewContactThreadViewController.m +++ b/Signal/src/ViewControllers/NewContactThreadViewController.m @@ -75,7 +75,6 @@ NS_ASSUME_NONNULL_BEGIN { [super loadView]; - self.view.backgroundColor = Theme.backgroundColor; _contactsViewHelper = [[ContactsViewHelper alloc] initWithDelegate:self]; _conversationSearcher = [ConversationSearcher shared]; _nonContactAccountSet = [NSMutableSet set]; @@ -145,7 +144,7 @@ NS_ASSUME_NONNULL_BEGIN [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(themeDidChange:) - name:NSNotificationNameThemeDidChange + name:ThemeDidChangeNotification object:nil]; } diff --git a/Signal/src/ViewControllers/Registration/CodeVerificationViewController.m b/Signal/src/ViewControllers/Registration/CodeVerificationViewController.m index b84aaa510..653659b47 100644 --- a/Signal/src/ViewControllers/Registration/CodeVerificationViewController.m +++ b/Signal/src/ViewControllers/Registration/CodeVerificationViewController.m @@ -68,6 +68,8 @@ NS_ASSUME_NONNULL_BEGIN { [super viewDidLoad]; + self.shouldUseTheme = NO; + [self createViews]; [self initializeKeyboardHandlers]; diff --git a/Signal/src/ViewControllers/Registration/RegistrationViewController.m b/Signal/src/ViewControllers/Registration/RegistrationViewController.m index f772a608b..f4609ffea 100644 --- a/Signal/src/ViewControllers/Registration/RegistrationViewController.m +++ b/Signal/src/ViewControllers/Registration/RegistrationViewController.m @@ -47,6 +47,8 @@ NSString *const kKeychainKey_LastRegisteredPhoneNumber = @"kKeychainKey_LastRegi { [super loadView]; + self.shouldUseTheme = NO; + [self createViews]; // Do any additional setup after loading the view. diff --git a/SignalMessaging/ViewControllers/OWSTableViewController.m b/SignalMessaging/ViewControllers/OWSTableViewController.m index ab193480c..2024bc9d0 100644 --- a/SignalMessaging/ViewControllers/OWSTableViewController.m +++ b/SignalMessaging/ViewControllers/OWSTableViewController.m @@ -483,7 +483,7 @@ NSString *const kOWSTableCellIdentifier = @"kOWSTableCellIdentifier"; [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(themeDidChange:) - name:NSNotificationNameThemeDidChange + name:ThemeDidChangeNotification object:nil]; } diff --git a/SignalMessaging/ViewControllers/OWSViewController.h b/SignalMessaging/ViewControllers/OWSViewController.h index 1afe534ee..81b488f7e 100644 --- a/SignalMessaging/ViewControllers/OWSViewController.h +++ b/SignalMessaging/ViewControllers/OWSViewController.h @@ -10,6 +10,8 @@ NS_ASSUME_NONNULL_BEGIN @property (nonatomic) BOOL shouldIgnoreKeyboardChanges; +@property (nonatomic) BOOL shouldUseTheme; + // We often want to pin one view to the bottom of a view controller // BUT adjust its location upward if the keyboard appears. - (void)autoPinViewToBottomOfViewControllerOrKeyboard:(UIView *)view; diff --git a/SignalMessaging/ViewControllers/OWSViewController.m b/SignalMessaging/ViewControllers/OWSViewController.m index b4d3eaa4c..231569c6b 100644 --- a/SignalMessaging/ViewControllers/OWSViewController.m +++ b/SignalMessaging/ViewControllers/OWSViewController.m @@ -4,6 +4,7 @@ #import "OWSViewController.h" #import "UIView+OWS.h" +#import NS_ASSUME_NONNULL_BEGIN @@ -30,6 +31,7 @@ NS_ASSUME_NONNULL_BEGIN { self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil]; if (!self) { + self.shouldUseTheme = YES; return self; } @@ -42,6 +44,7 @@ NS_ASSUME_NONNULL_BEGIN { self = [super initWithCoder:aDecoder]; if (!self) { + self.shouldUseTheme = YES; return self; } @@ -50,6 +53,15 @@ NS_ASSUME_NONNULL_BEGIN return self; } +- (void)viewDidLoad +{ + [super viewDidLoad]; + + if (self.shouldUseTheme) { + self.view.backgroundColor = Theme.backgroundColor; + } +} + - (void)autoPinViewToBottomOfViewControllerOrKeyboard:(UIView *)view { OWSAssert(view); diff --git a/SignalMessaging/categories/Theme.h b/SignalMessaging/categories/Theme.h index 6b88777e4..2a5cc56e6 100644 --- a/SignalMessaging/categories/Theme.h +++ b/SignalMessaging/categories/Theme.h @@ -10,7 +10,7 @@ NS_ASSUME_NONNULL_BEGIN #define THEME_ENABLED #endif -extern NSString *const NSNotificationNameThemeDidChange; +extern NSString *const ThemeDidChangeNotification; @interface Theme : NSObject diff --git a/SignalMessaging/categories/Theme.m b/SignalMessaging/categories/Theme.m index 9a2fb9eb9..b6ff7256e 100644 --- a/SignalMessaging/categories/Theme.m +++ b/SignalMessaging/categories/Theme.m @@ -11,7 +11,7 @@ NS_ASSUME_NONNULL_BEGIN -NSString *const NSNotificationNameThemeDidChange = @"NSNotificationNameThemeDidChange"; +NSString *const ThemeDidChangeNotification = @"ThemeDidChangeNotification"; NSString *const ThemeCollection = @"ThemeCollection"; NSString *const ThemeKeyThemeEnabled = @"ThemeKeyThemeEnabled"; @@ -41,9 +41,7 @@ NSString *const ThemeKeyThemeEnabled = @"ThemeKeyThemeEnabled"; [UIUtil setupSignalAppearence]; - [[NSNotificationCenter defaultCenter] postNotificationNameAsync:NSNotificationNameThemeDidChange - object:nil - userInfo:nil]; + [[NSNotificationCenter defaultCenter] postNotificationNameAsync:ThemeDidChangeNotification object:nil userInfo:nil]; } + (UIColor *)backgroundColor diff --git a/SignalMessaging/contacts/CountryCodeViewController.m b/SignalMessaging/contacts/CountryCodeViewController.m index 0799e24e3..c16039d17 100644 --- a/SignalMessaging/contacts/CountryCodeViewController.m +++ b/SignalMessaging/contacts/CountryCodeViewController.m @@ -25,6 +25,8 @@ { [super loadView]; + self.shouldUseTheme = NO; + self.view.backgroundColor = [UIColor whiteColor]; self.title = NSLocalizedString(@"COUNTRYCODE_SELECT_TITLE", @""); From 7759c9ca0f038f68f8b031e2bcc594e6f4cff8a1 Mon Sep 17 00:00:00 2001 From: Matthew Chen Date: Mon, 23 Jul 2018 15:36:39 -0400 Subject: [PATCH 2/5] Refine theme. --- .../Cells/OWSContactOffersCell.m | 16 +++++-- .../Cells/OWSContactShareButtonsView.m | 2 +- .../Cells/OWSMessageBubbleView.m | 2 +- .../Cells/OWSMessageHeaderView.m | 9 ++-- .../Cells/OWSSystemMessageCell.m | 8 ++-- .../ConversationViewController.m | 42 +++++++++++++++---- SignalMessaging/categories/Theme.h | 4 +- SignalMessaging/categories/Theme.m | 6 +++ 8 files changed, 66 insertions(+), 23 deletions(-) diff --git a/Signal/src/ViewControllers/ConversationView/Cells/OWSContactOffersCell.m b/Signal/src/ViewControllers/ConversationView/Cells/OWSContactOffersCell.m index f552d7a18..10bff29a3 100644 --- a/Signal/src/ViewControllers/ConversationView/Cells/OWSContactOffersCell.m +++ b/Signal/src/ViewControllers/ConversationView/Cells/OWSContactOffersCell.m @@ -46,7 +46,6 @@ NS_ASSUME_NONNULL_BEGIN self.layoutConstraints = @[]; self.titleLabel = [UILabel new]; - self.titleLabel.textColor = [UIColor ows_light60Color]; self.titleLabel.text = NSLocalizedString(@"CONVERSATION_VIEW_CONTACTS_OFFER_TITLE", @"Title for the group of buttons show for unknown contacts offering to add them to contacts, etc."); self.titleLabel.lineBreakMode = NSLineBreakByTruncatingTail; @@ -98,9 +97,7 @@ NS_ASSUME_NONNULL_BEGIN { UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom]; [button setTitle:title forState:UIControlStateNormal]; - [button setTitleColor:[UIColor ows_signalBlueColor] forState:UIControlStateNormal]; button.titleLabel.textAlignment = NSTextAlignmentCenter; - [button setBackgroundColor:[UIColor ows_light02Color]]; button.layer.cornerRadius = 4.f; [button addTarget:self action:selector forControlEvents:UIControlEventTouchUpInside]; return button; @@ -118,8 +115,21 @@ NS_ASSUME_NONNULL_BEGIN OWSAssert(self.viewItem); OWSAssert([self.viewItem.interaction isKindOfClass:[OWSContactOffersInteraction class]]); + // [OWSTableItem configureCell:self]; + self.backgroundColor = [Theme backgroundColor]; + [self configureFonts]; + self.titleLabel.textColor = Theme.secondaryColor; + for (UIButton *button in @[ + self.addToContactsButton, + self.addToProfileWhitelistButton, + self.blockButton, + ]) { + [button setTitleColor:[UIColor ows_signalBlueColor] forState:UIControlStateNormal]; + [button setBackgroundColor:Theme.conversationButtonBackgroundColor]; + } + OWSContactOffersInteraction *interaction = (OWSContactOffersInteraction *)self.viewItem.interaction; OWSAssert( diff --git a/Signal/src/ViewControllers/ConversationView/Cells/OWSContactShareButtonsView.m b/Signal/src/ViewControllers/ConversationView/Cells/OWSContactShareButtonsView.m index bd6a71808..0e3452766 100644 --- a/Signal/src/ViewControllers/ConversationView/Cells/OWSContactShareButtonsView.m +++ b/Signal/src/ViewControllers/ConversationView/Cells/OWSContactShareButtonsView.m @@ -113,7 +113,7 @@ NS_ASSUME_NONNULL_BEGIN OWSAssert([OWSContactShareButtonsView hasAnyButton:self.contactShare contactsManager:self.contactsManager]); self.layoutMargins = UIEdgeInsetsZero; - self.backgroundColor = [UIColor ows_light02Color]; + self.backgroundColor = Theme.conversationButtonBackgroundColor; UILabel *label = [UILabel new]; self.buttonView = label; diff --git a/Signal/src/ViewControllers/ConversationView/Cells/OWSMessageBubbleView.m b/Signal/src/ViewControllers/ConversationView/Cells/OWSMessageBubbleView.m index 9e63d8760..277eb50db 100644 --- a/Signal/src/ViewControllers/ConversationView/Cells/OWSMessageBubbleView.m +++ b/Signal/src/ViewControllers/ConversationView/Cells/OWSMessageBubbleView.m @@ -510,7 +510,7 @@ NS_ASSUME_NONNULL_BEGIN OWSAssert(buttonsView.backgroundColor); shadowView.fillColor = buttonsView.backgroundColor; - shadowView.layer.shadowColor = [UIColor blackColor].CGColor; + shadowView.layer.shadowColor = Theme.boldColor.CGColor; shadowView.layer.shadowOpacity = 0.12f; shadowView.layer.shadowOffset = CGSizeZero; shadowView.layer.shadowRadius = 1.f; diff --git a/Signal/src/ViewControllers/ConversationView/Cells/OWSMessageHeaderView.m b/Signal/src/ViewControllers/ConversationView/Cells/OWSMessageHeaderView.m index 392ce64fe..d1837ca13 100644 --- a/Signal/src/ViewControllers/ConversationView/Cells/OWSMessageHeaderView.m +++ b/Signal/src/ViewControllers/ConversationView/Cells/OWSMessageHeaderView.m @@ -53,12 +53,10 @@ const CGFloat OWSMessageHeaderViewDateHeaderVMargin = 23; [self.strokeView setContentHuggingHigh]; self.titleLabel = [UILabel new]; - self.titleLabel.textColor = [UIColor ows_light90Color]; self.titleLabel.textAlignment = NSTextAlignmentCenter; self.titleLabel.lineBreakMode = NSLineBreakByTruncatingTail; self.subtitleLabel = [UILabel new]; - self.subtitleLabel.textColor = [UIColor ows_light90Color]; // The subtitle may wrap to a second line. self.subtitleLabel.numberOfLines = 0; self.subtitleLabel.lineBreakMode = NSLineBreakByWordWrapping; @@ -81,6 +79,9 @@ const CGFloat OWSMessageHeaderViewDateHeaderVMargin = 23; OWSAssert(conversationStyle); OWSAssert(viewItem.unreadIndicator || viewItem.shouldShowDate); + self.titleLabel.textColor = Theme.primaryColor; + self.subtitleLabel.textColor = Theme.primaryColor; + [self configureLabelsWithViewItem:viewItem]; CGFloat strokeThickness = [self strokeThicknessWithViewItem:viewItem]; @@ -115,9 +116,9 @@ const CGFloat OWSMessageHeaderViewDateHeaderVMargin = 23; OWSAssert(viewItem); if (viewItem.unreadIndicator) { - return UIColor.ows_light60Color; + return (Theme.isDarkThemeEnabled ? UIColor.ows_dark60Color : UIColor.ows_light60Color); } else { - return UIColor.ows_light45Color; + return (Theme.isDarkThemeEnabled ? UIColor.ows_dark30Color : UIColor.ows_light45Color); } } diff --git a/Signal/src/ViewControllers/ConversationView/Cells/OWSSystemMessageCell.m b/Signal/src/ViewControllers/ConversationView/Cells/OWSSystemMessageCell.m index 6c51b30d8..cb79b795c 100644 --- a/Signal/src/ViewControllers/ConversationView/Cells/OWSSystemMessageCell.m +++ b/Signal/src/ViewControllers/ConversationView/Cells/OWSSystemMessageCell.m @@ -76,7 +76,6 @@ typedef void (^SystemMessageActionBlock)(void); self.layoutMargins = UIEdgeInsetsZero; self.contentView.layoutMargins = UIEdgeInsetsZero; - self.contentView.backgroundColor = UIColor.whiteColor; self.layoutConstraints = @[]; self.headerView = [OWSMessageHeaderView new]; @@ -103,7 +102,6 @@ typedef void (^SystemMessageActionBlock)(void); self.button = [UIButton buttonWithType:UIButtonTypeCustom]; [self.button setTitleColor:[UIColor ows_darkSkyBlueColor] forState:UIControlStateNormal]; self.button.titleLabel.textAlignment = NSTextAlignmentCenter; - [self.button setBackgroundColor:[UIColor ows_light02Color]]; self.button.layer.cornerRadius = 4.f; [self.button addTarget:self action:@selector(buttonWasPressed:) forControlEvents:UIControlEventTouchUpInside]; [self.button autoSetDimension:ALDimensionHeight toSize:self.buttonHeight]; @@ -164,6 +162,8 @@ typedef void (^SystemMessageActionBlock)(void); OWSAssert(self.viewItem); OWSAssert(transaction); + [self.button setBackgroundColor:Theme.conversationButtonBackgroundColor]; + TSInteraction *interaction = self.viewItem.interaction; self.action = [self actionForInteraction:interaction]; @@ -219,14 +219,14 @@ typedef void (^SystemMessageActionBlock)(void); - (UIColor *)textColor { - return [UIColor ows_light60Color]; + return Theme.secondaryColor; } - (UIColor *)iconColorForInteraction:(TSInteraction *)interaction { // "Phone", "Shield" and "Hourglass" icons have a lot of "ink" so they // are less dark for balance. - return [UIColor ows_light60Color]; + return Theme.secondaryColor; } - (nullable UIImage *)iconForInteraction:(TSInteraction *)interaction diff --git a/Signal/src/ViewControllers/ConversationView/ConversationViewController.m b/Signal/src/ViewControllers/ConversationView/ConversationViewController.m index 5c5f4b3b5..95190f62b 100644 --- a/Signal/src/ViewControllers/ConversationView/ConversationViewController.m +++ b/Signal/src/ViewControllers/ConversationView/ConversationViewController.m @@ -234,6 +234,7 @@ typedef enum : NSUInteger { @property (nonatomic) ContactShareViewHelper *contactShareViewHelper; @property (nonatomic) NSTimer *reloadTimer; @property (nonatomic, nullable) NSDate *lastReloadDate; +@property (nonatomic) BOOL didChangeTheme; @end @@ -352,6 +353,10 @@ typedef enum : NSUInteger { selector:@selector(keyboardWillChangeFrame:) name:UIKeyboardWillChangeFrameNotification object:nil]; + [[NSNotificationCenter defaultCenter] addObserver:self + selector:@selector(themeDidChange:) + name:ThemeDidChangeNotification + object:nil]; } - (BOOL)isGroupConversation @@ -560,14 +565,7 @@ typedef enum : NSUInteger { [self addNotificationListeners]; [self loadDraftInCompose]; -} - -- (void)loadView -{ - [super loadView]; - - // make sure toolbar extends below iPhoneX home button. - self.view.backgroundColor = Theme.toolbarBackgroundColor; + [self applyTheme]; } - (void)createContents @@ -589,7 +587,6 @@ typedef enum : NSUInteger { self.collectionView.showsVerticalScrollIndicator = YES; self.collectionView.showsHorizontalScrollIndicator = NO; self.collectionView.keyboardDismissMode = UIScrollViewKeyboardDismissModeInteractive; - self.collectionView.backgroundColor = [UIColor whiteColor]; [self.view addSubview:self.collectionView]; [self.collectionView autoPinEdgesToSuperviewEdges]; @@ -1188,6 +1185,13 @@ typedef enum : NSUInteger { [self becomeFirstResponder]; } } + + if (self.didChangeTheme) { + self.didChangeTheme = NO; + + [self applyTheme]; + [self.collectionView reloadData]; + } } // `viewWillDisappear` is called whenever the view *starts* to disappear, @@ -4243,6 +4247,26 @@ typedef enum : NSUInteger { } } +- (void)themeDidChange:(NSNotification *)notification +{ + OWSAssertIsOnMainThread(); + + [self applyTheme]; + [self.collectionView reloadData]; + self.didChangeTheme = YES; +} + +- (void)applyTheme +{ + OWSAssertIsOnMainThread(); + + // make sure toolbar extends below iPhoneX home button. + self.view.backgroundColor = Theme.toolbarBackgroundColor; + self.collectionView.backgroundColor = Theme.backgroundColor; + + [self updateNavigationBarSubtitleLabel]; +} + - (void)attachmentApproval:(AttachmentApprovalViewController *)attachmentApproval didApproveAttachment:(SignalAttachment * _Nonnull)attachment { [self sendMessageAttachment:attachment]; diff --git a/SignalMessaging/categories/Theme.h b/SignalMessaging/categories/Theme.h index 2a5cc56e6..ca0e76eae 100644 --- a/SignalMessaging/categories/Theme.h +++ b/SignalMessaging/categories/Theme.h @@ -34,7 +34,9 @@ extern NSString *const ThemeDidChangeNotification; @property (class, readonly, nonatomic) UIColor *toolbarBackgroundColor; -+ (UIColor *)cellSelectedColor; +@property (class, readonly, nonatomic) UIColor *conversationButtonBackgroundColor; + +@property (class, readonly, nonatomic) UIColor *cellSelectedColor; #pragma mark - diff --git a/SignalMessaging/categories/Theme.m b/SignalMessaging/categories/Theme.m index b6ff7256e..551fec985 100644 --- a/SignalMessaging/categories/Theme.m +++ b/SignalMessaging/categories/Theme.m @@ -96,6 +96,11 @@ NSString *const ThemeKeyThemeEnabled = @"ThemeKeyThemeEnabled"; return (Theme.isDarkThemeEnabled ? UIColor.ows_whiteColor : UIColor.ows_blackColor); } ++ (UIColor *)conversationButtonBackgroundColor +{ + return (Theme.isDarkThemeEnabled ? UIColor.ows_dark05Color : UIColor.ows_light02Color); +} + #pragma mark - + (UIBarStyle)barStyle @@ -106,6 +111,7 @@ NSString *const ThemeKeyThemeEnabled = @"ThemeKeyThemeEnabled"; return UIBarStyleDefault; } } + @end NS_ASSUME_NONNULL_END From 581347a7fbfd82eaeeb6c49ab124f1723fa80187 Mon Sep 17 00:00:00 2001 From: Matthew Chen Date: Mon, 23 Jul 2018 15:51:12 -0400 Subject: [PATCH 3/5] Refine theme. --- Signal/src/ViewControllers/ContactsPicker.swift | 6 ++++++ Signal/src/views/ContactCell.swift | 3 +++ SignalMessaging/attachments/ContactFieldView.swift | 12 ++++++------ .../ContactShareApprovalViewController.swift | 4 ++-- 4 files changed, 17 insertions(+), 8 deletions(-) diff --git a/Signal/src/ViewControllers/ContactsPicker.swift b/Signal/src/ViewControllers/ContactsPicker.swift index fbd920cbb..cc262db46 100644 --- a/Signal/src/ViewControllers/ContactsPicker.swift +++ b/Signal/src/ViewControllers/ContactsPicker.swift @@ -96,6 +96,11 @@ public class ContactsPicker: OWSViewController, UITableViewDelegate, UITableView override open func viewDidLoad() { super.viewDidLoad() + self.view.backgroundColor = Theme.backgroundColor + self.tableView.backgroundColor = Theme.backgroundColor + + self.searchBar.backgroundColor = Theme.backgroundColor + self.searchBar.barStyle = Theme.barStyle() searchBar.placeholder = NSLocalizedString("INVITE_FRIENDS_PICKER_SEARCHBAR_PLACEHOLDER", comment: "Search") // Prevent content from going under the navigation bar self.edgesForExtendedLayout = [] @@ -231,6 +236,7 @@ public class ContactsPicker: OWSViewController, UITableViewDelegate, UITableView owsFail("\(logTag) in \(#function) cell had unexpected type") return UITableViewCell() } + OWSTableItem.configureCell(cell) let dataSource = filteredSections let cnContact = dataSource[indexPath.section][indexPath.row] diff --git a/Signal/src/views/ContactCell.swift b/Signal/src/views/ContactCell.swift index b9591edc5..3de569d79 100644 --- a/Signal/src/views/ContactCell.swift +++ b/Signal/src/views/ContactCell.swift @@ -74,6 +74,9 @@ class ContactCell: UITableViewCell { self.contact = contact self.showsWhenSelected = showsWhenSelected + self.titleLabel.textColor = Theme.primaryColor + self.subtitleLabel.textColor = Theme.secondaryColor + let cnContact = contactsManager.cnContact(withId: contact.cnContactId) titleLabel.attributedText = cnContact?.formattedFullName(font: titleLabel.font) updateSubtitle(subtitleType: subtitleType, contact: contact) diff --git a/SignalMessaging/attachments/ContactFieldView.swift b/SignalMessaging/attachments/ContactFieldView.swift index 1895ca104..98b7d6c53 100644 --- a/SignalMessaging/attachments/ContactFieldView.swift +++ b/SignalMessaging/attachments/ContactFieldView.swift @@ -30,7 +30,7 @@ public class ContactFieldView: UIView { return } let row = UIView() - row.backgroundColor = UIColor(rgbHex: 0xdedee1) + row.backgroundColor = Theme.secondaryColor self.addSubview(row) row.autoSetDimension(.height, toSize: 1) row.autoPinLeadingToSuperviewMargin(withInset: hMargin) @@ -118,14 +118,14 @@ public class ContactFieldView: UIView { let nameLabel = UILabel() nameLabel.text = name.lowercased() nameLabel.font = UIFont.ows_dynamicTypeSubheadline - nameLabel.textColor = UIColor.black + nameLabel.textColor = Theme.secondaryColor nameLabel.lineBreakMode = .byTruncatingTail stackView.addArrangedSubview(nameLabel) let valueLabel = UILabel() valueLabel.text = value valueLabel.font = UIFont.ows_dynamicTypeBody - valueLabel.textColor = UIColor.ows_materialBlue + valueLabel.textColor = Theme.primaryColor valueLabel.lineBreakMode = .byTruncatingTail stackView.addArrangedSubview(valueLabel) @@ -148,7 +148,7 @@ public class ContactFieldView: UIView { let nameLabel = UILabel() nameLabel.text = address.localizedLabel() nameLabel.font = UIFont.ows_dynamicTypeSubheadline - nameLabel.textColor = UIColor.black + nameLabel.textColor = Theme.secondaryColor nameLabel.lineBreakMode = .byTruncatingTail stackView.addArrangedSubview(nameLabel) @@ -169,7 +169,7 @@ public class ContactFieldView: UIView { let nameLabel = UILabel() nameLabel.text = propertyName nameLabel.font = UIFont.ows_dynamicTypeBody - nameLabel.textColor = UIColor.black + nameLabel.textColor = Theme.secondaryColor nameLabel.lineBreakMode = .byTruncatingTail row.addArrangedSubview(nameLabel) nameLabel.setContentHuggingHigh() @@ -178,7 +178,7 @@ public class ContactFieldView: UIView { let valueLabel = UILabel() valueLabel.text = propertyValue valueLabel.font = UIFont.ows_dynamicTypeBody - valueLabel.textColor = UIColor.ows_materialBlue + valueLabel.textColor = Theme.primaryColor valueLabel.lineBreakMode = .byTruncatingTail row.addArrangedSubview(valueLabel) diff --git a/SignalMessaging/attachments/ContactShareApprovalViewController.swift b/SignalMessaging/attachments/ContactShareApprovalViewController.swift index 53418fd66..8316ee027 100644 --- a/SignalMessaging/attachments/ContactShareApprovalViewController.swift +++ b/SignalMessaging/attachments/ContactShareApprovalViewController.swift @@ -324,7 +324,7 @@ public class ContactShareApprovalViewController: OWSViewController, EditContactS self.navigationItem.title = NSLocalizedString("CONTACT_SHARE_APPROVAL_VIEW_TITLE", comment: "Title for the 'Approve contact share' view.") - self.view.backgroundColor = UIColor.white + self.view.backgroundColor = Theme.backgroundColor updateContent() @@ -416,7 +416,7 @@ public class ContactShareApprovalViewController: OWSViewController, EditContactS self.nameLabel = nameLabel nameLabel.text = contactShare.name.displayName nameLabel.font = UIFont.ows_dynamicTypeBody.ows_mediumWeight() - nameLabel.textColor = UIColor.black + nameLabel.textColor = Theme.primaryColor nameLabel.lineBreakMode = .byTruncatingTail stackView.addArrangedSubview(nameLabel) From fa8a07abf1b2a94906ff5467a0a599199b6e0718 Mon Sep 17 00:00:00 2001 From: Matthew Chen Date: Thu, 26 Jul 2018 10:54:45 -0400 Subject: [PATCH 4/5] Respond to CR. --- .../src/ViewControllers/ContactsPicker.swift | 1 - .../Cells/OWSContactOffersCell.m | 1 - .../Cells/OWSSystemMessageCell.m | 4 ++++ .../ConversationViewController.m | 21 ------------------- .../ConversationSearchViewController.swift | 4 ---- .../ViewControllers/HomeView/HomeViewCell.m | 2 ++ .../HomeView/HomeViewController.m | 1 - Signal/src/views/ContactCell.swift | 3 +++ .../ViewControllers/OWSTableViewController.m | 1 + SignalMessaging/Views/ContactTableViewCell.m | 7 +++++-- SignalMessaging/categories/UIView+OWS.h | 2 +- SignalMessaging/categories/UIView+OWS.m | 4 +++- 12 files changed, 19 insertions(+), 32 deletions(-) diff --git a/Signal/src/ViewControllers/ContactsPicker.swift b/Signal/src/ViewControllers/ContactsPicker.swift index cc262db46..3fd7f68ca 100644 --- a/Signal/src/ViewControllers/ContactsPicker.swift +++ b/Signal/src/ViewControllers/ContactsPicker.swift @@ -236,7 +236,6 @@ public class ContactsPicker: OWSViewController, UITableViewDelegate, UITableView owsFail("\(logTag) in \(#function) cell had unexpected type") return UITableViewCell() } - OWSTableItem.configureCell(cell) let dataSource = filteredSections let cnContact = dataSource[indexPath.section][indexPath.row] diff --git a/Signal/src/ViewControllers/ConversationView/Cells/OWSContactOffersCell.m b/Signal/src/ViewControllers/ConversationView/Cells/OWSContactOffersCell.m index 10bff29a3..f66679fe8 100644 --- a/Signal/src/ViewControllers/ConversationView/Cells/OWSContactOffersCell.m +++ b/Signal/src/ViewControllers/ConversationView/Cells/OWSContactOffersCell.m @@ -115,7 +115,6 @@ NS_ASSUME_NONNULL_BEGIN OWSAssert(self.viewItem); OWSAssert([self.viewItem.interaction isKindOfClass:[OWSContactOffersInteraction class]]); - // [OWSTableItem configureCell:self]; self.backgroundColor = [Theme backgroundColor]; [self configureFonts]; diff --git a/Signal/src/ViewControllers/ConversationView/Cells/OWSSystemMessageCell.m b/Signal/src/ViewControllers/ConversationView/Cells/OWSSystemMessageCell.m index cb79b795c..92b7d3cfd 100644 --- a/Signal/src/ViewControllers/ConversationView/Cells/OWSSystemMessageCell.m +++ b/Signal/src/ViewControllers/ConversationView/Cells/OWSSystemMessageCell.m @@ -49,6 +49,7 @@ typedef void (^SystemMessageActionBlock)(void); @property (nonatomic) UILabel *titleLabel; @property (nonatomic) UIButton *button; @property (nonatomic) UIStackView *vStackView; +@property (nonatomic) UIView *cellBackgroundView; @property (nonatomic) OWSMessageHeaderView *headerView; @property (nonatomic) NSLayoutConstraint *headerViewHeightConstraint; @property (nonatomic) NSArray *layoutConstraints; @@ -114,6 +115,7 @@ typedef void (^SystemMessageActionBlock)(void); self.vStackView.spacing = self.buttonVSpacing; self.vStackView.alignment = UIStackViewAlignmentCenter; self.vStackView.layoutMarginsRelativeArrangement = YES; + self.cellBackgroundView = [self.vStackView addBackgroundViewWithBackgroundColor:Theme.backgroundColor]; UIStackView *cellStackView = [[UIStackView alloc] initWithArrangedSubviews:@[ self.headerView, self.vStackView ]]; cellStackView.axis = UILayoutConstraintAxisVertical; @@ -162,6 +164,8 @@ typedef void (^SystemMessageActionBlock)(void); OWSAssert(self.viewItem); OWSAssert(transaction); + self.cellBackgroundView.backgroundColor = [Theme backgroundColor]; + [self.button setBackgroundColor:Theme.conversationButtonBackgroundColor]; TSInteraction *interaction = self.viewItem.interaction; diff --git a/Signal/src/ViewControllers/ConversationView/ConversationViewController.m b/Signal/src/ViewControllers/ConversationView/ConversationViewController.m index 95190f62b..f31cba94f 100644 --- a/Signal/src/ViewControllers/ConversationView/ConversationViewController.m +++ b/Signal/src/ViewControllers/ConversationView/ConversationViewController.m @@ -234,7 +234,6 @@ typedef enum : NSUInteger { @property (nonatomic) ContactShareViewHelper *contactShareViewHelper; @property (nonatomic) NSTimer *reloadTimer; @property (nonatomic, nullable) NSDate *lastReloadDate; -@property (nonatomic) BOOL didChangeTheme; @end @@ -353,10 +352,6 @@ typedef enum : NSUInteger { selector:@selector(keyboardWillChangeFrame:) name:UIKeyboardWillChangeFrameNotification object:nil]; - [[NSNotificationCenter defaultCenter] addObserver:self - selector:@selector(themeDidChange:) - name:ThemeDidChangeNotification - object:nil]; } - (BOOL)isGroupConversation @@ -1185,13 +1180,6 @@ typedef enum : NSUInteger { [self becomeFirstResponder]; } } - - if (self.didChangeTheme) { - self.didChangeTheme = NO; - - [self applyTheme]; - [self.collectionView reloadData]; - } } // `viewWillDisappear` is called whenever the view *starts* to disappear, @@ -4247,15 +4235,6 @@ typedef enum : NSUInteger { } } -- (void)themeDidChange:(NSNotification *)notification -{ - OWSAssertIsOnMainThread(); - - [self applyTheme]; - [self.collectionView reloadData]; - self.didChangeTheme = YES; -} - - (void)applyTheme { OWSAssertIsOnMainThread(); diff --git a/Signal/src/ViewControllers/HomeView/ConversationSearchViewController.swift b/Signal/src/ViewControllers/HomeView/ConversationSearchViewController.swift index 525114c76..1c24fe4a5 100644 --- a/Signal/src/ViewControllers/HomeView/ConversationSearchViewController.swift +++ b/Signal/src/ViewControllers/HomeView/ConversationSearchViewController.swift @@ -214,7 +214,6 @@ class ConversationSearchViewController: UITableViewController { owsFail("searchResult was unexpectedly nil") return UITableViewCell() } - OWSTableItem.configureCell(cell) cell.configure(withThread: searchResult.thread, contactsManager: contactsManager, blockedPhoneNumber: self.blockedPhoneNumberSet) return cell case .contacts: @@ -227,7 +226,6 @@ class ConversationSearchViewController: UITableViewController { owsFail("searchResult was unexpectedly nil") return UITableViewCell() } - OWSTableItem.configureCell(cell) cell.configure(with: searchResult.signalAccount, contactsManager: contactsManager) return cell case .messages: @@ -241,8 +239,6 @@ class ConversationSearchViewController: UITableViewController { return UITableViewCell() } - OWSTableItem.configureCell(cell) - var overrideSnippet = NSAttributedString() var overrideDate: Date? if searchResult.messageId != nil { diff --git a/Signal/src/ViewControllers/HomeView/HomeViewCell.m b/Signal/src/ViewControllers/HomeView/HomeViewCell.m index 0b1abe0e6..f19b85795 100644 --- a/Signal/src/ViewControllers/HomeView/HomeViewCell.m +++ b/Signal/src/ViewControllers/HomeView/HomeViewCell.m @@ -194,6 +194,8 @@ NS_ASSUME_NONNULL_BEGIN OWSAssert(contactsManager); OWSAssert(blockedPhoneNumberSet); + [OWSTableItem configureCell:self]; + self.thread = thread; self.contactsManager = contactsManager; diff --git a/Signal/src/ViewControllers/HomeView/HomeViewController.m b/Signal/src/ViewControllers/HomeView/HomeViewController.m index f5fe3d0bf..0c0c92c6c 100644 --- a/Signal/src/ViewControllers/HomeView/HomeViewController.m +++ b/Signal/src/ViewControllers/HomeView/HomeViewController.m @@ -806,7 +806,6 @@ NSString *const kArchivedConversationsReuseIdentifier = @"kArchivedConversations { HomeViewCell *cell = [self.tableView dequeueReusableCellWithIdentifier:HomeViewCell.cellReuseIdentifier]; OWSAssert(cell); - [OWSTableItem configureCell:cell]; ThreadViewModel *thread = [self threadViewModelForIndexPath:indexPath]; [cell configureWithThread:thread diff --git a/Signal/src/views/ContactCell.swift b/Signal/src/views/ContactCell.swift index 3de569d79..b2956dc55 100644 --- a/Signal/src/views/ContactCell.swift +++ b/Signal/src/views/ContactCell.swift @@ -71,6 +71,9 @@ class ContactCell: UITableViewCell { } func configure(contact: Contact, subtitleType: SubtitleCellValue, showsWhenSelected: Bool, contactsManager: OWSContactsManager) { + + OWSTableItem.configureCell(self) + self.contact = contact self.showsWhenSelected = showsWhenSelected diff --git a/SignalMessaging/ViewControllers/OWSTableViewController.m b/SignalMessaging/ViewControllers/OWSTableViewController.m index 2024bc9d0..890a23930 100644 --- a/SignalMessaging/ViewControllers/OWSTableViewController.m +++ b/SignalMessaging/ViewControllers/OWSTableViewController.m @@ -108,6 +108,7 @@ const CGFloat kOWSTable_DefaultCellHeight = 45.f; + (void)configureCell:(UITableViewCell *)cell { cell.backgroundColor = [Theme backgroundColor]; + cell.contentView.backgroundColor = [Theme backgroundColor]; cell.textLabel.font = [UIFont ows_regularFontWithSize:18.f]; cell.textLabel.textColor = [Theme primaryColor]; diff --git a/SignalMessaging/Views/ContactTableViewCell.m b/SignalMessaging/Views/ContactTableViewCell.m index 606b854d6..64d407f39 100644 --- a/SignalMessaging/Views/ContactTableViewCell.m +++ b/SignalMessaging/Views/ContactTableViewCell.m @@ -46,7 +46,6 @@ NS_ASSUME_NONNULL_BEGIN self.preservesSuperviewLayoutMargins = YES; self.contentView.preservesSuperviewLayoutMargins = YES; - [OWSTableItem configureCell:self]; self.cellView = [ContactCellView new]; [self.contentView addSubview:self.cellView]; @@ -56,11 +55,13 @@ NS_ASSUME_NONNULL_BEGIN - (void)configureWithSignalAccount:(SignalAccount *)signalAccount contactsManager:(OWSContactsManager *)contactsManager { - [self.cellView configureWithRecipientId:signalAccount.recipientId contactsManager:contactsManager]; + [self configureWithRecipientId:signalAccount.recipientId contactsManager:contactsManager]; } - (void)configureWithRecipientId:(NSString *)recipientId contactsManager:(OWSContactsManager *)contactsManager { + [OWSTableItem configureCell:self]; + [self.cellView configureWithRecipientId:recipientId contactsManager:contactsManager]; // Force layout, since imageView isn't being initally rendered on App Store optimized build. @@ -71,6 +72,8 @@ NS_ASSUME_NONNULL_BEGIN { OWSAssert(thread); + [OWSTableItem configureCell:self]; + [self.cellView configureWithThread:thread contactsManager:contactsManager]; // Force layout, since imageView isn't being initally rendered on App Store optimized build. diff --git a/SignalMessaging/categories/UIView+OWS.h b/SignalMessaging/categories/UIView+OWS.h index e661f64ea..729656459 100644 --- a/SignalMessaging/categories/UIView+OWS.h +++ b/SignalMessaging/categories/UIView+OWS.h @@ -143,7 +143,7 @@ CGFloat ScaleFromIPhone5(CGFloat iPhone5Value); @interface UIStackView (OWS) -- (void)addBackgroundViewWithBackgroundColor:(UIColor *)backgroundColor; +- (UIView *)addBackgroundViewWithBackgroundColor:(UIColor *)backgroundColor; @end diff --git a/SignalMessaging/categories/UIView+OWS.m b/SignalMessaging/categories/UIView+OWS.m index 0041884f7..aff3b6760 100644 --- a/SignalMessaging/categories/UIView+OWS.m +++ b/SignalMessaging/categories/UIView+OWS.m @@ -538,12 +538,14 @@ CGFloat ScaleFromIPhone5(CGFloat iPhone5Value) @implementation UIStackView (OWS) -- (void)addBackgroundViewWithBackgroundColor:(UIColor *)backgroundColor +- (UIView *)addBackgroundViewWithBackgroundColor:(UIColor *)backgroundColor { UIView *subview = [UIView new]; subview.backgroundColor = backgroundColor; [self addSubview:subview]; [subview autoPinEdgesToSuperviewEdges]; + [self sendSubviewToBack:subview]; + return subview; } @end From baf432f1eeaff4c645991879c2154408b95c16ec Mon Sep 17 00:00:00 2001 From: Matthew Chen Date: Thu, 26 Jul 2018 11:05:29 -0400 Subject: [PATCH 5/5] Respond to CR. --- .../ConversationView/Cells/OWSSystemMessageCell.m | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/Signal/src/ViewControllers/ConversationView/Cells/OWSSystemMessageCell.m b/Signal/src/ViewControllers/ConversationView/Cells/OWSSystemMessageCell.m index 92b7d3cfd..45e8bfa10 100644 --- a/Signal/src/ViewControllers/ConversationView/Cells/OWSSystemMessageCell.m +++ b/Signal/src/ViewControllers/ConversationView/Cells/OWSSystemMessageCell.m @@ -115,7 +115,10 @@ typedef void (^SystemMessageActionBlock)(void); self.vStackView.spacing = self.buttonVSpacing; self.vStackView.alignment = UIStackViewAlignmentCenter; self.vStackView.layoutMarginsRelativeArrangement = YES; - self.cellBackgroundView = [self.vStackView addBackgroundViewWithBackgroundColor:Theme.backgroundColor]; + + self.cellBackgroundView = [UIView new]; + self.cellBackgroundView.layer.cornerRadius = 5.f; + [self.contentView addSubview:self.cellBackgroundView]; UIStackView *cellStackView = [[UIStackView alloc] initWithArrangedSubviews:@[ self.headerView, self.vStackView ]]; cellStackView.axis = UILayoutConstraintAxisVertical; @@ -217,7 +220,15 @@ typedef void (^SystemMessageActionBlock)(void); self.layoutConstraints = @[ [self.titleLabel autoSetDimension:ALDimensionWidth toSize:titleSize.width], - [self.button autoSetDimension:ALDimensionWidth toSize:buttonSize.width + self.buttonHPadding * 2.f] + [self.button autoSetDimension:ALDimensionWidth toSize:buttonSize.width + self.buttonHPadding * 2.f], + + [self.cellBackgroundView autoPinEdge:ALEdgeTop toEdge:ALEdgeTop ofView:self.vStackView], + [self.cellBackgroundView autoPinEdge:ALEdgeBottom toEdge:ALEdgeBottom ofView:self.vStackView], + // Text in vStackView might flow right up to the edges, so only use half the gutter. + [self.cellBackgroundView autoPinEdgeToSuperviewEdge:ALEdgeLeading + withInset:self.conversationStyle.fullWidthGutterLeading * 0.5f], + [self.cellBackgroundView autoPinEdgeToSuperviewEdge:ALEdgeTrailing + withInset:self.conversationStyle.fullWidthGutterTrailing * 0.5f], ]; }