Refine home view.

This commit is contained in:
Matthew Chen 2018-07-12 17:45:29 -04:00
parent 4a2a6362b6
commit 20d1d11259
6 changed files with 91 additions and 23 deletions

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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