Merge branch 'charlesmchen/refineHomeView'

pull/1/head
Matthew Chen 7 years ago
commit 3e57a4442d

@ -137,39 +137,38 @@
[weakSelf showAdvanced]; [weakSelf showAdvanced];
}]]; }]];
} else { } else {
[section addItem:[OWSTableItem itemWithCustomCellBlock:^{ [section addItem:[OWSTableItem
UITableViewCell *cell = [UITableViewCell new]; itemWithCustomCellBlock:^{
cell.textLabel.text = NSLocalizedString(@"NETWORK_STATUS_HEADER", @""); UITableViewCell *cell = [OWSTableItem newCell];
cell.textLabel.font = [UIFont ows_regularFontWithSize:18.f]; cell.textLabel.text = NSLocalizedString(@"NETWORK_STATUS_HEADER", @"");
cell.textLabel.textColor = [UIColor blackColor]; cell.selectionStyle = UITableViewCellSelectionStyleNone;
cell.selectionStyle = UITableViewCellSelectionStyleNone; UILabel *accessoryLabel = [UILabel new];
UILabel *accessoryLabel = [UILabel new]; accessoryLabel.font = [UIFont ows_regularFontWithSize:18.f];
accessoryLabel.font = [UIFont ows_regularFontWithSize:18.f]; if (TSAccountManager.sharedInstance.isDeregistered) {
if (TSAccountManager.sharedInstance.isDeregistered) { accessoryLabel.text = NSLocalizedString(@"NETWORK_STATUS_DEREGISTERED",
accessoryLabel.text = NSLocalizedString( @"Error indicating that this device is no longer registered.");
@"NETWORK_STATUS_DEREGISTERED", @"Error indicating that this device is no longer registered."); accessoryLabel.textColor = [UIColor ows_redColor];
accessoryLabel.textColor = [UIColor ows_redColor]; } else {
} else { switch ([TSSocketManager sharedManager].state) {
switch ([TSSocketManager sharedManager].state) { case SocketManagerStateClosed:
case SocketManagerStateClosed: accessoryLabel.text = NSLocalizedString(@"NETWORK_STATUS_OFFLINE", @"");
accessoryLabel.text = NSLocalizedString(@"NETWORK_STATUS_OFFLINE", @""); accessoryLabel.textColor = [UIColor ows_redColor];
accessoryLabel.textColor = [UIColor ows_redColor]; break;
break; case SocketManagerStateConnecting:
case SocketManagerStateConnecting: accessoryLabel.text = NSLocalizedString(@"NETWORK_STATUS_CONNECTING", @"");
accessoryLabel.text = NSLocalizedString(@"NETWORK_STATUS_CONNECTING", @""); accessoryLabel.textColor = [UIColor ows_yellowColor];
accessoryLabel.textColor = [UIColor ows_yellowColor]; break;
break; case SocketManagerStateOpen:
case SocketManagerStateOpen: accessoryLabel.text = NSLocalizedString(@"NETWORK_STATUS_CONNECTED", @"");
accessoryLabel.text = NSLocalizedString(@"NETWORK_STATUS_CONNECTED", @""); accessoryLabel.textColor = [UIColor ows_greenColor];
accessoryLabel.textColor = [UIColor ows_greenColor]; break;
break; }
} }
} [accessoryLabel sizeToFit];
[accessoryLabel sizeToFit]; cell.accessoryView = accessoryLabel;
cell.accessoryView = accessoryLabel; return cell;
return cell; }
} actionBlock:nil]];
actionBlock:nil]];
} }
[section addItem:[OWSTableItem disclosureItemWithText:NSLocalizedString(@"SETTINGS_INVITE_TITLE", [section addItem:[OWSTableItem disclosureItemWithText:NSLocalizedString(@"SETTINGS_INVITE_TITLE",
@ -251,7 +250,7 @@
{ {
return [OWSTableItem return [OWSTableItem
itemWithCustomCellBlock:^{ itemWithCustomCellBlock:^{
UITableViewCell *cell = [UITableViewCell new]; UITableViewCell *cell = [OWSTableItem newCell];
cell.preservesSuperviewLayoutMargins = YES; cell.preservesSuperviewLayoutMargins = YES;
cell.contentView.preservesSuperviewLayoutMargins = YES; cell.contentView.preservesSuperviewLayoutMargins = YES;
cell.selectionStyle = UITableViewCellSelectionStyleNone; cell.selectionStyle = UITableViewCellSelectionStyleNone;
@ -276,7 +275,7 @@
- (UITableViewCell *)profileHeaderCell - (UITableViewCell *)profileHeaderCell
{ {
UITableViewCell *cell = [UITableViewCell new]; UITableViewCell *cell = [OWSTableItem newCell];
cell.preservesSuperviewLayoutMargins = YES; cell.preservesSuperviewLayoutMargins = YES;
cell.contentView.preservesSuperviewLayoutMargins = YES; cell.contentView.preservesSuperviewLayoutMargins = YES;
cell.selectionStyle = UITableViewCellSelectionStyleNone; cell.selectionStyle = UITableViewCellSelectionStyleNone;
@ -316,7 +315,7 @@
NSString *_Nullable localProfileName = [OWSProfileManager.sharedManager localProfileName]; NSString *_Nullable localProfileName = [OWSProfileManager.sharedManager localProfileName];
if (localProfileName.length > 0) { if (localProfileName.length > 0) {
titleLabel.text = localProfileName; titleLabel.text = localProfileName;
titleLabel.textColor = [UIColor blackColor]; titleLabel.textColor = [UIColor ows_themeForegroundColor];
titleLabel.font = [UIFont ows_dynamicTypeTitle2Font]; titleLabel.font = [UIFont ows_dynamicTypeTitle2Font];
} else { } else {
titleLabel.text = NSLocalizedString( titleLabel.text = NSLocalizedString(
@ -331,7 +330,7 @@
const CGFloat kSubtitlePointSize = 12.f; const CGFloat kSubtitlePointSize = 12.f;
UILabel *subtitleLabel = [UILabel new]; UILabel *subtitleLabel = [UILabel new];
subtitleLabel.textColor = [UIColor ows_darkGrayColor]; subtitleLabel.textColor = [UIColor ows_themeSecondaryColor];
subtitleLabel.font = [UIFont ows_regularFontWithSize:kSubtitlePointSize]; subtitleLabel.font = [UIFont ows_regularFontWithSize:kSubtitlePointSize];
subtitleLabel.attributedText = [[NSAttributedString alloc] subtitleLabel.attributedText = [[NSAttributedString alloc]
initWithString:[PhoneNumber bestEffortFormatPartialUserSpecifiedTextToLookLikeAPhoneNumber:[TSAccountManager initWithString:[PhoneNumber bestEffortFormatPartialUserSpecifiedTextToLookLikeAPhoneNumber:[TSAccountManager

@ -61,12 +61,13 @@ NS_ASSUME_NONNULL_BEGIN
{ {
OWSAssert(!self.avatarView); OWSAssert(!self.avatarView);
self.backgroundColor = [UIColor whiteColor]; self.backgroundColor = UIColor.ows_themeBackgroundColor;
_viewConstraints = [NSMutableArray new]; _viewConstraints = [NSMutableArray new];
UIView *selectedBackgroundView = [UIView new]; UIView *selectedBackgroundView = [UIView new];
selectedBackgroundView.backgroundColor = [[UIColor colorWithRGBHex:0x000000] colorWithAlphaComponent:0.08]; selectedBackgroundView.backgroundColor =
[(UIColor.isThemeEnabled ? [UIColor ows_whiteColor] : [UIColor ows_blackColor]) colorWithAlphaComponent:0.08];
self.selectedBackgroundView = selectedBackgroundView; self.selectedBackgroundView = selectedBackgroundView;
@ -225,9 +226,9 @@ NS_ASSUME_NONNULL_BEGIN
self.dateTimeLabel.text self.dateTimeLabel.text
= (overrideDate ? [self stringForDate:overrideDate] : [self stringForDate:thread.lastMessageDate]); = (overrideDate ? [self stringForDate:overrideDate] : [self stringForDate:thread.lastMessageDate]);
UIColor *textColor = [UIColor ows_light60Color]; UIColor *textColor = [UIColor ows_themeSecondaryColor];
if (hasUnreadMessages && overrideSnippet == nil) { if (hasUnreadMessages && overrideSnippet == nil) {
textColor = [UIColor ows_light90Color]; textColor = [UIColor ows_themeForegroundColor];
self.dateTimeLabel.font = self.dateTimeFont.ows_mediumWeight; self.dateTimeLabel.font = self.dateTimeFont.ows_mediumWeight;
} else { } else {
self.dateTimeLabel.font = self.dateTimeFont; self.dateTimeLabel.font = self.dateTimeFont;
@ -273,7 +274,9 @@ NS_ASSUME_NONNULL_BEGIN
}]; }];
} else { } else {
UIImage *_Nullable statusIndicatorImage = nil; UIImage *_Nullable statusIndicatorImage = nil;
UIColor *messageStatusViewTintColor = [UIColor ows_light35Color]; // TODO: Theme, Review with design.
UIColor *messageStatusViewTintColor
= (UIColor.isThemeEnabled ? [UIColor ows_dark30Color] : [UIColor ows_light35Color]);
BOOL shouldAnimateStatusIcon = NO; BOOL shouldAnimateStatusIcon = NO;
if ([self.thread.lastMessageForInbox isKindOfClass:[TSOutgoingMessage class]]) { if ([self.thread.lastMessageForInbox isKindOfClass:[TSOutgoingMessage class]]) {
TSOutgoingMessage *outgoingMessage = (TSOutgoingMessage *)self.thread.lastMessageForInbox; TSOutgoingMessage *outgoingMessage = (TSOutgoingMessage *)self.thread.lastMessageForInbox;
@ -363,7 +366,7 @@ NS_ASSUME_NONNULL_BEGIN
@"A label for conversations with blocked users.") @"A label for conversations with blocked users.")
attributes:@{ attributes:@{
NSFontAttributeName : self.snippetFont.ows_mediumWeight, NSFontAttributeName : self.snippetFont.ows_mediumWeight,
NSForegroundColorAttributeName : [UIColor ows_light90Color], NSForegroundColorAttributeName : [UIColor ows_themeForegroundColor],
}]]; }]];
} else { } else {
if ([thread isMuted]) { if ([thread isMuted]) {
@ -371,9 +374,9 @@ NS_ASSUME_NONNULL_BEGIN
initWithString:@"\ue067 " initWithString:@"\ue067 "
attributes:@{ attributes:@{
NSFontAttributeName : [UIFont ows_elegantIconsFont:9.f], NSFontAttributeName : [UIFont ows_elegantIconsFont:9.f],
NSForegroundColorAttributeName : (hasUnreadMessages NSForegroundColorAttributeName :
? [UIColor colorWithWhite:0.1f alpha:1.f] (hasUnreadMessages ? [UIColor ows_themeForegroundColor]
: [UIColor ows_light60Color]), : [UIColor ows_themeSecondaryColor]),
}]]; }]];
} }
NSString *displayableText = thread.lastMessageText; NSString *displayableText = thread.lastMessageText;
@ -385,8 +388,8 @@ NS_ASSUME_NONNULL_BEGIN
(hasUnreadMessages ? self.snippetFont.ows_mediumWeight (hasUnreadMessages ? self.snippetFont.ows_mediumWeight
: self.snippetFont), : self.snippetFont),
NSForegroundColorAttributeName : NSForegroundColorAttributeName :
(hasUnreadMessages ? [UIColor ows_light90Color] (hasUnreadMessages ? [UIColor ows_themeForegroundColor]
: [UIColor ows_light60Color]), : [UIColor ows_themeSecondaryColor]),
}]]; }]];
} }
} }
@ -488,6 +491,7 @@ NS_ASSUME_NONNULL_BEGIN
OWSAssertIsOnMainThread(); OWSAssertIsOnMainThread();
self.nameLabel.font = self.nameFont; self.nameLabel.font = self.nameFont;
self.nameLabel.textColor = [UIColor ows_themeForegroundColor];
ThreadViewModel *thread = self.thread; ThreadViewModel *thread = self.thread;
if (thread == nil) { if (thread == nil) {

@ -172,6 +172,10 @@ NSString *const kArchivedConversationsReuseIdentifier = @"kArchivedConversations
selector:@selector(outageStateDidChange:) selector:@selector(outageStateDidChange:)
name:OutageDetection.outageStateDidChange name:OutageDetection.outageStateDidChange
object:nil]; object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(themeDidChange:)
name:NSNotificationNameThemeDidChange
object:nil];
} }
- (void)dealloc - (void)dealloc
@ -211,14 +215,30 @@ NSString *const kArchivedConversationsReuseIdentifier = @"kArchivedConversations
[self updateReminderViews]; [self updateReminderViews];
} }
#pragma mark - Theme
- (void)themeDidChange:(id)notification
{
OWSAssertIsOnMainThread();
[self applyTheme];
[self.tableView reloadData];
}
- (void)applyTheme
{
OWSAssertIsOnMainThread();
self.view.backgroundColor = UIColor.ows_themeBackgroundColor;
self.tableView.backgroundColor = UIColor.ows_themeBackgroundColor;
}
#pragma mark - View Life Cycle #pragma mark - View Life Cycle
- (void)loadView - (void)loadView
{ {
[super loadView]; [super loadView];
self.view.backgroundColor = [UIColor whiteColor];
// TODO: Remove this. // TODO: Remove this.
if (self.homeViewMode == HomeViewMode_Inbox) { if (self.homeViewMode == HomeViewMode_Inbox) {
[SignalApp.sharedApp setHomeViewController:self]; [SignalApp.sharedApp setHomeViewController:self];
@ -308,6 +328,8 @@ NSString *const kArchivedConversationsReuseIdentifier = @"kArchivedConversations
[self.tableView insertSubview:pullToRefreshView atIndex:0]; [self.tableView insertSubview:pullToRefreshView atIndex:0];
[self updateReminderViews]; [self updateReminderViews];
[self applyTheme];
} }
- (void)updateReminderViews - (void)updateReminderViews
@ -359,7 +381,13 @@ NSString *const kArchivedConversationsReuseIdentifier = @"kArchivedConversations
searchBar.searchBarStyle = UISearchBarStyleMinimal; searchBar.searchBarStyle = UISearchBarStyleMinimal;
searchBar.placeholder = NSLocalizedString(@"HOME_VIEW_CONVERSATION_SEARCHBAR_PLACEHOLDER", searchBar.placeholder = NSLocalizedString(@"HOME_VIEW_CONVERSATION_SEARCHBAR_PLACEHOLDER",
@"Placeholder text for search bar which filters conversations."); @"Placeholder text for search bar which filters conversations.");
searchBar.backgroundColor = [UIColor whiteColor]; searchBar.backgroundColor = UIColor.ows_themeBackgroundColor;
if (UIColor.isThemeEnabled) {
searchBar.barStyle = UIBarStyleBlack;
} else {
searchBar.barStyle = UIBarStyleDefault;
}
searchBar.delegate = self; searchBar.delegate = self;
[searchBar sizeToFit]; [searchBar sizeToFit];
@ -808,7 +836,7 @@ NSString *const kArchivedConversationsReuseIdentifier = @"kArchivedConversations
[subview removeFromSuperview]; [subview removeFromSuperview];
} }
cell.backgroundColor = [UIColor whiteColor]; cell.backgroundColor = UIColor.ows_themeBackgroundColor;
UIImage *disclosureImage = [UIImage imageNamed:(CurrentAppContext().isRTL ? @"NavBarBack" : @"NavBarBackRTL")]; UIImage *disclosureImage = [UIImage imageNamed:(CurrentAppContext().isRTL ? @"NavBarBack" : @"NavBarBackRTL")];
OWSAssert(disclosureImage); OWSAssert(disclosureImage);
@ -822,7 +850,7 @@ NSString *const kArchivedConversationsReuseIdentifier = @"kArchivedConversations
label.text = NSLocalizedString(@"HOME_VIEW_ARCHIVED_CONVERSATIONS", @"Label for 'archived conversations' button."); label.text = NSLocalizedString(@"HOME_VIEW_ARCHIVED_CONVERSATIONS", @"Label for 'archived conversations' button.");
label.textAlignment = NSTextAlignmentCenter; label.textAlignment = NSTextAlignmentCenter;
label.font = [UIFont ows_dynamicTypeBodyFont]; label.font = [UIFont ows_dynamicTypeBodyFont];
label.textColor = [UIColor blackColor]; label.textColor = UIColor.ows_themeForegroundColor;
UIStackView *stackView = [UIStackView new]; UIStackView *stackView = [UIStackView new];
stackView.axis = UILayoutConstraintAxisHorizontal; stackView.axis = UILayoutConstraintAxisHorizontal;
@ -1411,6 +1439,7 @@ NSString *const kArchivedConversationsReuseIdentifier = @"kArchivedConversations
- (void)updateEmptyBoxText - (void)updateEmptyBoxText
{ {
// TODO: Theme, review with design.
_emptyBoxLabel.textColor = [UIColor grayColor]; _emptyBoxLabel.textColor = [UIColor grayColor];
_emptyBoxLabel.font = [UIFont ows_regularFontWithSize:18.f]; _emptyBoxLabel.font = [UIFont ows_regularFontWithSize:18.f];
_emptyBoxLabel.textAlignment = NSTextAlignmentCenter; _emptyBoxLabel.textAlignment = NSTextAlignmentCenter;
@ -1448,10 +1477,11 @@ NSString *const kArchivedConversationsReuseIdentifier = @"kArchivedConversations
value:[UIFont ows_regularFontWithSize:14.f] value:[UIFont ows_regularFontWithSize:14.f]
range:NSMakeRange(firstLine.length + 1, secondLine.length)]; range:NSMakeRange(firstLine.length + 1, secondLine.length)];
[fullLabelString addAttribute:NSForegroundColorAttributeName [fullLabelString addAttribute:NSForegroundColorAttributeName
value:[UIColor blackColor] value:UIColor.ows_themeForegroundColor
range:NSMakeRange(0, firstLine.length)]; range:NSMakeRange(0, firstLine.length)];
// TODO: Theme, Review with design.
[fullLabelString addAttribute:NSForegroundColorAttributeName [fullLabelString addAttribute:NSForegroundColorAttributeName
value:[UIColor ows_darkGrayColor] value:UIColor.ows_themeSecondaryColor
range:NSMakeRange(firstLine.length + 1, secondLine.length)]; range:NSMakeRange(firstLine.length + 1, secondLine.length)];
_emptyBoxLabel.attributedText = fullLabelString; _emptyBoxLabel.attributedText = fullLabelString;
} }

