Skip to content

Commit

Permalink
add to pod works
Browse files Browse the repository at this point in the history
  • Loading branch information
Ammon Bartram committed Nov 7, 2011
1 parent 3818cb5 commit 1629252
Show file tree
Hide file tree
Showing 5 changed files with 79 additions and 32 deletions.
7 changes: 6 additions & 1 deletion Humanity/Humanity/Group Screen/MemberListViewController.h
Expand Up @@ -8,7 +8,12 @@


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


@interface MemberListViewController : UIViewController<UITableViewDelegate, UITableViewDataSource> @class GroupSelectorManager;
@interface MemberListViewController : UIViewController<UITableViewDelegate, UITableViewDataSource> {
UIView *_footerView;
GroupSelectorManager *_groupSelector;
}



@property (nonatomic, retain) NSMutableArray *members; @property (nonatomic, retain) NSMutableArray *members;
@property (nonatomic, retain) UITableView *memberTableView; @property (nonatomic, retain) UITableView *memberTableView;
Expand Down
32 changes: 32 additions & 0 deletions Humanity/Humanity/Group Screen/MemberListViewController.m
Expand Up @@ -7,6 +7,7 @@
// //


#import "MemberListViewController.h" #import "MemberListViewController.h"
#import "GroupSelectorManager.h"


@implementation MemberListViewController @implementation MemberListViewController


Expand All @@ -25,6 +26,12 @@ -(id)init {
return self; return self;
} }


- (void) dealloc {
[_footerView release];
[_groupSelector release];
[super dealloc];
}

