NewsBlur/media/ios/Classes/FirstTimeUserAddNewsBlurViewController.m

110 lines
2.8 KiB
Mathematica
Raw Normal View History

2012-07-22 14:23:50 -07:00
//
// FTUXAddNewsBlurViewController.m
// NewsBlur
//
// Created by Roy Yang on 7/22/12.
// Copyright (c) 2012 NewsBlur. All rights reserved.
//
#import "FirstTimeUserAddNewsBlurViewController.h"
@implementation FirstTimeUserAddNewsBlurViewController
@synthesize appDelegate;
@synthesize nextButton;
@synthesize instructionsLabel;
2012-07-22 14:23:50 -07:00
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {
// Custom initialization
}
return self;
}
- (void)viewDidLoad {
2012-07-22 14:23:50 -07:00
[super viewDidLoad];
// Do any additional setup after loading the view from its nib.
2012-08-10 21:10:32 -07:00
UIBarButtonItem *next = [[UIBarButtonItem alloc] initWithTitle:@"Start Enjoying" style:UIBarButtonSystemItemDone target:self action:@selector(tapNextButton)];
2012-07-22 14:23:50 -07:00
self.nextButton = next;
self.navigationItem.rightBarButtonItem = next;
2012-08-12 16:50:34 -07:00
self.navigationItem.title = @"All Done!";
2012-07-22 14:23:50 -07:00
if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone) {
self.instructionsLabel.font = [UIFont systemFontOfSize:13];
}
2012-07-22 14:23:50 -07:00
}
- (void)viewDidUnload
{
[self setNextButton:nil];
[self setInstructionsLabel:nil];
2012-07-22 14:23:50 -07:00
[super viewDidUnload];
// Release any retained subviews of the main view.
// e.g. self.myOutlet = nil;
}
- (void)viewWillAppear:(BOOL)animated {
}
- (void)viewDidAppear:(BOOL)animated {
}
2012-08-11 18:03:28 -07:00
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
// Return YES for supported orientations
if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) {
return YES;
} else if (UIInterfaceOrientationIsPortrait(interfaceOrientation)) {
return YES;
}
return NO;
2012-07-22 14:23:50 -07:00
}
- (IBAction)tapNextButton {
[appDelegate.ftuxNavigationController dismissModalViewControllerAnimated:YES];
}
- (IBAction)tapNewsBlurButton:(id)sender {
UIButton *button = (UIButton *)sender;
button.selected = YES;
button.userInteractionEnabled = NO;
[self addSite:@"http://blog.newsblur.com/"];
}
#pragma mark -
#pragma mark Add Site
- (void)addSite:(NSString *)siteUrl {
NSString *urlString = [NSString stringWithFormat:@"http://%@/reader/add_url",
NEWSBLUR_URL];
NSURL *url = [NSURL URLWithString:urlString];
ASIFormDataRequest *request = [ASIFormDataRequest requestWithURL:url];
[request setPostValue:siteUrl forKey:@"url"];
[request setDelegate:self];
[request setDidFinishSelector:@selector(finishAddSite:)];
2012-07-22 14:23:50 -07:00
[request setDidFailSelector:@selector(requestFailed:)];
[request startAsynchronous];
}
- (void)requestFailed:(ASIHTTPRequest *)request {
NSError *error = [request error];
NSLog(@"Error: %@", error);
}
- (void)finishAddSite:(ASIHTTPRequest *)request {
NSLog(@"request: %@", request);
2012-07-22 14:23:50 -07:00
}
@end