diff options
author | Vitaly Takmazov | 2013-11-07 12:18:27 +0400 |
---|---|---|
committer | Vitaly Takmazov | 2013-11-07 12:18:27 +0400 |
commit | ff23c4eb5d382d25c2e4779e0ea8f4b724651105 (patch) | |
tree | fe2c0e99608add7a851f797ab31d5e33b98de281 | |
parent | 8c69b5408e5d2870d60f15662f1d567e6cd55da7 (diff) |
load public pages from reveal view
-rw-r--r-- | Juick/AppDelegate.m | 2 | ||||
-rw-r--r-- | Juick/MessagesViewController.h | 2 | ||||
-rw-r--r-- | Juick/MessagesViewController.m | 14 | ||||
-rw-r--r-- | Juick/RevealPanelViewController.m | 26 |
4 files changed, 34 insertions, 10 deletions
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 <UIKit/UIKit.h> @interface MessagesViewController : UITableViewController<UISplitViewControllerDelegate> -- (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 |