- (void)didReceiveMemoryWarning - (void)didReceiveMemoryWarning
{ {
// Releases the view if it doesn't have a superview. // Releases the view if it doesn't have a superview.
Expand All @@ -47,13 +54,38 @@ - (void)loadView


[view addSubview:self.memberTableView]; [view addSubview:self.memberTableView];


_footerView = [[UIView alloc] initWithFrame:CGRectMake(0, view.bounds.size.height - 44. - 20. - 44. - 49., 320, 44.)];
_footerView.backgroundColor = [UIColor grayColor];
UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
[button setTitle:@"Add People" forState:UIControlStateNormal];
[button setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
button.titleLabel.font = [UIFont boldSystemFontOfSize:18.0];
button.backgroundColor = [UIColor colorWithRed:30./255.0 green:128/255.0 blue:20/255.0 alpha:1.0];
[button addTarget:self action:@selector(addPeople:) forControlEvents:UIControlEventTouchUpInside];
[_footerView addSubview:button];
button.frame = CGRectMake(0, 0, 200, 35);
CGRect frame = button.frame;
frame.origin.x = _footerView.frame.size.width / 2. - frame.size.width / 2.;
frame.origin.y = _footerView.frame.size.height / 2. - frame.size.height / 2.;
button.frame = frame;

[view addSubview:_footerView];

self.view = view; self.view = view;
[view release]; [view release];


self.navigationController.navigationBar.barStyle = UIBarStyleBlack; self.navigationController.navigationBar.barStyle = UIBarStyleBlack;


} }


- (void) addPeople:(id)sender{
if (!_groupSelector) {
_groupSelector = [[GroupSelectorManager alloc] init];
//TODO: set a dictionary with info on the pod
_groupSelector.pod = [NSDictionary dictionary];
}
[_groupSelector showGroupView:self.navigationController];
}


/* /*
// Implement viewDidLoad to do additional setup after loading the view, typically from a nib. // Implement viewDidLoad to do additional setup after loading the view, typically from a nib.
Expand Down
5 changes: 2 additions & 3 deletions Humanity/Humanity/GroupPicker/GroupSelectorManager.h
Expand Up @@ -9,14 +9,13 @@
#import "ContactFetchManager.h" #import "ContactFetchManager.h"
#import "SCGroupSelectorTableViewController.h" #import "SCGroupSelectorTableViewController.h"


@class SCVideo;
@interface GroupSelectorManager : NSObject<SCContactFetcherDelegate, SCGroupSelectorTableViewControllerDelegate> { @interface GroupSelectorManager : NSObject<SCContactFetcherDelegate, SCGroupSelectorTableViewControllerDelegate> {
SCVideo *_video;
ContactFetchManager *_contactFetcher; ContactFetchManager *_contactFetcher;
SCGroupSelectorTableViewController *_shareGroupSelectorController; SCGroupSelectorTableViewController *_shareGroupSelectorController;
NSDictionary *_pod;
} }


- (void) showGroupView:(UINavigationController *)navCon; - (void) showGroupView:(UINavigationController *)navCon;
@property(nonatomic, retain) NSDictionary *pod;


@property (nonatomic, retain) SCVideo *video;
@end @end
63 changes: 37 additions & 26 deletions Humanity/Humanity/GroupPicker/GroupSelectorManager.m
Expand Up @@ -14,7 +14,7 @@
#import "AccountManager.h" #import "AccountManager.h"


@implementation GroupSelectorManager @implementation GroupSelectorManager
@synthesize video = _video; @synthesize pod = _pod;




- (id) init { - (id) init {
Expand All @@ -30,13 +30,19 @@ - (void) showGroupView:(UINavigationController *)navCon {
[_contactFetcher fetchContacts]; [_contactFetcher fetchContacts];
[_shareGroupSelectorController release]; [_shareGroupSelectorController release];
_shareGroupSelectorController = [[SCGroupSelectorTableViewController alloc] initWithItems:_contactFetcher.shareItems]; _shareGroupSelectorController = [[SCGroupSelectorTableViewController alloc] initWithItems:_contactFetcher.shareItems];
_shareGroupSelectorController.title = NSLocalizedString(@"Create Pod", nil); if (_pod) {
_shareGroupSelectorController.displayAddPeopleButton = YES;
_shareGroupSelectorController.title = NSLocalizedString(@"Add People", nil);
} else {
_shareGroupSelectorController.title = NSLocalizedString(@"Create Pod", nil);
}

_shareGroupSelectorController.delegate = self; _shareGroupSelectorController.delegate = self;
[navCon pushViewController:_shareGroupSelectorController animated:YES]; [navCon pushViewController:_shareGroupSelectorController animated:YES];
} }


- (void) dealloc { - (void) dealloc {
[_video release]; [_pod release];
[_contactFetcher release]; [_contactFetcher release];
[_shareGroupSelectorController release]; [_shareGroupSelectorController release];
[super dealloc]; [super dealloc];
Expand All @@ -51,30 +57,35 @@ - (void) contactFetcherDidFetchContacts:(ContactFetchManager *)fetch {
- (void) groupSelectorDidClose:(SCGroupSelectorTableViewController *)groupSelector doneClicked:(BOOL)done { - (void) groupSelectorDidClose:(SCGroupSelectorTableViewController *)groupSelector doneClicked:(BOOL)done {
NSLog(@"groupSelectorDidClose"); NSLog(@"groupSelectorDidClose");
if (done && groupSelector.selectedItems.count) { if (done && groupSelector.selectedItems.count) {
ASIFormDataRequest *request = [ASIFormDataRequest apiRequestWithAPI:@"messages" target:self selectorFormat:@"podCreateRequest"]; if (!_pod) {
request.requestMethod = POST; ASIFormDataRequest *request = [ASIFormDataRequest apiRequestWithAPI:@"messages" target:self selectorFormat:@"podCreateRequest"];
[request setPostValue:[AccountManager sharedAccountManager].accessToken forKey:@"token"]; request.requestMethod = POST;
[request setPostValue:groupSelector.message forKey:@"content"]; [request setPostValue:[AccountManager sharedAccountManager].accessToken forKey:@"token"];
[request setPostValue:[groupSelector titleForSelectedGroupWithFont:[UIFont boldSystemFontOfSize:18.0] constrainedToWidth:320.] forKey:@"new_group[name]"]; [request setPostValue:groupSelector.message forKey:@"content"];
[request setPostValue:[groupSelector titleForSelectedGroupWithFont:[UIFont boldSystemFontOfSize:18.0] constrainedToWidth:320.] forKey:@"new_group[name]"];


for (NSDictionary *d in groupSelector.selectedItems) { for (NSDictionary *d in groupSelector.selectedItems) {
if ([[d objectForKey:@"type"] isEqual:@"humanity"]) { if ([[d objectForKey:@"type"] isEqual:@"humanity"]) {
[request setPostValue:[d objectForKey:@"id"] forKey:@"new_group[user_ids][]"]; [request setPostValue:[d objectForKey:@"id"] forKey:@"new_group[user_ids][]"];
} else if ([[d objectForKey:@"type"] isEqual:@"phone"]) { } else if ([[d objectForKey:@"type"] isEqual:@"phone"]) {
[request setPostValue:[d objectForKey:@"id"] forKey:@"new_group[phone_numbers][][number]"]; [request setPostValue:[d objectForKey:@"id"] forKey:@"new_group[phone_numbers][][number]"];
if ([d objectForKey:@"first_name"]) if ([d objectForKey:@"first_name"])
[request setPostValue:[d objectForKey:@"first_name"] forKey:@"new_group[phone_numbers][][first_name]"]; [request setPostValue:[d objectForKey:@"first_name"] forKey:@"new_group[phone_numbers][][first_name]"];
if ([d objectForKey:@"last_name"]) if ([d objectForKey:@"last_name"])
[request setPostValue:[d objectForKey:@"last_name"] forKey:@"new_group[phone_numbers][][last_name]"]; [request setPostValue:[d objectForKey:@"last_name"] forKey:@"new_group[phone_numbers][][last_name]"];
} else if ([[d objectForKey:@"type"] isEqual:@"email"]) { } else if ([[d objectForKey:@"type"] isEqual:@"email"]) {
[request setPostValue:[d objectForKey:@"id"] forKey:@"new_group[emails][][email]"]; [request setPostValue:[d objectForKey:@"id"] forKey:@"new_group[emails][][email]"];
if ([d objectForKey:@"first_name"]) if ([d objectForKey:@"first_name"])
[request setPostValue:[d objectForKey:@"first_name"] forKey:@"new_group[emails][][first_name]"]; [request setPostValue:[d objectForKey:@"first_name"] forKey:@"new_group[emails][][first_name]"];
if ([d objectForKey:@"last_name"]) if ([d objectForKey:@"last_name"])
[request setPostValue:[d objectForKey:@"last_name"] forKey:@"new_group[emails][][last_name]"]; [request setPostValue:[d objectForKey:@"last_name"] forKey:@"new_group[emails][][last_name]"];
} }
} }
[[SCAPIRequestController sharedController] addRequest:request]; [[SCAPIRequestController sharedController] addRequest:request];
} else {
//TODO: add people to pod

}
} }
} }


Expand Down
Expand Up @@ -242,11 +242,11 @@ - (id) initWithItems:(NSArray *)items {
UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom]; UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
[button setTitle:@"Add To Pod" forState:UIControlStateNormal]; [button setTitle:@"Add To Pod" forState:UIControlStateNormal];
[button setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal]; [button setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
button.titleLabel.font = [UIFont boldSystemFontOfSize:14.0]; button.titleLabel.font = [UIFont boldSystemFontOfSize:18.0];
button.backgroundColor = [UIColor colorWithRed:30./255.0 green:128/255.0 blue:20/255.0 alpha:1.0]; button.backgroundColor = [UIColor colorWithRed:30./255.0 green:128/255.0 blue:20/255.0 alpha:1.0];
[button addTarget:self action:@selector(doneButtonPressed:) forControlEvents:UIControlEventTouchUpInside]; [button addTarget:self action:@selector(doneButtonPressed:) forControlEvents:UIControlEventTouchUpInside];
[_addPeopleView addSubview:button]; [_addPeopleView addSubview:button];
button.frame = CGRectMake(0, 0, 150, 30); button.frame = CGRectMake(0, 0, 200, 35);
button.center = _addPeopleView.center; button.center = _addPeopleView.center;
_addPeopleView.hidden = YES; _addPeopleView.hidden = YES;


Expand Down

0 comments on commit 1629252

Please sign in to comment.