Refine theme.

This commit is contained in:
Matthew Chen 2018-07-23 15:36:39 -04:00
parent f795b12a86
commit 7759c9ca0f
8 changed files with 66 additions and 23 deletions

View File

@ -46,7 +46,6 @@ NS_ASSUME_NONNULL_BEGIN
self.layoutConstraints = @[];
self.titleLabel = [UILabel new];
self.titleLabel.textColor = [UIColor ows_light60Color];
self.titleLabel.text = NSLocalizedString(@"CONVERSATION_VIEW_CONTACTS_OFFER_TITLE",
@"Title for the group of buttons show for unknown contacts offering to add them to contacts, etc.");
self.titleLabel.lineBreakMode = NSLineBreakByTruncatingTail;
@ -98,9 +97,7 @@ NS_ASSUME_NONNULL_BEGIN
{
UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
[button setTitle:title forState:UIControlStateNormal];
[button setTitleColor:[UIColor ows_signalBlueColor] forState:UIControlStateNormal];
button.titleLabel.textAlignment = NSTextAlignmentCenter;
[button setBackgroundColor:[UIColor ows_light02Color]];
button.layer.cornerRadius = 4.f;
[button addTarget:self action:selector forControlEvents:UIControlEventTouchUpInside];
return button;
@ -118,8 +115,21 @@ NS_ASSUME_NONNULL_BEGIN
OWSAssert(self.viewItem);
OWSAssert([self.viewItem.interaction isKindOfClass:[OWSContactOffersInteraction class]]);
// [OWSTableItem configureCell:self];
self.backgroundColor = [Theme backgroundColor];
[self configureFonts];
self.titleLabel.textColor = Theme.secondaryColor;
for (UIButton *button in @[
self.addToContactsButton,
self.addToProfileWhitelistButton,
self.blockButton,
]) {
[button setTitleColor:[UIColor ows_signalBlueColor] forState:UIControlStateNormal];
[button setBackgroundColor:Theme.conversationButtonBackgroundColor];
}
OWSContactOffersInteraction *interaction = (OWSContactOffersInteraction *)self.viewItem.interaction;
OWSAssert(

View File

@ -113,7 +113,7 @@ NS_ASSUME_NONNULL_BEGIN
OWSAssert([OWSContactShareButtonsView hasAnyButton:self.contactShare contactsManager:self.contactsManager]);
self.layoutMargins = UIEdgeInsetsZero;
self.backgroundColor = [UIColor ows_light02Color];
self.backgroundColor = Theme.conversationButtonBackgroundColor;
UILabel *label = [UILabel new];
self.buttonView = label;

View File

@ -510,7 +510,7 @@ NS_ASSUME_NONNULL_BEGIN
OWSAssert(buttonsView.backgroundColor);
shadowView.fillColor = buttonsView.backgroundColor;
shadowView.layer.shadowColor = [UIColor blackColor].CGColor;
shadowView.layer.shadowColor = Theme.boldColor.CGColor;
shadowView.layer.shadowOpacity = 0.12f;
shadowView.layer.shadowOffset = CGSizeZero;
shadowView.layer.shadowRadius = 1.f;

View File

@ -53,12 +53,10 @@ const CGFloat OWSMessageHeaderViewDateHeaderVMargin = 23;
[self.strokeView setContentHuggingHigh];
self.titleLabel = [UILabel new];
self.titleLabel.textColor = [UIColor ows_light90Color];
self.titleLabel.textAlignment = NSTextAlignmentCenter;
self.titleLabel.lineBreakMode = NSLineBreakByTruncatingTail;
self.subtitleLabel = [UILabel new];
self.subtitleLabel.textColor = [UIColor ows_light90Color];
// The subtitle may wrap to a second line.
self.subtitleLabel.numberOfLines = 0;
self.subtitleLabel.lineBreakMode = NSLineBreakByWordWrapping;
@ -81,6 +79,9 @@ const CGFloat OWSMessageHeaderViewDateHeaderVMargin = 23;
OWSAssert(conversationStyle);
OWSAssert(viewItem.unreadIndicator || viewItem.shouldShowDate);
self.titleLabel.textColor = Theme.primaryColor;
self.subtitleLabel.textColor = Theme.primaryColor;
[self configureLabelsWithViewItem:viewItem];
CGFloat strokeThickness = [self strokeThicknessWithViewItem:viewItem];
@ -115,9 +116,9 @@ const CGFloat OWSMessageHeaderViewDateHeaderVMargin = 23;
OWSAssert(viewItem);
if (viewItem.unreadIndicator) {
return UIColor.ows_light60Color;
return (Theme.isDarkThemeEnabled ? UIColor.ows_dark60Color : UIColor.ows_light60Color);
} else {
return UIColor.ows_light45Color;
return (Theme.isDarkThemeEnabled ? UIColor.ows_dark30Color : UIColor.ows_light45Color);
}
}

View File

@ -76,7 +76,6 @@ typedef void (^SystemMessageActionBlock)(void);
self.layoutMargins = UIEdgeInsetsZero;
self.contentView.layoutMargins = UIEdgeInsetsZero;
self.contentView.backgroundColor = UIColor.whiteColor;
self.layoutConstraints = @[];
self.headerView = [OWSMessageHeaderView new];
@ -103,7 +102,6 @@ typedef void (^SystemMessageActionBlock)(void);
self.button = [UIButton buttonWithType:UIButtonTypeCustom];
[self.button setTitleColor:[UIColor ows_darkSkyBlueColor] forState:UIControlStateNormal];
self.button.titleLabel.textAlignment = NSTextAlignmentCenter;
[self.button setBackgroundColor:[UIColor ows_light02Color]];
self.button.layer.cornerRadius = 4.f;
[self.button addTarget:self action:@selector(buttonWasPressed:) forControlEvents:UIControlEventTouchUpInside];
[self.button autoSetDimension:ALDimensionHeight toSize:self.buttonHeight];
@ -164,6 +162,8 @@ typedef void (^SystemMessageActionBlock)(void);
OWSAssert(self.viewItem);
OWSAssert(transaction);
[self.button setBackgroundColor:Theme.conversationButtonBackgroundColor];
TSInteraction *interaction = self.viewItem.interaction;
self.action = [self actionForInteraction:interaction];
@ -219,14 +219,14 @@ typedef void (^SystemMessageActionBlock)(void);
- (UIColor *)textColor
{
return [UIColor ows_light60Color];
return Theme.secondaryColor;
}
- (UIColor *)iconColorForInteraction:(TSInteraction *)interaction
{
// "Phone", "Shield" and "Hourglass" icons have a lot of "ink" so they
// are less dark for balance.
return [UIColor ows_light60Color];
return Theme.secondaryColor;
}
- (nullable UIImage *)iconForInteraction:(TSInteraction *)interaction

View File

@ -234,6 +234,7 @@ typedef enum : NSUInteger {
@property (nonatomic) ContactShareViewHelper *contactShareViewHelper;
@property (nonatomic) NSTimer *reloadTimer;
@property (nonatomic, nullable) NSDate *lastReloadDate;
@property (nonatomic) BOOL didChangeTheme;
@end
@ -352,6 +353,10 @@ typedef enum : NSUInteger {
selector:@selector(keyboardWillChangeFrame:)
name:UIKeyboardWillChangeFrameNotification
object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(themeDidChange:)
name:ThemeDidChangeNotification
object:nil];
}
- (BOOL)isGroupConversation
@ -560,14 +565,7 @@ typedef enum : NSUInteger {
[self addNotificationListeners];
[self loadDraftInCompose];
}
- (void)loadView
{
[super loadView];
// make sure toolbar extends below iPhoneX home button.
self.view.backgroundColor = Theme.toolbarBackgroundColor;
[self applyTheme];
}
- (void)createContents
@ -589,7 +587,6 @@ typedef enum : NSUInteger {
self.collectionView.showsVerticalScrollIndicator = YES;
self.collectionView.showsHorizontalScrollIndicator = NO;
self.collectionView.keyboardDismissMode = UIScrollViewKeyboardDismissModeInteractive;
self.collectionView.backgroundColor = [UIColor whiteColor];
[self.view addSubview:self.collectionView];
[self.collectionView autoPinEdgesToSuperviewEdges];
@ -1188,6 +1185,13 @@ typedef enum : NSUInteger {
[self becomeFirstResponder];
}
}
if (self.didChangeTheme) {
self.didChangeTheme = NO;
[self applyTheme];
[self.collectionView reloadData];
}
}
// `viewWillDisappear` is called whenever the view *starts* to disappear,
@ -4243,6 +4247,26 @@ typedef enum : NSUInteger {
}
}
- (void)themeDidChange:(NSNotification *)notification
{
OWSAssertIsOnMainThread();
[self applyTheme];
[self.collectionView reloadData];
self.didChangeTheme = YES;
}
- (void)applyTheme
{
OWSAssertIsOnMainThread();
// make sure toolbar extends below iPhoneX home button.
self.view.backgroundColor = Theme.toolbarBackgroundColor;
self.collectionView.backgroundColor = Theme.backgroundColor;
[self updateNavigationBarSubtitleLabel];
}
- (void)attachmentApproval:(AttachmentApprovalViewController *)attachmentApproval didApproveAttachment:(SignalAttachment * _Nonnull)attachment
{
[self sendMessageAttachment:attachment];

View File

@ -34,7 +34,9 @@ extern NSString *const ThemeDidChangeNotification;
@property (class, readonly, nonatomic) UIColor *toolbarBackgroundColor;
+ (UIColor *)cellSelectedColor;
@property (class, readonly, nonatomic) UIColor *conversationButtonBackgroundColor;
@property (class, readonly, nonatomic) UIColor *cellSelectedColor;
#pragma mark -

View File

@ -96,6 +96,11 @@ NSString *const ThemeKeyThemeEnabled = @"ThemeKeyThemeEnabled";
return (Theme.isDarkThemeEnabled ? UIColor.ows_whiteColor : UIColor.ows_blackColor);
}
+ (UIColor *)conversationButtonBackgroundColor
{
return (Theme.isDarkThemeEnabled ? UIColor.ows_dark05Color : UIColor.ows_light02Color);
}
#pragma mark -
+ (UIBarStyle)barStyle
@ -106,6 +111,7 @@ NSString *const ThemeKeyThemeEnabled = @"ThemeKeyThemeEnabled";
return UIBarStyleDefault;
}
}
@end
NS_ASSUME_NONNULL_END