Skip to content

Commit

Permalink
Clean up View Controllers, setup the HomeViewController, remove some …
Browse files Browse the repository at this point in the history
…unused ViewControllers
  • Loading branch information
Casing Chu committed Feb 19, 2015
1 parent a025ce6 commit 7f3e950
Show file tree
Hide file tree
Showing 18 changed files with 406 additions and 457 deletions.
40 changes: 20 additions & 20 deletions unnamed.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,12 @@
/* Begin PBXBuildFile section */
3E2BB7E01A94FF0000E78B3A /* AppNavigationController.m in Sources */ = {isa = PBXBuildFile; fileRef = 3E2BB7DE1A94FF0000E78B3A /* AppNavigationController.m */; };
3E2BB7E11A94FF0000E78B3A /* AppNavigationController.xib in Resources */ = {isa = PBXBuildFile; fileRef = 3E2BB7DF1A94FF0000E78B3A /* AppNavigationController.xib */; };
3E7C1D4F1A958BC10046FDE1 /* HomeViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 3E7C1D4D1A958BC10046FDE1 /* HomeViewController.m */; };
3E7C1D501A958BC10046FDE1 /* HomeViewController.xib in Resources */ = {isa = PBXBuildFile; fileRef = 3E7C1D4E1A958BC10046FDE1 /* HomeViewController.xib */; };
3E7C1D541A958D120046FDE1 /* SurveyCell.m in Sources */ = {isa = PBXBuildFile; fileRef = 3E7C1D521A958D120046FDE1 /* SurveyCell.m */; };
3E7C1D551A958D120046FDE1 /* SurveyCell.xib in Resources */ = {isa = PBXBuildFile; fileRef = 3E7C1D531A958D120046FDE1 /* SurveyCell.xib */; };
B87C15BC1A93113400191823 /* LoginViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = B87C15B71A93113400191823 /* LoginViewController.m */; };
B87C15BD1A93113400191823 /* LoginViewController.xib in Resources */ = {isa = PBXBuildFile; fileRef = B87C15B81A93113400191823 /* LoginViewController.xib */; };
B87C15BE1A93113400191823 /* MainViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = B87C15BA1A93113400191823 /* MainViewController.m */; };
B87C15BF1A93113400191823 /* MainViewController.xib in Resources */ = {isa = PBXBuildFile; fileRef = B87C15BB1A93113400191823 /* MainViewController.xib */; };
B8BA93E81A9459B5003BD476 /* User.m in Sources */ = {isa = PBXBuildFile; fileRef = B8BA93E71A9459B5003BD476 /* User.m */; };
B8BA93EB1A9464C7003BD476 /* Survey.m in Sources */ = {isa = PBXBuildFile; fileRef = B8BA93EA1A9464C7003BD476 /* Survey.m */; };
B8BA93F41A947718003BD476 /* Answer.m in Sources */ = {isa = PBXBuildFile; fileRef = B8BA93F31A947718003BD476 /* Answer.m */; };
Expand All @@ -30,8 +32,6 @@
E25DBF071A9489530074D48B /* TabBarMenuViewController.xib in Resources */ = {isa = PBXBuildFile; fileRef = E25DBF051A9489530074D48B /* TabBarMenuViewController.xib */; };
E25DBF0B1A948D870074D48B /* ProfileViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = E25DBF091A948D870074D48B /* ProfileViewController.m */; };
E25DBF0C1A948D870074D48B /* ProfileViewController.xib in Resources */ = {isa = PBXBuildFile; fileRef = E25DBF0A1A948D870074D48B /* ProfileViewController.xib */; };
E25DBF101A948E190074D48B /* SurveyViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = E25DBF0E1A948E190074D48B /* SurveyViewController.m */; };
E25DBF111A948E190074D48B /* SurveyViewController.xib in Resources */ = {isa = PBXBuildFile; fileRef = E25DBF0F1A948E190074D48B /* SurveyViewController.xib */; };
EAB0BC95865217516AEE88BF /* libPods.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 4AEAEEA448EAC175BD0FED56 /* libPods.a */; };
/* End PBXBuildFile section */

