Refine theme.

pull/1/head
Matthew Chen 7 years ago
parent f795b12a86
commit 7759c9ca0f

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

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

@ -510,7 +510,7 @@ NS_ASSUME_NONNULL_BEGIN
OWSAssert(buttonsView.backgroundColor); OWSAssert(buttonsView.backgroundColor);
shadowView.fillColor = 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.shadowOpacity = 0.12f;
shadowView.layer.shadowOffset = CGSizeZero; shadowView.layer.shadowOffset = CGSizeZero;
shadowView.layer.shadowRadius = 1.f; shadowView.layer.shadowRadius = 1.f;

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

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

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

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

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

Loading…
Cancel
Save