2012-07-10 12:34:58 -07:00
|
|
|
//
|
|
|
|
// DashboardViewController.m
|
|
|
|
// NewsBlur
|
|
|
|
//
|
|
|
|
// Created by Roy Yang on 7/10/12.
|
|
|
|
// Copyright (c) 2012 NewsBlur. All rights reserved.
|
|
|
|
//
|
|
|
|
|
|
|
|
#import "DashboardViewController.h"
|
|
|
|
#import "NewsBlurAppDelegate.h"
|
2012-07-11 18:08:07 -07:00
|
|
|
#import "ActivityModule.h"
|
2012-07-11 20:19:42 -07:00
|
|
|
#import "InteractionsModule.h"
|
2012-07-12 00:10:42 -07:00
|
|
|
#import "UserProfileViewController.h"
|
2012-07-10 12:34:58 -07:00
|
|
|
|
2012-07-21 18:56:25 -07:00
|
|
|
#define FEEDBACK_URL @"http://dev.newsblur.com/about"
|
|
|
|
|
2012-07-10 12:34:58 -07:00
|
|
|
@implementation DashboardViewController
|
|
|
|
|
|
|
|
@synthesize appDelegate;
|
2012-07-12 10:59:17 -07:00
|
|
|
@synthesize interactionsModule;
|
|
|
|
@synthesize activitiesModule;
|
2012-07-21 18:56:25 -07:00
|
|
|
@synthesize feedbackWebView;
|
2012-07-24 16:42:18 -07:00
|
|
|
@synthesize topToolbar;
|
2012-07-21 15:59:10 -07:00
|
|
|
@synthesize toolbar;
|
|
|
|
@synthesize segmentedButton;
|
2012-07-21 12:58:22 -07:00
|
|
|
|
2012-07-10 12:34:58 -07:00
|
|
|
|
|
|
|
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil {
|
|
|
|
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
|
|
|
|
if (self) {
|
|
|
|
// Custom initialization
|
|
|
|
}
|
|
|
|
return self;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void)viewDidLoad {
|
|
|
|
[super viewDidLoad];
|
|
|
|
// Do any additional setup after loading the view from its nib.
|
2012-07-21 15:59:10 -07:00
|
|
|
self.toolbar.tintColor = [UIColor colorWithRed:0.16f green:0.36f blue:0.46 alpha:0.9];
|
2012-07-21 18:56:25 -07:00
|
|
|
self.interactionsModule.hidden = NO;
|
|
|
|
self.activitiesModule.hidden = YES;
|
|
|
|
self.feedbackWebView.hidden = YES;
|
|
|
|
self.feedbackWebView.delegate = self;
|
|
|
|
|
2012-07-24 16:42:18 -07:00
|
|
|
self.topToolbar.tintColor = [UIColor colorWithRed:0.16f green:0.36f blue:0.46 alpha:0.9];
|
|
|
|
|
2012-07-21 18:56:25 -07:00
|
|
|
// preload feedback
|
|
|
|
self.feedbackWebView.scalesPageToFit = YES;
|
|
|
|
|
2012-07-21 18:25:56 -07:00
|
|
|
|
2012-07-21 18:56:25 -07:00
|
|
|
NSString *urlAddress = FEEDBACK_URL;
|
|
|
|
//Create a URL object.
|
|
|
|
NSURL *url = [NSURL URLWithString:urlAddress];
|
|
|
|
//URL Requst Object
|
|
|
|
NSURLRequest *requestObj = [NSURLRequest requestWithURL:url];
|
|
|
|
//Load the request in the UIWebView.
|
|
|
|
[self.feedbackWebView loadRequest:requestObj];
|
2012-07-24 16:42:18 -07:00
|
|
|
|
2012-07-10 12:34:58 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
- (void)viewDidUnload {
|
|
|
|
[self setAppDelegate:nil];
|
2012-07-12 10:59:17 -07:00
|
|
|
[self setInteractionsModule:nil];
|
|
|
|
[self setActivitiesModule:nil];
|
2012-07-21 15:59:10 -07:00
|
|
|
[self setToolbar:nil];
|
|
|
|
[self setSegmentedButton:nil];
|
2012-07-21 18:56:25 -07:00
|
|
|
[self setFeedbackWebView:nil];
|
2012-07-24 16:42:18 -07:00
|
|
|
[self setTopToolbar:nil];
|
2012-07-10 12:34:58 -07:00
|
|
|
[super viewDidUnload];
|
|
|
|
// Release any retained subviews of the main view.
|
|
|
|
// e.g. self.myOutlet = nil;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void)viewWillAppear:(BOOL)animated {
|
2012-07-24 16:42:18 -07:00
|
|
|
|
2012-07-10 12:34:58 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
|
|
|
|
return YES;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (IBAction)doLogout:(id)sender {
|
|
|
|
[appDelegate confirmLogout];
|
|
|
|
}
|
2012-07-10 16:48:05 -07:00
|
|
|
|
|
|
|
# pragma mark
|
2012-07-26 23:07:47 -07:00
|
|
|
# pragma mark Navigation
|
2012-07-11 20:19:42 -07:00
|
|
|
|
2012-07-21 15:59:10 -07:00
|
|
|
- (IBAction)tapSegmentedButton:(id)sender {
|
|
|
|
int selectedSegmentIndex = [self.segmentedButton selectedSegmentIndex];
|
|
|
|
|
|
|
|
if (selectedSegmentIndex == 0) {
|
|
|
|
self.interactionsModule.hidden = NO;
|
|
|
|
self.activitiesModule.hidden = YES;
|
2012-07-21 18:56:25 -07:00
|
|
|
self.feedbackWebView.hidden = YES;
|
2012-07-21 15:59:10 -07:00
|
|
|
} else if (selectedSegmentIndex == 1) {
|
|
|
|
self.interactionsModule.hidden = YES;
|
|
|
|
self.activitiesModule.hidden = NO;
|
2012-07-21 18:56:25 -07:00
|
|
|
self.feedbackWebView.hidden = YES;
|
2012-07-21 15:59:10 -07:00
|
|
|
} else if (selectedSegmentIndex == 2) {
|
2012-07-21 18:56:25 -07:00
|
|
|
self.interactionsModule.hidden = YES;
|
|
|
|
self.activitiesModule.hidden = YES;
|
|
|
|
self.feedbackWebView.hidden = NO;
|
2012-07-21 15:59:10 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-07-11 20:19:42 -07:00
|
|
|
# pragma mark
|
2012-07-26 23:07:47 -07:00
|
|
|
# pragma mark Interactions
|
2012-07-11 20:19:42 -07:00
|
|
|
|
2012-07-26 23:07:47 -07:00
|
|
|
- (void)refreshInteractions {
|
|
|
|
[self.interactionsModule fetchInteractionsDetail:1];
|
2012-07-11 18:08:07 -07:00
|
|
|
}
|
|
|
|
|
2012-07-26 23:07:47 -07:00
|
|
|
# pragma mark
|
|
|
|
# pragma mark Activities
|
2012-07-16 22:35:28 -07:00
|
|
|
|
2012-07-26 23:07:47 -07:00
|
|
|
- (void)refreshActivity {
|
|
|
|
[self.activitiesModule fetchActivitiesDetail:1];
|
2012-07-11 18:08:07 -07:00
|
|
|
}
|
|
|
|
|
2012-07-21 18:56:25 -07:00
|
|
|
# pragma mark
|
|
|
|
# pragma mark Feedback
|
|
|
|
|
|
|
|
- (BOOL)webView:(UIWebView *)webView
|
|
|
|
shouldStartLoadWithRequest:(NSURLRequest *)request
|
|
|
|
navigationType:(UIWebViewNavigationType)navigationType {
|
|
|
|
NSURL *url = [request URL];
|
|
|
|
NSString *urlString = [NSString stringWithFormat:@"%@", url];
|
|
|
|
|
|
|
|
if ([urlString isEqualToString: FEEDBACK_URL]){
|
|
|
|
return YES;
|
|
|
|
} else {
|
|
|
|
return NO;
|
|
|
|
}
|
|
|
|
}
|
2012-07-21 15:59:10 -07:00
|
|
|
@end
|