Expand All @@ -50,14 +50,17 @@
3E2BB7DD1A94FF0000E78B3A /* AppNavigationController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AppNavigationController.h; sourceTree = "<group>"; };
3E2BB7DE1A94FF0000E78B3A /* AppNavigationController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AppNavigationController.m; sourceTree = "<group>"; };
3E2BB7DF1A94FF0000E78B3A /* AppNavigationController.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = AppNavigationController.xib; sourceTree = "<group>"; };
3E7C1D4C1A958BC10046FDE1 /* HomeViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = HomeViewController.h; sourceTree = "<group>"; };
3E7C1D4D1A958BC10046FDE1 /* HomeViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = HomeViewController.m; sourceTree = "<group>"; };
3E7C1D4E1A958BC10046FDE1 /* HomeViewController.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = HomeViewController.xib; sourceTree = "<group>"; };
3E7C1D511A958D120046FDE1 /* SurveyCell.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SurveyCell.h; sourceTree = "<group>"; };
3E7C1D521A958D120046FDE1 /* SurveyCell.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SurveyCell.m; sourceTree = "<group>"; };
3E7C1D531A958D120046FDE1 /* SurveyCell.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = SurveyCell.xib; sourceTree = "<group>"; };
4AEAEEA448EAC175BD0FED56 /* libPods.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libPods.a; sourceTree = BUILT_PRODUCTS_DIR; };
5BA90E0F57CF5978BEB02DE4 /* Pods.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = Pods.release.xcconfig; path = "Pods/Target Support Files/Pods/Pods.release.xcconfig"; sourceTree = "<group>"; };
B87C15B61A93113400191823 /* LoginViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LoginViewController.h; sourceTree = "<group>"; };
B87C15B71A93113400191823 /* LoginViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = LoginViewController.m; sourceTree = "<group>"; };
B87C15B81A93113400191823 /* LoginViewController.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = LoginViewController.xib; sourceTree = "<group>"; };
B87C15B91A93113400191823 /* MainViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MainViewController.h; sourceTree = "<group>"; };
B87C15BA1A93113400191823 /* MainViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MainViewController.m; sourceTree = "<group>"; };
B87C15BB1A93113400191823 /* MainViewController.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = MainViewController.xib; sourceTree = "<group>"; };
B8BA93E61A9459B5003BD476 /* User.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = User.h; sourceTree = "<group>"; };
B8BA93E71A9459B5003BD476 /* User.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = User.m; sourceTree = "<group>"; };
B8BA93E91A9464C7003BD476 /* Survey.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Survey.h; sourceTree = "<group>"; };
Expand Down Expand Up @@ -88,9 +91,6 @@
E25DBF081A948D870074D48B /* ProfileViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ProfileViewController.h; sourceTree = "<group>"; };
E25DBF091A948D870074D48B /* ProfileViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ProfileViewController.m; sourceTree = "<group>"; };
E25DBF0A1A948D870074D48B /* ProfileViewController.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = ProfileViewController.xib; sourceTree = "<group>"; };
E25DBF0D1A948E190074D48B /* SurveyViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SurveyViewController.h; sourceTree = "<group>"; };
E25DBF0E1A948E190074D48B /* SurveyViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SurveyViewController.m; sourceTree = "<group>"; };
E25DBF0F1A948E190074D48B /* SurveyViewController.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = SurveyViewController.xib; sourceTree = "<group>"; };
/* End PBXFileReference section */

