Permalink
Browse files

all be okay..

  • Loading branch information...
1 parent c62e4d4 commit 8d46196cf8a9cb6b1ee6633da7a7b31ea53b7e60 @jovhenni19 committed Dec 23, 2013
Showing with 3,820 additions and 1,184 deletions.
  1. +40 −34 AgentBridge.xcodeproj/project.pbxproj
  2. BIN ...xcodeproj/project.xcworkspace/xcuserdata/host24_iosdev.xcuserdatad/UserInterfaceState.xcuserstate
  3. +779 −195 AgentBridge/ABridge_ActivityPagesViewController.m
  4. +1 −1 AgentBridge/ABridge_AgentInvitesViewController.h
  5. +136 −7 AgentBridge/ABridge_AgentInvitesViewController.m
  6. +21 −0 AgentBridge/ABridge_AutocompleteTextField.h
  7. +192 −0 AgentBridge/ABridge_AutocompleteTextField.m
  8. +2 −1 AgentBridge/ABridge_BrokerageViewController.h
  9. +387 −74 AgentBridge/ABridge_BrokerageViewController.m
  10. +2 −0 AgentBridge/ABridge_BuyerPagesViewController.m
  11. +1 −0 AgentBridge/ABridge_BuyerPopsViewController.h
  12. +88 −2 AgentBridge/ABridge_BuyerPopsViewController.m
  13. +6 −0 AgentBridge/ABridge_BuyerViewController.m
  14. +44 −41 AgentBridge/ABridge_ContactInfoViewController.m
  15. +3 −0 AgentBridge/ABridge_PropertyPagesViewController.h
  16. +292 −27 AgentBridge/ABridge_PropertyPagesViewController.m
  17. +20 −19 AgentBridge/ABridge_PropertyPagesViewController.xib
  18. +1 −1 AgentBridge/ABridge_PropertyViewController.h
  19. +125 −0 AgentBridge/ABridge_PropertyViewController.m
  20. +1 −1 AgentBridge/AgentBridge-Info.plist
  21. +5 −3 AgentBridge/AgentBridge.xcdatamodeld/AgentBridge.xcdatamodel/contents
  22. +12 −10 AgentBridge/CoreData Objects/Activity.h
  23. +12 −10 AgentBridge/CoreData Objects/Activity.m
  24. +0 −24 AgentBridge/HTAutocomplete/HTAutocompleteManager.h
  25. +0 −114 AgentBridge/HTAutocomplete/HTAutocompleteManager.m
  26. +0 −72 AgentBridge/HTAutocomplete/HTAutocompleteTextField.h
  27. +0 −327 AgentBridge/HTAutocomplete/HTAutocompleteTextField.m
  28. +0 −18 AgentBridge/HTAutocomplete/HTEmailAutocompleteTextField.h
  29. +0 −93 AgentBridge/HTAutocomplete/HTEmailAutocompleteTextField.m
  30. +71 −0 AgentBridge/MLPAutoCompleteTextField/MLPAutoCompleteTextField.h
  31. +1,073 −0 AgentBridge/MLPAutoCompleteTextField/MLPAutoCompleteTextField.m
  32. +46 −0 AgentBridge/MLPAutoCompleteTextField/MLPAutoCompleteTextFieldDataSource.h
  33. +48 −0 AgentBridge/MLPAutoCompleteTextField/MLPAutoCompleteTextFieldDelegate.h
  34. +35 −0 AgentBridge/MLPAutoCompleteTextField/MLPAutoCompletionObject.h
  35. +53 −0 AgentBridge/MLPAutoCompleteTextField/NSString+Levenshtein.h
  36. +140 −0 AgentBridge/MLPAutoCompleteTextField/NSString+Levenshtein.m
  37. +184 −110 AgentBridge/Main.storyboard
