diff options
author | Vitaly Takmazov | 2016-08-28 21:03:22 +0300 |
---|---|---|
committer | Vitaly Takmazov | 2016-08-28 21:03:22 +0300 |
commit | 188d8e4ea870d1a6c8edd5a9b323742804badeba (patch) | |
tree | 071067f7189a6474d49abb952b1b04b820985b7a /Juick/RevealPanelViewController.m | |
parent | a74588083c4950e9237dff7a84ccdd129b72c950 (diff) |
project cleanup
Diffstat (limited to 'Juick/RevealPanelViewController.m')
-rw-r--r-- | Juick/RevealPanelViewController.m | 182 |
1 files changed, 0 insertions, 182 deletions
diff --git a/Juick/RevealPanelViewController.m b/Juick/RevealPanelViewController.m deleted file mode 100644 index d890f97..0000000 --- a/Juick/RevealPanelViewController.m +++ /dev/null @@ -1,182 +0,0 @@ -// -// RevealPanelViewController.m -// Juick -// -// Created by Vitaly Takmazov on 04.11.13. -// Copyright (c) 2013 com.juick. All rights reserved. -// - -#import "SWRevealViewController.h" - -#import "RevealPanelViewController.h" -#import "MessagesViewController.h" - -#import "ColorScheme.h" -#import "NSURL+PathParameters.h" -#import "NavCell.h" -#import "Message.h" -#import "User.h" - - -static NSString *CellIdentifier = @"NavCell"; - -@interface RevealPanelViewController () - -@end - -@implementation RevealPanelViewController - -- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil -{ - self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil]; - if (self) { - // Custom initialization - } - return self; -} - -- (void)viewDidLoad -{ - [super viewDidLoad]; - [self.view setBackgroundColor:[ColorScheme mainBackground]]; - self.tableView = [[UITableView alloc] init]; - [self.tableView setBackgroundColor:[ColorScheme mainBackground]]; - self.tableView.delegate = self; - self.tableView.dataSource = self; - [self.tableView setSeparatorInset:UIEdgeInsetsZero]; - self.tableView.separatorStyle = UITableViewCellSeparatorStyleSingleLine; - self.tableView.separatorColor =[UIColor darkGrayColor]; - [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 refreshInfo]; -} - --(void) refreshInfo { - NSString *text; - UIColor *color; - - if ([User isAuthenticated]) { - text = @"Sign Out"; - color = [UIColor redColor]; - 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];*/ - } - }]; - }); - } else { - text = @"Sign In"; - color = [UIColor greenColor]; - } - [self.signButton setTitle:text forState:UIControlStateNormal]; - [self.signButton setBackgroundColor:color]; -} - --(void) signInOut { - [self refreshInfo]; - [self pushLoginForm]; -} - --(void) viewWillLayoutSubviews { - [super viewWillLayoutSubviews]; - self.tableView.frame = CGRectMake(0, 0, self.view.bounds.size.width, 400); - self.signButton.frame = CGRectMake(0, self.view.bounds.size.height - 40, self.view.bounds.size.width, 40); -} - -- (void)didReceiveMemoryWarning -{ - [super didReceiveMemoryWarning]; - // Dispose of any resources that can be recreated. -} - - -- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView { - return 1; -} - -- (NSInteger) tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { - return 4; -} - -- (CGFloat) tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath { - return 32 + 10*2; // icon size + insets -} - -- (UITableViewCell *) tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { - NavCell * cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath]; - NSInteger row = indexPath.row; - [cell.contentView setBackgroundColor:[UIColor whiteColor]]; - cell.icon.font = [UIFont fontWithName:kFontAwesomeFamilyName size:32.f]; - cell.icon.textColor = [ColorScheme linkColor]; - cell.descriptionText.textColor = [ColorScheme linkColor]; - if (row == 0) { - cell.descriptionText.text = @"My feed"; - cell.icon.text = [NSString fontAwesomeIconStringForEnum:FAIconHome]; - - } else if (row == 1) { - cell.descriptionText.text = @"Popular"; - cell.icon.text = [NSString fontAwesomeIconStringForEnum:FAIconComments]; - } else if (row == 2) { - cell.descriptionText.text = @"Discover"; - cell.icon.text = [NSString fontAwesomeIconStringForEnum:FAIconSearch]; - } else if (row == 3) { - cell.descriptionText.text = @"Images"; - cell.icon.text = [NSString fontAwesomeIconStringForEnum:FAIconPicture]; - } - UIView *bgColorView = [[UIView alloc] init]; - bgColorView.backgroundColor = [UIColor blackColor]; - bgColorView.layer.masksToBounds = YES; - [cell setSelectedBackgroundView:bgColorView]; - [cell.contentView setNeedsLayout]; - [cell.contentView layoutIfNeeded]; - return cell; -} - -- (void) pushLoginForm { - [self.revealViewController revealToggle:self]; - UIViewController *loginView = [[LoginViewController alloc] init]; - UINavigationController *messages = (UINavigationController *)self.revealViewController.frontViewController; - [messages pushViewController:loginView animated:YES]; -} - -- (void) tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { - NSInteger row = indexPath.row; - NSString *targetPath; - NSDictionary *targetParams; - NSString *targetTitle; - if (row == 0) { - if ([[PDKeychainBindings sharedKeychainBindings] stringForKey:@"com.juick.username"] == nil) { - [self pushLoginForm]; - return; - } else { - targetTitle = @"My feed"; - targetPath = [Message feedUrl]; - } - - } - if (row == 1) { - targetTitle = @"Popular"; - targetPath = [Message messagesUrl]; - targetParams = [NSDictionary dictionaryWithObjectsAndKeys:@"1", @"popular", nil]; - } else if (row == 2) { - targetTitle = @"Discover"; - targetPath = [Message messagesUrl]; - } - if (row == 3) { - targetTitle = @"Images"; - targetPath = [Message messagesUrl]; - targetParams = [NSDictionary dictionaryWithObjectsAndKeys:@"photo", @"media", nil]; - } - SWRevealViewController *reveal = self.revealViewController; - UINavigationController *front = (UINavigationController *)reveal.frontViewController; - MessagesViewController *messages = (MessagesViewController *)[front.viewControllers objectAtIndex:0]; - [messages loadFromPath:targetPath withParams:targetParams withTitle:targetTitle]; - [reveal revealToggle:self]; -} - -@end |