/* Begin PBXFrameworksBuildPhase section */
Expand Down Expand Up @@ -205,6 +205,9 @@
B8C0DBD91A95138C0023BC39 /* ComposeAnswerCell.h */,
B8C0DBDA1A95138C0023BC39 /* ComposeAnswerCell.m */,
B8C0DBDB1A95138C0023BC39 /* ComposeAnswerCell.xib */,
3E7C1D511A958D120046FDE1 /* SurveyCell.h */,
3E7C1D521A958D120046FDE1 /* SurveyCell.m */,
3E7C1D531A958D120046FDE1 /* SurveyCell.xib */,
);
name = View;
sourceTree = "<group>";
Expand All @@ -215,21 +218,18 @@
B87C15B61A93113400191823 /* LoginViewController.h */,
B87C15B71A93113400191823 /* LoginViewController.m */,
B87C15B81A93113400191823 /* LoginViewController.xib */,
B87C15B91A93113400191823 /* MainViewController.h */,
B87C15BA1A93113400191823 /* MainViewController.m */,
B87C15BB1A93113400191823 /* MainViewController.xib */,
E25DBF031A9489530074D48B /* TabBarMenuViewController.h */,
E25DBF041A9489530074D48B /* TabBarMenuViewController.m */,
E25DBF051A9489530074D48B /* TabBarMenuViewController.xib */,
E25DBF081A948D870074D48B /* ProfileViewController.h */,
E25DBF091A948D870074D48B /* ProfileViewController.m */,
E25DBF0A1A948D870074D48B /* ProfileViewController.xib */,
E25DBF0D1A948E190074D48B /* SurveyViewController.h */,
E25DBF0E1A948E190074D48B /* SurveyViewController.m */,
E25DBF0F1A948E190074D48B /* SurveyViewController.xib */,
B8C0DBCA1A94F71A0023BC39 /* ComposeViewController.h */,
B8C0DBCB1A94F71A0023BC39 /* ComposeViewController.m */,
B8C0DBCC1A94F71A0023BC39 /* ComposeViewController.xib */,
3E7C1D4C1A958BC10046FDE1 /* HomeViewController.h */,
3E7C1D4D1A958BC10046FDE1 /* HomeViewController.m */,
3E7C1D4E1A958BC10046FDE1 /* HomeViewController.xib */,
);
name = Control;
sourceTree = "<group>";
Expand Down Expand Up @@ -335,14 +335,14 @@
files = (
E25DBF0C1A948D870074D48B /* ProfileViewController.xib in Resources */,
3E2BB7E11A94FF0000E78B3A /* AppNavigationController.xib in Resources */,
E25DBF111A948E190074D48B /* SurveyViewController.xib in Resources */,
E25DBF071A9489530074D48B /* TabBarMenuViewController.xib in Resources */,
B8C291C31A930BDD000F2143 /* LaunchScreen.xib in Resources */,
3E7C1D551A958D120046FDE1 /* SurveyCell.xib in Resources */,
B8C291C01A930BDD000F2143 /* Images.xcassets in Resources */,
B87C15BD1A93113400191823 /* LoginViewController.xib in Resources */,
B87C15BF1A93113400191823 /* MainViewController.xib in Resources */,
B8C0DBDD1A95138C0023BC39 /* ComposeAnswerCell.xib in Resources */,
B8C0DBCE1A94F71A0023BC39 /* ComposeViewController.xib in Resources */,
3E7C1D501A958BC10046FDE1 /* HomeViewController.xib in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down Expand Up @@ -395,17 +395,17 @@
files = (
B8BA93E81A9459B5003BD476 /* User.m in Sources */,
3E2BB7E01A94FF0000E78B3A /* AppNavigationController.m in Sources */,
E25DBF101A948E190074D48B /* SurveyViewController.m in Sources */,
B8BA93F41A947718003BD476 /* Answer.m in Sources */,
B8C0DBCD1A94F71A0023BC39 /* ComposeViewController.m in Sources */,
3E7C1D541A958D120046FDE1 /* SurveyCell.m in Sources */,
B8C291B81A930BDD000F2143 /* AppDelegate.m in Sources */,
B8C291B51A930BDD000F2143 /* main.m in Sources */,
E25DBF0B1A948D870074D48B /* ProfileViewController.m in Sources */,
3E7C1D4F1A958BC10046FDE1 /* HomeViewController.m in Sources */,
B8BA93EB1A9464C7003BD476 /* Survey.m in Sources */,
E25DBF061A9489530074D48B /* TabBarMenuViewController.m in Sources */,
B8C0DBDC1A95138C0023BC39 /* ComposeAnswerCell.m in Sources */,
B87C15BC1A93113400191823 /* LoginViewController.m in Sources */,
B87C15BE1A93113400191823 /* MainViewController.m in Sources */,
B8BA93F71A947817003BD476 /* Vote.m in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
Expand Down
2 changes: 2 additions & 0 deletions unnamed/AppDelegate.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,13 @@
//

#import <UIKit/UIKit.h>
#import "TabBarMenuViewController.h"

@interface AppDelegate : UIResponder <UIApplicationDelegate>

@property (strong, nonatomic) UIWindow *window;

+ (TabBarMenuViewController *)tabBarMenuViewController;

@end

35 changes: 20 additions & 15 deletions unnamed/AppDelegate.m
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@

#import "AppDelegate.h"
#import "LoginViewController.h"
#import "MainViewController.h"
#import "HomeViewController.h"
#import <FacebookSDK/FacebookSDK.h>
#import <Parse/Parse.h>
#import <ParseFacebookUtils/PFFacebookUtils.h>
#import "User.h"
#import "TabBarMenuViewController.h"
#import "SurveyViewController.h"
#import "ComposeViewController.h"
#import "ProfileViewController.h"
#import "AppNavigationController.h"

Expand All @@ -27,6 +27,22 @@ @interface AppDelegate ()

@implementation AppDelegate

+ (TabBarMenuViewController *)tabBarMenuViewController {
static TabBarMenuViewController *instance = nil;

instance = [[TabBarMenuViewController alloc] init];

AppNavigationController * vc1 = [[AppNavigationController alloc] initWithRootViewController:[[HomeViewController alloc] init]];
AppNavigationController * vc2 = [[AppNavigationController alloc] initWithRootViewController:[[ComposeViewController alloc] init]];
AppNavigationController * vc3 = [[AppNavigationController alloc] initWithRootViewController:[[ProfileViewController alloc] init]];

//adding sub view controllers
NSArray* controllers = [NSArray arrayWithObjects:vc1, vc2, vc3, nil];
instance.viewControllers = controllers;
//instance.modalTransitionStyle = UIModalTransitionStyleCrossDissolve;

return instance;
}

- (void) showFBSessionState{
//Debugging purpose to see whether
Expand Down Expand Up @@ -89,21 +105,10 @@ - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(
}

if(shouldOpenLoginView){
self.window.rootViewController = [[AppNavigationController alloc] initWithRootViewController:[[LoginViewController alloc] init]];
self.window.rootViewController = [[LoginViewController alloc] init];
self.window.backgroundColor = [UIColor whiteColor];
}else{
//here we create the tab bar view controller
TabBarMenuViewController * tbmvc = [[TabBarMenuViewController alloc] init];

AppNavigationController * vc1 = [[AppNavigationController alloc] initWithRootViewController:[[MainViewController alloc] init]];
AppNavigationController * vc2 = [[AppNavigationController alloc] initWithRootViewController:[[SurveyViewController alloc] init]];
AppNavigationController * vc3 = [[AppNavigationController alloc] initWithRootViewController:[[ProfileViewController alloc] init]];

//adding sub view controllers
NSArray* controllers = [NSArray arrayWithObjects:vc1, vc2, vc3, nil];
tbmvc.viewControllers = controllers;

self.window.rootViewController = tbmvc;
self.window.rootViewController = [AppDelegate tabBarMenuViewController];
}

[self.window makeKeyAndVisible];
Expand Down
13 changes: 2 additions & 11 deletions unnamed/AppNavigationController.m
Original file line number Diff line number Diff line change
Expand Up @@ -16,22 +16,13 @@ @implementation AppNavigationController

- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view from its nib.
self.navigationBar.translucent = NO;
self.navigationBar.barTintColor = [UIColor whiteColor];
}

- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation
// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
// Get the new view controller using [segue destinationViewController].
// Pass the selected object to the new view controller.
}
*/

@end
14 changes: 12 additions & 2 deletions unnamed/ComposeViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,16 @@ @interface ComposeViewController () <UITableViewDataSource, UITableViewDelegate,
@end

@implementation ComposeViewController

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil {
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {
self.title = @"Create";
self.tabBarItem.image = [UIImage imageNamed:@"Poll Topic"];
}
return self;
}

- (ComposeAnswerCell *)prototypeCell {
if (!_prototypeCell) {
_prototypeCell = [self.tableView dequeueReusableCellWithIdentifier:AnswerCell];
Expand All @@ -36,8 +46,8 @@ - (ComposeAnswerCell *)prototypeCell {

- (void)viewDidLoad {
[super viewDidLoad];
self.title = @"Create";
self.navigationController.navigationBar.translucent = NO;

// Button
UIBarButtonItem *cancelButton = [[UIBarButtonItem alloc] initWithTitle:@"Cancel" style:UIBarButtonItemStylePlain target:self action:@selector(onCancelButton)];
self.navigationItem.leftBarButtonItem = cancelButton;
UIBarButtonItem *submitButton = [[UIBarButtonItem alloc] initWithTitle:@"Submit" style:UIBarButtonItemStylePlain target:self action:@selector(onSubmitButton)];
Expand Down
13 changes: 13 additions & 0 deletions unnamed/HomeViewController.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
//
// HomeViewController.h
// unnamed
//
// Created by Casing Chu on 2/18/15.
// Copyright (c) 2015 com.yahoo. All rights reserved.
//

#import <UIKit/UIKit.h>

@interface HomeViewController : UIViewController

@end
80 changes: 80 additions & 0 deletions unnamed/HomeViewController.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
//
// HomeViewController.m
// unnamed
//
// Created by Casing Chu on 2/18/15.
// Copyright (c) 2015 com.yahoo. All rights reserved.
//

#import "HomeViewController.h"
#import "SurveyCell.h"

NSString * const kSurveyCell = @"SurveyCell";

@interface HomeViewController () <UITableViewDelegate, UITableViewDataSource>
@property (weak, nonatomic) IBOutlet UITableView *tableView;
@property (nonatomic, strong) UIRefreshControl *tableRefreshControl;

@property (nonatomic,strong) NSMutableArray *surveys;

@end

@implementation HomeViewController

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil {
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {
self.title = @"Home";
self.tabBarItem.image = [UIImage imageNamed:@"Home"];
}
return self;
}

- (void)viewDidLoad {
[super viewDidLoad];

// Setup Objects
self.surveys = [[NSMutableArray alloc] init];

// Table Refresh control
self.tableRefreshControl = [[UIRefreshControl alloc] init];
[self.tableRefreshControl addTarget:self action:@selector(onTableRefresh) forControlEvents:UIControlEventValueChanged];
[self.tableView insertSubview:self.tableRefreshControl atIndex:0];

// TableView Setup
self.tableView.dataSource = self;
self.tableView.delegate = self;
[self.tableView registerNib:[UINib nibWithNibName:kSurveyCell bundle:nil] forCellReuseIdentifier:kSurveyCell];
self.tableView.rowHeight = UITableViewAutomaticDimension;
}

- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}

#pragma mark - RefreshControl
- (void)onTableRefresh {
NSLog(@"onTableRefresh");
[self.tableRefreshControl endRefreshing];
}

#pragma mark - TableViewDelegate Methods
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
return self.surveys.count;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
SurveyCell *cell = [self.tableView dequeueReusableCellWithIdentifier:kSurveyCell];
return cell;
}

- (CGFloat)tableView:(UITableView *)tableView estimatedHeightForRowAtIndexPath:(NSIndexPath *)indexPath {
return UITableViewAutomaticDimension;
}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
[tableView deselectRowAtIndexPath:indexPath animated:YES];
}

@end
Loading

0 comments on commit 7f3e950

Please sign in to comment.