Oops, something went wrong.
Oops, something went wrong.
@@ -9,6 +9,6 @@
#import "ABridge_ParentViewController.h"
#import "ASIHTTPRequest.h"
-@interface ABridge_AgentInvitesViewController : ABridge_ParentViewController
+@interface ABridge_AgentInvitesViewController : ABridge_ParentViewController <UITextFieldDelegate>
@end
@@ -16,14 +16,18 @@ @interface ABridge_AgentInvitesViewController ()
@property (weak, nonatomic) IBOutlet UITextField *textFieldEmail;
@property (weak, nonatomic) IBOutlet UITextField *textFieldZipcode;
@property (weak, nonatomic) IBOutlet UIButton *buttonSend;
+@property (weak, nonatomic) IBOutlet UIView *viewContent;
+@property (weak, nonatomic) IBOutlet UIActivityIndicatorView *activityIndicator;
- (IBAction)sendInvite:(id)sender;
@property (assign, nonatomic) NSInteger numberOfInvites;
+@property (strong, nonatomic) AgentProfile *profileData;
@end
@implementation ABridge_AgentInvitesViewController
@synthesize numberOfInvites;
+@synthesize profileData;
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
@@ -74,16 +78,25 @@ - (void)viewDidLoad
fetchedObjects = nil;
fetchedObjects = [context executeFetchRequest:fetchRequest error:&error];
- AgentProfile *profileData = nil;
for (AgentProfile *profile in fetchedObjects) {
if ([profile.user_id integerValue] == [[[fetchedObjects firstObject] valueForKey:@"user_id"] integerValue]) {
- profileData = profile;
+ self.profileData = profile;
break;
}
}
+ [self checkInvites];
- NSString *parameters = [NSString stringWithFormat:@"?profile_id=%@", profileData.profile_id];
+}
+
+- (void)didReceiveMemoryWarning
+{
+ [super didReceiveMemoryWarning];
+ // Dispose of any resources that can be recreated.
+}
+
+- (void) checkInvites {
+ NSString *parameters = [NSString stringWithFormat:@"?profile_id=%@", self.profileData.profile_id];
NSString *urlString = [NSString stringWithFormat:@"http://keydiscoveryinc.com/agent_bridge/webservice/getinvites.php%@",parameters];
@@ -109,6 +122,12 @@ - (void)viewDidLoad
self.labelInviteTitle.text = [NSString stringWithFormat:@"You may sponsor %i agents for membership.",self.numberOfInvites];
[self.labelInviteTitle sizeToFit];
+
+ self.textFieldEmail.text = @"";
+ self.textFieldFirstname.text = @"";
+ self.textFieldLastname.text = @"";
+ self.textFieldZipcode.text = @"";
+ self.buttonSend.enabled = YES;
}
}];
@@ -118,18 +137,109 @@ - (void)viewDidLoad
}];
[request startAsynchronous];
-
}
-- (void)didReceiveMemoryWarning
+-(BOOL) NSStringIsValidEmail:(NSString *)checkString
{
- [super didReceiveMemoryWarning];
- // Dispose of any resources that can be recreated.
+ BOOL stricterFilter = YES; // Discussion http://blog.logichigh.com/2010/09/02/validating-an-e-mail-address/
+ NSString *stricterFilterString = @"[A-Z0-9a-z\\._%+-]+@([A-Za-z0-9-]+\\.)+[A-Za-z]{2,4}";
+ NSString *laxString = @".+@([A-Za-z0-9]+\\.)+[A-Za-z]{2}[A-Za-z]*";
+ NSString *emailRegex = stricterFilter ? stricterFilterString : laxString;
+ NSPredicate *emailTest = [NSPredicate predicateWithFormat:@"SELF MATCHES %@", emailRegex];
+ return [emailTest evaluateWithObject:checkString];
}
- (IBAction)sendInvite:(id)sender {
+ [self.textFieldFirstname resignFirstResponder];
+ [self.textFieldLastname resignFirstResponder];
+ [self.textFieldEmail resignFirstResponder];
+ [self.textFieldZipcode resignFirstResponder];
+
+ self.buttonSend.enabled = NO;
+ self.activityIndicator.hidden = NO;
+ if ([self NSStringIsValidEmail:self.textFieldEmail.text]) {
+ NSString *parameters = [NSString stringWithFormat:@"?email=%@", self.textFieldEmail.text];
+
+ NSString *urlString = [NSString stringWithFormat:@"http://keydiscoveryinc.com/agent_bridge/webservice/validate_invite.php%@",parameters];
+
+ __block NSError *errorData = nil;
+ __block ASIHTTPRequest *request = [ASIHTTPRequest requestWithURL:[NSURL URLWithString:urlString]];
+ [request setCompletionBlock:^{
+ NSData *responseData = [request responseData];
+ NSDictionary *json = [NSJSONSerialization JSONObjectWithData:responseData options:NSJSONReadingAllowFragments error:&errorData];
+
+ if ([[json objectForKey:@"status"] integerValue] > 0) {
+
+ UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Invite Error" message:[json objectForKey:@"message"] delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil];
+ [alert show];
+ self.buttonSend.enabled = YES;
+ self.activityIndicator.hidden = YES;
+ }
+ else {
+ //Submit invite
+
+ self.buttonSend.enabled = NO;
+ self.activityIndicator.hidden = NO;
+
+ [self submit];
+ }
+
+ }];
+ [request setFailedBlock:^{
+ NSError *error = [request error];
+ NSLog(@"25 error:%@",error);
+
+ }];
+ [request startAsynchronous];
+ }
+ else {
+
+ self.buttonSend.enabled = YES;
+ self.activityIndicator.hidden = YES;
+ UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Invite Error" message:@"Please Input a valid Email Address" delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil];
+ [alert show];
+ }
+}
+
+- (void) submit {
+ NSString *parametersSend = [NSString stringWithFormat:@"?firstname=%@&lastname=%@&email=%@&zip=%@&user_id=%@&profile_id=%@", self.textFieldFirstname.text, self.textFieldLastname.text, self.textFieldEmail.text, self.textFieldZipcode.text, self.profileData.user_id, self.profileData.profile_id];
+
+ NSString *urlStringSend = [NSString stringWithFormat:@"http://keydiscoveryinc.com/agent_bridge/webservice/send_invite.php%@",parametersSend];
+// NSLog(@"url:%@",urlStringSend);
+ __block NSError *errorDataSend = nil;
+ __block ASIHTTPRequest *requestSend = [ASIHTTPRequest requestWithURL:[NSURL URLWithString:urlStringSend]];
+ [requestSend setCompletionBlock:^{
+ NSData *responseDataSend = [requestSend responseData];
+ NSDictionary *jsonSend = [NSJSONSerialization JSONObjectWithData:responseDataSend options:NSJSONReadingAllowFragments error:&errorDataSend];
+// NSLog(@"%@json:%@",[requestSend responseString],jsonSend);
+ if ([[jsonSend objectForKey:@"status"] integerValue] == 1) {
+
+ NSLog(@"Successful");
+
+ UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Message" message:@"Invitation Sent." delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil];
+ [alert show];
+ [self checkInvites];
+ }
+ else {
+ NSLog(@"Failed");
+ }
+ self.buttonSend.enabled = YES;
+ self.activityIndicator.hidden = YES;
+
+ }];
+ [requestSend setFailedBlock:^{
+ NSError *error = [requestSend error];
+ NSLog(@"25 error:%@",error);
+
+ }];
+ [requestSend startAsynchronous];
}
+- (BOOL)textFieldShouldReturn:(UITextField *)textField {
+
+ [textField resignFirstResponder];
+ return NO;
+}
- (void) addPaddingAndBorder:(UITextField*)textField color:(UIColor*)color {
UIView *paddingView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 15, 20)];
@@ -139,4 +249,23 @@ - (void) addPaddingAndBorder:(UITextField*)textField color:(UIColor*)color {
textField.layer.borderColor = color.CGColor;
textField.layer.borderWidth = 1.0f;
}
+
+- (void)textFieldDidBeginEditing:(UITextField *)textField {
+ [UIView animateWithDuration:0.2 animations:^{
+ CGRect frame = self.viewContent.frame;
+ frame.origin.y = -17.0f;
+ self.viewContent.frame = frame;
+ }];
+}
+
+- (void)textFieldDidEndEditing:(UITextField *)textField {
+ [UIView animateWithDuration:0.2 animations:^{
+ CGRect frame = self.viewContent.frame;
+ frame.origin.y = 52.0f;
+ self.viewContent.frame = frame;
+ }];
+}
+
+
+
@end
@@ -0,0 +1,21 @@
+//
+// ABridge_AutocompleteTextField.h
+// AgentBridge
+//
+// Created by host24_iOS Dev on 12/23/13.
+// Copyright (c) 2013 host24_iOS Dev. All rights reserved.
+//
+
+#import <UIKit/UIKit.h>
+#import <QuartzCore/QuartzCore.h>
+
+@interface ABridge_AutocompleteTextField : UITextField <UITableViewDelegate, UITableViewDataSource> {
+ NSMutableArray *autoCompleteArray;
+ NSMutableArray *elementArray, *lowerCaseElementArray;
+ UITableView *autoCompleteTableView;
+}
+
+@property (strong, nonatomic) NSArray *autoCompleteContents;
+@property (assign, nonatomic) CGFloat tableRowHeight;
+
+@end
Oops, something went wrong.

0 comments on commit 8d46196

Please sign in to comment.