Refine home view.

pull/1/head
Matthew Chen 7 years ago
parent 4a2a6362b6
commit 20d1d11259

@ -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: 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];
} }
- (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 #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);
} }
} }

@ -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: Review with design.
return (UIColor.isThemeEnabled ? UIColor.ows_dark60Color : UIColor.ows_light60Color);
} }
+ (UIColor *)ows_navbarTitleColor + (UIColor *)ows_navbarTitleColor
{ {
return UIColor.ows_light90Color; // TODO: 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: 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 @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