From 4ea5d9b8496040c2d92948b30c7098a4a4cbc490 Mon Sep 17 00:00:00 2001 From: Matthew Chen Date: Thu, 16 Aug 2018 11:31:55 -0400 Subject: [PATCH 1/3] Theme review. --- .../OWSLinkedDevicesTableViewController.m | 1 + .../src/ViewControllers/ContactsPicker.swift | 1 + .../ConversationSearchViewController.swift | 1 + .../HomeView/HomeViewController.m | 1 + .../MessageDetailViewController.swift | 4 ++-- .../ViewControllers/ContactFieldView.swift | 4 ++-- .../ViewControllers/OWSTableViewController.m | 1 + SignalMessaging/categories/Theme.h | 2 ++ SignalMessaging/categories/Theme.m | 19 +++++++++++++------ SignalMessaging/utils/ConversationStyle.swift | 11 +++++++++-- 10 files changed, 33 insertions(+), 12 deletions(-) diff --git a/Signal/src/ViewControllers/AppSettings/OWSLinkedDevicesTableViewController.m b/Signal/src/ViewControllers/AppSettings/OWSLinkedDevicesTableViewController.m index e4e1fd07a..aa3d4ed24 100644 --- a/Signal/src/ViewControllers/AppSettings/OWSLinkedDevicesTableViewController.m +++ b/Signal/src/ViewControllers/AppSettings/OWSLinkedDevicesTableViewController.m @@ -48,6 +48,7 @@ int const OWSLinkedDevicesTableViewControllerSectionAddDevice = 1; self.isExpectingMoreDevices = NO; self.tableView.rowHeight = UITableViewAutomaticDimension; self.tableView.estimatedRowHeight = 60; + self.tableView.separatorColor = Theme.hairlineColor; [self.tableView applyScrollViewInsetsFix]; diff --git a/Signal/src/ViewControllers/ContactsPicker.swift b/Signal/src/ViewControllers/ContactsPicker.swift index ada0594e0..f629c749a 100644 --- a/Signal/src/ViewControllers/ContactsPicker.swift +++ b/Signal/src/ViewControllers/ContactsPicker.swift @@ -96,6 +96,7 @@ public class ContactsPicker: OWSViewController, UITableViewDelegate, UITableView self.view = UIView() let tableView = UITableView() self.tableView = tableView + self.tableView.separatorColor = Theme.hairlineColor view.addSubview(tableView) tableView.autoPinEdgesToSuperviewEdges() diff --git a/Signal/src/ViewControllers/HomeView/ConversationSearchViewController.swift b/Signal/src/ViewControllers/HomeView/ConversationSearchViewController.swift index 324655521..59cca17fa 100644 --- a/Signal/src/ViewControllers/HomeView/ConversationSearchViewController.swift +++ b/Signal/src/ViewControllers/HomeView/ConversationSearchViewController.swift @@ -60,6 +60,7 @@ class ConversationSearchViewController: UITableViewController { tableView.rowHeight = UITableViewAutomaticDimension tableView.estimatedRowHeight = 60 + tableView.separatorColor = Theme.hairlineColor tableView.register(EmptySearchResultCell.self, forCellReuseIdentifier: EmptySearchResultCell.reuseIdentifier) tableView.register(HomeViewCell.self, forCellReuseIdentifier: HomeViewCell.cellReuseIdentifier()) diff --git a/Signal/src/ViewControllers/HomeView/HomeViewController.m b/Signal/src/ViewControllers/HomeView/HomeViewController.m index fc71b246d..b78a7fdb0 100644 --- a/Signal/src/ViewControllers/HomeView/HomeViewController.m +++ b/Signal/src/ViewControllers/HomeView/HomeViewController.m @@ -318,6 +318,7 @@ NSString *const kArchivedConversationsReuseIdentifier = @"kArchivedConversations self.tableView.delegate = self; self.tableView.dataSource = self; self.tableView.separatorStyle = UITableViewCellSeparatorStyleNone; + self.tableView.separatorColor = Theme.hairlineColor; [self.tableView registerClass:[HomeViewCell class] forCellReuseIdentifier:HomeViewCell.cellReuseIdentifier]; [self.tableView registerClass:[UITableViewCell class] forCellReuseIdentifier:kArchivedConversationsReuseIdentifier]; [self.view addSubview:self.tableView]; diff --git a/Signal/src/ViewControllers/MessageDetailViewController.swift b/Signal/src/ViewControllers/MessageDetailViewController.swift index ab3923fd2..223ab41ae 100644 --- a/Signal/src/ViewControllers/MessageDetailViewController.swift +++ b/Signal/src/ViewControllers/MessageDetailViewController.swift @@ -225,8 +225,8 @@ class MessageDetailViewController: OWSViewController, MediaGalleryDataSourceDele // TODO: It'd be nice to inset these dividers from the edge of the screen. let addDivider = { let divider = UIView() - divider.backgroundColor = Theme.secondaryColor - divider.autoSetDimension(.height, toSize: 0.5) + divider.backgroundColor = Theme.hairlineColor + divider.autoSetDimension(.height, toSize: CGHairlineWidth()) groupRows.append(divider) } diff --git a/SignalMessaging/ViewControllers/ContactFieldView.swift b/SignalMessaging/ViewControllers/ContactFieldView.swift index 98b7d6c53..2fad8696e 100644 --- a/SignalMessaging/ViewControllers/ContactFieldView.swift +++ b/SignalMessaging/ViewControllers/ContactFieldView.swift @@ -30,9 +30,9 @@ public class ContactFieldView: UIView { return } let row = UIView() - row.backgroundColor = Theme.secondaryColor + row.backgroundColor = Theme.hairlineColor self.addSubview(row) - row.autoSetDimension(.height, toSize: 1) + row.autoSetDimension(.height, toSize: CGHairlineWidth()) row.autoPinLeadingToSuperviewMargin(withInset: hMargin) row.autoPinTrailingToSuperviewMargin() row.autoPinEdge(.top, to: .bottom, of: prevRow, withOffset: 0) diff --git a/SignalMessaging/ViewControllers/OWSTableViewController.m b/SignalMessaging/ViewControllers/OWSTableViewController.m index b0b12a0a3..6a4619b37 100644 --- a/SignalMessaging/ViewControllers/OWSTableViewController.m +++ b/SignalMessaging/ViewControllers/OWSTableViewController.m @@ -721,6 +721,7 @@ NSString *const kOWSTableCellIdentifier = @"kOWSTableCellIdentifier"; self.view.backgroundColor = Theme.backgroundColor; self.tableView.backgroundColor = Theme.backgroundColor; + self.tableView.separatorColor = Theme.hairlineColor; } @end diff --git a/SignalMessaging/categories/Theme.h b/SignalMessaging/categories/Theme.h index 95cbd1343..103fc17a2 100644 --- a/SignalMessaging/categories/Theme.h +++ b/SignalMessaging/categories/Theme.h @@ -28,6 +28,8 @@ extern NSString *const ThemeDidChangeNotification; @property (class, readonly, nonatomic) UIColor *boldColor; @property (class, readonly, nonatomic) UIColor *offBackgroundColor; @property (class, readonly, nonatomic) UIColor *middleGrayColor; +@property (class, readonly, nonatomic) UIColor *placeholderColor; +@property (class, readonly, nonatomic) UIColor *hairlineColor; #pragma mark - Global App Colors diff --git a/SignalMessaging/categories/Theme.m b/SignalMessaging/categories/Theme.m index ed246518e..490477e90 100644 --- a/SignalMessaging/categories/Theme.m +++ b/SignalMessaging/categories/Theme.m @@ -64,14 +64,12 @@ NSString *const ThemeKeyThemeEnabled = @"ThemeKeyThemeEnabled"; + (UIColor *)primaryColor { - // TODO: Theme, Review with design. - return (Theme.isDarkThemeEnabled ? UIColor.ows_whiteColor : UIColor.ows_light90Color); + return (Theme.isDarkThemeEnabled ? UIColor.ows_dark05Color : UIColor.ows_light90Color); } + (UIColor *)secondaryColor { - // TODO: Theme, Review with design. - return (Theme.isDarkThemeEnabled ? UIColor.ows_dark60Color : UIColor.ows_light60Color); + return (Theme.isDarkThemeEnabled ? UIColor.ows_dark30Color : UIColor.ows_light60Color); } + (UIColor *)boldColor @@ -86,6 +84,16 @@ NSString *const ThemeKeyThemeEnabled = @"ThemeKeyThemeEnabled"; return [UIColor colorWithWhite:0.5f alpha:1.f]; } ++ (UIColor *)placeholderColor +{ + return (Theme.isDarkThemeEnabled ? UIColor.ows_light35Color : UIColor.ows_dark55Color); +} + ++ (UIColor *)hairlineColor +{ + return (Theme.isDarkThemeEnabled ? UIColor.ows_light45Color : UIColor.ows_dark60Color); +} + #pragma mark - Global App Colors + (UIColor *)navbarBackgroundColor @@ -101,8 +109,7 @@ NSString *const ThemeKeyThemeEnabled = @"ThemeKeyThemeEnabled"; + (UIColor *)navbarTitleColor { - // TODO: Theme, Review with design. - return (Theme.isDarkThemeEnabled ? UIColor.ows_dark60Color : UIColor.ows_light60Color); + return Theme.primaryColor; } + (UIColor *)toolbarBackgroundColor diff --git a/SignalMessaging/utils/ConversationStyle.swift b/SignalMessaging/utils/ConversationStyle.swift index 043713b9f..13c48594d 100644 --- a/SignalMessaging/utils/ConversationStyle.swift +++ b/SignalMessaging/utils/ConversationStyle.swift @@ -143,7 +143,10 @@ public class ConversationStyle: NSObject { return color } - private static let defaultBubbleColorIncoming = UIColor.ows_messageBubbleLightGray + @objc + private static var defaultBubbleColorIncoming: UIColor { + return Theme.isDarkThemeEnabled ? UIColor.ows_dark70 : UIColor.ows_messageBubbleLightGray + } @objc public let bubbleColorOutgoingFailed = UIColor.ows_darkSkyBlue @@ -189,7 +192,11 @@ public class ConversationStyle: NSObject { } @objc - public static var bubbleTextColorIncoming = UIColor.ows_light90 + public static var bubbleTextColorIncoming: UIColor { + return Theme.isDarkThemeEnabled ? UIColor.ows_white : UIColor.ows_light90 + } + + @objc public static var bubbleTextColorOutgoing = UIColor.ows_white @objc From d62e07d6f1ee053147e0eb09a8f2716db2196d77 Mon Sep 17 00:00:00 2001 From: Matthew Chen Date: Thu, 16 Aug 2018 16:22:31 -0400 Subject: [PATCH 2/3] Theme review. --- .../ConversationView/Cells/OWSContactShareButtonsView.m | 2 +- .../ConversationView/Cells/OWSMessageHeaderView.m | 4 ++-- .../src/ViewControllers/MenuActionsViewController.swift | 9 ++++++++- SignalMessaging/categories/Theme.m | 4 ++-- 4 files changed, 13 insertions(+), 6 deletions(-) diff --git a/Signal/src/ViewControllers/ConversationView/Cells/OWSContactShareButtonsView.m b/Signal/src/ViewControllers/ConversationView/Cells/OWSContactShareButtonsView.m index 0e3452766..a3733c3f7 100644 --- a/Signal/src/ViewControllers/ConversationView/Cells/OWSContactShareButtonsView.m +++ b/Signal/src/ViewControllers/ConversationView/Cells/OWSContactShareButtonsView.m @@ -129,7 +129,7 @@ NS_ASSUME_NONNULL_BEGIN OWSFail(@"%@ unexpected button state.", self.logTag); } label.font = OWSContactShareButtonsView.buttonFont; - label.textColor = UIColor.ows_materialBlueColor; + label.textColor = (Theme.isDarkThemeEnabled ? UIColor.ows_whiteColor : UIColor.ows_materialBlueColor); label.textAlignment = NSTextAlignmentCenter; [self addSubview:label]; [label ows_autoPinToSuperviewEdges]; diff --git a/Signal/src/ViewControllers/ConversationView/Cells/OWSMessageHeaderView.m b/Signal/src/ViewControllers/ConversationView/Cells/OWSMessageHeaderView.m index d1837ca13..9fd50d9df 100644 --- a/Signal/src/ViewControllers/ConversationView/Cells/OWSMessageHeaderView.m +++ b/Signal/src/ViewControllers/ConversationView/Cells/OWSMessageHeaderView.m @@ -116,9 +116,9 @@ const CGFloat OWSMessageHeaderViewDateHeaderVMargin = 23; OWSAssert(viewItem); if (viewItem.unreadIndicator) { - return (Theme.isDarkThemeEnabled ? UIColor.ows_dark60Color : UIColor.ows_light60Color); + return Theme.secondaryColor; } else { - return (Theme.isDarkThemeEnabled ? UIColor.ows_dark30Color : UIColor.ows_light45Color); + return Theme.hairlineColor; } } diff --git a/Signal/src/ViewControllers/MenuActionsViewController.swift b/Signal/src/ViewControllers/MenuActionsViewController.swift index f65ab1e85..59d515829 100644 --- a/Signal/src/ViewControllers/MenuActionsViewController.swift +++ b/Signal/src/ViewControllers/MenuActionsViewController.swift @@ -414,7 +414,14 @@ class MenuActionView: UIButton { isUserInteractionEnabled = true backgroundColor = defaultBackgroundColor - let imageView = UIImageView(image: action.image) + var image = action.image + if Theme.isDarkThemeEnabled { + image = image.withRenderingMode(.alwaysTemplate) + } + let imageView = UIImageView(image: image) + if Theme.isDarkThemeEnabled { + imageView.tintColor = UIColor.ows_dark30 + } let imageWidth: CGFloat = 24 imageView.autoSetDimensions(to: CGSize(width: imageWidth, height: imageWidth)) imageView.isUserInteractionEnabled = false diff --git a/SignalMessaging/categories/Theme.m b/SignalMessaging/categories/Theme.m index 490477e90..a6fd5c993 100644 --- a/SignalMessaging/categories/Theme.m +++ b/SignalMessaging/categories/Theme.m @@ -86,12 +86,12 @@ NSString *const ThemeKeyThemeEnabled = @"ThemeKeyThemeEnabled"; + (UIColor *)placeholderColor { - return (Theme.isDarkThemeEnabled ? UIColor.ows_light35Color : UIColor.ows_dark55Color); + return (Theme.isDarkThemeEnabled ? UIColor.ows_dark55Color : UIColor.ows_light35Color); } + (UIColor *)hairlineColor { - return (Theme.isDarkThemeEnabled ? UIColor.ows_light45Color : UIColor.ows_dark60Color); + return (Theme.isDarkThemeEnabled ? UIColor.ows_dark60Color : UIColor.ows_light45Color); } #pragma mark - Global App Colors From decb0c54ca7ebc5b9ed49825c2259806804b226a Mon Sep 17 00:00:00 2001 From: Matthew Chen Date: Thu, 16 Aug 2018 17:27:20 -0400 Subject: [PATCH 3/3] Theme review. --- .../ConversationInputTextView.m | 9 ++--- .../ConversationInputToolbar.m | 3 +- .../ConversationViewController.m | 2 +- .../ConversationSearchViewController.swift | 33 ++++++++++++++++++- .../AttachmentApprovalViewController.swift | 8 +++-- SignalMessaging/Views/OWSNavigationBar.swift | 1 - 6 files changed, 46 insertions(+), 10 deletions(-) diff --git a/Signal/src/ViewControllers/ConversationView/ConversationInputTextView.m b/Signal/src/ViewControllers/ConversationView/ConversationInputTextView.m index 97fdbb408..e66f5b7ba 100644 --- a/Signal/src/ViewControllers/ConversationView/ConversationInputTextView.m +++ b/Signal/src/ViewControllers/ConversationView/ConversationInputTextView.m @@ -27,8 +27,10 @@ NS_ASSUME_NONNULL_BEGIN self.delegate = self; - self.backgroundColor = (Theme.isDarkThemeEnabled ? UIColor.ows_dark95Color : UIColor.ows_light02Color); - self.layer.borderColor = [Theme.primaryColor colorWithAlphaComponent:0.12f].CGColor; + self.backgroundColor = (Theme.isDarkThemeEnabled ? UIColor.ows_dark85Color : UIColor.ows_light02Color); + self.layer.borderColor + = (Theme.isDarkThemeEnabled ? [Theme.primaryColor colorWithAlphaComponent:0.06f].CGColor + : [Theme.primaryColor colorWithAlphaComponent:0.12f].CGColor); self.layer.borderWidth = 0.5f; self.scrollIndicatorInsets = UIEdgeInsetsMake(4, 4, 4, 4); @@ -48,8 +50,7 @@ NS_ASSUME_NONNULL_BEGIN self.placeholderView = [UILabel new]; self.placeholderView.text = NSLocalizedString(@"new_message", @""); - self.placeholderView.textColor - = (Theme.isDarkThemeEnabled ? UIColor.ows_dark55Color : UIColor.ows_light35Color); + self.placeholderView.textColor = Theme.placeholderColor; self.placeholderView.userInteractionEnabled = NO; [self addSubview:self.placeholderView]; diff --git a/Signal/src/ViewControllers/ConversationView/ConversationInputToolbar.m b/Signal/src/ViewControllers/ConversationView/ConversationInputToolbar.m index e8cd6c38e..24ea27888 100644 --- a/Signal/src/ViewControllers/ConversationView/ConversationInputToolbar.m +++ b/Signal/src/ViewControllers/ConversationView/ConversationInputToolbar.m @@ -93,6 +93,7 @@ const CGFloat kMaxTextViewHeight = 98; self.backgroundColor = [Theme.toolbarBackgroundColor colorWithAlphaComponent:alpha]; UIVisualEffectView *blurEffectView = [[UIVisualEffectView alloc] initWithEffect:Theme.barBlurEffect]; + blurEffectView.layer.zPosition = -1; [self addSubview:blurEffectView]; [blurEffectView autoPinEdgesToSuperviewEdges]; } @@ -379,7 +380,7 @@ const CGFloat kMaxTextViewHeight = 98; self.voiceMemoUI = [UIView new]; self.voiceMemoUI.userInteractionEnabled = NO; - self.voiceMemoUI.backgroundColor = [UIColor whiteColor]; + self.voiceMemoUI.backgroundColor = Theme.toolbarBackgroundColor; [self addSubview:self.voiceMemoUI]; self.voiceMemoUI.frame = CGRectMake(0, 0, self.bounds.size.width, self.bounds.size.height); diff --git a/Signal/src/ViewControllers/ConversationView/ConversationViewController.m b/Signal/src/ViewControllers/ConversationView/ConversationViewController.m index 18e387b51..c92ac5727 100644 --- a/Signal/src/ViewControllers/ConversationView/ConversationViewController.m +++ b/Signal/src/ViewControllers/ConversationView/ConversationViewController.m @@ -3170,7 +3170,7 @@ typedef enum : NSUInteger { } - (void)sendQualityAdjustedAttachmentForVideo:(NSURL *)movieURL - filename:(NSString *)filename + filename:(nullable NSString *)filename skipApprovalDialog:(BOOL)skipApprovalDialog { OWSAssertIsOnMainThread(); diff --git a/Signal/src/ViewControllers/HomeView/ConversationSearchViewController.swift b/Signal/src/ViewControllers/HomeView/ConversationSearchViewController.swift index 59cca17fa..d0bd634ae 100644 --- a/Signal/src/ViewControllers/HomeView/ConversationSearchViewController.swift +++ b/Signal/src/ViewControllers/HomeView/ConversationSearchViewController.swift @@ -256,7 +256,7 @@ class ConversationSearchViewController: UITableViewController { if let messageSnippet = searchResult.snippet { overrideSnippet = NSAttributedString(string: messageSnippet, attributes: [ - NSAttributedStringKey.foregroundColor: Theme.primaryColor + NSAttributedStringKey.foregroundColor: Theme.secondaryColor ]) } else { owsFail("\(ConversationSearchViewController.logTag()) message search result is missing message snippet") @@ -277,6 +277,37 @@ class ConversationSearchViewController: UITableViewController { return 4 } + override func tableView(_ tableView: UITableView, heightForHeaderInSection section: Int) -> CGFloat { + guard let view = self.tableView(tableView, viewForHeaderInSection: section) else { + return 0 + } + return view.height() + } + + override func tableView(_ tableView: UITableView, viewForHeaderInSection section: Int) -> UIView? { + guard let title = self.tableView(tableView, titleForHeaderInSection: section) else { + return nil + } + + let label = UILabel() + label.textColor = Theme.secondaryColor + label.text = title + label.font = UIFont.ows_dynamicTypeBody.ows_mediumWeight() + label.tag = section + label.sizeToFit() + + let hMargin: CGFloat = 15 + let vMargin: CGFloat = 4 + let wrapper = UIView() + wrapper.backgroundColor = Theme.offBackgroundColor + wrapper.addSubview(label) + label.autoPinWidthToSuperview(withMargin: hMargin) + label.autoPinHeightToSuperview(withMargin: vMargin) + wrapper.frame = CGRect(x: 0, y: 0, width: label.width() + 2 * hMargin, height: label.height() + 2 * vMargin) + + return wrapper + } + override func tableView(_ tableView: UITableView, titleForHeaderInSection section: Int) -> String? { guard let searchSection = SearchSection(rawValue: section) else { owsFail("unknown section: \(section)") diff --git a/SignalMessaging/ViewControllers/AttachmentApprovalViewController.swift b/SignalMessaging/ViewControllers/AttachmentApprovalViewController.swift index 6fb65b75b..8b435fb7d 100644 --- a/SignalMessaging/ViewControllers/AttachmentApprovalViewController.swift +++ b/SignalMessaging/ViewControllers/AttachmentApprovalViewController.swift @@ -530,11 +530,15 @@ class CaptioningToolbar: UIView, UITextViewDelegate { self.backgroundColor = UIColor.clear textView.delegate = self - textView.backgroundColor = UIColor.white + textView.backgroundColor = (Theme.isDarkThemeEnabled ? UIColor.ows_dark85 : UIColor.ows_light02) + textView.layer.borderColor = (Theme.isDarkThemeEnabled + ? Theme.primaryColor.withAlphaComponent(0.06).cgColor + : Theme.primaryColor.withAlphaComponent(0.12).cgColor) + textView.layer.borderWidth = 0.5 textView.layer.cornerRadius = kMinTextViewHeight / 2 - textView.addBorder(with: UIColor.lightGray) textView.font = UIFont.ows_dynamicTypeBody + textView.textColor = Theme.primaryColor textView.returnKeyType = .done textView.textContainerInset = UIEdgeInsets(top: 7, left: 7, bottom: 7, right: 7) textView.scrollIndicatorInsets = UIEdgeInsets(top: 5, left: 0, bottom: 5, right: 3) diff --git a/SignalMessaging/Views/OWSNavigationBar.swift b/SignalMessaging/Views/OWSNavigationBar.swift index 2e55f0f2c..ff0b91786 100644 --- a/SignalMessaging/Views/OWSNavigationBar.swift +++ b/SignalMessaging/Views/OWSNavigationBar.swift @@ -98,7 +98,6 @@ public class OWSNavigationBar: UINavigationBar { // On iOS11, despite inserting the blur at 0, other views are later inserted into the navbar behind the blur, // so we have to set a zindex to avoid obscuring navbar title/buttons. blurEffectView.layer.zPosition = -1 - } }