@ -121,7 +121,7 @@ NS_ASSUME_NONNULL_BEGIN
// Status bar is overlaying the green "call banner" // Status bar is overlaying the green "call banner"
return UIStatusBarStyleLightContent; return UIStatusBarStyleLightContent;
} else { } else {
return super.preferredStatusBarStyle; return (UIColor.isThemeEnabled ? UIStatusBarStyleLightContent : super.preferredStatusBarStyle);
} }
} }

@ -52,6 +52,8 @@ typedef UITableViewCell *_Nonnull (^OWSTableCustomCellBlock)(void);
@property (nonatomic, weak) UIViewController *tableViewController; @property (nonatomic, weak) UIViewController *tableViewController;
+ (UITableViewCell *)newCell;
+ (OWSTableItem *)itemWithTitle:(NSString *)title actionBlock:(nullable OWSTableActionBlock)actionBlock; + (OWSTableItem *)itemWithTitle:(NSString *)title actionBlock:(nullable OWSTableActionBlock)actionBlock;
+ (OWSTableItem *)itemWithCustomCell:(UITableViewCell *)customCell + (OWSTableItem *)itemWithCustomCell:(UITableViewCell *)customCell

@ -4,6 +4,7 @@
#import "OWSTableViewController.h" #import "OWSTableViewController.h"
#import "OWSNavigationController.h" #import "OWSNavigationController.h"
#import "UIColor+OWS.h"
#import "UIFont+OWS.h" #import "UIFont+OWS.h"
#import "UIView+OWS.h" #import "UIView+OWS.h"
@ -97,6 +98,15 @@ const CGFloat kOWSTable_DefaultCellHeight = 45.f;
@implementation OWSTableItem @implementation OWSTableItem
+ (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];
return cell;
}
+ (OWSTableItem *)itemWithTitle:(NSString *)title actionBlock:(nullable OWSTableActionBlock)actionBlock + (OWSTableItem *)itemWithTitle:(NSString *)title actionBlock:(nullable OWSTableActionBlock)actionBlock
{ {
OWSAssert(title.length > 0); OWSAssert(title.length > 0);
@ -163,10 +173,8 @@ const CGFloat kOWSTable_DefaultCellHeight = 45.f;
OWSTableItem *item = [OWSTableItem new]; OWSTableItem *item = [OWSTableItem new];
item.actionBlock = actionBlock; item.actionBlock = actionBlock;
item.customCellBlock = ^{ item.customCellBlock = ^{
UITableViewCell *cell = [UITableViewCell new]; UITableViewCell *cell = [OWSTableItem newCell];
cell.textLabel.text = text; cell.textLabel.text = text;
cell.textLabel.font = [UIFont ows_regularFontWithSize:18.f];
cell.textLabel.textColor = [UIColor blackColor];
cell.accessoryType = accessoryType; cell.accessoryType = accessoryType;
return cell; return cell;
}; };
@ -198,7 +206,7 @@ const CGFloat kOWSTable_DefaultCellHeight = 45.f;
reuseIdentifier:@"UITableViewCellStyleValue1"]; reuseIdentifier:@"UITableViewCellStyleValue1"];
cell.textLabel.text = text; cell.textLabel.text = text;
cell.textLabel.font = [UIFont ows_regularFontWithSize:18.f]; cell.textLabel.font = [UIFont ows_regularFontWithSize:18.f];
cell.textLabel.textColor = [UIColor blackColor]; cell.textLabel.textColor = [UIColor ows_themeForegroundColor];
cell.detailTextLabel.text = detailText; cell.detailTextLabel.text = detailText;
[cell setAccessoryType:UITableViewCellAccessoryDisclosureIndicator]; [cell setAccessoryType:UITableViewCellAccessoryDisclosureIndicator];
return cell; return cell;
@ -223,10 +231,8 @@ const CGFloat kOWSTable_DefaultCellHeight = 45.f;
} }
}; };
item.customCellBlock = ^{ item.customCellBlock = ^{
UITableViewCell *cell = [UITableViewCell new]; UITableViewCell *cell = [OWSTableItem newCell];
cell.textLabel.text = text; cell.textLabel.text = text;
cell.textLabel.font = [UIFont ows_regularFontWithSize:18.f];
cell.textLabel.textColor = [UIColor blackColor];
cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator; cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
return cell; return cell;
}; };
@ -252,10 +258,8 @@ const CGFloat kOWSTable_DefaultCellHeight = 45.f;
OWSTableItem *item = [OWSTableItem new]; OWSTableItem *item = [OWSTableItem new];
item.actionBlock = actionBlock; item.actionBlock = actionBlock;
item.customCellBlock = ^{ item.customCellBlock = ^{
UITableViewCell *cell = [UITableViewCell new]; UITableViewCell *cell = [OWSTableItem newCell];
cell.textLabel.text = text; cell.textLabel.text = text;
cell.textLabel.font = [UIFont ows_regularFontWithSize:18.f];
cell.textLabel.textColor = [UIColor blackColor];
return cell; return cell;
}; };
return item; return item;
@ -267,13 +271,14 @@ const CGFloat kOWSTable_DefaultCellHeight = 45.f;
OWSTableItem *item = [OWSTableItem new]; OWSTableItem *item = [OWSTableItem new];
item.customCellBlock = ^{ item.customCellBlock = ^{
UITableViewCell *cell = [UITableViewCell new]; UITableViewCell *cell = [OWSTableItem newCell];
cell.textLabel.text = text; cell.textLabel.text = text;
// These cells look quite different. // These cells look quite different.
// //
// Smaller font. // Smaller font.
cell.textLabel.font = [UIFont ows_regularFontWithSize:15.f]; cell.textLabel.font = [UIFont ows_regularFontWithSize:15.f];
// Soft color. // Soft color.
// TODO: Theme, review with design.
cell.textLabel.textColor = [UIColor colorWithWhite:0.5f alpha:1.f]; cell.textLabel.textColor = [UIColor colorWithWhite:0.5f alpha:1.f];
// Centered. // Centered.
cell.textLabel.textAlignment = NSTextAlignmentCenter; cell.textLabel.textAlignment = NSTextAlignmentCenter;
@ -298,10 +303,8 @@ const CGFloat kOWSTable_DefaultCellHeight = 45.f;
OWSTableItem *item = [OWSTableItem new]; OWSTableItem *item = [OWSTableItem new];
item.customCellBlock = ^{ item.customCellBlock = ^{
UITableViewCell *cell = [UITableViewCell new]; UITableViewCell *cell = [OWSTableItem newCell];
cell.textLabel.text = text; cell.textLabel.text = text;
cell.textLabel.font = [UIFont ows_regularFontWithSize:18.f];
cell.textLabel.textColor = [UIColor blackColor];
cell.userInteractionEnabled = NO; cell.userInteractionEnabled = NO;
return cell; return cell;
}; };
@ -315,14 +318,12 @@ const CGFloat kOWSTable_DefaultCellHeight = 45.f;
OWSTableItem *item = [OWSTableItem new]; OWSTableItem *item = [OWSTableItem new];
item.customCellBlock = ^{ item.customCellBlock = ^{
UITableViewCell *cell = [UITableViewCell new]; UITableViewCell *cell = [OWSTableItem newCell];
cell.textLabel.text = text; cell.textLabel.text = text;
cell.textLabel.font = [UIFont ows_regularFontWithSize:18.f];
cell.textLabel.textColor = [UIColor blackColor];
UILabel *accessoryLabel = [UILabel new]; UILabel *accessoryLabel = [UILabel new];
accessoryLabel.text = accessoryText; accessoryLabel.text = accessoryText;
accessoryLabel.textColor = [UIColor lightGrayColor]; accessoryLabel.textColor = [UIColor ows_themeSecondaryColor];
accessoryLabel.font = [UIFont ows_regularFontWithSize:16.0f]; accessoryLabel.font = [UIFont ows_regularFontWithSize:16.0f];
accessoryLabel.textAlignment = NSTextAlignmentRight; accessoryLabel.textAlignment = NSTextAlignmentRight;
[accessoryLabel sizeToFit]; [accessoryLabel sizeToFit];
@ -352,10 +353,8 @@ const CGFloat kOWSTable_DefaultCellHeight = 45.f;
OWSTableItem *item = [OWSTableItem new]; OWSTableItem *item = [OWSTableItem new];
__weak id weakTarget = target; __weak id weakTarget = target;
item.customCellBlock = ^{ item.customCellBlock = ^{
UITableViewCell *cell = [UITableViewCell new]; UITableViewCell *cell = [OWSTableItem newCell];
cell.textLabel.text = text; cell.textLabel.text = text;
cell.textLabel.font = [UIFont ows_regularFontWithSize:18.f];
cell.textLabel.textColor = [UIColor blackColor];
UISwitch *cellSwitch = [UISwitch new]; UISwitch *cellSwitch = [UISwitch new];
cell.accessoryView = cellSwitch; cell.accessoryView = cellSwitch;
@ -460,6 +459,18 @@ NSString *const kOWSTableCellIdentifier = @"kOWSTableCellIdentifier";
[self.tableView autoPinEdgesToSuperviewEdges]; [self.tableView autoPinEdgesToSuperviewEdges];
[self.tableView registerClass:[UITableViewCell class] forCellReuseIdentifier:kOWSTableCellIdentifier]; [self.tableView registerClass:[UITableViewCell class] forCellReuseIdentifier:kOWSTableCellIdentifier];
[self applyTheme];
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(themeDidChange:)
name:NSNotificationNameThemeDidChange
object:nil];
}
- (void)dealloc
{
[[NSNotificationCenter defaultCenter] removeObserver:self];
} }
- (void)viewWillAppear:(BOOL)animated - (void)viewWillAppear:(BOOL)animated
@ -672,6 +683,24 @@ NSString *const kOWSTableCellIdentifier = @"kOWSTableCellIdentifier";
[self.delegate tableViewWillBeginDragging]; [self.delegate tableViewWillBeginDragging];
} }
#pragma mark - Theme
- (void)themeDidChange:(id)notification
{
OWSAssertIsOnMainThread();
[self applyTheme];
[self.tableView reloadData];
}
- (void)applyTheme
{
OWSAssertIsOnMainThread();
self.view.backgroundColor = UIColor.ows_themeBackgroundColor;
self.tableView.backgroundColor = UIColor.ows_themeBackgroundColor;
}
@end @end
NS_ASSUME_NONNULL_END NS_ASSUME_NONNULL_END

@ -10,6 +10,8 @@ NS_ASSUME_NONNULL_BEGIN
#define THEME_ENABLED #define THEME_ENABLED
#endif #endif
extern NSString *const NSNotificationNameThemeDidChange;
@interface UIColor (OWS) @interface UIColor (OWS)
#pragma mark - Global App Colors #pragma mark - Global App Colors
@ -88,6 +90,10 @@ NS_ASSUME_NONNULL_BEGIN
+ (void)setIsThemeEnabled:(BOOL)value; + (void)setIsThemeEnabled:(BOOL)value;
#endif #endif
+ (UIColor *)ows_themeBackgroundColor;
+ (UIColor *)ows_themeForegroundColor;
+ (UIColor *)ows_themeSecondaryColor;
@end @end
NS_ASSUME_NONNULL_END NS_ASSUME_NONNULL_END

@ -4,12 +4,16 @@
#import "OWSMath.h" #import "OWSMath.h"
#import "UIColor+OWS.h" #import "UIColor+OWS.h"
#import "UIUtil.h"
#import <SignalServiceKit/Cryptography.h> #import <SignalServiceKit/Cryptography.h>
#import <SignalServiceKit/NSNotificationCenter+OWS.h>
#import <SignalServiceKit/OWSPrimaryStorage.h> #import <SignalServiceKit/OWSPrimaryStorage.h>
#import <SignalServiceKit/YapDatabaseConnection+OWS.h> #import <SignalServiceKit/YapDatabaseConnection+OWS.h>
NS_ASSUME_NONNULL_BEGIN NS_ASSUME_NONNULL_BEGIN
NSString *const NSNotificationNameThemeDidChange = @"NSNotificationNameThemeDidChange";
NSString *const UIColorCollection = @"UIColorCollection"; NSString *const UIColorCollection = @"UIColorCollection";
NSString *const UIColorKeyThemeEnabled = @"UIColorKeyThemeEnabled"; NSString *const UIColorKeyThemeEnabled = @"UIColorKeyThemeEnabled";
@ -19,17 +23,19 @@ NSString *const UIColorKeyThemeEnabled = @"UIColorKeyThemeEnabled";
+ (UIColor *)ows_navbarBackgroundColor + (UIColor *)ows_navbarBackgroundColor
{ {
return UIColor.ows_whiteColor; return (UIColor.isThemeEnabled ? UIColor.ows_blackColor : UIColor.ows_whiteColor);
} }
+ (UIColor *)ows_navbarIconColor + (UIColor *)ows_navbarIconColor
{ {
return UIColor.ows_light60Color; // TODO: Theme, Review with design.
return (UIColor.isThemeEnabled ? UIColor.ows_dark60Color : UIColor.ows_light60Color);
} }
+ (UIColor *)ows_navbarTitleColor + (UIColor *)ows_navbarTitleColor
{ {
return UIColor.ows_light90Color; // TODO: Theme, Review with design.
return (UIColor.isThemeEnabled ? UIColor.ows_dark60Color : UIColor.ows_light60Color);
} }
#pragma mark - #pragma mark -
@ -361,6 +367,29 @@ NSString *const UIColorKeyThemeEnabled = @"UIColorKeyThemeEnabled";
[OWSPrimaryStorage.sharedManager.dbReadWriteConnection setBool:value [OWSPrimaryStorage.sharedManager.dbReadWriteConnection setBool:value
forKey:UIColorKeyThemeEnabled forKey:UIColorKeyThemeEnabled
inCollection:UIColorCollection]; 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 @end

@ -15,7 +15,6 @@
NS_ASSUME_NONNULL_BEGIN NS_ASSUME_NONNULL_BEGIN
NSString *const kNSNotificationName_BlockedPhoneNumbersDidChange = @"kNSNotificationName_BlockedPhoneNumbersDidChange"; NSString *const kNSNotificationName_BlockedPhoneNumbersDidChange = @"kNSNotificationName_BlockedPhoneNumbersDidChange";
extern NSString *const kNSNotificationName_BlockedPhoneNumbersDidChange;
NSString *const kOWSBlockingManager_BlockedPhoneNumbersCollection = @"kOWSBlockingManager_BlockedPhoneNumbersCollection"; NSString *const kOWSBlockingManager_BlockedPhoneNumbersCollection = @"kOWSBlockingManager_BlockedPhoneNumbersCollection";
// This key is used to persist the current "blocked phone numbers" state. // This key is used to persist the current "blocked phone numbers" state.

Loading…
Cancel
Save