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