From b7dd51438ef6623c2e59ebe45ca80c9ba0612298 Mon Sep 17 00:00:00 2001 From: Michael Kirk Date: Wed, 13 Jul 2016 14:34:44 -0700 Subject: [PATCH] Move colors into style class // FREEBIE --- Signal/src/UIColor+OWS.h | 10 +--- Signal/src/UIColor+OWS.m | 48 ++++++++++++------- .../view controllers/MessagesViewController.m | 10 ++-- 3 files changed, 35 insertions(+), 33 deletions(-) diff --git a/Signal/src/UIColor+OWS.h b/Signal/src/UIColor+OWS.h index 4df424fa6..6e68a2938 100644 --- a/Signal/src/UIColor+OWS.h +++ b/Signal/src/UIColor+OWS.h @@ -11,21 +11,15 @@ @interface UIColor (OWS) + (UIColor *)ows_materialBlueColor; - + (UIColor *)ows_fadedBlueColor; - + (UIColor *)ows_darkBackgroundColor; - + (UIColor *)ows_darkGrayColor; - + (UIColor *)ows_yellowColor; - + (UIColor *)ows_greenColor; - + (UIColor *)ows_redColor; - + (UIColor *)ows_blackColor; - ++ (UIColor *)ows_errorMessageBorderColor; ++ (UIColor *)ows_infoMessageBorderColor; + (UIColor *)backgroundColorForContact:(NSString *)contactIdentifier; @end diff --git a/Signal/src/UIColor+OWS.m b/Signal/src/UIColor+OWS.m index c77496644..299d14a0d 100644 --- a/Signal/src/UIColor+OWS.m +++ b/Signal/src/UIColor+OWS.m @@ -1,61 +1,74 @@ -// -// UIColor+UIColor_OWS.m -// Signal -// // Created by Dylan Bourgeois on 25/11/14. // Copyright (c) 2014 Open Whisper Systems. All rights reserved. -// #import "Cryptography.h" #import "UIColor+OWS.h" @implementation UIColor (OWS) - -+ (UIColor *)ows_materialBlueColor { ++ (UIColor *)ows_materialBlueColor +{ // blue: #2090EA return [UIColor colorWithRed:32.f / 255.f green:144.f / 255.f blue:234.f / 255.f alpha:1.f]; } -+ (UIColor *)ows_blackColor { ++ (UIColor *)ows_blackColor +{ // black: #080A00 return [UIColor colorWithRed:8.f / 255.f green:10.f / 255.f blue:0. / 255.f alpha:1.f]; } - -+ (UIColor *)ows_darkGrayColor { ++ (UIColor *)ows_darkGrayColor +{ return [UIColor colorWithRed:81.f / 255.f green:81.f / 255.f blue:81.f / 255.f alpha:1.f]; } -+ (UIColor *)ows_darkBackgroundColor { ++ (UIColor *)ows_darkBackgroundColor +{ return [UIColor colorWithRed:35.f / 255.f green:31.f / 255.f blue:32.f / 255.f alpha:1.f]; } -+ (UIColor *)ows_fadedBlueColor { ++ (UIColor *)ows_fadedBlueColor +{ // blue: #B6DEF4 return [UIColor colorWithRed:182.f / 255.f green:222.f / 255.f blue:244.f / 255.f alpha:1.f]; } -+ (UIColor *)ows_yellowColor { ++ (UIColor *)ows_yellowColor +{ // gold: #FFBB5C return [UIColor colorWithRed:245.f / 255.f green:186.f / 255.f blue:98.f / 255.f alpha:1.f]; } -+ (UIColor *)ows_greenColor { ++ (UIColor *)ows_greenColor +{ // green: #BF4240 return [UIColor colorWithRed:66.f / 255.f green:191.f / 255.f blue:64.f / 255.f alpha:1.f]; } -+ (UIColor *)ows_redColor { ++ (UIColor *)ows_redColor +{ // red: #FF3867 return [UIColor colorWithRed:255. / 255.f green:56.f / 255.f blue:103.f / 255.f alpha:1.f]; } -+ (UIColor *)ows_lightBackgroundColor { ++ (UIColor *)ows_errorMessageBorderColor +{ + return [UIColor colorWithRed:195.f / 255.f green:0 blue:22.f / 255.f alpha:1.0f]; +} + ++ (UIColor *)ows_infoMessageBorderColor +{ + return [UIColor colorWithRed:239.f / 255.f green:189.f / 255.f blue:88.f / 255.f alpha:1.0f]; +} + ++ (UIColor *)ows_lightBackgroundColor +{ return [UIColor colorWithRed:242.f / 255.f green:242.f / 255.f blue:242.f / 255.f alpha:1.f]; } -+ (UIColor *)backgroundColorForContact:(NSString *)contactIdentifier { ++ (UIColor *)backgroundColorForContact:(NSString *)contactIdentifier +{ NSArray *colors = @[ [UIColor colorWithRed:204.f / 255.f green:148.f / 255.f blue:102.f / 255.f alpha:1.f], [UIColor colorWithRed:187.f / 255.f green:104.f / 255.f blue:62.f / 255.f alpha:1.f], @@ -88,5 +101,4 @@ return [colors objectAtIndex:(choose % [colors count])]; } - @end diff --git a/Signal/src/view controllers/MessagesViewController.m b/Signal/src/view controllers/MessagesViewController.m index c27e9fcef..1f3c9e906 100644 --- a/Signal/src/view controllers/MessagesViewController.m +++ b/Signal/src/view controllers/MessagesViewController.m @@ -837,9 +837,7 @@ typedef enum : NSUInteger { } callCell.cellLabel.attributedText = attributedText; callCell.cellLabel.numberOfLines = 0; // uses as many lines as it needs - - // TODO is this a constant somewhere else already? - callCell.cellLabel.textColor = [UIColor colorWithRed:32.f/255.f green:144.f/255.f blue:234.f/255.f alpha:1.f]; + callCell.cellLabel.textColor = [UIColor ows_materialBlueColor]; callCell.layer.shouldRasterize = YES; callCell.layer.rasterizationScale = [UIScreen mainScreen].scale; @@ -854,8 +852,7 @@ typedef enum : NSUInteger { infoCell.cellLabel.text = [infoMessage text]; infoCell.cellLabel.textColor = [UIColor darkGrayColor]; - // TODO is this a constant somewhere else already? - infoCell.textContainer.layer.borderColor = [[UIColor colorWithRed:239.f/255.f green:189.f/255.f blue:88.f/255.f alpha:1.0f] CGColor]; + infoCell.textContainer.layer.borderColor = infoCell.textContainer.layer.borderColor = [[UIColor ows_infoMessageBorderColor] CGColor]; infoCell.headerImageView.image = [UIImage imageNamed:@"warning_white"]; infoCell.layer.shouldRasterize = YES; infoCell.layer.rasterizationScale = [UIScreen mainScreen].scale; @@ -869,8 +866,7 @@ typedef enum : NSUInteger { errorCell.cellLabel.text = [errorMessage text]; errorCell.cellLabel.textColor = [UIColor darkGrayColor]; - // TODO is this a constant somewhere else already? - errorCell.textContainer.layer.borderColor = [[UIColor colorWithRed:195.f/255.f green:0 blue:22.f/255.f alpha:1.0f] CGColor]; + errorCell.textContainer.layer.borderColor = [[UIColor ows_errorMessageBorderColor] CGColor]; errorCell.headerImageView.image = [UIImage imageNamed:@"error_white"]; errorCell.layer.shouldRasterize = YES; errorCell.layer.rasterizationScale = [UIScreen mainScreen].scale;