// // 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 "ColorsAndButtons.h" #import "NSURL+PathParameters.h" @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.navigationController.navigationBar.topItem setTitleView:[[UIImageView alloc] initWithImage:[ColorsAndButtons logo]]]; [self.view setBackgroundColor:[ColorsAndButtons navbarBackground]]; self.tableView.separatorStyle = UITableViewCellSeparatorStyleNone; self.tableView.separatorColor =[UIColor blackColor]; } - (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; } - (UITableViewCell *) tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { static NSString *cellIdentifier = @"MenuCell"; UITableViewCell * cell = [tableView dequeueReusableCellWithIdentifier:cellIdentifier]; 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]; } if (row == 0) { cell.detailTextLabel.text = @"My feed"; cell.textLabel.text = [NSString fontAwesomeIconStringForEnum:FAIconHome]; } else if (row == 1) { cell.detailTextLabel.text = @"Popular"; cell.textLabel.text = [NSString fontAwesomeIconStringForEnum:FAIconComments]; } else if (row == 2) { cell.detailTextLabel.text = @"Discover"; cell.textLabel.text = [NSString fontAwesomeIconStringForEnum:FAIconSearch]; } else if (row == 3) { cell.detailTextLabel.text = @"Images"; cell.textLabel.text = [NSString fontAwesomeIconStringForEnum:FAIconPicture]; } return cell; } - (void) tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { NSInteger row = indexPath.row; NSURL *targetUrl; NSString *targetTitle; if (row == 1) { targetTitle = @"Popular"; targetUrl = [[NSURL URLWithString:@"https://api.juick.com/messages"] URLByAppendingParameters:[NSDictionary dictionaryWithObjectsAndKeys:@"1", @"popular", nil]]; } else if (row == 2) { targetTitle = @"Discover"; targetUrl = [NSURL URLWithString:@"https://api.juick.com/messages"]; } if (row == 3) { targetTitle = @"Images"; targetUrl = [[NSURL URLWithString:@"https://api.juick.com/messages"] URLByAppendingParameters:[NSDictionary dictionaryWithObjectsAndKeys:@"photo", @"media", nil]]; } SWRevealViewController *reveal = self.revealViewController; UINavigationController *front = (UINavigationController *)reveal.frontViewController; MessagesViewController *messages = (MessagesViewController *)[front.viewControllers objectAtIndex:0]; [messages loadFromURL:targetUrl withTitle:targetTitle]; [reveal revealToggle:self]; } @end