Permalink
Browse files

add to pod works

  • Loading branch information...
1 parent 3818cb5 commit 16292528517696798e26e6a96d7187e8e056257c Ammon Bartram committed Nov 7, 2011
@@ -8,7 +8,12 @@
#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) UITableView *memberTableView;
@@ -7,6 +7,7 @@
//
#import "MemberListViewController.h"
+#import "GroupSelectorManager.h"
@implementation MemberListViewController
@@ -25,6 +26,12 @@ -(id)init {
return self;
}
+- (void) dealloc {
+ [_footerView release];
+ [_groupSelector release];
+ [super dealloc];
+}
+
- (void)didReceiveMemoryWarning
{
// Releases the view if it doesn't have a superview.
@@ -47,13 +54,38 @@ - (void)loadView
[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;
[view release];
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.
@@ -9,14 +9,13 @@
#import "ContactFetchManager.h"
#import "SCGroupSelectorTableViewController.h"
-@class SCVideo;
@interface GroupSelectorManager : NSObject<SCContactFetcherDelegate, SCGroupSelectorTableViewControllerDelegate> {
- SCVideo *_video;
ContactFetchManager *_contactFetcher;
SCGroupSelectorTableViewController *_shareGroupSelectorController;
+ NSDictionary *_pod;
}
- (void) showGroupView:(UINavigationController *)navCon;
+@property(nonatomic, retain) NSDictionary *pod;
-@property (nonatomic, retain) SCVideo *video;
@end
@@ -14,7 +14,7 @@
#import "AccountManager.h"
@implementation GroupSelectorManager
-@synthesize video = _video;
+@synthesize pod = _pod;
- (id) init {
@@ -30,13 +30,19 @@ - (void) showGroupView:(UINavigationController *)navCon {
[_contactFetcher fetchContacts];
[_shareGroupSelectorController release];
_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;
[navCon pushViewController:_shareGroupSelectorController animated:YES];
}
- (void) dealloc {
- [_video release];
+ [_pod release];
[_contactFetcher release];
[_shareGroupSelectorController release];
[super dealloc];
@@ -51,30 +57,35 @@ - (void) contactFetcherDidFetchContacts:(ContactFetchManager *)fetch {
- (void) groupSelectorDidClose:(SCGroupSelectorTableViewController *)groupSelector doneClicked:(BOOL)done {
NSLog(@"groupSelectorDidClose");
if (done && groupSelector.selectedItems.count) {
- ASIFormDataRequest *request = [ASIFormDataRequest apiRequestWithAPI:@"messages" target:self selectorFormat:@"podCreateRequest"];
- request.requestMethod = POST;
- [request setPostValue:[AccountManager sharedAccountManager].accessToken forKey:@"token"];
- [request setPostValue:groupSelector.message forKey:@"content"];
- [request setPostValue:[groupSelector titleForSelectedGroupWithFont:[UIFont boldSystemFontOfSize:18.0] constrainedToWidth:320.] forKey:@"new_group[name]"];
+ if (!_pod) {
+ ASIFormDataRequest *request = [ASIFormDataRequest apiRequestWithAPI:@"messages" target:self selectorFormat:@"podCreateRequest"];
+ request.requestMethod = POST;
+ [request setPostValue:[AccountManager sharedAccountManager].accessToken forKey:@"token"];
+ [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) {
- if ([[d objectForKey:@"type"] isEqual:@"humanity"]) {
- [request setPostValue:[d objectForKey:@"id"] forKey:@"new_group[user_ids][]"];
- } else if ([[d objectForKey:@"type"] isEqual:@"phone"]) {
- [request setPostValue:[d objectForKey:@"id"] forKey:@"new_group[phone_numbers][][number]"];
- if ([d objectForKey:@"first_name"])
- [request setPostValue:[d objectForKey:@"first_name"] forKey:@"new_group[phone_numbers][][first_name]"];
- if ([d objectForKey:@"last_name"])
- [request setPostValue:[d objectForKey:@"last_name"] forKey:@"new_group[phone_numbers][][last_name]"];
- } else if ([[d objectForKey:@"type"] isEqual:@"email"]) {
- [request setPostValue:[d objectForKey:@"id"] forKey:@"new_group[emails][][email]"];
- if ([d objectForKey:@"first_name"])
- [request setPostValue:[d objectForKey:@"first_name"] forKey:@"new_group[emails][][first_name]"];
- if ([d objectForKey:@"last_name"])
- [request setPostValue:[d objectForKey:@"last_name"] forKey:@"new_group[emails][][last_name]"];
- }
- }
- [[SCAPIRequestController sharedController] addRequest:request];
+ for (NSDictionary *d in groupSelector.selectedItems) {
+ if ([[d objectForKey:@"type"] isEqual:@"humanity"]) {
+ [request setPostValue:[d objectForKey:@"id"] forKey:@"new_group[user_ids][]"];
+ } else if ([[d objectForKey:@"type"] isEqual:@"phone"]) {
+ [request setPostValue:[d objectForKey:@"id"] forKey:@"new_group[phone_numbers][][number]"];
+ if ([d objectForKey:@"first_name"])
+ [request setPostValue:[d objectForKey:@"first_name"] forKey:@"new_group[phone_numbers][][first_name]"];
+ if ([d objectForKey:@"last_name"])
+ [request setPostValue:[d objectForKey:@"last_name"] forKey:@"new_group[phone_numbers][][last_name]"];
+ } else if ([[d objectForKey:@"type"] isEqual:@"email"]) {
+ [request setPostValue:[d objectForKey:@"id"] forKey:@"new_group[emails][][email]"];
+ if ([d objectForKey:@"first_name"])
+ [request setPostValue:[d objectForKey:@"first_name"] forKey:@"new_group[emails][][first_name]"];
+ if ([d objectForKey:@"last_name"])
+ [request setPostValue:[d objectForKey:@"last_name"] forKey:@"new_group[emails][][last_name]"];
+ }
+ }
+ [[SCAPIRequestController sharedController] addRequest:request];
+ } else {
+ //TODO: add people to pod
+
+ }
}
}
@@ -242,11 +242,11 @@ - (id) initWithItems:(NSArray *)items {
UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
[button setTitle:@"Add To Pod" 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 addTarget:self action:@selector(doneButtonPressed:) forControlEvents:UIControlEventTouchUpInside];
[_addPeopleView addSubview:button];
- button.frame = CGRectMake(0, 0, 150, 30);
+ button.frame = CGRectMake(0, 0, 200, 35);
button.center = _addPeopleView.center;
_addPeopleView.hidden = YES;

0 comments on commit 1629252

Please sign in to comment.