From ce630eef61d4acd8f5c4e1d6a3a60780c5ec4af3 Mon Sep 17 00:00:00 2001 From: Vitaly Takmazov Date: Wed, 18 Dec 2013 05:53:29 +0400 Subject: cleanup and ios6 fixes --- Juick/AppDelegate.m | 10 +++---- Juick/ColorScheme.h | 17 ++++++++++++ Juick/ColorScheme.m | 36 ++++++++++++++++++++++++++ Juick/ColorsAndButtons.h | 20 -------------- Juick/ColorsAndButtons.m | 50 ----------------------------------- Juick/Juick-Info.plist | 16 ++++++------ Juick/Juick-Prefix.pch | 1 + Juick/Juick.ipa | Bin 0 -> 1052917 bytes Juick/MessageCell.m | 28 +++++++++++++------- Juick/MessagesViewController.m | 32 ++++++++++------------- Juick/NavCell.h | 14 ++++++++++ Juick/NavCell.m | 53 ++++++++++++++++++++++++++++++++++++++ Juick/RevealPanelViewController.m | 53 +++++++++++++++++++++++--------------- Juick/UIImage+Crop.h | 15 ----------- Juick/UIImage+Crop.m | 28 -------------------- 15 files changed, 198 insertions(+), 175 deletions(-) create mode 100644 Juick/ColorScheme.h create mode 100644 Juick/ColorScheme.m delete mode 100644 Juick/ColorsAndButtons.h delete mode 100644 Juick/ColorsAndButtons.m create mode 100644 Juick/Juick.ipa create mode 100644 Juick/NavCell.h create mode 100644 Juick/NavCell.m delete mode 100644 Juick/UIImage+Crop.h delete mode 100644 Juick/UIImage+Crop.m (limited to 'Juick') diff --git a/Juick/AppDelegate.m b/Juick/AppDelegate.m index a776b43..7ccaf13 100644 --- a/Juick/AppDelegate.m +++ b/Juick/AppDelegate.m @@ -11,7 +11,7 @@ #import "RevealPanelViewController.h" #import "SWRevealViewController.h" -#import "ColorsAndButtons.h" +#import "ColorScheme.h" #import "Message.h" @implementation AppDelegate @@ -20,10 +20,10 @@ { // style the navigation bar if (NSFoundationVersionNumber > NSFoundationVersionNumber_iOS_6_1) { - [[UINavigationBar appearance] setBarTintColor:[ColorsAndButtons navbarBackground]]; - } - [[UINavigationBar appearance] setTintColor:[ColorsAndButtons navbarFont]]; - [[UINavigationBar appearance] setTitleTextAttributes:@{NSForegroundColorAttributeName: [ColorsAndButtons navbarFont]}]; + [[UINavigationBar appearance] setBarTintColor:[ColorScheme navbarBackground]]; + [[UINavigationBar appearance] setTintColor:[ColorScheme navbarFont]]; + [[UINavigationBar appearance] setTitleTextAttributes:@{NSForegroundColorAttributeName: [ColorScheme navbarFont]}]; + } // make the status bar white [UIApplication sharedApplication].statusBarStyle = UIStatusBarStyleLightContent; diff --git a/Juick/ColorScheme.h b/Juick/ColorScheme.h new file mode 100644 index 0000000..275962c --- /dev/null +++ b/Juick/ColorScheme.h @@ -0,0 +1,17 @@ +// +// Colors.h +// Juick +// +// Created by Vitaly Takmazov on 05.11.13. +// Copyright (c) 2013 com.juick. All rights reserved. +// + +#import + +@interface ColorScheme : NSObject + ++(UIColor *) navbarBackground; ++(UIColor *) mainBackground; ++(UIColor *) navbarFont; ++(UIColor *) linkColor; +@end diff --git a/Juick/ColorScheme.m b/Juick/ColorScheme.m new file mode 100644 index 0000000..257cc72 --- /dev/null +++ b/Juick/ColorScheme.m @@ -0,0 +1,36 @@ +// +// Colors.m +// Juick +// +// Created by Vitaly Takmazov on 05.11.13. +// Copyright (c) 2013 com.juick. All rights reserved. +// + +#import "ColorScheme.h" + +@implementation ColorScheme + ++ (void) initialize +{ + [super initialize]; +} + + ++ (UIColor *) mainBackground { + return [UIColor colorWithRed:238/255.0f green:238/255.0f blue:229/255.0f alpha:1.0f]; +} + ++ (UIColor *) linkColor { + return [UIColor colorWithRed:0/255.0f green:102/255.0f blue:153/255.0f alpha:1.0f]; +} + ++ (UIColor *) navbarBackground { + return [UIColor colorWithRed:51/255.0f green:51/255.0f blue:51/255.0f alpha:1.0f]; +} + ++ (UIColor *) navbarFont { + return [UIColor colorWithRed:153/255.0f green:154/255.0f blue:153/255.0f alpha:1.0f]; +} + + +@end diff --git a/Juick/ColorsAndButtons.h b/Juick/ColorsAndButtons.h deleted file mode 100644 index 260bff1..0000000 --- a/Juick/ColorsAndButtons.h +++ /dev/null @@ -1,20 +0,0 @@ -// -// Colors.h -// Juick -// -// Created by Vitaly Takmazov on 05.11.13. -// Copyright (c) 2013 com.juick. All rights reserved. -// - -#import - -@interface ColorsAndButtons : NSObject - -+(UIColor *) navbarBackground; -+(UIColor *) mainBackground; -+(UIColor *) navbarFont; -+(UIColor *) linkColor; -+(UIImage *) homeImage; -+(UIImage *) discoverImage; -+(UIImage *) logo; -@end diff --git a/Juick/ColorsAndButtons.m b/Juick/ColorsAndButtons.m deleted file mode 100644 index c99707d..0000000 --- a/Juick/ColorsAndButtons.m +++ /dev/null @@ -1,50 +0,0 @@ -// -// Colors.m -// Juick -// -// Created by Vitaly Takmazov on 05.11.13. -// Copyright (c) 2013 com.juick. All rights reserved. -// - -#import "ColorsAndButtons.h" -#import "UIImage+Crop.h" - -UIImage *buttons; - -@implementation ColorsAndButtons - -+ (void) initialize -{ - [super initialize]; - buttons = [UIImage imageNamed:@"buttons.png"]; -} - - -+ (UIColor *) mainBackground { - return [UIColor colorWithRed:238/255.0f green:238/255.0f blue:229/255.0f alpha:1.0f]; -} - -+ (UIColor *) linkColor { - return [UIColor colorWithRed:0/255.0f green:102/255.0f blue:153/255.0f alpha:1.0f]; -} - -+ (UIColor *) navbarBackground { - return [UIColor colorWithRed:51/255.0f green:51/255.0f blue:51/255.0f alpha:1]; -} - -+ (UIColor *) navbarFont { - return [UIColor colorWithRed:153/255.0f green:154/255.0f blue:153/255.0f alpha:1]; -} - -+(UIImage *) homeImage { - return [buttons crop:CGRectMake(142, 0, 32, 32)]; -} -+ (UIImage *) discoverImage { - return [buttons crop:CGRectMake(174, 0, 32, 32)]; -} - -+ (UIImage *) logo { - return [buttons crop:CGRectMake(0, 0, 109, 32)]; -} - -@end diff --git a/Juick/Juick-Info.plist b/Juick/Juick-Info.plist index 2f29b33..33830ba 100644 --- a/Juick/Juick-Info.plist +++ b/Juick/Juick-Info.plist @@ -17,15 +17,21 @@ CFBundlePackageType APPL CFBundleShortVersionString - 1.0.1 + 1.0.4 CFBundleSignature ???? CFBundleVersion - 1.0.1 + 1.0.4 LSApplicationCategoryType public.app-category.social-networking LSRequiresIPhoneOS + NSHumanReadableCopyright + + UIAppFonts + + FontAwesome.ttf + UIPrerenderedIcon UIRequiredDeviceCapabilities @@ -48,12 +54,6 @@ UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight - UIAppFonts - - FontAwesome.ttf - - NSHumanReadableCopyright - UIViewControllerBasedStatusBarAppearance diff --git a/Juick/Juick-Prefix.pch b/Juick/Juick-Prefix.pch index 1bd0628..ad49a41 100644 --- a/Juick/Juick-Prefix.pch +++ b/Juick/Juick-Prefix.pch @@ -16,4 +16,5 @@ #import #import #define MAS_SHORTHAND + #import "Masonry.h" #endif diff --git a/Juick/Juick.ipa b/Juick/Juick.ipa new file mode 100644 index 0000000..e3ffdbf Binary files /dev/null and b/Juick/Juick.ipa differ diff --git a/Juick/MessageCell.m b/Juick/MessageCell.m index 3f06436..0dea69a 100644 --- a/Juick/MessageCell.m +++ b/Juick/MessageCell.m @@ -7,9 +7,8 @@ // #import "MessageCell.h" -#import "ColorsAndButtons.h" -#import "Masonry.h" -#import "JMImageCache.h" +#import "ColorScheme.h" +#import @interface MessageCell () @@ -23,7 +22,7 @@ { self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]; if (self) { - [self setBackgroundColor:[UIColor whiteColor]]; + [self.contentView setBackgroundColor:[UIColor whiteColor]]; self.avatar = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 32, 32)]; [self.avatar setBackgroundColor:[UIColor clearColor]]; @@ -31,7 +30,7 @@ [self.titleLabel setLineBreakMode:NSLineBreakByTruncatingTail]; [self.titleLabel setNumberOfLines:1]; [self.titleLabel setTextAlignment:NSTextAlignmentLeft]; - [self.titleLabel setTextColor:[ColorsAndButtons linkColor]]; + [self.titleLabel setTextColor:[ColorScheme linkColor]]; [self.titleLabel setBackgroundColor:[UIColor clearColor]]; self.timestampLabel = [[UILabel alloc] initWithFrame:CGRectZero]; @@ -105,19 +104,16 @@ make.left.equalTo(self.avatar.right).with.offset(padding.left); make.top.equalTo(self.titleLabel.bottom).with.offset(padding.top /2); make.right.equalTo(self.contentView.right).with.offset(-padding.right); - make.bottom.equalTo(self.bodyLabel.top).with.offset(-padding.bottom); }]; [self.bodyLabel makeConstraints:^(MASConstraintMaker *make) { make.left.equalTo(self.contentView.left).with.offset(padding.left); make.top.equalTo(self.timestampLabel.bottom).with.offset(padding.top); make.right.equalTo(self.contentView.right).with.offset(-padding.right); - make.bottom.equalTo(self.attach.top).with.offset(-padding.bottom); }]; [self.attach makeConstraints:^(MASConstraintMaker *make) { make.left.equalTo(self.contentView.left).with.offset(padding.left); - make.bottom.equalTo(self.summaryLabel.top).with.offset(-padding.bottom); make.right.equalTo(self.contentView.right).with.offset(-padding.right); make.top.equalTo(self.bodyLabel.bottom).with.offset(padding.top); }]; @@ -147,7 +143,7 @@ - (void) bind:(Message *)msg { [self.avatar setImageWithURL:[NSURL URLWithString:[NSString stringWithFormat:@"http://i.juick.com/as/%d.png", [msg.userID intValue]]]]; - + __weak MessageCell *weakSelf = self; self.titleLabel.text = msg.user; self.timestampLabel.text = msg.timestamp; if (msg.repliesCount > 0) { @@ -165,10 +161,22 @@ [msg.text stringByDecodingHTMLEntities]]; } if ([msg.attach length] > 0) { - [self.attach setImageWithURL:[NSURL URLWithString:msg.attach] key:[NSString stringWithFormat:@"%d", [msg.MID intValue]] placeholder:[UIImage imageNamed:@"AttachPlaceholder.png"]]; + [self.attach setImageWithURL:[NSURL URLWithString:msg.attach] placeholderImage:[UIImage imageNamed:@"AttachPlaceholder.png"] options:SDWebImageContinueInBackground + progress:^(NSUInteger receivedSize, long long expectedSize) { + // <#code#> + } completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType) { + [weakSelf setNeedsUpdateConstraints]; + [weakSelf updateConstraintsIfNeeded]; + [weakSelf.contentView setNeedsLayout]; + [weakSelf.contentView layoutIfNeeded]; + }]; } else { self.attach.image = nil; } + [weakSelf setNeedsUpdateConstraints]; + [weakSelf updateConstraintsIfNeeded]; + [weakSelf.contentView setNeedsLayout]; + [weakSelf.contentView layoutIfNeeded]; } - (void) attributedLabel:(TTTAttributedLabel *)label didSelectLinkWithURL:(NSURL *)url { diff --git a/Juick/MessagesViewController.m b/Juick/MessagesViewController.m index 4361148..b77901b 100644 --- a/Juick/MessagesViewController.m +++ b/Juick/MessagesViewController.m @@ -12,7 +12,7 @@ #import "MessageCell.h" #import "Message.h" -#import "ColorsAndButtons.h" +#import "ColorScheme.h" #import "NewPostViewController.h" @@ -80,14 +80,20 @@ static NSString *CellIdentifier = @"MessageCell"; { [super viewDidLoad]; self.dataLoading = NO; - [self.view setBackgroundColor:[ColorsAndButtons mainBackground]]; + [self.view setBackgroundColor:[ColorScheme mainBackground]]; self.messages = [NSMutableArray array]; UIRefreshControl *refresh = [[UIRefreshControl alloc] init]; [refresh addTarget:self action:@selector(refreshData:) forControlEvents:UIControlEventValueChanged]; self.refreshControl = refresh; - - //UINib *cellNib = [UINib nibWithNibName:@"MessageCell" bundle:nil]; - //[self.tableView registerNib:cellNib forCellReuseIdentifier:@"MessageCell"]; + SWRevealViewController *revealController = [self revealViewController]; + if (revealController) { + // TODO: add to thread view too + [self.view addGestureRecognizer:[revealController panGestureRecognizer]]; + } + if (NSFoundationVersionNumber <= NSFoundationVersionNumber_iOS_6_1) { + self.navigationController.navigationBar.tintColor = [ColorScheme navbarBackground]; + } + [self.tableView registerClass:[MessageCell class] forCellReuseIdentifier:CellIdentifier]; } @@ -142,14 +148,10 @@ static NSString *CellIdentifier = @"MessageCell"; } - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { - MessageCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath]; + MessageCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier]; [cell updateFonts]; Message *msg = [_messages objectAtIndex:indexPath.row]; [cell bind:msg]; - [cell setNeedsUpdateConstraints]; - [cell updateConstraintsIfNeeded]; - [cell.contentView setNeedsLayout]; - [cell.contentView layoutIfNeeded]; cell.bodyLabel.preferredMaxLayoutWidth = CGRectGetWidth(cell.bodyLabel.frame); [cell.contentView layoutIfNeeded]; @@ -166,12 +168,6 @@ static NSString *CellIdentifier = @"MessageCell"; [cell bind:msg]; - [cell setNeedsUpdateConstraints]; - [cell updateConstraintsIfNeeded]; - - [cell.contentView setNeedsLayout]; - [cell.contentView layoutIfNeeded]; - cell.bodyLabel.preferredMaxLayoutWidth = CGRectGetWidth(cell.bodyLabel.frame); [cell.contentView layoutIfNeeded]; @@ -182,9 +178,9 @@ static NSString *CellIdentifier = @"MessageCell"; - (CGFloat)tableView:(UITableView *)tableView estimatedHeightForRowAtIndexPath:(NSIndexPath *)indexPath { - if (self.dataLoading) { + /* if (self.dataLoading) { return [self tableView:tableView heightForRowAtIndexPath:indexPath]; - } + }*/ return 500.0f; } diff --git a/Juick/NavCell.h b/Juick/NavCell.h new file mode 100644 index 0000000..50eec8d --- /dev/null +++ b/Juick/NavCell.h @@ -0,0 +1,14 @@ +// +// NavCell.h +// Juick +// +// Created by Vitaly on 17.12.13. +// Copyright (c) 2013 com.juick. All rights reserved. +// + +#import + +@interface NavCell : UITableViewCell +@property (strong, nonatomic) IBOutlet UILabel *iconLabel; +@property (strong, nonatomic) IBOutlet UILabel *descriptionTextLabel; +@end diff --git a/Juick/NavCell.m b/Juick/NavCell.m new file mode 100644 index 0000000..0b16e43 --- /dev/null +++ b/Juick/NavCell.m @@ -0,0 +1,53 @@ +// +// NavCell.m +// Juick +// +// Created by Vitaly on 17.12.13. +// Copyright (c) 2013 com.juick. All rights reserved. +// + +#import "NavCell.h" + +@interface NavCell () + +@property (nonatomic, assign) BOOL didSetupConstraints; + +@end + +@implementation NavCell + +- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier +{ + self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]; + if (self) { + self.backgroundColor = [UIColor blackColor]; + self.iconLabel = [[UILabel alloc] initWithFrame:CGRectZero]; + self.descriptionTextLabel = [[UILabel alloc] initWithFrame:CGRectZero]; + [self.contentView addSubview:self.iconLabel]; + [self.contentView addSubview:self.descriptionTextLabel]; + } + return self; +} + +- (void)updateConstraints { + [super updateConstraints]; + + if (self.didSetupConstraints) return; + [self.iconLabel makeConstraints:^(MASConstraintMaker *make) { + make.left.equalTo(self.contentView.left).with.offset(20.f); + make.top.equalTo(self.contentView.top).with.offset(10.f); + make.width.equalTo(@36); + make.height.equalTo(@36); + + }]; + + [self.descriptionTextLabel makeConstraints:^(MASConstraintMaker *make) { + make.left.equalTo(self.iconLabel.right).with.offset(10.f); + make.top.equalTo(self.contentView.top).with.offset(15.f); + make.right.equalTo(self.contentView.right).with.offset(-20.f); + }]; + + self.didSetupConstraints = YES; +} + +@end diff --git a/Juick/RevealPanelViewController.m b/Juick/RevealPanelViewController.m index ecac5df..a9c71e8 100644 --- a/Juick/RevealPanelViewController.m +++ b/Juick/RevealPanelViewController.m @@ -11,8 +11,13 @@ #import "RevealPanelViewController.h" #import "MessagesViewController.h" -#import "ColorsAndButtons.h" +#import "ColorScheme.h" #import "NSURL+PathParameters.h" +#import "NavCell.h" + + + +static NSString *CellIdentifier = @"NavCell"; @interface RevealPanelViewController () @@ -32,11 +37,15 @@ - (void)viewDidLoad { [super viewDidLoad]; - [self.navigationController.navigationBar.topItem - setTitleView:[[UIImageView alloc] initWithImage:[ColorsAndButtons logo]]]; - [self.view setBackgroundColor:[ColorsAndButtons navbarBackground]]; + self.title = @"Juick"; + + if (NSFoundationVersionNumber <= NSFoundationVersionNumber_iOS_6_1) { + self.navigationController.navigationBar.tintColor = [ColorScheme navbarBackground]; + } + [self.view setBackgroundColor:[ColorScheme navbarBackground]]; self.tableView.separatorStyle = UITableViewCellSeparatorStyleNone; self.tableView.separatorColor =[UIColor blackColor]; + [self.tableView registerClass:[NavCell class] forCellReuseIdentifier:CellIdentifier]; } - (void)didReceiveMemoryWarning @@ -55,30 +64,32 @@ } - (UITableViewCell *) tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { - static NSString *cellIdentifier = @"MenuCell"; - UITableViewCell * cell = [tableView dequeueReusableCellWithIdentifier:cellIdentifier]; + NavCell * cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath]; NSInteger row = indexPath.row; - if (cell == nil) { - cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleValue2 reuseIdentifier:cellIdentifier]; - [cell setBackgroundColor:[ColorsAndButtons navbarBackground]]; - cell.textLabel.font = [UIFont fontWithName:kFontAwesomeFamilyName size:20.f]; - cell.textLabel.textColor = [ColorsAndButtons navbarFont]; - cell.detailTextLabel.textColor = [ColorsAndButtons navbarFont]; - } + [cell.contentView setBackgroundColor:[ColorScheme navbarBackground]]; + cell.iconLabel.font = [UIFont fontWithName:kFontAwesomeFamilyName size:32.f]; + cell.iconLabel.textColor = [ColorScheme navbarFont]; + cell.iconLabel.backgroundColor = [ColorScheme navbarBackground]; + cell.descriptionTextLabel.backgroundColor = [ColorScheme navbarBackground]; + cell.descriptionTextLabel.textColor = [ColorScheme navbarFont]; if (row == 0) { - cell.detailTextLabel.text = @"My feed"; - cell.textLabel.text = [NSString fontAwesomeIconStringForEnum:FAIconHome]; + cell.descriptionTextLabel.text = @"My feed"; + cell.iconLabel.text = [NSString fontAwesomeIconStringForEnum:FAIconHome]; } else if (row == 1) { - cell.detailTextLabel.text = @"Popular"; - cell.textLabel.text = [NSString fontAwesomeIconStringForEnum:FAIconComments]; + cell.descriptionTextLabel.text = @"Popular"; + cell.iconLabel.text = [NSString fontAwesomeIconStringForEnum:FAIconComments]; } else if (row == 2) { - cell.detailTextLabel.text = @"Discover"; - cell.textLabel.text = [NSString fontAwesomeIconStringForEnum:FAIconSearch]; + cell.descriptionTextLabel.text = @"Discover"; + cell.iconLabel.text = [NSString fontAwesomeIconStringForEnum:FAIconSearch]; } else if (row == 3) { - cell.detailTextLabel.text = @"Images"; - cell.textLabel.text = [NSString fontAwesomeIconStringForEnum:FAIconPicture]; + cell.descriptionTextLabel.text = @"Images"; + cell.iconLabel.text = [NSString fontAwesomeIconStringForEnum:FAIconPicture]; } + [cell setNeedsUpdateConstraints]; + [cell updateConstraintsIfNeeded]; + [cell.contentView setNeedsLayout]; + [cell.contentView layoutIfNeeded]; return cell; } diff --git a/Juick/UIImage+Crop.h b/Juick/UIImage+Crop.h deleted file mode 100644 index 4eeaed2..0000000 --- a/Juick/UIImage+Crop.h +++ /dev/null @@ -1,15 +0,0 @@ -// -// UIImage+Crop.h -// Juick -// -// Created by Vitaly Takmazov on 05.11.13. -// Copyright (c) 2013 com.juick. All rights reserved. -// - -#import - -@interface UIImage (Crop) - -- (UIImage *)crop:(CGRect)rect; - -@end diff --git a/Juick/UIImage+Crop.m b/Juick/UIImage+Crop.m deleted file mode 100644 index d51b94e..0000000 --- a/Juick/UIImage+Crop.m +++ /dev/null @@ -1,28 +0,0 @@ -// -// UIImage+Crop.m -// Juick -// -// Created by Vitaly Takmazov on 05.11.13. -// Copyright (c) 2013 com.juick. All rights reserved. -// - -#import "UIImage+Crop.h" - -@implementation UIImage (Crop) - -- (UIImage *)crop:(CGRect)rect { - - rect = CGRectMake(rect.origin.x*self.scale, - rect.origin.y*self.scale, - rect.size.width*self.scale, - rect.size.height*self.scale); - - CGImageRef imageRef = CGImageCreateWithImageInRect([self CGImage], rect); - UIImage *result = [UIImage imageWithCGImage:imageRef - scale:self.scale - orientation:self.imageOrientation]; - CGImageRelease(imageRef); - return result; -} - -@end -- cgit v1.2.3