From 63f9e9576991fa8e50ca728836c6ba6917bbbc26 Mon Sep 17 00:00:00 2001 From: Vitaly Takmazov Date: Thu, 30 Jan 2014 17:16:06 +0400 Subject: LoginView --- Juick/RevealPanelViewController.m | 27 ++++++++++++++++++++++----- 1 file changed, 22 insertions(+), 5 deletions(-) (limited to 'Juick/RevealPanelViewController.m') diff --git a/Juick/RevealPanelViewController.m b/Juick/RevealPanelViewController.m index a9c71e8..c39c6cd 100644 --- a/Juick/RevealPanelViewController.m +++ b/Juick/RevealPanelViewController.m @@ -14,6 +14,7 @@ #import "ColorScheme.h" #import "NSURL+PathParameters.h" #import "NavCell.h" +#import "Message.h" @@ -95,23 +96,39 @@ static NSString *CellIdentifier = @"NavCell"; - (void) tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { NSInteger row = indexPath.row; - NSURL *targetUrl; + NSString *targetPath; + NSDictionary *targetParams; NSString *targetTitle; + if (row == 0) { + if ([[PDKeychainBindings sharedKeychainBindings] stringForKey:@"com.juick.username"] == nil) { + [self.revealViewController revealToggle:self]; + UIViewController *loginView = [[LoginViewController alloc] initWithStyle:UITableViewStyleGrouped]; + UINavigationController *messages = (UINavigationController *)self.revealViewController.frontViewController; + [messages pushViewController:loginView animated:YES]; + return; + } else { + targetTitle = @"My feed"; + targetPath = [Message feedUrl]; + } + + } if (row == 1) { targetTitle = @"Popular"; - targetUrl = [[NSURL URLWithString:@"https://api.juick.com/messages"] URLByAppendingParameters:[NSDictionary dictionaryWithObjectsAndKeys:@"1", @"popular", nil]]; + targetPath = [Message messagesUrl]; + targetParams = [NSDictionary dictionaryWithObjectsAndKeys:@"1", @"popular", nil]; } else if (row == 2) { targetTitle = @"Discover"; - targetUrl = [NSURL URLWithString:@"https://api.juick.com/messages"]; + targetPath = [Message messagesUrl]; } if (row == 3) { targetTitle = @"Images"; - targetUrl = [[NSURL URLWithString:@"https://api.juick.com/messages"] URLByAppendingParameters:[NSDictionary dictionaryWithObjectsAndKeys:@"photo", @"media", nil]]; + 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 loadFromURL:targetUrl withTitle:targetTitle]; + [messages loadFromPath:targetPath withParams:targetParams withTitle:targetTitle]; [reveal revealToggle:self]; } -- cgit v1.2.3