2012-10-12 13:58:26 -04:00
|
|
|
//
|
|
|
|
// FeedDetailMenuViewController.m
|
|
|
|
// NewsBlur
|
|
|
|
//
|
|
|
|
// Created by Samuel Clay on 10/10/12.
|
|
|
|
// Copyright (c) 2012 NewsBlur. All rights reserved.
|
|
|
|
//
|
|
|
|
|
|
|
|
#import "FeedDetailMenuViewController.h"
|
|
|
|
#import "NewsBlurAppDelegate.h"
|
|
|
|
#import "MBProgressHUD.h"
|
|
|
|
#import "NBContainerViewController.h"
|
|
|
|
#import "FeedDetailViewController.h"
|
2012-10-16 15:48:04 -07:00
|
|
|
#import "MenuTableViewCell.h"
|
2012-10-12 13:58:26 -04:00
|
|
|
|
|
|
|
@implementation FeedDetailMenuViewController
|
|
|
|
|
|
|
|
@synthesize appDelegate;
|
|
|
|
@synthesize menuOptions;
|
|
|
|
@synthesize menuTableView;
|
|
|
|
|
|
|
|
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
|
|
|
|
{
|
|
|
|
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
|
|
|
|
if (self) {
|
|
|
|
// Custom initialization
|
|
|
|
}
|
|
|
|
return self;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void)viewDidLoad
|
|
|
|
{
|
|
|
|
[super viewDidLoad];
|
2012-10-14 19:39:24 -04:00
|
|
|
self.menuTableView.backgroundColor = UIColorFromRGB(0xF0FFF0);
|
|
|
|
self.menuTableView.separatorColor = UIColorFromRGB(0x8AA378);
|
2012-10-12 13:58:26 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
- (void)viewDidUnload
|
|
|
|
{
|
|
|
|
[super viewDidUnload];
|
|
|
|
// Release any retained subviews of the main view.
|
|
|
|
// e.g. self.myOutlet = nil;
|
|
|
|
self.menuOptions = nil;
|
|
|
|
self.menuTableView = nil;
|
|
|
|
}
|
|
|
|
|
2012-10-14 17:52:07 -07:00
|
|
|
- (void)viewWillAppear:(BOOL)animated {
|
|
|
|
[self.menuTableView reloadData];
|
2012-10-14 19:39:24 -04:00
|
|
|
}
|
|
|
|
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
|
|
|
|
return YES;
|
|
|
|
}
|
|
|
|
|
2012-10-14 17:52:07 -07:00
|
|
|
- (BOOL)automaticallyForwardAppearanceAndRotationMethodsToChildViewControllers {
|
|
|
|
return YES;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (BOOL)shouldAutomaticallyForwardAppearanceMethods {
|
|
|
|
return YES;
|
|
|
|
}
|
|
|
|
|
2012-10-14 19:39:24 -04:00
|
|
|
- (void)buildMenuOptions {
|
2012-10-12 13:58:26 -04:00
|
|
|
NSMutableArray *options = [NSMutableArray array];
|
|
|
|
|
2012-10-14 19:39:24 -04:00
|
|
|
// NSString *title = appDelegate.isRiverView ?
|
|
|
|
// appDelegate.activeFolder :
|
|
|
|
// [appDelegate.activeFeed objectForKey:@"feed_title"];
|
|
|
|
|
2012-10-12 13:58:26 -04:00
|
|
|
NSString *deleteText = [NSString stringWithFormat:@"Delete %@",
|
|
|
|
appDelegate.isRiverView ?
|
|
|
|
@"this entire folder" :
|
|
|
|
@"this site"];
|
2012-10-14 19:39:24 -04:00
|
|
|
[options addObject:[deleteText uppercaseString]];
|
2012-10-12 13:58:26 -04:00
|
|
|
|
2012-10-14 19:39:24 -04:00
|
|
|
[options addObject:[@"Move to another folder" uppercaseString]];
|
2012-10-12 13:58:26 -04:00
|
|
|
|
|
|
|
if (!appDelegate.isRiverView) {
|
2012-10-14 19:39:24 -04:00
|
|
|
[options addObject:[@"Insta-fetch stories" uppercaseString]];
|
2012-10-12 13:58:26 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
self.menuOptions = options;
|
|
|
|
}
|
|
|
|
|
|
|
|
#pragma mark -
|
|
|
|
#pragma mark - Table view data source
|
|
|
|
|
|
|
|
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
|
|
|
|
{
|
2012-10-14 19:39:24 -04:00
|
|
|
[self buildMenuOptions];
|
|
|
|
|
2012-10-12 13:58:26 -04:00
|
|
|
return [self.menuOptions count];
|
|
|
|
}
|
|
|
|
|
|
|
|
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
|
|
|
|
{
|
|
|
|
static NSString *CellIndentifier = @"Cell";
|
|
|
|
|
|
|
|
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIndentifier];
|
|
|
|
|
|
|
|
if (cell == nil) {
|
2012-10-16 15:48:04 -07:00
|
|
|
cell = [[MenuTableViewCell alloc]
|
2012-10-12 13:58:26 -04:00
|
|
|
initWithStyle:UITableViewCellStyleDefault
|
|
|
|
reuseIdentifier:CellIndentifier];
|
|
|
|
}
|
|
|
|
|
|
|
|
cell.textLabel.text = [self.menuOptions objectAtIndex:[indexPath row]];
|
2012-10-14 19:39:24 -04:00
|
|
|
|
|
|
|
if (indexPath.row == 0) {
|
|
|
|
cell.imageView.image = [UIImage imageNamed:@"bin_closed"];
|
|
|
|
} else if (indexPath.row == 1) {
|
|
|
|
cell.imageView.image = [UIImage imageNamed:@"arrow_branch"];
|
|
|
|
} else if (indexPath.row == 2) {
|
|
|
|
cell.imageView.image = [UIImage imageNamed:@"car"];
|
|
|
|
}
|
2012-10-12 13:58:26 -04:00
|
|
|
|
|
|
|
return cell;
|
|
|
|
}
|
|
|
|
|
2012-10-14 19:39:24 -04:00
|
|
|
- (float)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
|
|
|
|
return 38;
|
|
|
|
}
|
|
|
|
|
2012-10-12 13:58:26 -04:00
|
|
|
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
|
|
|
|
{
|
|
|
|
if (indexPath.row == 0) {
|
2012-10-14 19:39:24 -04:00
|
|
|
[appDelegate.feedDetailViewController confirmDeleteSite];
|
|
|
|
} else if (indexPath.row == 1) {
|
|
|
|
[appDelegate.feedDetailViewController openMoveView];
|
|
|
|
} else if (indexPath.row == 2) {
|
|
|
|
[appDelegate.feedDetailViewController instafetchFeed];
|
2012-10-12 13:58:26 -04:00
|
|
|
}
|
|
|
|
|
2012-10-15 09:16:01 -07:00
|
|
|
if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) {
|
|
|
|
[appDelegate.masterContainerViewController hidePopover];
|
|
|
|
} else {
|
|
|
|
[appDelegate.feedDetailViewController.popoverController dismissPopoverAnimated:YES];
|
|
|
|
appDelegate.feedDetailViewController.popoverController = nil;
|
|
|
|
}
|
2012-10-12 13:58:26 -04:00
|
|
|
[tableView deselectRowAtIndexPath:indexPath animated:YES];
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
@end
|