NewsBlur/clients/ios/Classes/FirstTimeUserAddNewsBlurViewController.m

130 lines
4.1 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"
#import "NewsBlur-Swift.h"
2012-07-22 14:23:50 -07:00
@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];
self.appDelegate = [NewsBlurAppDelegate sharedAppDelegate];
2012-07-22 14:23:50 -07:00
UIBarButtonItem *next = [[UIBarButtonItem alloc] initWithTitle:@"Start reading" style:UIBarButtonItemStyleDone target:self action:@selector(tapNextButton)];
2012-07-22 14:23:50 -07:00
self.nextButton = next;
self.navigationItem.rightBarButtonItem = next;
self.navigationItem.title = @"All Done";
2012-07-22 14:23:50 -07:00
}
- (void)viewWillAppear:(BOOL)animated {
2014-09-18 11:25:51 -07:00
[super viewWillAppear:animated];
[self.navigationItem.rightBarButtonItem setStyle:UIBarButtonItemStyleDone];
2012-07-22 14:23:50 -07:00
}
- (void)viewDidAppear:(BOOL)animated {
2014-09-18 11:25:51 -07:00
[super viewDidAppear:animated];
[self addSite:@"http://blog.newsblur.com/rss"];
[self addPopular];
2012-07-22 14:23:50 -07:00
}
//- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
// // Return YES for supported orientations
// if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPad) {
// return YES;
// } else if (UIInterfaceOrientationIsPortrait(interfaceOrientation)) {
// return YES;
// }
//
// return NO;
//}
2012-07-22 14:23:50 -07:00
- (IBAction)tapNextButton {
[appDelegate.ftuxNavigationController dismissViewControllerAnimated:YES completion:nil];
2012-08-15 13:04:05 -07:00
[appDelegate.feedsViewController fetchFeedList:NO];
2012-07-22 14:23:50 -07:00
}
- (IBAction)tapNewsBlurButton:(id)sender {
UIButton *button = (UIButton *)sender;
button.selected = YES;
button.userInteractionEnabled = NO;
2012-08-12 20:09:45 -07:00
UIImage *checkmark = [UIImage imageNamed:@"258-checkmark"];
UIImageView *checkmarkView = [[UIImageView alloc] initWithImage:checkmark];
checkmarkView.frame = CGRectMake(button.frame.origin.x + button.frame.size.width - 24,
button.frame.origin.y + 8,
16,
16);
[self.view addSubview:checkmarkView];
[self addSite:@"http://blog.newsblur.com/rss"];
2012-07-22 14:23:50 -07:00
}
2012-08-12 20:09:45 -07:00
- (IBAction)tapPopularButton:(id)sender {
UIButton *button = (UIButton *)sender;
button.selected = YES;
button.userInteractionEnabled = NO;
UIImage *checkmark = [UIImage imageNamed:@"258-checkmark"];
UIImageView *checkmarkView = [[UIImageView alloc] initWithImage:checkmark];
checkmarkView.frame = CGRectMake(button.frame.origin.x + button.frame.size.width - 24,
button.frame.origin.y + 8,
16,
16);
[self.view addSubview:checkmarkView];
[self addPopular];
}
2012-07-22 14:23:50 -07:00
#pragma mark -
#pragma mark Add Site
2012-08-12 20:09:45 -07:00
- (void)addPopular {
NSString *urlString = [NSString stringWithFormat:@"%@/social/follow/",
2016-01-21 22:11:37 -08:00
self.appDelegate.url];
2017-03-19 18:15:36 -07:00
NSMutableDictionary *params = [NSMutableDictionary dictionary];
2012-08-12 20:09:45 -07:00
[params setObject:@"social:popular" forKey:@"user_id"];
2017-03-19 18:15:36 -07:00
[appDelegate POST:urlString parameters:params target:self success:@selector(finishAddSite:) failure:@selector(informError:)];
2012-08-12 20:09:45 -07:00
}
2012-07-22 14:23:50 -07:00
- (void)addSite:(NSString *)siteUrl {
NSString *urlString = [NSString stringWithFormat:@"%@/reader/add_url/",
2016-01-21 22:11:37 -08:00
self.appDelegate.url];
2017-03-19 18:15:36 -07:00
NSMutableDictionary *params = [NSMutableDictionary dictionary];
[params setObject:siteUrl forKey:@"url"];
[params setObject:@"true" forKey:@"auto_active"];
[params setObject:@"true" forKey:@"skip_fetch"];
2012-07-22 14:23:50 -07:00
[appDelegate POST:urlString parameters:params target:self success:@selector(finishAddSite:) failure:@selector(informError:)];
}
2017-03-19 18:15:36 -07:00
- (void)finishAddSite:(NSDictionary *)results {
2012-08-12 20:19:07 -07:00
NSLog(@"results are %@", results);
2012-07-22 14:23:50 -07:00
}
@end