diff --git a/Signal.xcodeproj/project.pbxproj b/Signal.xcodeproj/project.pbxproj index ee6f104b1..ddadf0c38 100644 --- a/Signal.xcodeproj/project.pbxproj +++ b/Signal.xcodeproj/project.pbxproj @@ -194,6 +194,8 @@ 34C6B0AB1FA0E46F00D35993 /* test-mp3.mp3 in Resources */ = {isa = PBXBuildFile; fileRef = 34C6B0A71FA0E46F00D35993 /* test-mp3.mp3 */; }; 34C6B0AC1FA0E46F00D35993 /* test-mp4.mp4 in Resources */ = {isa = PBXBuildFile; fileRef = 34C6B0A81FA0E46F00D35993 /* test-mp4.mp4 */; }; 34C6B0AE1FA0E4AA00D35993 /* test-jpg.jpg in Resources */ = {isa = PBXBuildFile; fileRef = 34C6B0AD1FA0E4AA00D35993 /* test-jpg.jpg */; }; + 34C82E5120F8E1F300E9688D /* Theme.h in Headers */ = {isa = PBXBuildFile; fileRef = 34C82E4F20F8E1F000E9688D /* Theme.h */; settings = {ATTRIBUTES = (Public, ); }; }; + 34C82E5220F8E1F300E9688D /* Theme.m in Sources */ = {isa = PBXBuildFile; fileRef = 34C82E5020F8E1F100E9688D /* Theme.m */; }; 34CA631B2097806F00E526A0 /* OWSContactShareView.m in Sources */ = {isa = PBXBuildFile; fileRef = 34CA631A2097806E00E526A0 /* OWSContactShareView.m */; }; 34CCAF381F0C0599004084F4 /* AppUpdateNag.m in Sources */ = {isa = PBXBuildFile; fileRef = 34CCAF371F0C0599004084F4 /* AppUpdateNag.m */; }; 34CE88E71F2FB9A10098030F /* ProfileViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 34CE88E61F2FB9A10098030F /* ProfileViewController.m */; }; @@ -835,6 +837,8 @@ 34C6B0A71FA0E46F00D35993 /* test-mp3.mp3 */ = {isa = PBXFileReference; lastKnownFileType = audio.mp3; path = "test-mp3.mp3"; sourceTree = ""; }; 34C6B0A81FA0E46F00D35993 /* test-mp4.mp4 */ = {isa = PBXFileReference; lastKnownFileType = file; path = "test-mp4.mp4"; sourceTree = ""; }; 34C6B0AD1FA0E4AA00D35993 /* test-jpg.jpg */ = {isa = PBXFileReference; lastKnownFileType = image.jpeg; path = "test-jpg.jpg"; sourceTree = ""; }; + 34C82E4F20F8E1F000E9688D /* Theme.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Theme.h; sourceTree = ""; }; + 34C82E5020F8E1F100E9688D /* Theme.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = Theme.m; sourceTree = ""; }; 34CA1C261F7156F300E51C51 /* MessageDetailViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MessageDetailViewController.swift; sourceTree = ""; }; 34CA1C281F7164F700E51C51 /* MediaMessageView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MediaMessageView.swift; sourceTree = ""; }; 34CA63192097806E00E526A0 /* OWSContactShareView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = OWSContactShareView.h; sourceTree = ""; }; @@ -1496,22 +1500,24 @@ 34480B5C1FD0A98800BC14EF /* categories */ = { isa = PBXGroup; children = ( - 45BB93371E688E14001E3939 /* UIDevice+featureSupport.swift */, 4551DB59205C562300C8AE75 /* Collection+OWS.swift */, 346129C51FD2072D00532771 /* NSAttributedString+OWS.h */, 346129C11FD2072D00532771 /* NSAttributedString+OWS.m */, 346129C01FD2072C00532771 /* NSString+OWS.h */, 346129C21FD2072D00532771 /* NSString+OWS.m */, 346129C41FD2072D00532771 /* Promise+retainUntilComplete.swift */, + 452D1AF220810B6F00A67F7F /* String+OWS.swift */, + 34C82E4F20F8E1F000E9688D /* Theme.h */, + 34C82E5020F8E1F100E9688D /* Theme.m */, 34480B5D1FD0A98800BC14EF /* UIColor+OWS.h */, 34480B5E1FD0A98800BC14EF /* UIColor+OWS.m */, + 45BB93371E688E14001E3939 /* UIDevice+featureSupport.swift */, 34480B661FD0AA9400BC14EF /* UIFont+OWS.h */, 34480B651FD0AA9400BC14EF /* UIFont+OWS.m */, 34480B5F1FD0A98800BC14EF /* UIView+OWS.h */, 34480B601FD0A98800BC14EF /* UIView+OWS.m */, 346129D41FD20ADC00532771 /* UIViewController+OWS.h */, 346129D31FD20ADB00532771 /* UIViewController+OWS.m */, - 452D1AF220810B6F00A67F7F /* String+OWS.swift */, ); path = categories; sourceTree = ""; @@ -2450,6 +2456,7 @@ 344F248420069E9C00CFB4F4 /* CountryCodeViewController.h in Headers */, 4503F1C4204711D300CEE724 /* OWS107LegacySounds.h in Headers */, 346129711FD1D74C00532771 /* SignalKeyingStorage.h in Headers */, + 34C82E5120F8E1F300E9688D /* Theme.h in Headers */, 34612A011FD5F31400532771 /* OWS104CreateRecipientIdentities.h in Headers */, 450998691FD8C10200D89EB3 /* AttachmentSharing.h in Headers */, 346129C71FD2072E00532771 /* NSString+OWS.h in Headers */, @@ -3160,6 +3167,7 @@ 454A965B1FD601BF008D2A0E /* MediaMessageView.swift in Sources */, 45BC829D1FD9C4B400011CF3 /* ShareViewDelegate.swift in Sources */, 4565ED06200EA29900C46DBB /* VideoPlayerView.swift in Sources */, + 34C82E5220F8E1F300E9688D /* Theme.m in Sources */, 3461295B1FD1D74C00532771 /* Environment.m in Sources */, 346129D51FD20ADC00532771 /* UIViewController+OWS.m in Sources */, 451F8A431FD714FE005CB9DA /* AvatarImageView.swift in Sources */, diff --git a/Signal/src/ViewControllers/AppSettings/AboutTableViewController.m b/Signal/src/ViewControllers/AppSettings/AboutTableViewController.m index fb9c8c0ed..e7a6a775a 100644 --- a/Signal/src/ViewControllers/AppSettings/AboutTableViewController.m +++ b/Signal/src/ViewControllers/AppSettings/AboutTableViewController.m @@ -71,7 +71,7 @@ UILabel *copyrightLabel = [UILabel new]; copyrightLabel.text = NSLocalizedString(@"SETTINGS_COPYRIGHT", @""); - copyrightLabel.textColor = [UIColor ows_darkGrayColor]; + copyrightLabel.textColor = [Theme secondaryColor]; copyrightLabel.font = [UIFont ows_regularFontWithSize:15.0f]; copyrightLabel.numberOfLines = 2; copyrightLabel.lineBreakMode = NSLineBreakByWordWrapping; diff --git a/Signal/src/ViewControllers/AppSettings/AdvancedSettingsTableViewController.m b/Signal/src/ViewControllers/AppSettings/AdvancedSettingsTableViewController.m index d8555a8df..34fdc4657 100644 --- a/Signal/src/ViewControllers/AppSettings/AdvancedSettingsTableViewController.m +++ b/Signal/src/ViewControllers/AppSettings/AdvancedSettingsTableViewController.m @@ -198,8 +198,9 @@ NS_ASSUME_NONNULL_BEGIN #ifdef THEME_ENABLED OWSTableSection *themeSection = [OWSTableSection new]; themeSection.headerTitle = NSLocalizedString(@"THEME_SECTION", nil); - [themeSection addItem:[OWSTableItem switchItemWithText:NSLocalizedString(@"SETTINGS_ADVANCED_THEME", @"") - isOn:[UIColor isThemeEnabled] + [themeSection addItem:[OWSTableItem switchItemWithText:NSLocalizedString(@"SETTINGS_ADVANCED_DARK_THEME", + @"Label for setting that enables dark theme.") + isOn:[Theme isDarkThemeEnabled] target:weakSelf selector:@selector(didToggleThemeSwitch:)]]; [contents addSection:themeSection]; @@ -287,7 +288,9 @@ NS_ASSUME_NONNULL_BEGIN #ifdef THEME_ENABLED - (void)didToggleThemeSwitch:(UISwitch *)sender { - [UIColor setIsThemeEnabled:sender.isOn]; + [Theme setIsDarkThemeEnabled:sender.isOn]; + + [self updateTableContents]; // TODO: Notify and refresh. } diff --git a/Signal/src/ViewControllers/AppSettings/AppSettingsViewController.m b/Signal/src/ViewControllers/AppSettings/AppSettingsViewController.m index 480673d7f..9706ac479 100644 --- a/Signal/src/ViewControllers/AppSettings/AppSettingsViewController.m +++ b/Signal/src/ViewControllers/AppSettings/AppSettingsViewController.m @@ -316,7 +316,7 @@ NSString *_Nullable localProfileName = [OWSProfileManager.sharedManager localProfileName]; if (localProfileName.length > 0) { titleLabel.text = localProfileName; - titleLabel.textColor = [UIColor ows_themeForegroundColor]; + titleLabel.textColor = [Theme primaryColor]; titleLabel.font = [UIFont ows_dynamicTypeTitle2Font]; } else { titleLabel.text = NSLocalizedString( @@ -331,7 +331,7 @@ const CGFloat kSubtitlePointSize = 12.f; UILabel *subtitleLabel = [UILabel new]; - subtitleLabel.textColor = [UIColor ows_themeSecondaryColor]; + subtitleLabel.textColor = [Theme secondaryColor]; subtitleLabel.font = [UIFont ows_regularFontWithSize:kSubtitlePointSize]; subtitleLabel.attributedText = [[NSAttributedString alloc] initWithString:[PhoneNumber bestEffortFormatPartialUserSpecifiedTextToLookLikeAPhoneNumber:[TSAccountManager diff --git a/Signal/src/ViewControllers/AppSettings/DomainFrontingCountryViewController.m b/Signal/src/ViewControllers/AppSettings/DomainFrontingCountryViewController.m index 06028daf5..70a477b26 100644 --- a/Signal/src/ViewControllers/AppSettings/DomainFrontingCountryViewController.m +++ b/Signal/src/ViewControllers/AppSettings/DomainFrontingCountryViewController.m @@ -60,18 +60,19 @@ NS_ASSUME_NONNULL_BEGIN section.headerTitle = NSLocalizedString( @"DOMAIN_FRONTING_COUNTRY_VIEW_SECTION_HEADER", @"Section title for the 'domain fronting country' view."); for (OWSCountryMetadata *countryMetadata in [OWSCountryMetadata allCountryMetadatas]) { - [section addItem:[OWSTableItem itemWithCustomCellBlock:^{ - UITableViewCell *cell = [UITableViewCell new]; - cell.textLabel.text = countryMetadata.localizedCountryName; - cell.textLabel.font = [UIFont ows_regularFontWithSize:18.f]; - cell.textLabel.textColor = [UIColor blackColor]; - - if ([countryMetadata.countryCode isEqualToString:currentCountryCode]) { - cell.accessoryType = UITableViewCellAccessoryCheckmark; - } - - return cell; - } + [section addItem:[OWSTableItem + itemWithCustomCellBlock:^{ + UITableViewCell *cell = [OWSTableItem newCell]; + cell.textLabel.text = countryMetadata.localizedCountryName; + cell.textLabel.font = [UIFont ows_regularFontWithSize:18.f]; + cell.textLabel.textColor = [UIColor blackColor]; + + if ([countryMetadata.countryCode isEqualToString:currentCountryCode]) { + cell.accessoryType = UITableViewCellAccessoryCheckmark; + } + + return cell; + } actionBlock:^{ [weakSelf selectCountry:countryMetadata]; }]]; diff --git a/Signal/src/ViewControllers/AppSettings/NotificationSettingsOptionsViewController.m b/Signal/src/ViewControllers/AppSettings/NotificationSettingsOptionsViewController.m index 9c1b736df..a0a50101f 100644 --- a/Signal/src/ViewControllers/AppSettings/NotificationSettingsOptionsViewController.m +++ b/Signal/src/ViewControllers/AppSettings/NotificationSettingsOptionsViewController.m @@ -33,14 +33,15 @@ @[ @(NotificationNamePreview), @(NotificationNameNoPreview), @(NotificationNoNameNoPreview) ]) { NotificationType notificationType = (NotificationType)option.intValue; - [section addItem:[OWSTableItem itemWithCustomCellBlock:^{ - UITableViewCell *cell = [UITableViewCell new]; - [[cell textLabel] setText:[prefs nameForNotificationPreviewType:notificationType]]; - if (selectedNotifType == notificationType) { - cell.accessoryType = UITableViewCellAccessoryCheckmark; - } - return cell; - } + [section addItem:[OWSTableItem + itemWithCustomCellBlock:^{ + UITableViewCell *cell = [OWSTableItem newCell]; + [[cell textLabel] setText:[prefs nameForNotificationPreviewType:notificationType]]; + if (selectedNotifType == notificationType) { + cell.accessoryType = UITableViewCellAccessoryCheckmark; + } + return cell; + } actionBlock:^{ [weakSelf setNotificationType:notificationType]; }]]; diff --git a/Signal/src/ViewControllers/ConversationView/Cells/OWSMessageBubbleView.m b/Signal/src/ViewControllers/ConversationView/Cells/OWSMessageBubbleView.m index 47b67bd1a..de173a0c8 100644 --- a/Signal/src/ViewControllers/ConversationView/Cells/OWSMessageBubbleView.m +++ b/Signal/src/ViewControllers/ConversationView/Cells/OWSMessageBubbleView.m @@ -345,8 +345,8 @@ NS_ASSUME_NONNULL_BEGIN OWSBubbleShapeView *strokeView = [OWSBubbleShapeView bubbleDrawView]; strokeView.strokeThickness = CGHairlineWidth(); - strokeView.strokeColor = (UIColor.isThemeEnabled ? [UIColor colorWithWhite:1.f alpha:0.2f] - : [UIColor colorWithWhite:0.f alpha:0.2f]); + strokeView.strokeColor = (Theme.isDarkThemeEnabled ? [UIColor colorWithWhite:1.f alpha:0.2f] + : [UIColor colorWithWhite:0.f alpha:0.2f]); [bodyMediaView addSubview:strokeView]; [self.bubbleView addPartnerView:strokeView]; [self.viewConstraints addObjectsFromArray:[strokeView ows_autoPinToSuperviewEdges]]; diff --git a/Signal/src/ViewControllers/ConversationView/ConversationHeaderView.swift b/Signal/src/ViewControllers/ConversationView/ConversationHeaderView.swift index abc37ce7f..8ffc6a458 100644 --- a/Signal/src/ViewControllers/ConversationView/ConversationHeaderView.swift +++ b/Signal/src/ViewControllers/ConversationView/ConversationHeaderView.swift @@ -64,13 +64,13 @@ public class ConversationHeaderView: UIStackView { avatarView.layer.borderWidth = 0 titleLabel = UILabel() - titleLabel.textColor = .ows_navbarTitle + titleLabel.textColor = Theme.navbarTitleColor titleLabel.lineBreakMode = .byTruncatingTail titleLabel.font = titlePrimaryFont titleLabel.setContentHuggingHigh() subtitleLabel = UILabel() - subtitleLabel.textColor = .ows_navbarTitle + subtitleLabel.textColor = Theme.navbarTitleColor subtitleLabel.lineBreakMode = .byTruncatingTail subtitleLabel.font = subtitleFont subtitleLabel.setContentHuggingHigh() diff --git a/Signal/src/ViewControllers/ConversationView/ConversationInputToolbar.m b/Signal/src/ViewControllers/ConversationView/ConversationInputToolbar.m index aeb2a92c6..ed33a4f63 100644 --- a/Signal/src/ViewControllers/ConversationView/ConversationInputToolbar.m +++ b/Signal/src/ViewControllers/ConversationView/ConversationInputToolbar.m @@ -87,10 +87,10 @@ const CGFloat kMaxTextViewHeight = 98; self.layoutMargins = UIEdgeInsetsZero; if (UIAccessibilityIsReduceTransparencyEnabled()) { - self.backgroundColor = [UIColor ows_toolbarBackgroundColor]; + self.backgroundColor = Theme.toolbarBackgroundColor; } else { CGFloat alpha = OWSNavigationBar.backgroundBlurMutingFactor; - self.backgroundColor = [[UIColor ows_toolbarBackgroundColor] colorWithAlphaComponent:alpha]; + self.backgroundColor = [Theme.toolbarBackgroundColor colorWithAlphaComponent:alpha]; UIBlurEffect *blurEffect = [UIBlurEffect effectWithStyle:UIBlurEffectStyleLight]; UIVisualEffectView *blurEffectView = [[UIVisualEffectView alloc] initWithEffect:blurEffect]; @@ -119,7 +119,7 @@ const CGFloat kMaxTextViewHeight = 98; UIImage *attachmentImage = [UIImage imageNamed:@"ic_circled_plus"]; [self.attachmentButton setImage:[attachmentImage imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate] forState:UIControlStateNormal]; - self.attachmentButton.tintColor = UIColor.ows_navbarIconColor; + self.attachmentButton.tintColor = Theme.navbarIconColor; [self.attachmentButton autoSetDimensionsToSize:CGSizeMake(40, kMinTextViewHeight)]; _sendButton = [UIButton buttonWithType:UIButtonTypeCustom]; @@ -138,7 +138,7 @@ const CGFloat kMaxTextViewHeight = 98; _voiceMemoButton = [UIButton buttonWithType:UIButtonTypeCustom]; [self.voiceMemoButton setImage:[voiceMemoIcon imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate] forState:UIControlStateNormal]; - self.voiceMemoButton.imageView.tintColor = UIColor.ows_navbarIconColor; + self.voiceMemoButton.imageView.tintColor = Theme.navbarIconColor; [self.voiceMemoButton autoSetDimensionsToSize:CGSizeMake(40, kMinTextViewHeight)]; // We want to be permissive about the voice message gesture, so we hang diff --git a/Signal/src/ViewControllers/ConversationView/ConversationViewController.m b/Signal/src/ViewControllers/ConversationView/ConversationViewController.m index c3e8f4eda..c48e41927 100644 --- a/Signal/src/ViewControllers/ConversationView/ConversationViewController.m +++ b/Signal/src/ViewControllers/ConversationView/ConversationViewController.m @@ -571,7 +571,7 @@ typedef enum : NSUInteger { [super loadView]; // make sure toolbar extends below iPhoneX home button. - self.view.backgroundColor = [UIColor ows_toolbarBackgroundColor]; + self.view.backgroundColor = Theme.toolbarBackgroundColor; } - (void)createContents @@ -1355,11 +1355,11 @@ typedef enum : NSUInteger { if (OWSWindowManager.sharedManager.hasCall) { callButton.enabled = NO; callButton.userInteractionEnabled = NO; - callButton.tintColor = [UIColor.ows_navbarIconColor colorWithAlphaComponent:0.7]; + callButton.tintColor = [Theme.navbarIconColor colorWithAlphaComponent:0.7]; } else { callButton.enabled = YES; callButton.userInteractionEnabled = YES; - callButton.tintColor = UIColor.ows_navbarIconColor; + callButton.tintColor = Theme.navbarIconColor; } UIEdgeInsets imageEdgeInsets = UIEdgeInsetsZero; @@ -1387,7 +1387,7 @@ typedef enum : NSUInteger { DisappearingTimerConfigurationView *timerView = [[DisappearingTimerConfigurationView alloc] initWithDurationSeconds:self.disappearingMessagesConfiguration.durationSeconds]; timerView.delegate = self; - timerView.tintColor = UIColor.ows_navbarIconColor; + timerView.tintColor = Theme.navbarIconColor; // As of iOS11, we can size barButton item custom views with autoLayout. // Before that, though we can still use autoLayout *within* the customView, @@ -1409,7 +1409,7 @@ typedef enum : NSUInteger { { NSMutableAttributedString *subtitleText = [NSMutableAttributedString new]; - UIColor *subtitleColor = [UIColor.ows_navbarTitleColor colorWithAlphaComponent:(CGFloat)0.9]; + UIColor *subtitleColor = [Theme.navbarTitleColor colorWithAlphaComponent:(CGFloat)0.9]; if (self.thread.isMuted) { // Show a "mute" icon before the navigation bar subtitle if this thread is muted. [subtitleText appendAttributedString:[[NSAttributedString alloc] diff --git a/Signal/src/ViewControllers/HomeView/HomeViewCell.m b/Signal/src/ViewControllers/HomeView/HomeViewCell.m index f9ecd330c..bde7dd8ba 100644 --- a/Signal/src/ViewControllers/HomeView/HomeViewCell.m +++ b/Signal/src/ViewControllers/HomeView/HomeViewCell.m @@ -61,13 +61,12 @@ NS_ASSUME_NONNULL_BEGIN { OWSAssert(!self.avatarView); - self.backgroundColor = UIColor.ows_themeBackgroundColor; + self.backgroundColor = Theme.backgroundColor; _viewConstraints = [NSMutableArray new]; UIView *selectedBackgroundView = [UIView new]; - selectedBackgroundView.backgroundColor = - [(UIColor.isThemeEnabled ? [UIColor ows_whiteColor] : [UIColor ows_blackColor]) colorWithAlphaComponent:0.08f]; + selectedBackgroundView.backgroundColor = [Theme.cellSelectedColor colorWithAlphaComponent:0.08f]; self.selectedBackgroundView = selectedBackgroundView; @@ -226,9 +225,9 @@ NS_ASSUME_NONNULL_BEGIN self.dateTimeLabel.text = (overrideDate ? [self stringForDate:overrideDate] : [self stringForDate:thread.lastMessageDate]); - UIColor *textColor = [UIColor ows_themeSecondaryColor]; + UIColor *textColor = [Theme secondaryColor]; if (hasUnreadMessages && overrideSnippet == nil) { - textColor = [UIColor ows_themeForegroundColor]; + textColor = [Theme primaryColor]; self.dateTimeLabel.font = self.dateTimeFont.ows_mediumWeight; } else { self.dateTimeLabel.font = self.dateTimeFont; @@ -276,7 +275,7 @@ NS_ASSUME_NONNULL_BEGIN UIImage *_Nullable statusIndicatorImage = nil; // TODO: Theme, Review with design. UIColor *messageStatusViewTintColor - = (UIColor.isThemeEnabled ? [UIColor ows_dark30Color] : [UIColor ows_light35Color]); + = (Theme.isDarkThemeEnabled ? [UIColor ows_dark30Color] : [UIColor ows_light35Color]); BOOL shouldAnimateStatusIcon = NO; if ([self.thread.lastMessageForInbox isKindOfClass:[TSOutgoingMessage class]]) { TSOutgoingMessage *outgoingMessage = (TSOutgoingMessage *)self.thread.lastMessageForInbox; @@ -366,7 +365,7 @@ NS_ASSUME_NONNULL_BEGIN @"A label for conversations with blocked users.") attributes:@{ NSFontAttributeName : self.snippetFont.ows_mediumWeight, - NSForegroundColorAttributeName : [UIColor ows_themeForegroundColor], + NSForegroundColorAttributeName : [Theme primaryColor], }]]; } else { if ([thread isMuted]) { @@ -375,8 +374,8 @@ NS_ASSUME_NONNULL_BEGIN attributes:@{ NSFontAttributeName : [UIFont ows_elegantIconsFont:9.f], NSForegroundColorAttributeName : - (hasUnreadMessages ? [UIColor ows_themeForegroundColor] - : [UIColor ows_themeSecondaryColor]), + (hasUnreadMessages ? [Theme primaryColor] + : [Theme secondaryColor]), }]]; } NSString *displayableText = thread.lastMessageText; @@ -388,8 +387,8 @@ NS_ASSUME_NONNULL_BEGIN (hasUnreadMessages ? self.snippetFont.ows_mediumWeight : self.snippetFont), NSForegroundColorAttributeName : - (hasUnreadMessages ? [UIColor ows_themeForegroundColor] - : [UIColor ows_themeSecondaryColor]), + (hasUnreadMessages ? [Theme primaryColor] + : [Theme secondaryColor]), }]]; } } @@ -491,7 +490,7 @@ NS_ASSUME_NONNULL_BEGIN OWSAssertIsOnMainThread(); self.nameLabel.font = self.nameFont; - self.nameLabel.textColor = [UIColor ows_themeForegroundColor]; + self.nameLabel.textColor = [Theme primaryColor]; ThreadViewModel *thread = self.thread; if (thread == nil) { diff --git a/Signal/src/ViewControllers/HomeView/HomeViewController.m b/Signal/src/ViewControllers/HomeView/HomeViewController.m index ba50c92be..81719972c 100644 --- a/Signal/src/ViewControllers/HomeView/HomeViewController.m +++ b/Signal/src/ViewControllers/HomeView/HomeViewController.m @@ -229,8 +229,8 @@ NSString *const kArchivedConversationsReuseIdentifier = @"kArchivedConversations { OWSAssertIsOnMainThread(); - self.view.backgroundColor = UIColor.ows_themeBackgroundColor; - self.tableView.backgroundColor = UIColor.ows_themeBackgroundColor; + self.view.backgroundColor = Theme.backgroundColor; + self.tableView.backgroundColor = Theme.backgroundColor; } #pragma mark - View Life Cycle @@ -383,12 +383,8 @@ 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 = UIColor.ows_themeBackgroundColor; - if (UIColor.isThemeEnabled) { - searchBar.barStyle = UIBarStyleBlack; - } else { - searchBar.barStyle = UIBarStyleDefault; - } + searchBar.backgroundColor = Theme.backgroundColor; + searchBar.barStyle = Theme.barStyle; searchBar.delegate = self; [searchBar sizeToFit]; @@ -448,6 +444,8 @@ NSString *const kArchivedConversationsReuseIdentifier = @"kArchivedConversations } // Settings button. + // + // TODO: Theme UIImage *image = [UIImage imageNamed:@"button_settings_white"]; UIBarButtonItem *settingsButton = [[UIBarButtonItem alloc] initWithImage:image style:UIBarButtonItemStylePlain target:self action:@selector(settingsButtonPressed:)]; settingsButton.accessibilityLabel = CommonStrings.openSettingsButton; @@ -803,13 +801,12 @@ NSString *const kArchivedConversationsReuseIdentifier = @"kArchivedConversations { UITableViewCell *cell = [self.tableView dequeueReusableCellWithIdentifier:kArchivedConversationsReuseIdentifier]; OWSAssert(cell); + [OWSTableItem configureCell:cell]; for (UIView *subview in cell.contentView.subviews) { [subview removeFromSuperview]; } - cell.backgroundColor = UIColor.ows_themeBackgroundColor; - UIImage *disclosureImage = [UIImage imageNamed:(CurrentAppContext().isRTL ? @"NavBarBack" : @"NavBarBackRTL")]; OWSAssert(disclosureImage); UIImageView *disclosureImageView = [UIImageView new]; @@ -822,7 +819,7 @@ NSString *const kArchivedConversationsReuseIdentifier = @"kArchivedConversations label.text = NSLocalizedString(@"HOME_VIEW_ARCHIVED_CONVERSATIONS", @"Label for 'archived conversations' button."); label.textAlignment = NSTextAlignmentCenter; label.font = [UIFont ows_dynamicTypeBodyFont]; - label.textColor = UIColor.ows_themeForegroundColor; + label.textColor = Theme.primaryColor; UIStackView *stackView = [UIStackView new]; stackView.axis = UILayoutConstraintAxisHorizontal; @@ -1449,11 +1446,11 @@ NSString *const kArchivedConversationsReuseIdentifier = @"kArchivedConversations value:[UIFont ows_regularFontWithSize:14.f] range:NSMakeRange(firstLine.length + 1, secondLine.length)]; [fullLabelString addAttribute:NSForegroundColorAttributeName - value:UIColor.ows_themeForegroundColor + value:Theme.primaryColor range:NSMakeRange(0, firstLine.length)]; // TODO: Theme, Review with design. [fullLabelString addAttribute:NSForegroundColorAttributeName - value:UIColor.ows_themeSecondaryColor + value:Theme.secondaryColor range:NSMakeRange(firstLine.length + 1, secondLine.length)]; _emptyBoxLabel.attributedText = fullLabelString; } diff --git a/Signal/src/ViewControllers/MediaPageViewController.swift b/Signal/src/ViewControllers/MediaPageViewController.swift index 27b15d3fe..086f67904 100644 --- a/Signal/src/ViewControllers/MediaPageViewController.swift +++ b/Signal/src/ViewControllers/MediaPageViewController.swift @@ -587,7 +587,7 @@ class MediaPageViewController: UIPageViewController, UIPageViewControllerDataSou lazy private var headerNameLabel: UILabel = { let label = UILabel() - label.textColor = .ows_navbarTitle + label.textColor = Theme.navbarTitleColor label.font = UIFont.ows_regularFont(withSize: 17) label.textAlignment = .center label.adjustsFontSizeToFitWidth = true @@ -598,7 +598,7 @@ class MediaPageViewController: UIPageViewController, UIPageViewControllerDataSou lazy private var headerDateLabel: UILabel = { let label = UILabel() - label.textColor = .ows_navbarTitle + label.textColor = Theme.navbarTitleColor label.font = UIFont.ows_regularFont(withSize: 12) label.textAlignment = .center label.adjustsFontSizeToFitWidth = true diff --git a/Signal/src/ViewControllers/NewContactThreadViewController.m b/Signal/src/ViewControllers/NewContactThreadViewController.m index 3d10efb7c..d7c53557f 100644 --- a/Signal/src/ViewControllers/NewContactThreadViewController.m +++ b/Signal/src/ViewControllers/NewContactThreadViewController.m @@ -75,7 +75,7 @@ NS_ASSUME_NONNULL_BEGIN { [super loadView]; - self.view.backgroundColor = UIColor.whiteColor; + self.view.backgroundColor = Theme.backgroundColor; _contactsViewHelper = [[ContactsViewHelper alloc] initWithDelegate:self]; _conversationSearcher = [ConversationSearcher shared]; _nonContactAccountSet = [NSMutableSet set]; @@ -102,7 +102,8 @@ NS_ASSUME_NONNULL_BEGIN searchBar.searchBarStyle = UISearchBarStyleMinimal; searchBar.delegate = self; searchBar.placeholder = NSLocalizedString(@"SEARCH_BYNAMEORNUMBER_PLACEHOLDER_TEXT", @""); - searchBar.backgroundColor = [UIColor whiteColor]; + searchBar.backgroundColor = [Theme backgroundColor]; + searchBar.barStyle = Theme.barStyle; [searchBar sizeToFit]; _tableViewController = [OWSTableViewController new]; @@ -139,6 +140,18 @@ NS_ASSUME_NONNULL_BEGIN [self.tableViewController.tableView insertSubview:pullToRefreshView atIndex:0]; [self updateTableContents]; + + [self applyTheme]; + + [[NSNotificationCenter defaultCenter] addObserver:self + selector:@selector(themeDidChange:) + name:NSNotificationNameThemeDidChange + object:nil]; +} + +- (void)dealloc +{ + [[NSNotificationCenter defaultCenter] removeObserver:self]; } - (void)pullToRefreshPerformed:(UIRefreshControl *)refreshControl @@ -166,7 +179,7 @@ NS_ASSUME_NONNULL_BEGIN - (UIView *)createNoSignalContactsView { UIView *view = [UIView new]; - view.backgroundColor = [UIColor whiteColor]; + view.backgroundColor = [Theme backgroundColor]; UIView *contents = [UIView new]; [view addSubview:contents]; @@ -188,7 +201,7 @@ NS_ASSUME_NONNULL_BEGIN UILabel *titleLabel = [UILabel new]; titleLabel.text = NSLocalizedString( @"EMPTY_CONTACTS_LABEL_LINE1", "Full width label displayed when attempting to compose message"); - titleLabel.textColor = [UIColor blackColor]; + titleLabel.textColor = [Theme primaryColor]; titleLabel.font = [UIFont ows_mediumFontWithSize:ScaleFromIPhone5To7Plus(17.f, 20.f)]; titleLabel.textAlignment = NSTextAlignmentCenter; titleLabel.lineBreakMode = NSLineBreakByWordWrapping; @@ -201,7 +214,7 @@ NS_ASSUME_NONNULL_BEGIN UILabel *subtitleLabel = [UILabel new]; subtitleLabel.text = NSLocalizedString( @"EMPTY_CONTACTS_LABEL_LINE2", "Full width label displayed when attempting to compose message"); - subtitleLabel.textColor = [UIColor colorWithWhite:0.32f alpha:1.f]; + subtitleLabel.textColor = [Theme secondaryColor]; subtitleLabel.font = [UIFont ows_regularFontWithSize:ScaleFromIPhone5To7Plus(12.f, 14.f)]; subtitleLabel.textAlignment = NSTextAlignmentCenter; subtitleLabel.lineBreakMode = NSLineBreakByWordWrapping; @@ -392,7 +405,7 @@ NS_ASSUME_NONNULL_BEGIN @"A label that indicates the user has no Signal contacts.") customRowHeight:UITableViewAutomaticDimension]]; } else { - UITableViewCell *loadingCell = [UITableViewCell new]; + UITableViewCell *loadingCell = [OWSTableItem newCell]; OWSAssert(loadingCell.contentView); UIActivityIndicatorView *activityIndicatorView = @@ -993,6 +1006,22 @@ NS_ASSUME_NONNULL_BEGIN } } +#pragma mark - Theme + +- (void)themeDidChange:(id)notification +{ + OWSAssertIsOnMainThread(); + + [self applyTheme]; +} + +- (void)applyTheme +{ + OWSAssertIsOnMainThread(); + + self.view.backgroundColor = Theme.backgroundColor; +} + @end NS_ASSUME_NONNULL_END diff --git a/Signal/src/ViewControllers/NewGroupViewController.m b/Signal/src/ViewControllers/NewGroupViewController.m index 2e1a73c5e..f9cfddf12 100644 --- a/Signal/src/ViewControllers/NewGroupViewController.m +++ b/Signal/src/ViewControllers/NewGroupViewController.m @@ -137,7 +137,7 @@ const NSUInteger kNewGroupViewControllerAvatarWidth = 68; firstSectionHeader.userInteractionEnabled = YES; [firstSectionHeader addGestureRecognizer:[[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(headerWasTapped:)]]; - firstSectionHeader.backgroundColor = [UIColor whiteColor]; + firstSectionHeader.backgroundColor = [Theme backgroundColor]; UIView *threadInfoView = [UIView new]; [firstSectionHeader addSubview:threadInfoView]; [threadInfoView autoPinWidthToSuperviewWithMargin:16.f]; @@ -155,7 +155,7 @@ const NSUInteger kNewGroupViewControllerAvatarWidth = 68; UITextField *groupNameTextField = [UITextField new]; _groupNameTextField = groupNameTextField; - groupNameTextField.textColor = [UIColor blackColor]; + groupNameTextField.textColor = [Theme primaryColor]; groupNameTextField.font = [UIFont ows_dynamicTypeTitle2Font]; groupNameTextField.placeholder = NSLocalizedString(@"NEW_GROUP_NAMEGROUP_REQUEST_DEFAULT", @"Placeholder text for group name field"); diff --git a/Signal/src/ViewControllers/OWS2FARegistrationViewController.m b/Signal/src/ViewControllers/OWS2FARegistrationViewController.m index 5c1a86aa9..c238e26da 100644 --- a/Signal/src/ViewControllers/OWS2FARegistrationViewController.m +++ b/Signal/src/ViewControllers/OWS2FARegistrationViewController.m @@ -63,7 +63,7 @@ NS_ASSUME_NONNULL_BEGIN self.title = NSLocalizedString(@"REGISTRATION_ENTER_LOCK_PIN_NAV_TITLE", @"Navigation title shown when user is re-registering after having enabled registration lock"); - self.view.backgroundColor = UIColor.whiteColor; + self.view.backgroundColor = [Theme backgroundColor]; PinEntryView *entryView = [PinEntryView new]; self.entryView = entryView; diff --git a/Signal/src/ViewControllers/OWS2FASettingsViewController.m b/Signal/src/ViewControllers/OWS2FASettingsViewController.m index b8b246dda..f07c19537 100644 --- a/Signal/src/ViewControllers/OWS2FASettingsViewController.m +++ b/Signal/src/ViewControllers/OWS2FASettingsViewController.m @@ -33,7 +33,7 @@ NS_ASSUME_NONNULL_BEGIN { [super viewDidLoad]; - self.view.backgroundColor = UIColor.whiteColor; + self.view.backgroundColor = [Theme backgroundColor]; self.title = NSLocalizedString(@"ENABLE_2FA_VIEW_TITLE", @"Title for the 'enable two factor auth PIN' views."); @@ -99,7 +99,7 @@ NS_ASSUME_NONNULL_BEGIN - (UILabel *)createLabelWithText:(NSString *)text { UILabel *label = [UILabel new]; - label.textColor = [UIColor blackColor]; + label.textColor = [Theme primaryColor]; label.text = text; label.font = [UIFont ows_regularFontWithSize:ScaleFromIPhone5To7Plus(14.f, 16.f)]; label.numberOfLines = 0; @@ -112,7 +112,7 @@ NS_ASSUME_NONNULL_BEGIN - (void)createPinTextfield { self.pinTextfield = [UITextField new]; - self.pinTextfield.textColor = [UIColor blackColor]; + self.pinTextfield.textColor = [Theme primaryColor]; self.pinTextfield.font = [UIFont ows_mediumFontWithSize:ScaleFromIPhone5To7Plus(30.f, 36.f)]; self.pinTextfield.textAlignment = NSTextAlignmentCenter; self.pinTextfield.keyboardType = UIKeyboardTypeNumberPad; diff --git a/Signal/src/ViewControllers/ThreadSettings/OWSConversationSettingsViewController.m b/Signal/src/ViewControllers/ThreadSettings/OWSConversationSettingsViewController.m index e90439722..1193d56cf 100644 --- a/Signal/src/ViewControllers/ThreadSettings/OWSConversationSettingsViewController.m +++ b/Signal/src/ViewControllers/ThreadSettings/OWSConversationSettingsViewController.m @@ -368,7 +368,7 @@ const CGFloat kIconViewLength = 24; [mainSection addItem:[OWSTableItem itemWithCustomCellBlock:^{ - UITableViewCell *cell = [UITableViewCell new]; + UITableViewCell *cell = [OWSTableItem newCell]; OWSConversationSettingsViewController *strongSelf = weakSelf; OWSCAssert(strongSelf); cell.preservesSuperviewLayoutMargins = YES; @@ -383,7 +383,7 @@ const CGFloat kIconViewLength = 24; UILabel *rowLabel = [UILabel new]; rowLabel.text = NSLocalizedString( @"DISAPPEARING_MESSAGES", @"table cell label in conversation settings"); - rowLabel.textColor = [UIColor blackColor]; + rowLabel.textColor = [Theme primaryColor]; rowLabel.font = [UIFont ows_dynamicTypeBodyFont]; rowLabel.lineBreakMode = NSLineBreakByTruncatingTail; @@ -403,7 +403,7 @@ const CGFloat kIconViewLength = 24; UILabel *subtitleLabel = [UILabel new]; subtitleLabel.text = NSLocalizedString( @"DISAPPEARING_MESSAGES_DESCRIPTION", @"subheading in conversation settings"); - subtitleLabel.textColor = [UIColor blackColor]; + subtitleLabel.textColor = [Theme primaryColor]; subtitleLabel.font = [UIFont ows_dynamicTypeCaption1Font]; subtitleLabel.numberOfLines = 0; subtitleLabel.lineBreakMode = NSLineBreakByWordWrapping; @@ -422,7 +422,7 @@ const CGFloat kIconViewLength = 24; [mainSection addItem:[OWSTableItem itemWithCustomCellBlock:^{ - UITableViewCell *cell = [UITableViewCell new]; + UITableViewCell *cell = [OWSTableItem newCell]; OWSConversationSettingsViewController *strongSelf = weakSelf; OWSCAssert(strongSelf); cell.preservesSuperviewLayoutMargins = YES; @@ -433,7 +433,7 @@ const CGFloat kIconViewLength = 24; UILabel *rowLabel = strongSelf.disappearingMessagesDurationLabel; [strongSelf updateDisappearingMessagesDurationLabel]; - rowLabel.textColor = [UIColor blackColor]; + rowLabel.textColor = [Theme primaryColor]; rowLabel.font = [UIFont ows_dynamicTypeBodyFont]; // don't truncate useful duration info which is in the tail rowLabel.lineBreakMode = NSLineBreakByTruncatingHead; @@ -514,6 +514,7 @@ const CGFloat kIconViewLength = 24; itemWithCustomCellBlock:^{ UITableViewCell *cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:nil]; + [OWSTableItem configureCell:cell]; OWSConversationSettingsViewController *strongSelf = weakSelf; OWSCAssert(strongSelf); cell.preservesSuperviewLayoutMargins = YES; @@ -525,7 +526,7 @@ const CGFloat kIconViewLength = 24; UILabel *rowLabel = [UILabel new]; rowLabel.text = NSLocalizedString(@"SETTINGS_ITEM_NOTIFICATION_SOUND", @"Label for settings view that allows user to change the notification sound."); - rowLabel.textColor = [UIColor blackColor]; + rowLabel.textColor = [Theme primaryColor]; rowLabel.font = [UIFont ows_dynamicTypeBodyFont]; rowLabel.lineBreakMode = NSLineBreakByTruncatingTail; @@ -552,6 +553,7 @@ const CGFloat kIconViewLength = 24; itemWithCustomCellBlock:^{ UITableViewCell *cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:nil]; + [OWSTableItem configureCell:cell]; OWSConversationSettingsViewController *strongSelf = weakSelf; OWSCAssert(strongSelf); cell.preservesSuperviewLayoutMargins = YES; @@ -563,7 +565,7 @@ const CGFloat kIconViewLength = 24; UILabel *rowLabel = [UILabel new]; rowLabel.text = NSLocalizedString(@"CONVERSATION_SETTINGS_MUTE_LABEL", @"label for 'mute thread' cell in conversation settings"); - rowLabel.textColor = [UIColor blackColor]; + rowLabel.textColor = [Theme primaryColor]; rowLabel.font = [UIFont ows_dynamicTypeBodyFont]; rowLabel.lineBreakMode = NSLineBreakByTruncatingTail; @@ -680,13 +682,13 @@ const CGFloat kIconViewLength = 24; { OWSAssert(name.length > 0); - UITableViewCell *cell = [UITableViewCell new]; + UITableViewCell *cell = [OWSTableItem newCell]; cell.preservesSuperviewLayoutMargins = YES; cell.contentView.preservesSuperviewLayoutMargins = YES; UILabel *rowLabel = [UILabel new]; rowLabel.text = name; - rowLabel.textColor = [UIColor blackColor]; + rowLabel.textColor = [Theme primaryColor]; rowLabel.font = [UIFont ows_dynamicTypeBodyFont]; rowLabel.lineBreakMode = NSLineBreakByTruncatingTail; @@ -742,7 +744,7 @@ const CGFloat kIconViewLength = 24; UILabel *threadTitleLabel = [UILabel new]; threadTitleLabel.text = self.threadName; - threadTitleLabel.textColor = [UIColor blackColor]; + threadTitleLabel.textColor = [Theme primaryColor]; threadTitleLabel.font = [UIFont ows_dynamicTypeTitle2Font]; threadTitleLabel.lineBreakMode = NSLineBreakByTruncatingTail; [threadNameView addSubview:threadTitleLabel]; @@ -755,7 +757,7 @@ const CGFloat kIconViewLength = 24; const CGFloat kSubtitlePointSize = 12.f; void (^addSubtitle)(NSAttributedString *) = ^(NSAttributedString *subtitle) { UILabel *subtitleLabel = [UILabel new]; - subtitleLabel.textColor = [UIColor ows_darkGrayColor]; + subtitleLabel.textColor = [Theme secondaryColor]; subtitleLabel.font = [UIFont ows_regularFontWithSize:kSubtitlePointSize]; subtitleLabel.attributedText = subtitle; subtitleLabel.lineBreakMode = NSLineBreakByTruncatingTail; @@ -833,7 +835,7 @@ const CGFloat kIconViewLength = 24; OWSAssert(icon); UIImageView *iconView = [UIImageView new]; iconView.image = [icon imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate]; - iconView.tintColor = [UIColor ows_darkIconColor]; + iconView.tintColor = [Theme secondaryColor]; iconView.contentMode = UIViewContentModeScaleAspectFit; iconView.layer.minificationFilter = kCAFilterTrilinear; iconView.layer.magnificationFilter = kCAFilterTrilinear; diff --git a/Signal/src/ViewControllers/ThreadSettings/UpdateGroupViewController.m b/Signal/src/ViewControllers/ThreadSettings/UpdateGroupViewController.m index c76d00467..a738115b9 100644 --- a/Signal/src/ViewControllers/ThreadSettings/UpdateGroupViewController.m +++ b/Signal/src/ViewControllers/ThreadSettings/UpdateGroupViewController.m @@ -172,7 +172,7 @@ NS_ASSUME_NONNULL_BEGIN firstSectionHeader.userInteractionEnabled = YES; [firstSectionHeader addGestureRecognizer:[[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(headerWasTapped:)]]; - firstSectionHeader.backgroundColor = [UIColor whiteColor]; + firstSectionHeader.backgroundColor = [Theme backgroundColor]; UIView *threadInfoView = [UIView new]; [firstSectionHeader addSubview:threadInfoView]; [threadInfoView autoPinWidthToSuperviewWithMargin:16.f]; @@ -193,7 +193,7 @@ NS_ASSUME_NONNULL_BEGIN UITextField *groupNameTextField = [UITextField new]; _groupNameTextField = groupNameTextField; self.groupNameTextField.text = [self.thread.groupModel.groupName ows_stripped]; - groupNameTextField.textColor = [UIColor blackColor]; + groupNameTextField.textColor = [Theme primaryColor]; groupNameTextField.font = [UIFont ows_dynamicTypeTitle2Font]; groupNameTextField.placeholder = NSLocalizedString(@"NEW_GROUP_NAMEGROUP_REQUEST_DEFAULT", @"Placeholder text for group name field"); diff --git a/Signal/src/views/DismissableTextField.swift b/Signal/src/views/DismissableTextField.swift index 75e98f2a3..fd5c391ae 100644 --- a/Signal/src/views/DismissableTextField.swift +++ b/Signal/src/views/DismissableTextField.swift @@ -23,7 +23,7 @@ class DismissInputBar: UIToolbar { self.items = [spacer, dismissButton] self.isTranslucent = false self.isOpaque = true - self.barTintColor = UIColor.ows_toolbarBackground + self.barTintColor = Theme.toolbarBackgroundColor self.autoresizingMask = .flexibleHeight self.translatesAutoresizingMaskIntoConstraints = false diff --git a/Signal/src/views/PinEntryView.m b/Signal/src/views/PinEntryView.m index cf69c398f..0f215cfda 100644 --- a/Signal/src/views/PinEntryView.m +++ b/Signal/src/views/PinEntryView.m @@ -47,7 +47,7 @@ NS_ASSUME_NONNULL_BEGIN - (UILabel *)createLabelWithText:(nullable NSString *)text { UILabel *label = [UILabel new]; - label.textColor = [UIColor blackColor]; + label.textColor = [Theme primaryColor]; label.text = text; label.font = self.labelFont; label.numberOfLines = 0; @@ -65,7 +65,7 @@ NS_ASSUME_NONNULL_BEGIN self.pinTextfield = [UITextField new]; } - self.pinTextfield.textColor = [UIColor blackColor]; + self.pinTextfield.textColor = [Theme primaryColor]; self.pinTextfield.font = [UIFont ows_mediumFontWithSize:ScaleFromIPhone5To7Plus(30.f, 36.f)]; self.pinTextfield.textAlignment = NSTextAlignmentCenter; self.pinTextfield.keyboardType = UIKeyboardTypeNumberPad; diff --git a/Signal/src/views/ReminderView.swift b/Signal/src/views/ReminderView.swift index 5b8e4201f..7909aa4ce 100644 --- a/Signal/src/views/ReminderView.swift +++ b/Signal/src/views/ReminderView.swift @@ -66,7 +66,10 @@ class ReminderView: UIView { case .nag: self.backgroundColor = UIColor.ows_reminderYellow case .explanation: - self.backgroundColor = UIColor(rgbHex: 0xf5f5f5) + // TODO: Theme, review with design. + self.backgroundColor = (Theme.isDarkThemeEnabled() + ? UIColor(rgbHex: 0x202020) + : UIColor(rgbHex: 0xf5f5f5)) } self.clipsToBounds = true @@ -85,7 +88,7 @@ class ReminderView: UIView { // Label label.font = UIFont.ows_dynamicTypeSubheadline container.addArrangedSubview(label) - label.textColor = UIColor.black.withAlphaComponent(0.9) + label.textColor = Theme.primaryColor label.numberOfLines = 0 label.lineBreakMode = .byWordWrapping @@ -99,7 +102,7 @@ class ReminderView: UIView { } let iconView = UIImageView(image: iconImage.withRenderingMode(.alwaysTemplate)) iconView.contentMode = .scaleAspectFit - iconView.tintColor = UIColor.black.withAlphaComponent(0.6) + iconView.tintColor = Theme.secondaryColor iconView.autoSetDimension(.width, toSize: 13) container.addArrangedSubview(iconView) } diff --git a/Signal/translations/en.lproj/Localizable.strings b/Signal/translations/en.lproj/Localizable.strings index 85fda9c3e..70d49d827 100644 --- a/Signal/translations/en.lproj/Localizable.strings +++ b/Signal/translations/en.lproj/Localizable.strings @@ -1889,15 +1889,15 @@ /* Table header for the 'censorship circumvention' section. */ "SETTINGS_ADVANCED_CENSORSHIP_CIRCUMVENTION_HEADER" = "Censorship Circumvention"; +/* Label for setting that enables dark theme. */ +"SETTINGS_ADVANCED_DARK_THEME" = "Dark Theme"; + /* No comment provided by engineer. */ "SETTINGS_ADVANCED_DEBUGLOG" = "Enable Debug Log"; /* No comment provided by engineer. */ "SETTINGS_ADVANCED_SUBMIT_DEBUGLOG" = "Submit Debug Log"; -/* No comment provided by engineer. */ -"SETTINGS_ADVANCED_THEME" = "Theme"; - /* No comment provided by engineer. */ "SETTINGS_ADVANCED_TITLE" = "Advanced"; diff --git a/SignalMessaging/SignalMessaging.h b/SignalMessaging/SignalMessaging.h index cce161506..850b3d987 100644 --- a/SignalMessaging/SignalMessaging.h +++ b/SignalMessaging/SignalMessaging.h @@ -42,6 +42,7 @@ FOUNDATION_EXPORT const unsigned char SignalMessagingVersionString[]; #import #import #import +#import #import #import #import diff --git a/SignalMessaging/ViewControllers/OWSNavigationController.m b/SignalMessaging/ViewControllers/OWSNavigationController.m index bd38547ee..264e193dd 100644 --- a/SignalMessaging/ViewControllers/OWSNavigationController.m +++ b/SignalMessaging/ViewControllers/OWSNavigationController.m @@ -121,7 +121,7 @@ NS_ASSUME_NONNULL_BEGIN // Status bar is overlaying the green "call banner" return UIStatusBarStyleLightContent; } else { - return (UIColor.isThemeEnabled ? UIStatusBarStyleLightContent : super.preferredStatusBarStyle); + return (Theme.isDarkThemeEnabled ? UIStatusBarStyleLightContent : super.preferredStatusBarStyle); } } diff --git a/SignalMessaging/ViewControllers/OWSTableViewController.h b/SignalMessaging/ViewControllers/OWSTableViewController.h index 0aa07dd34..c90133e84 100644 --- a/SignalMessaging/ViewControllers/OWSTableViewController.h +++ b/SignalMessaging/ViewControllers/OWSTableViewController.h @@ -53,6 +53,7 @@ typedef UITableViewCell *_Nonnull (^OWSTableCustomCellBlock)(void); @property (nonatomic, weak) UIViewController *tableViewController; + (UITableViewCell *)newCell; ++ (void)configureCell:(UITableViewCell *)cell; + (OWSTableItem *)itemWithTitle:(NSString *)title actionBlock:(nullable OWSTableActionBlock)actionBlock; diff --git a/SignalMessaging/ViewControllers/OWSTableViewController.m b/SignalMessaging/ViewControllers/OWSTableViewController.m index 44fe661b5..ab193480c 100644 --- a/SignalMessaging/ViewControllers/OWSTableViewController.m +++ b/SignalMessaging/ViewControllers/OWSTableViewController.m @@ -101,12 +101,21 @@ const CGFloat kOWSTable_DefaultCellHeight = 45.f; + (UITableViewCell *)newCell { UITableViewCell *cell = [UITableViewCell new]; - cell.backgroundColor = [UIColor ows_themeBackgroundColor]; - cell.textLabel.font = [UIFont ows_regularFontWithSize:18.f]; - cell.textLabel.textColor = [UIColor ows_themeForegroundColor]; + [self configureCell:cell]; return cell; } ++ (void)configureCell:(UITableViewCell *)cell +{ + cell.backgroundColor = [Theme backgroundColor]; + cell.textLabel.font = [UIFont ows_regularFontWithSize:18.f]; + cell.textLabel.textColor = [Theme primaryColor]; + + UIView *selectedBackgroundView = [UIView new]; + selectedBackgroundView.backgroundColor = [Theme.cellSelectedColor colorWithAlphaComponent:0.08]; + cell.selectedBackgroundView = selectedBackgroundView; +} + + (OWSTableItem *)itemWithTitle:(NSString *)title actionBlock:(nullable OWSTableActionBlock)actionBlock { OWSAssert(title.length > 0); @@ -204,9 +213,8 @@ const CGFloat kOWSTable_DefaultCellHeight = 45.f; item.customCellBlock = ^{ UITableViewCell *cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:@"UITableViewCellStyleValue1"]; + [OWSTableItem configureCell:cell]; cell.textLabel.text = text; - cell.textLabel.font = [UIFont ows_regularFontWithSize:18.f]; - cell.textLabel.textColor = [UIColor ows_themeForegroundColor]; cell.detailTextLabel.text = detailText; [cell setAccessoryType:UITableViewCellAccessoryDisclosureIndicator]; return cell; @@ -323,7 +331,7 @@ const CGFloat kOWSTable_DefaultCellHeight = 45.f; UILabel *accessoryLabel = [UILabel new]; accessoryLabel.text = accessoryText; - accessoryLabel.textColor = [UIColor ows_themeSecondaryColor]; + accessoryLabel.textColor = [Theme secondaryColor]; accessoryLabel.font = [UIFont ows_regularFontWithSize:16.0f]; accessoryLabel.textAlignment = NSTextAlignmentRight; [accessoryLabel sizeToFit]; @@ -708,8 +716,8 @@ NSString *const kOWSTableCellIdentifier = @"kOWSTableCellIdentifier"; { OWSAssertIsOnMainThread(); - self.view.backgroundColor = UIColor.ows_themeBackgroundColor; - self.tableView.backgroundColor = UIColor.ows_themeBackgroundColor; + self.view.backgroundColor = Theme.backgroundColor; + self.tableView.backgroundColor = Theme.backgroundColor; } @end diff --git a/SignalMessaging/Views/ContactCellView.m b/SignalMessaging/Views/ContactCellView.m index dbb9d15f6..9bf165f33 100644 --- a/SignalMessaging/Views/ContactCellView.m +++ b/SignalMessaging/Views/ContactCellView.m @@ -58,18 +58,14 @@ const CGFloat kContactCellAvatarTextMargin = 12; self.nameLabel = [UILabel new]; self.nameLabel.lineBreakMode = NSLineBreakByTruncatingTail; - self.nameLabel.textColor = [UIColor blackColor]; self.profileNameLabel = [UILabel new]; self.profileNameLabel.lineBreakMode = NSLineBreakByTruncatingTail; - self.profileNameLabel.textColor = [UIColor grayColor]; self.subtitleLabel = [UILabel new]; - self.subtitleLabel.textColor = [UIColor ows_darkGrayColor]; self.accessoryLabel = [[UILabel alloc] init]; self.accessoryLabel.textAlignment = NSTextAlignmentRight; - self.accessoryLabel.textColor = [UIColor colorWithWhite:0.5f alpha:1.f]; self.accessoryViewContainer = [UIView containerView]; @@ -91,15 +87,20 @@ const CGFloat kContactCellAvatarTextMargin = 12; [self addArrangedSubview:self.nameContainerView]; [self addArrangedSubview:self.accessoryViewContainer]; - [self configureFonts]; + [self configureFontsAndColors]; } -- (void)configureFonts +- (void)configureFontsAndColors { self.nameLabel.font = [UIFont ows_dynamicTypeBodyFont]; self.profileNameLabel.font = [UIFont ows_regularFontWithSize:11.f]; self.subtitleLabel.font = [UIFont ows_regularFontWithSize:11.f]; self.accessoryLabel.font = [UIFont ows_mediumFontWithSize:13.f]; + + self.nameLabel.textColor = [Theme primaryColor]; + self.profileNameLabel.textColor = [Theme secondaryColor]; + self.subtitleLabel.textColor = [Theme secondaryColor]; + self.accessoryLabel.textColor = [UIColor colorWithWhite:0.5f alpha:1.f]; } - (void)configureWithSignalAccount:(SignalAccount *)signalAccount contactsManager:(OWSContactsManager *)contactsManager @@ -113,7 +114,7 @@ const CGFloat kContactCellAvatarTextMargin = 12; OWSAssert(contactsManager); // Update fonts to reflect changes to dynamic type. - [self configureFonts]; + [self configureFontsAndColors]; self.recipientId = recipientId; self.contactsManager = contactsManager; @@ -143,7 +144,7 @@ const CGFloat kContactCellAvatarTextMargin = 12; self.thread = thread; // Update fonts to reflect changes to dynamic type. - [self configureFonts]; + [self configureFontsAndColors]; self.contactsManager = contactsManager; @@ -155,7 +156,7 @@ const CGFloat kContactCellAvatarTextMargin = 12; NSAttributedString *attributedText = [[NSAttributedString alloc] initWithString:threadName attributes:@{ - NSForegroundColorAttributeName : [UIColor blackColor], + NSForegroundColorAttributeName : [Theme primaryColor], }]; self.nameLabel.attributedText = attributedText; diff --git a/SignalMessaging/Views/ContactTableViewCell.m b/SignalMessaging/Views/ContactTableViewCell.m index 151937bb6..606b854d6 100644 --- a/SignalMessaging/Views/ContactTableViewCell.m +++ b/SignalMessaging/Views/ContactTableViewCell.m @@ -4,6 +4,8 @@ #import "ContactTableViewCell.h" #import "ContactCellView.h" +#import "OWSTableViewController.h" +#import "UIColor+OWS.h" #import "UIFont+OWS.h" #import "UIView+OWS.h" #import @@ -44,6 +46,7 @@ NS_ASSUME_NONNULL_BEGIN self.preservesSuperviewLayoutMargins = YES; self.contentView.preservesSuperviewLayoutMargins = YES; + [OWSTableItem configureCell:self]; self.cellView = [ContactCellView new]; [self.contentView addSubview:self.cellView]; diff --git a/SignalMessaging/Views/OWSNavigationBar.swift b/SignalMessaging/Views/OWSNavigationBar.swift index cab3b561c..353ec422a 100644 --- a/SignalMessaging/Views/OWSNavigationBar.swift +++ b/SignalMessaging/Views/OWSNavigationBar.swift @@ -47,7 +47,7 @@ public class OWSNavigationBar: UINavigationBar { if !UIAccessibilityIsReduceTransparencyEnabled() { // Make navbar more translucent than default. Navbars remove alpha from any assigned backgroundColor, so // to achieve transparency, we have to assign a transparent image. - let color = UIColor.ows_navbarBackground.withAlphaComponent(OWSNavigationBar.backgroundBlurMutingFactor) + let color = Theme.navbarBackgroundColor.withAlphaComponent(OWSNavigationBar.backgroundBlurMutingFactor) let backgroundImage = UIImage(color: color) self.setBackgroundImage(backgroundImage, for: .default) let blurEffect = UIBlurEffect(style: .light) diff --git a/SignalMessaging/attachments/MessageApprovalViewController.swift b/SignalMessaging/attachments/MessageApprovalViewController.swift index df826831e..938985cb1 100644 --- a/SignalMessaging/attachments/MessageApprovalViewController.swift +++ b/SignalMessaging/attachments/MessageApprovalViewController.swift @@ -99,7 +99,7 @@ public class MessageApprovalViewController: OWSViewController, UITextViewDelegat private func createRecipientRow() -> UIView { let recipientRow = UIView.container() - recipientRow.backgroundColor = UIColor.ows_toolbarBackground + recipientRow.backgroundColor = Theme.toolbarBackgroundColor // Hairline borders should be 1 pixel, not 1 point. let borderThickness = 1.0 / UIScreen.main.scale diff --git a/SignalMessaging/categories/Theme.h b/SignalMessaging/categories/Theme.h new file mode 100644 index 000000000..6b88777e4 --- /dev/null +++ b/SignalMessaging/categories/Theme.h @@ -0,0 +1,45 @@ +// +// Copyright (c) 2018 Open Whisper Systems. All rights reserved. +// + +#import + +NS_ASSUME_NONNULL_BEGIN + +#ifdef DEBUG +#define THEME_ENABLED +#endif + +extern NSString *const NSNotificationNameThemeDidChange; + +@interface Theme : NSObject + +- (instancetype)init NS_UNAVAILABLE; + ++ (BOOL)isDarkThemeEnabled; +#ifdef THEME_ENABLED ++ (void)setIsDarkThemeEnabled:(BOOL)value; +#endif + +@property (class, readonly, nonatomic) UIColor *backgroundColor; +@property (class, readonly, nonatomic) UIColor *primaryColor; +@property (class, readonly, nonatomic) UIColor *secondaryColor; +@property (class, readonly, nonatomic) UIColor *boldColor; + +#pragma mark - Global App Colors + +@property (class, readonly, nonatomic) UIColor *navbarBackgroundColor; +@property (class, readonly, nonatomic) UIColor *navbarIconColor; +@property (class, readonly, nonatomic) UIColor *navbarTitleColor; + +@property (class, readonly, nonatomic) UIColor *toolbarBackgroundColor; + ++ (UIColor *)cellSelectedColor; + +#pragma mark - + ++ (UIBarStyle)barStyle; + +@end + +NS_ASSUME_NONNULL_END diff --git a/SignalMessaging/categories/Theme.m b/SignalMessaging/categories/Theme.m new file mode 100644 index 000000000..9a2fb9eb9 --- /dev/null +++ b/SignalMessaging/categories/Theme.m @@ -0,0 +1,113 @@ +// +// Copyright (c) 2018 Open Whisper Systems. All rights reserved. +// + +#import "Theme.h" +#import "UIColor+OWS.h" +#import "UIUtil.h" +#import +#import +#import + +NS_ASSUME_NONNULL_BEGIN + +NSString *const NSNotificationNameThemeDidChange = @"NSNotificationNameThemeDidChange"; + +NSString *const ThemeCollection = @"ThemeCollection"; +NSString *const ThemeKeyThemeEnabled = @"ThemeKeyThemeEnabled"; + +@implementation Theme + ++ (BOOL)isDarkThemeEnabled +{ + OWSAssertIsOnMainThread(); + +#ifndef THEME_ENABLED + return NO; +#else + return [OWSPrimaryStorage.sharedManager.dbReadConnection boolForKey:ThemeKeyThemeEnabled + inCollection:ThemeCollection + defaultValue:NO]; +#endif +} + ++ (void)setIsDarkThemeEnabled:(BOOL)value +{ + OWSAssertIsOnMainThread(); + + [OWSPrimaryStorage.sharedManager.dbReadWriteConnection setBool:value + forKey:ThemeKeyThemeEnabled + inCollection:ThemeCollection]; + + [UIUtil setupSignalAppearence]; + + [[NSNotificationCenter defaultCenter] postNotificationNameAsync:NSNotificationNameThemeDidChange + object:nil + userInfo:nil]; +} + ++ (UIColor *)backgroundColor +{ + return (Theme.isDarkThemeEnabled ? UIColor.ows_blackColor : UIColor.ows_whiteColor); +} + ++ (UIColor *)primaryColor +{ + // TODO: Theme, Review with design. + return (Theme.isDarkThemeEnabled ? UIColor.ows_whiteColor : UIColor.ows_light90Color); +} + ++ (UIColor *)secondaryColor +{ + // TODO: Theme, Review with design. + return (Theme.isDarkThemeEnabled ? UIColor.ows_dark60Color : UIColor.ows_light60Color); +} + ++ (UIColor *)boldColor +{ + // TODO: Review with design. + return (Theme.isDarkThemeEnabled ? UIColor.ows_whiteColor : UIColor.blackColor); +} + +#pragma mark - Global App Colors + ++ (UIColor *)navbarBackgroundColor +{ + return (Theme.isDarkThemeEnabled ? UIColor.ows_blackColor : UIColor.ows_whiteColor); +} + ++ (UIColor *)navbarIconColor +{ + // TODO: Theme, Review with design. + return (Theme.isDarkThemeEnabled ? UIColor.ows_dark60Color : UIColor.ows_light60Color); +} + ++ (UIColor *)navbarTitleColor +{ + // TODO: Theme, Review with design. + return (Theme.isDarkThemeEnabled ? UIColor.ows_dark60Color : UIColor.ows_light60Color); +} + ++ (UIColor *)toolbarBackgroundColor +{ + return self.navbarBackgroundColor; +} + ++ (UIColor *)cellSelectedColor +{ + return (Theme.isDarkThemeEnabled ? UIColor.ows_whiteColor : UIColor.ows_blackColor); +} + +#pragma mark - + ++ (UIBarStyle)barStyle +{ + if (Theme.isDarkThemeEnabled) { + return UIBarStyleBlack; + } else { + return UIBarStyleDefault; + } +} +@end + +NS_ASSUME_NONNULL_END diff --git a/SignalMessaging/categories/UIColor+OWS.h b/SignalMessaging/categories/UIColor+OWS.h index c31fb084d..621a1f0cb 100644 --- a/SignalMessaging/categories/UIColor+OWS.h +++ b/SignalMessaging/categories/UIColor+OWS.h @@ -2,24 +2,13 @@ // Copyright (c) 2018 Open Whisper Systems. All rights reserved. // +#import "Theme.h" #import NS_ASSUME_NONNULL_BEGIN -#ifdef DEBUG -#define THEME_ENABLED -#endif - -extern NSString *const NSNotificationNameThemeDidChange; - @interface UIColor (OWS) -#pragma mark - Global App Colors - -@property (class, readonly, nonatomic) UIColor *ows_navbarBackgroundColor; -@property (class, readonly, nonatomic) UIColor *ows_navbarIconColor; -@property (class, readonly, nonatomic) UIColor *ows_navbarTitleColor; - #pragma mark - @property (class, readonly, nonatomic) UIColor *ows_systemPrimaryButtonColor; @@ -35,7 +24,6 @@ extern NSString *const NSNotificationNameThemeDidChange; @property (class, readonly, nonatomic) UIColor *ows_darkIconColor; @property (class, readonly, nonatomic) UIColor *ows_errorMessageBorderColor; @property (class, readonly, nonatomic) UIColor *ows_infoMessageBorderColor; -@property (class, readonly, nonatomic) UIColor *ows_toolbarBackgroundColor; @property (class, readonly, nonatomic) UIColor *ows_messageBubbleLightGrayColor; + (UIColor *)colorWithRGBHex:(unsigned long)value; @@ -83,17 +71,6 @@ extern NSString *const NSNotificationNameThemeDidChange; @property (class, readonly, nonatomic) UIColor *ows_grey600Color; @property (class, readonly, nonatomic) UIColor *ows_darkSkyBlueColor; -#pragma mark - Theme - -+ (BOOL)isThemeEnabled; -#ifdef THEME_ENABLED -+ (void)setIsThemeEnabled:(BOOL)value; -#endif - -+ (UIColor *)ows_themeBackgroundColor; -+ (UIColor *)ows_themeForegroundColor; -+ (UIColor *)ows_themeSecondaryColor; - @end NS_ASSUME_NONNULL_END diff --git a/SignalMessaging/categories/UIColor+OWS.m b/SignalMessaging/categories/UIColor+OWS.m index bbf0c9b35..525c5e01a 100644 --- a/SignalMessaging/categories/UIColor+OWS.m +++ b/SignalMessaging/categories/UIColor+OWS.m @@ -4,40 +4,12 @@ #import "UIColor+OWS.h" #import "OWSMath.h" -#import "UIUtil.h" #import -#import -#import -#import NS_ASSUME_NONNULL_BEGIN -NSString *const NSNotificationNameThemeDidChange = @"NSNotificationNameThemeDidChange"; - -NSString *const UIColorCollection = @"UIColorCollection"; -NSString *const UIColorKeyThemeEnabled = @"UIColorKeyThemeEnabled"; - @implementation UIColor (OWS) -#pragma mark - Global App Colors - -+ (UIColor *)ows_navbarBackgroundColor -{ - return (UIColor.isThemeEnabled ? UIColor.ows_blackColor : UIColor.ows_whiteColor); -} - -+ (UIColor *)ows_navbarIconColor -{ - // TODO: Theme, Review with design. - return (UIColor.isThemeEnabled ? UIColor.ows_dark60Color : UIColor.ows_light60Color); -} - -+ (UIColor *)ows_navbarTitleColor -{ - // TODO: Theme, Review with design. - return (UIColor.isThemeEnabled ? UIColor.ows_dark60Color : UIColor.ows_light60Color); -} - #pragma mark - + (UIColor *)ows_signalBrandBlueColor @@ -103,11 +75,6 @@ NSString *const UIColorKeyThemeEnabled = @"UIColorKeyThemeEnabled"; return [UIColor colorWithRed:239.f / 255.f green:189.f / 255.f blue:88.f / 255.f alpha:1.0f]; } -+ (UIColor *)ows_toolbarBackgroundColor -{ - return self.ows_navbarBackgroundColor; -} - + (UIColor *)ows_lightBackgroundColor { return [UIColor colorWithRed:242.f / 255.f green:242.f / 255.f blue:242.f / 255.f alpha:1.f]; @@ -349,53 +316,6 @@ NSString *const UIColorKeyThemeEnabled = @"UIColorKeyThemeEnabled"; return [self.ows_conversationColorMap allKeysForObject:color].firstObject; } -#pragma mark - Theme - -+ (BOOL)isThemeEnabled -{ - OWSAssertIsOnMainThread(); - -#ifdef THEME_ENABLED - return NO; -#else - return [OWSPrimaryStorage.sharedManager.dbReadConnection boolForKey:UIColorKeyThemeEnabled - inCollection:UIColorCollection - defaultValue:NO]; -#endif -} - -+ (void)setIsThemeEnabled:(BOOL)value -{ - OWSAssertIsOnMainThread(); - - [OWSPrimaryStorage.sharedManager.dbReadWriteConnection setBool:value - forKey:UIColorKeyThemeEnabled - inCollection:UIColorCollection]; - - [UIUtil setupSignalAppearence]; - - [[NSNotificationCenter defaultCenter] postNotificationNameAsync:NSNotificationNameThemeDidChange - object:nil - userInfo:nil]; -} - -+ (UIColor *)ows_themeBackgroundColor -{ - return (UIColor.isThemeEnabled ? UIColor.ows_blackColor : UIColor.ows_whiteColor); -} - -+ (UIColor *)ows_themeForegroundColor -{ - // TODO: Theme, Review with design. - return (UIColor.isThemeEnabled ? UIColor.ows_whiteColor : UIColor.ows_light90Color); -} - -+ (UIColor *)ows_themeSecondaryColor -{ - // TODO: Theme, Review with design. - return (UIColor.isThemeEnabled ? UIColor.ows_dark60Color : UIColor.ows_light60Color); -} - @end NS_ASSUME_NONNULL_END diff --git a/SignalMessaging/categories/UIViewController+OWS.m b/SignalMessaging/categories/UIViewController+OWS.m index 208a0cad6..012b7635d 100644 --- a/SignalMessaging/categories/UIViewController+OWS.m +++ b/SignalMessaging/categories/UIViewController+OWS.m @@ -76,7 +76,7 @@ NS_ASSUME_NONNULL_BEGIN UIImage *backImage = [[UIImage imageNamed:(isRTL ? @"NavBarBackRTL" : @"NavBarBack")] imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate]; OWSAssert(backImage); [backButton setImage:backImage forState:UIControlStateNormal]; - backButton.tintColor = UIColor.ows_navbarIconColor; + backButton.tintColor = Theme.navbarIconColor; backButton.contentHorizontalAlignment = UIControlContentHorizontalAlignmentLeft; diff --git a/SignalMessaging/contacts/CountryCodeViewController.m b/SignalMessaging/contacts/CountryCodeViewController.m index e5e488d7b..0799e24e3 100644 --- a/SignalMessaging/contacts/CountryCodeViewController.m +++ b/SignalMessaging/contacts/CountryCodeViewController.m @@ -71,21 +71,22 @@ OWSAssert([PhoneNumberUtil callingCodeFromCountryCode:countryCode].length > 0); OWSAssert(![[PhoneNumberUtil callingCodeFromCountryCode:countryCode] isEqualToString:@"+0"]); - [section addItem:[OWSTableItem itemWithCustomCellBlock:^{ - UITableViewCell *cell = [UITableViewCell new]; - cell.textLabel.text = [PhoneNumberUtil countryNameFromCountryCode:countryCode]; - cell.textLabel.font = [UIFont ows_regularFontWithSize:18.f]; - cell.textLabel.textColor = [UIColor blackColor]; - - UILabel *countryCodeLabel = [UILabel new]; - countryCodeLabel.text = [PhoneNumberUtil callingCodeFromCountryCode:countryCode]; - countryCodeLabel.font = [UIFont ows_regularFontWithSize:16.f]; - countryCodeLabel.textColor = [UIColor ows_darkGrayColor]; - [countryCodeLabel sizeToFit]; - cell.accessoryView = countryCodeLabel; - - return cell; - } + [section addItem:[OWSTableItem + itemWithCustomCellBlock:^{ + UITableViewCell *cell = [OWSTableItem newCell]; + cell.textLabel.text = [PhoneNumberUtil countryNameFromCountryCode:countryCode]; + cell.textLabel.font = [UIFont ows_regularFontWithSize:18.f]; + cell.textLabel.textColor = [UIColor blackColor]; + + UILabel *countryCodeLabel = [UILabel new]; + countryCodeLabel.text = [PhoneNumberUtil callingCodeFromCountryCode:countryCode]; + countryCodeLabel.font = [UIFont ows_regularFontWithSize:16.f]; + countryCodeLabel.textColor = [UIColor ows_darkGrayColor]; + [countryCodeLabel sizeToFit]; + cell.accessoryView = countryCodeLabel; + + return cell; + } actionBlock:^{ [weakSelf countryCodeWasSelected:countryCode]; }]]; diff --git a/SignalMessaging/contacts/OWSContactsManager.m b/SignalMessaging/contacts/OWSContactsManager.m index da1d9864b..cb62e1726 100644 --- a/SignalMessaging/contacts/OWSContactsManager.m +++ b/SignalMessaging/contacts/OWSContactsManager.m @@ -762,9 +762,9 @@ NSString *const OWSContactsManagerKeyNextFullIntersectionDate = @"OWSContactsMan UIFont *boldFont = [UIFont ows_mediumFontWithSize:font.pointSize]; NSDictionary *boldFontAttributes = - @{ NSFontAttributeName : boldFont, NSForegroundColorAttributeName : [UIColor blackColor] }; + @{ NSFontAttributeName : boldFont, NSForegroundColorAttributeName : [Theme boldColor] }; NSDictionary *normalFontAttributes = - @{ NSFontAttributeName : font, NSForegroundColorAttributeName : [UIColor ows_darkGrayColor] }; + @{ NSFontAttributeName : font, NSForegroundColorAttributeName : [Theme primaryColor] }; NSDictionary *firstNameAttributes = (self.shouldSortByGivenName ? boldFontAttributes : normalFontAttributes); NSDictionary *lastNameAttributes diff --git a/SignalMessaging/contacts/SelectRecipientViewController.m b/SignalMessaging/contacts/SelectRecipientViewController.m index 8104548bf..c1c19c4c6 100644 --- a/SignalMessaging/contacts/SelectRecipientViewController.m +++ b/SignalMessaging/contacts/SelectRecipientViewController.m @@ -55,7 +55,7 @@ NSString *const kSelectRecipientViewControllerCellIdentifier = @"kSelectRecipien { [super loadView]; - self.view.backgroundColor = [UIColor whiteColor]; + self.view.backgroundColor = [Theme backgroundColor]; _contactsViewHelper = [[ContactsViewHelper alloc] initWithDelegate:self]; @@ -97,6 +97,7 @@ NSString *const kSelectRecipientViewControllerCellIdentifier = @"kSelectRecipien [_tableViewController.view autoPinEdgeToSuperviewEdge:ALEdgeBottom]; self.tableViewController.tableView.rowHeight = UITableViewAutomaticDimension; self.tableViewController.tableView.estimatedRowHeight = 60; + _tableViewController.view.backgroundColor = [Theme backgroundColor]; [self updateTableContents]; @@ -107,7 +108,7 @@ NSString *const kSelectRecipientViewControllerCellIdentifier = @"kSelectRecipien { UILabel *countryCodeLabel = [UILabel new]; countryCodeLabel.font = [UIFont ows_mediumFontWithSize:18.f]; - countryCodeLabel.textColor = [UIColor blackColor]; + countryCodeLabel.textColor = [Theme primaryColor]; countryCodeLabel.text = NSLocalizedString(@"REGISTRATION_DEFAULT_COUNTRY_NAME", @"Label for the country code field"); return countryCodeLabel; @@ -132,7 +133,7 @@ NSString *const kSelectRecipientViewControllerCellIdentifier = @"kSelectRecipien { UILabel *phoneNumberLabel = [UILabel new]; phoneNumberLabel.font = [UIFont ows_mediumFontWithSize:18.f]; - phoneNumberLabel.textColor = [UIColor blackColor]; + phoneNumberLabel.textColor = [Theme primaryColor]; phoneNumberLabel.text = NSLocalizedString(@"REGISTRATION_PHONENUMBER_BUTTON", @"Label for the phone number textfield"); return phoneNumberLabel; @@ -148,7 +149,7 @@ NSString *const kSelectRecipientViewControllerCellIdentifier = @"kSelectRecipien if (!_examplePhoneNumberLabel) { _examplePhoneNumberLabel = [UILabel new]; _examplePhoneNumberLabel.font = [self examplePhoneNumberFont]; - _examplePhoneNumberLabel.textColor = [UIColor colorWithWhite:0.5f alpha:1.f]; + _examplePhoneNumberLabel.textColor = [Theme secondaryColor]; } return _examplePhoneNumberLabel; @@ -392,7 +393,7 @@ NSString *const kSelectRecipientViewControllerCellIdentifier = @"kSelectRecipien BOOL isEnabled = [self hasValidPhoneNumber]; self.phoneNumberButton.enabled = isEnabled; [self.phoneNumberButton - setBackgroundColorsWithUpColor:(isEnabled ? [UIColor ows_signalBrandBlueColor] : [UIColor lightGrayColor])]; + setBackgroundColorsWithUpColor:(isEnabled ? [UIColor ows_signalBrandBlueColor] : [Theme secondaryColor])]; } #pragma mark - CountryCodeViewControllerDelegate @@ -457,7 +458,7 @@ NSString *const kSelectRecipientViewControllerCellIdentifier = @"kSelectRecipien SelectRecipientViewController *strongSelf = weakSelf; OWSCAssert(strongSelf); - UITableViewCell *cell = [UITableViewCell new]; + UITableViewCell *cell = [OWSTableItem newCell]; cell.preservesSuperviewLayoutMargins = YES; cell.contentView.preservesSuperviewLayoutMargins = YES; diff --git a/SignalMessaging/utils/UIUtil.m b/SignalMessaging/utils/UIUtil.m index f49452e30..d555b052d 100644 --- a/SignalMessaging/utils/UIUtil.m +++ b/SignalMessaging/utils/UIUtil.m @@ -26,12 +26,12 @@ + (void)setupSignalAppearence { - UINavigationBar.appearance.barTintColor = UIColor.ows_navbarBackgroundColor; - UINavigationBar.appearance.tintColor = UIColor.ows_navbarIconColor; - UIToolbar.appearance.barTintColor = UIColor.ows_navbarBackgroundColor; - UIToolbar.appearance.tintColor = UIColor.ows_navbarIconColor; + UINavigationBar.appearance.barTintColor = Theme.navbarBackgroundColor; + UINavigationBar.appearance.tintColor = Theme.navbarIconColor; + UIToolbar.appearance.barTintColor = Theme.navbarBackgroundColor; + UIToolbar.appearance.tintColor = Theme.navbarIconColor; - UIBarButtonItem.appearance.tintColor = UIColor.ows_navbarIconColor; + UIBarButtonItem.appearance.tintColor = Theme.navbarIconColor; // [[UIBarButtonItem appearanceWhenContainedIn:[UISearchBar class], nil] setTintColor:[UIColor // ows_materialBlueColor]]; @@ -40,7 +40,7 @@ [[UIToolbar appearance] setTintColor:[UIColor ows_materialBlueColor]]; // If we set NSShadowAttributeName, the NSForegroundColorAttributeName value is ignored. - UINavigationBar.appearance.titleTextAttributes = @{ NSForegroundColorAttributeName : UIColor.ows_navbarTitleColor }; + UINavigationBar.appearance.titleTextAttributes = @{ NSForegroundColorAttributeName : Theme.navbarTitleColor }; } @end