From ff23c4eb5d382d25c2e4779e0ea8f4b724651105 Mon Sep 17 00:00:00 2001 From: Vitaly Takmazov Date: Thu, 7 Nov 2013 12:18:27 +0400 Subject: load public pages from reveal view --- Juick/AppDelegate.m | 2 +- Juick/MessagesViewController.h | 2 +- Juick/MessagesViewController.m | 14 ++++++-------- Juick/RevealPanelViewController.m | 26 ++++++++++++++++++++++++++ 4 files changed, 34 insertions(+), 10 deletions(-) (limited to 'Juick') diff --git a/Juick/AppDelegate.m b/Juick/AppDelegate.m index 28bacc9..292ef7f 100644 --- a/Juick/AppDelegate.m +++ b/Juick/AppDelegate.m @@ -25,7 +25,7 @@ // make the status bar white [UIApplication sharedApplication].statusBarStyle = UIStatusBarStyleLightContent; - MessagesViewController *messages = [[MessagesViewController alloc] initWithURL:[NSURL URLWithString:@"https://api.juick.com/messages"]]; + MessagesViewController *messages = [[MessagesViewController alloc] init]; RevealPanelViewController *rear = [[RevealPanelViewController alloc] init]; UINavigationController *main = [[UINavigationController alloc] initWithRootViewController:messages]; diff --git a/Juick/MessagesViewController.h b/Juick/MessagesViewController.h index be69672..3e6af7e 100644 --- a/Juick/MessagesViewController.h +++ b/Juick/MessagesViewController.h @@ -9,7 +9,7 @@ #import @interface MessagesViewController : UITableViewController -- (id)initWithURL:(NSURL *)messagesURL; +- (void)loadFromURL:(NSURL *)messagesURL withTitle:(NSString *)title; - (void) refreshData:(UIRefreshControl *)refresh; - (void) composePressed; @end diff --git a/Juick/MessagesViewController.m b/Juick/MessagesViewController.m index 55f8a19..6c594ba 100644 --- a/Juick/MessagesViewController.m +++ b/Juick/MessagesViewController.m @@ -32,13 +32,11 @@ static NSString *CellIdentifier = @"MessageCell"; @implementation MessagesViewController -- (id)initWithURL:(NSURL *)messagesURL +- (void)loadFromURL:(NSURL *)messagesURL withTitle:(NSString *)title { - self = [super init]; - if (self) { - self.url = messagesURL; - } - return self; + [self setUrl:messagesURL]; + self.title = title; + [self refreshData:nil]; } - (void) refreshData:(UIRefreshControl *)refresh { @@ -95,7 +93,6 @@ static NSString *CellIdentifier = @"MessageCell"; { [super viewDidLoad]; self.dataLoading = NO; - self.title = @"Discover"; [self.view setBackgroundColor:[ColorsAndButtons mainBackground]]; if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone) { SWRevealViewController *revealController = [self revealViewController]; @@ -114,7 +111,8 @@ static NSString *CellIdentifier = @"MessageCell"; //UINib *cellNib = [UINib nibWithNibName:@"MessageCell" bundle:nil]; //[self.tableView registerNib:cellNib forCellReuseIdentifier:@"MessageCell"]; - [self.tableView registerClass:[MessageCell class] forCellReuseIdentifier:CellIdentifier]; + [self.tableView registerClass:[MessageCell class] forCellReuseIdentifier:CellIdentifier]; + [self loadFromURL:[NSURL URLWithString:@"https://api.juick.com/messages"] withTitle:@"Discover"]; } diff --git a/Juick/RevealPanelViewController.m b/Juick/RevealPanelViewController.m index 7053832..ec575a0 100644 --- a/Juick/RevealPanelViewController.m +++ b/Juick/RevealPanelViewController.m @@ -6,9 +6,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 () @@ -74,4 +78,26 @@ 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 -- cgit v1.2.3