// // TrainerViewController.m // NewsBlur // // Created by Samuel Clay on 12/24/12. // Copyright (c) 2012 NewsBlur. All rights reserved. // #import "TrainerViewController.h" #import "StringHelper.h" @implementation TrainerViewController @synthesize closeButton; @synthesize webView; @synthesize navBar; @synthesize appDelegate; - (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil { self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil]; if (self) { // Custom initialization } return self; } - (void)viewDidLoad { [super viewDidLoad]; self.appDelegate = [NewsBlurAppDelegate sharedAppDelegate]; navBar.tintColor = UIColorFromRGB(0x183353); } - (void)viewWillAppear:(BOOL)animated { [[UIMenuController sharedMenuController] setMenuItems:[NSArray arrayWithObjects: [[UIMenuItem alloc] initWithTitle:@"👎 Hide" action:@selector(changeTitle:)], [[UIMenuItem alloc] initWithTitle:@"👍 Focus" action:@selector(changeTitle:)], nil]]; UILabel *titleLabel = (UILabel *)[appDelegate makeFeedTitle:appDelegate.activeFeed]; titleLabel.shadowColor = UIColorFromRGB(0x306070); navBar.topItem.titleView = titleLabel; NSString *path = [[NSBundle mainBundle] bundlePath]; NSURL *baseURL = [NSURL fileURLWithPath:path]; [self.webView loadHTMLString:[self makeTrainerSections] baseURL:baseURL]; } - (void)viewDidAppear:(BOOL)animated { } - (void)viewDidDisappear:(BOOL)animated { [super viewDidDisappear:animated]; [[UIMenuController sharedMenuController] setMenuItems:nil]; } #pragma mark - #pragma mark Story layout - (NSString *)makeTrainerSections { NSString *storyAuthor = [self makeAuthor]; NSString *storyTags = [self makeTags]; NSString *storyTitle = [self makeTitle]; NSString *storyPublisher = [self makePublisher]; int contentWidth = self.view.frame.size.width; NSString *contentWidthClass; if (contentWidth > 700) { contentWidthClass = @"NB-ipad-wide"; } else if (contentWidth > 480) { contentWidthClass = @"NB-ipad-narrow"; } else { contentWidthClass = @"NB-iphone"; } // set up layout values based on iPad/iPhone NSString *headerString = [NSString stringWithFormat:@ "" "", contentWidth]; NSString *footerString = [NSString stringWithFormat:@ "" "" ""]; NSString *htmlString = [NSString stringWithFormat:@ "" "
%@" // header string "" "