NewsBlur/media/ios/Classes/FeedDetailMenuViewController.m

144 lines
4.1 KiB
Mathematica
Raw Normal View History

//
// 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"
@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);
}
- (void)viewDidUnload
{
[super viewDidUnload];
// Release any retained subviews of the main view.
// e.g. self.myOutlet = nil;
self.menuOptions = nil;
self.menuTableView = nil;
}
- (void)viewWillAppear:(BOOL)animated {
[self.menuTableView reloadData];
2012-10-14 19:39:24 -04:00
}
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
return YES;
}
- (BOOL)automaticallyForwardAppearanceAndRotationMethodsToChildViewControllers {
return YES;
}
- (BOOL)shouldAutomaticallyForwardAppearanceMethods {
return YES;
}
2012-10-14 19:39:24 -04:00
- (void)buildMenuOptions {
NSMutableArray *options = [NSMutableArray array];
2012-10-14 19:39:24 -04:00
// NSString *title = appDelegate.isRiverView ?
// appDelegate.activeFolder :
// [appDelegate.activeFeed objectForKey:@"feed_title"];
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-14 19:39:24 -04:00
[options addObject:[@"Move to another folder" uppercaseString]];
if (!appDelegate.isRiverView) {
2012-10-14 19:39:24 -04:00
[options addObject:[@"Insta-fetch stories" uppercaseString]];
}
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];
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]
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"];
}
return cell;
}
2012-10-14 19:39:24 -04:00
- (float)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
return 38;
}
- (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];
}
if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) {
[appDelegate.masterContainerViewController hidePopover];
} else {
[appDelegate.feedDetailViewController.popoverController dismissPopoverAnimated:YES];
appDelegate.feedDetailViewController.popoverController = nil;
}
[tableView deselectRowAtIndexPath:indexPath animated:YES];
}
@end