From e32c85b7650c0869a2aa319111a837ede75669d1 Mon Sep 17 00:00:00 2001 From: Vitaly Takmazov Date: Sun, 14 Aug 2016 02:55:21 +0300 Subject: new navcell layout --- Juick/AppDelegate.h | 1 - Juick/Juick-Prefix.pch | 1 - Juick/NavCell.h | 16 ------------ Juick/NavCell.m | 43 --------------------------------- Juick/RevealPanelViewController.h | 2 -- Juick/RevealPanelViewController.m | 30 +++++++++++------------ Juick/TitleView.h | 19 --------------- Juick/TitleView.m | 37 ---------------------------- Juick/UILabel+Utils.h | 15 ------------ Juick/UILabel+Utils.m | 16 ------------ Juick/Views/NavCell.h | 14 +++++++++++ Juick/Views/NavCell.m | 24 ++++++++++++++++++ Juick/Views/NavCell.xib | 51 +++++++++++++++++++++++++++++++++++++++ 13 files changed, 103 insertions(+), 166 deletions(-) delete mode 100644 Juick/NavCell.h delete mode 100644 Juick/NavCell.m delete mode 100644 Juick/TitleView.h delete mode 100644 Juick/TitleView.m delete mode 100644 Juick/UILabel+Utils.h delete mode 100644 Juick/UILabel+Utils.m create mode 100644 Juick/Views/NavCell.h create mode 100644 Juick/Views/NavCell.m create mode 100644 Juick/Views/NavCell.xib (limited to 'Juick') diff --git a/Juick/AppDelegate.h b/Juick/AppDelegate.h index 561f7ee..c0a7650 100644 --- a/Juick/AppDelegate.h +++ b/Juick/AppDelegate.h @@ -8,7 +8,6 @@ #import #import "User.h" -#import "TitleView.h" @class SWRevealViewController; diff --git a/Juick/Juick-Prefix.pch b/Juick/Juick-Prefix.pch index a0abcee..bd31eac 100644 --- a/Juick/Juick-Prefix.pch +++ b/Juick/Juick-Prefix.pch @@ -18,7 +18,6 @@ #import #import "NSString+HTML.h" #import "UIImage+Utils.h" - #import "UILabel+Utils.h" #import "NSDate+TimeAgo.h" #import "TTTAttributedLabel.h" #endif diff --git a/Juick/NavCell.h b/Juick/NavCell.h deleted file mode 100644 index e210636..0000000 --- a/Juick/NavCell.h +++ /dev/null @@ -1,16 +0,0 @@ -// -// NavCell.h -// Juick -// -// Created by Vitaly on 17.12.13. -// Copyright (c) 2013 com.juick. All rights reserved. -// - -#import - -#import "UILabel+Utils.h" - -@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 deleted file mode 100644 index 8cd460a..0000000 --- a/Juick/NavCell.m +++ /dev/null @@ -1,43 +0,0 @@ -// -// 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.iconLabel = [[UILabel alloc] initWithFrame:CGRectZero]; - self.descriptionTextLabel = [[UILabel alloc] initWithFrame:CGRectZero]; - self.descriptionTextLabel.numberOfLines = 1; - self.descriptionTextLabel.textAlignment = NSTextAlignmentLeft; - [self.contentView addSubview:self.iconLabel]; - [self.contentView addSubview:self.descriptionTextLabel]; - } - return self; -} - -- (void)layoutSubviews { - [super layoutSubviews]; - - CGRect iconRect = [UILabel sizeForLabel:self.iconLabel width:36.0f]; - self.iconLabel.frame = CGRectMake(10, 10, iconRect.size.width, iconRect.size.height); - float textHeight = [UILabel sizeForLabel:self.descriptionTextLabel width:self.contentView.bounds.size.width].size.height; - self.descriptionTextLabel.frame = CGRectMake(10 + self.iconLabel.frame.size.width + 10, 10 + (iconRect.size.height - textHeight) / 2, - self.contentView.bounds.size.width - self.iconLabel.frame.size.width - 10*3, textHeight); -} - -@end diff --git a/Juick/RevealPanelViewController.h b/Juick/RevealPanelViewController.h index 89f87e9..0300274 100644 --- a/Juick/RevealPanelViewController.h +++ b/Juick/RevealPanelViewController.h @@ -9,11 +9,9 @@ #import #import #import "LoginViewController.h" -#import "TitleView.h" #import @interface RevealPanelViewController : UIViewController @property (nonatomic, strong) IBOutlet UITableView *tableView; @property (nonatomic, strong) IBOutlet UIButton *signButton; -@property(nonatomic, strong) IBOutlet TitleView *titleView; @end diff --git a/Juick/RevealPanelViewController.m b/Juick/RevealPanelViewController.m index fe44509..b79ceff 100644 --- a/Juick/RevealPanelViewController.m +++ b/Juick/RevealPanelViewController.m @@ -50,13 +50,11 @@ static NSString *CellIdentifier = @"NavCell"; [self.tableView setSeparatorInset:UIEdgeInsetsZero]; self.tableView.separatorStyle = UITableViewCellSeparatorStyleSingleLine; self.tableView.separatorColor =[UIColor darkGrayColor]; - [self.tableView registerClass:[NavCell class] forCellReuseIdentifier:CellIdentifier]; + [self.tableView registerNib:[UINib nibWithNibName:@"NavCell" bundle:nil] forCellReuseIdentifier:CellIdentifier]; [self.view addSubview:self.tableView]; self.signButton = [[UIButton alloc] init]; [self.signButton addTarget:self action:@selector(signInOut) forControlEvents:UIControlEventTouchUpInside]; [self.view addSubview:self.signButton]; - self.titleView = [[TitleView alloc] initWithImage:nil title:@"Juick"]; - [self.navigationItem setTitleView:self.titleView]; [self refreshInfo]; } @@ -70,8 +68,8 @@ static NSString *CellIdentifier = @"NavCell"; dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_LOW, 0), ^{ [User get:[[PDKeychainBindings sharedKeychainBindings] stringForKey:@"com.juick.username"] callback:^(User *user) { if (user != nil) { - [self.titleView.image setImageWithURL:[NSURL URLWithString:[NSString stringWithFormat:@"https://i.juick.com/as/%@.png", user.uid]]]; - [self.titleView.title setText:user.uname]; + /*[self.titleView.image setImageWithURL:[NSURL URLWithString:[NSString stringWithFormat:@"https://i.juick.com/as/%@.png", user.uid]]]; + [self.titleView.title setText:user.uname];*/ } }]; }); @@ -117,24 +115,24 @@ static NSString *CellIdentifier = @"NavCell"; NavCell * cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath]; NSInteger row = indexPath.row; [cell.contentView setBackgroundColor:[ColorScheme navbarBackground]]; - cell.iconLabel.font = [UIFont fontWithName:kFontAwesomeFamilyName size:32.f]; - cell.iconLabel.textColor = [ColorScheme navbarFont]; + cell.icon.font = [UIFont fontWithName:kFontAwesomeFamilyName size:32.f]; + cell.icon.textColor = [ColorScheme navbarFont]; //cell.iconLabel.backgroundColor = [ColorScheme navbarBackground]; //cell.descriptionTextLabel.backgroundColor = [ColorScheme navbarBackground]; - cell.descriptionTextLabel.textColor = [ColorScheme navbarFont]; + cell.descriptionText.textColor = [ColorScheme navbarFont]; if (row == 0) { - cell.descriptionTextLabel.text = @"My feed"; - cell.iconLabel.text = [NSString fontAwesomeIconStringForEnum:FAIconHome]; + cell.descriptionText.text = @"My feed"; + cell.icon.text = [NSString fontAwesomeIconStringForEnum:FAIconHome]; } else if (row == 1) { - cell.descriptionTextLabel.text = @"Popular"; - cell.iconLabel.text = [NSString fontAwesomeIconStringForEnum:FAIconComments]; + cell.descriptionText.text = @"Popular"; + cell.icon.text = [NSString fontAwesomeIconStringForEnum:FAIconComments]; } else if (row == 2) { - cell.descriptionTextLabel.text = @"Discover"; - cell.iconLabel.text = [NSString fontAwesomeIconStringForEnum:FAIconSearch]; + cell.descriptionText.text = @"Discover"; + cell.icon.text = [NSString fontAwesomeIconStringForEnum:FAIconSearch]; } else if (row == 3) { - cell.descriptionTextLabel.text = @"Images"; - cell.iconLabel.text = [NSString fontAwesomeIconStringForEnum:FAIconPicture]; + cell.descriptionText.text = @"Images"; + cell.icon.text = [NSString fontAwesomeIconStringForEnum:FAIconPicture]; } UIView *bgColorView = [[UIView alloc] init]; bgColorView.backgroundColor = [UIColor blackColor]; diff --git a/Juick/TitleView.h b/Juick/TitleView.h deleted file mode 100644 index 17288ef..0000000 --- a/Juick/TitleView.h +++ /dev/null @@ -1,19 +0,0 @@ -// -// TitleView.h -// Juick -// -// Created by Vitaly on 01.02.14. -// Copyright (c) 2014 com.juick. All rights reserved. -// - -#import -#import "UILabel+Utils.h" -#import "ColorScheme.h" - -@interface TitleView : UIView -@property (nonatomic, strong) IBOutlet UIImageView *image; -@property (nonatomic, strong) IBOutlet UILabel *title; - --(id) initWithImage:(UIImage *) image title:(NSString *)title; - -@end diff --git a/Juick/TitleView.m b/Juick/TitleView.m deleted file mode 100644 index 3948041..0000000 --- a/Juick/TitleView.m +++ /dev/null @@ -1,37 +0,0 @@ -// -// TitleView.m -// Juick -// -// Created by Vitaly on 01.02.14. -// Copyright (c) 2014 com.juick. All rights reserved. -// - -#import "TitleView.h" - -@implementation TitleView - --(id) initWithImage:(UIImage *)image title:(NSString *)title { - self = [super initWithFrame:CGRectMake(0, 0, 300.0f, 52.0f)]; - if (self) { - self.image = [[UIImageView alloc] init]; - self.image.image = image; - self.title = [[UILabel alloc] init]; - self.title.numberOfLines = 1; - self.title.textAlignment = NSTextAlignmentLeft; - self.title.text = title; - self.title.textColor = [ColorScheme navbarFont]; - [self addSubview:self.image]; - [self addSubview:self.title]; - } - return self; -} - --(void) layoutSubviews { - [super layoutSubviews]; - self.image.frame = CGRectMake(10, 10, 32, 32); - float textHeight = [UILabel sizeForLabel:self.title width:320.0f].size.height; - self.title.frame = CGRectMake(10 + 32 + 10, 10 + (32 - textHeight) / 2, - self.bounds.size.width - 32 - 10*3, textHeight); -} - -@end diff --git a/Juick/UILabel+Utils.h b/Juick/UILabel+Utils.h deleted file mode 100644 index 2e9cbb6..0000000 --- a/Juick/UILabel+Utils.h +++ /dev/null @@ -1,15 +0,0 @@ -// -// UILabel+Utils.h -// Juick -// -// Created by Vitaly on 01.02.14. -// Copyright (c) 2014 com.juick. All rights reserved. -// - -#import - -@interface UILabel (Utils) - -+ (CGRect) sizeForLabel:(UILabel *)label width:(CGFloat)width; - -@end diff --git a/Juick/UILabel+Utils.m b/Juick/UILabel+Utils.m deleted file mode 100644 index 91136d0..0000000 --- a/Juick/UILabel+Utils.m +++ /dev/null @@ -1,16 +0,0 @@ -// -// UILabel+Utils.m -// Juick -// -// Created by Vitaly on 01.02.14. -// Copyright (c) 2014 com.juick. All rights reserved. -// - -#import "UILabel+Utils.h" - -@implementation UILabel (Utils) - -+ (CGRect) sizeForLabel:(UILabel *)label width:(CGFloat)width { - return [label.text boundingRectWithSize:(CGSize) {width, CGFLOAT_MAX} options:NSStringDrawingUsesLineFragmentOrigin attributes:@{NSFontAttributeName:label.font} context:nil]; -} -@end diff --git a/Juick/Views/NavCell.h b/Juick/Views/NavCell.h new file mode 100644 index 0000000..c8c2b41 --- /dev/null +++ b/Juick/Views/NavCell.h @@ -0,0 +1,14 @@ +// +// NavCell.h +// Juick +// +// Created by Vitaly Takmazov on 14/08/16. +// Copyright © 2016 com.juick. All rights reserved. +// + +#import + +@interface NavCell : UITableViewCell +@property (weak, nonatomic) IBOutlet UILabel *icon; +@property (weak, nonatomic) IBOutlet UILabel *descriptionText; +@end diff --git a/Juick/Views/NavCell.m b/Juick/Views/NavCell.m new file mode 100644 index 0000000..f2ab9f1 --- /dev/null +++ b/Juick/Views/NavCell.m @@ -0,0 +1,24 @@ +// +// NavCell.m +// Juick +// +// Created by Vitaly Takmazov on 14/08/16. +// Copyright © 2016 com.juick. All rights reserved. +// + +#import "NavCell.h" + +@implementation NavCell + +- (void)awakeFromNib { + [super awakeFromNib]; + // Initialization code +} + +- (void)setSelected:(BOOL)selected animated:(BOOL)animated { + [super setSelected:selected animated:animated]; + + // Configure the view for the selected state +} + +@end diff --git a/Juick/Views/NavCell.xib b/Juick/Views/NavCell.xib new file mode 100644 index 0000000..bf2691d --- /dev/null +++ b/Juick/Views/NavCell.xib @@ -0,0 +1,51 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + -- cgit v1.2.3