diff --git a/Source/DataModels/RHDataModel.h b/Source/DataModels/RHDataModel.h index f60b21e..c6019a1 100644 --- a/Source/DataModels/RHDataModel.h +++ b/Source/DataModels/RHDataModel.h @@ -61,7 +61,7 @@ typedef void ( ^CompletedBlock )(); + (NSArray *) getDocumentsInProject: (NSString *) project; + (NSArray *) getDocumentsInProject: (NSString *) project since: (NSString*) date; + (NSArray *) getProjects; - ++ (void) addProject:(NSString *) projectName; //+ (UIImage *) getThumbnailForId: (NSString *) documentId; diff --git a/Source/DataModels/RHDataModel.m b/Source/DataModels/RHDataModel.m index b42ac6b..fb03989 100644 --- a/Source/DataModels/RHDataModel.m +++ b/Source/DataModels/RHDataModel.m @@ -101,7 +101,7 @@ - (id) initWithBlock:( void ( ^ )() ) didStartBlock { map: @"function(doc) { emit( doc._id, {'id' :doc._id, 'reporter' : doc.reporter, 'comment' : doc.comment, 'thumb' : doc.thumb, 'medium' : doc.medium, 'created_at' : doc.created_at} );}"]; [design defineViewNamed: @"projects" - map: @"function(doc) { emit(doc.project, null); }" + map: @"function(doc) { if(doc.project) { emit(doc.project, null);} }" reduce: @"function(key, values) { return true;}"]; [design saveChanges]; @@ -343,6 +343,12 @@ + (NSArray *) getUserDocumentsWithOffset:(NSInteger)offset andLimit:(NSInteger)l return [self.instance _getUserDocuments]; } + ++ (void) addProject:(NSString *) projectName { + NSDictionary * document = [NSDictionary dictionaryWithObjectsAndKeys:projectName, @"project", nil]; + [RHDataModel addDocument:document]; +} + - (NSArray *) _getProjects { CouchDesignDocument* design = [database designDocumentWithName: @"rhusMobile"]; CouchQuery * couchQuery = [design queryViewNamed: @"projects"]; //asLiveQuery]; @@ -376,6 +382,7 @@ + (void) addDocument: (NSDictionary *) document { [self.instance.query start]; }]; [op start]; + [op wait]; //kickin it synchronous for right now. } diff --git a/Source/DataModels/RHSettings.h b/Source/DataModels/RHSettings.h index cf56418..93de2a3 100644 --- a/Source/DataModels/RHSettings.h +++ b/Source/DataModels/RHSettings.h @@ -25,6 +25,9 @@ + (BOOL) useRemoteServer; + (NSString *) couchRemoteServer; +//Other Settings ++ (BOOL) allowNewProjectCreation; + //Development + (BOOL) useCamera; diff --git a/Source/Views and Controllers/MapViewController.h b/Source/Views and Controllers/MapViewController.h index 93aa437..ddb316e 100644 --- a/Source/Views and Controllers/MapViewController.h +++ b/Source/Views and Controllers/MapViewController.h @@ -10,12 +10,13 @@ #import #import "FullscreenTransitionDelegate.h" #import "TimelineVisualizationView.h" +#import "ProjectsTableViewController.h" @interface MapViewController : UIViewController - + { id fullscreenTransitionDelegate; @@ -26,7 +27,7 @@ IBOutlet UIButton * syncButton; IBOutlet UIView * spinnerContainerView; IBOutlet UIView * overlayView; - IBOutlet UIViewController * projectsViewController; + IBOutlet ProjectsTableViewController * projectsViewController; UIButton * mapInsetButton; @@ -49,7 +50,7 @@ @property(nonatomic, strong) UIButton * syncButton; @property(nonatomic, strong) UIView * spinnerContainerView; @property(nonatomic, strong) UIView * overlayView; -@property(nonatomic, strong) UIViewController * projectsViewController; +@property(nonatomic, strong) ProjectsTableViewController * projectsViewController; @property(nonatomic, strong) NSMutableArray * nextDocumentSet; @property(nonatomic, strong) NSMutableArray * activeDocuments; @@ -105,6 +106,7 @@ - (void)showDetailViewForIndex: (NSInteger) index; - (void)hideInfoView; +- (void) populate; - (IBAction)didTouchThumbnail:(id)sender; diff --git a/Source/Views and Controllers/MapViewController.m b/Source/Views and Controllers/MapViewController.m index c9ad3f1..d8679d7 100644 --- a/Source/Views and Controllers/MapViewController.m +++ b/Source/Views and Controllers/MapViewController.m @@ -104,8 +104,8 @@ - (void)didReceiveMemoryWarning - (void)viewDidLoad { [super viewDidLoad]; - - + projectsViewController.delegate = self; + //Set up some tags self.detailScrollView.tag = kDetailScrollViewTag; self.galleryScrollView.tag = kGalleryScrollViewTag; @@ -201,22 +201,18 @@ - (void) setupGalleryScrollView{ } -- (void) populateTestingData{ - //spoof map data - //later on read this spoofed data from the data layer - /* - float latHigh = 42.362; - float latLow = 42.293; - float longHigh = -83.101; - float longLow = -82.935; - for(int i=0; i<10; i++){ - float latitude = latLow + (latHigh-latLow) * ( arc4random() % 1000 )/1000; - float longitude = longLow + (longHigh-longLow) * ( arc4random() % 1000 )/1000; - CLLocationCoordinate2D coordinate; - coordinate.latitude = latitude; - coordinate.longitude = longitude; - [self.mapView addAnnotation:[SSMapAnnotation mapAnnotationWithCoordinate:coordinate title:@"Hey Guy!"] ]; - }*/ +- (void) populate { + [self addAnnotations]; + + [self setupGalleryScrollView]; + + if(launchInGalleryMode) { + [UIView beginAnimations:nil context:NULL]; + [fullscreenTransitionDelegate subviewRequestingFullscreen]; + [UIView commitAnimations]; + firstView = FALSE; + } + } - (void) addAnnotations { @@ -273,16 +269,9 @@ - (void)viewDidAppear:(BOOL)animated { // - actually it's not, because something isn't in place yet, and nothing loads //Both should be key-value observers and already be updated //by the time the user clicks on the button. - [self addAnnotations]; - [self setupGalleryScrollView]; + [self populate]; - if(launchInGalleryMode) { - [UIView beginAnimations:nil context:NULL]; - [fullscreenTransitionDelegate subviewRequestingFullscreen]; - [UIView commitAnimations]; - firstView = FALSE; - } } - (void)viewDidUnload @@ -802,6 +791,10 @@ - (void)scrollViewDidScroll:(UIScrollView *)scrollView { [self updateTimestampView]; } +#pragma mark - ProjectsTableViewControllerDelegate +-(void) didChangeProject { + [self populate]; +} @end diff --git a/Source/Views and Controllers/MapViewController.xib b/Source/Views and Controllers/MapViewController.xib index 1346e25..678b0bd 100644 --- a/Source/Views and Controllers/MapViewController.xib +++ b/Source/Views and Controllers/MapViewController.xib @@ -19,6 +19,7 @@ IBProxyObject IBUICustomObject IBUINavigationItem + IBUITextField IBUIScrollView IBUIView IBMKMapView @@ -72,7 +73,6 @@ {{439, 0}, {42, 47}} - NO IBCocoaTouchFramework 0 @@ -364,7 +364,6 @@ {{0, 6}, {480, 48}} - NO IBCocoaTouchFramework @@ -585,7 +584,6 @@ {{19, 279}, {48, 21}} - NO YES 7 @@ -630,7 +628,6 @@ {480, 320} - 1 NO IBCocoaTouchFramework @@ -681,7 +678,6 @@ {{425.5, 136}, {35, 35}} - NO IBCocoaTouchFramework 0 @@ -810,7 +806,6 @@ {{20, 84}, {322, 64}} - 3 MC42NjY2NjY2NjY3AA @@ -829,11 +824,11 @@ 2 IBCocoaTouchFramework - + 1 14 - + Helvetica 14 16 @@ -957,7 +952,6 @@ {{424, 0}, {58, 320}} - IBCocoaTouchFramework @@ -983,7 +977,6 @@ {{88, 44}, {80, 21}} - NO YES 4 @@ -1028,7 +1021,7 @@ 274 - {{0, 43}, {460, 276}} + {{0, 43}, {388, 276}} @@ -1072,7 +1065,7 @@ 292 - {{353, 4}, {102, 35}} + {{281, 4}, {102, 35}} @@ -1092,7 +1085,7 @@ - {{0, -1}, {460, 44}} + {{0, -1}, {388, 44}} @@ -1116,7 +1109,7 @@ - {460, 320} + {388, 320} @@ -1131,6 +1124,96 @@ IBCocoaTouchFramework + + + 292 + + + + 292 + {{20, 20}, {310, 31}} + + + + NO + YES + IBCocoaTouchFramework + 0 + + 3 + + 3 + MAA + + + YES + 17 + + IBCocoaTouchFramework + + + + + + + 292 + {{29, 59}, {72, 37}} + + + + NO + IBCocoaTouchFramework + 0 + 0 + 1 + Add + + + 1 + MC4xOTYwNzg0MzQ2IDAuMzA5ODAzOTMyOSAwLjUyMTU2ODY1NgA + + + + + + + + 292 + {{145, 59}, {74, 37}} + + + + NO + IBCocoaTouchFramework + 0 + 0 + 1 + Cancel + + + 1 + MC4xOTYwNzg0MzQ2IDAuMzA5ODAzOTMyOSAwLjUyMTU2ODY1NgA + + + + + + + {345, 126} + + + + + 1 + MC43NDExNzY0ODYgMC4wODIzNTI5NDM3MiAwLjMxMzcyNTUwMTMAA + + 0.5 + + 3 + 3 + + IBCocoaTouchFramework + @@ -1422,6 +1505,30 @@ 130 + + + tableView + + + + 143 + + + + addProjectDialog + + + + 144 + + + + projectNameField + + + + 147 + didTouchAddProject: @@ -1433,12 +1540,30 @@ - didTouchCancel: + didTouchDone: 7 - 138 + 148 + + + + didTouchConfirmProject: + + + 7 + + 146 + + + + didTouchCancelAddProject: + + + 7 + + 145 @@ -1842,6 +1967,32 @@ + + 139 + + + + + + + + Add Project Dialog + + + 140 + + + + + 141 + + + + + 142 + + + @@ -1869,6 +2020,10 @@ com.apple.InterfaceBuilder.IBCocoaTouchPlugin com.apple.InterfaceBuilder.IBCocoaTouchPlugin com.apple.InterfaceBuilder.IBCocoaTouchPlugin + com.apple.InterfaceBuilder.IBCocoaTouchPlugin + com.apple.InterfaceBuilder.IBCocoaTouchPlugin + com.apple.InterfaceBuilder.IBCocoaTouchPlugin + com.apple.InterfaceBuilder.IBCocoaTouchPlugin com.apple.InterfaceBuilder.IBCocoaTouchPlugin com.apple.InterfaceBuilder.IBCocoaTouchPlugin @@ -1925,7 +2080,7 @@ - 138 + 148 @@ -2009,7 +2164,7 @@ MKMapView UILabel UIView - UIViewController + ProjectsTableViewController UILabel UIView UIButton @@ -2070,7 +2225,7 @@ projectsViewController - UIViewController + ProjectsTableViewController reporter @@ -2115,29 +2270,52 @@ UIViewController id - id + id + id + id didTouchAddProject: id - - didTouchCancel: + + didTouchCancelAddProject: + id + + + didTouchConfirmProject: + id + + + didTouchDone: id - - navigationBar - UINavigationBar - - - navigationBar - + + UIView + UINavigationBar + UITextField + UITableView + + + + addProjectDialog + UIView + + navigationBar UINavigationBar - + + projectNameField + UITextField + + + tableView + UITableView + + IBProjectSource ./Classes/ProjectsTableViewController.h diff --git a/Source/Views and Controllers/ProjectsTableViewController.h b/Source/Views and Controllers/ProjectsTableViewController.h index 85d4ac5..ba998e0 100644 --- a/Source/Views and Controllers/ProjectsTableViewController.h +++ b/Source/Views and Controllers/ProjectsTableViewController.h @@ -8,16 +8,33 @@ #import +@protocol ProjectsTableViewControllerDelegate + +- (void) didChangeProject; + +@end + @interface ProjectsTableViewController : UIViewController { IBOutlet UINavigationBar * navigationBar; + IBOutlet UIView * addProjectDialog; + IBOutlet UITableView * tableView; + IBOutlet UITextField * projectNameField; NSArray * projects; + id delegate; } @property(nonatomic, retain) UINavigationBar * navigationBar; @property(nonatomic, retain) NSArray * projects; +@property(nonatomic, retain) UIView * addProjectDialog; +@property(nonatomic, retain) UITableView * tableView; +@property(nonatomic, retain) UITextField * projectNameField; +@property(nonatomic, retain) id delegate; --(IBAction) didTouchCancel:(id)sender; +-(IBAction) didTouchDone:(id)sender; -(IBAction) didTouchAddProject:(id)sender; +-(IBAction) didTouchConfirmProject:(id)sender; +-(IBAction) didTouchCancelAddProject:(id)sender; + @end diff --git a/Source/Views and Controllers/ProjectsTableViewController.m b/Source/Views and Controllers/ProjectsTableViewController.m index a13a2db..054a440 100644 --- a/Source/Views and Controllers/ProjectsTableViewController.m +++ b/Source/Views and Controllers/ProjectsTableViewController.m @@ -14,6 +14,10 @@ @implementation ProjectsTableViewController @synthesize navigationBar; @synthesize projects; +@synthesize addProjectDialog; +@synthesize tableView; +@synthesize projectNameField; +@synthesize delegate; - (void)didReceiveMemoryWarning { @@ -94,7 +98,13 @@ - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(N } // Configure the cell... - cell.textLabel.text = (NSString*) [projects objectAtIndex: [indexPath row]]; + NSString * currentProject = [[RHDataModel instance] project]; + NSString * aProject = (NSString*) [projects objectAtIndex: [indexPath row]]; + cell.textLabel.text = aProject; + if([currentProject isEqualToString: aProject]){ + cell.accessoryType = UITableViewCellAccessoryCheckmark; + } + return cell; } @@ -151,16 +161,43 @@ - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath RHDataModel * rhDataModel = [RHDataModel instance]; rhDataModel.project = (NSString *) [self.projects objectAtIndex: [indexPath row]]; + UITableViewCell * cell = [tableView cellForRowAtIndexPath:indexPath]; + cell.accessoryType = UITableViewCellAccessoryCheckmark; + cell.selected = NO; +} + +- (void)tableView:(UITableView *)tableView didDeselectRowAtIndexPath:(NSIndexPath *)indexPath { + UITableViewCell * cell = [tableView cellForRowAtIndexPath:indexPath]; + cell.accessoryType = UITableViewCellAccessoryNone; } + #pragma mark - IBActions --(IBAction) didTouchCancel:(id)sender{ +-(IBAction) didTouchDone:(id)sender{ + [self.delegate didChangeProject]; [self.view removeFromSuperview]; + } -(IBAction) didTouchAddProject:(id)sender{ + [self.view addSubview:self.addProjectDialog]; +} + +-(IBAction) didTouchConfirmProject:(id)sender{ + if(projectNameField.text){ + [RHDataModel addProject:projectNameField.text]; + } + [self.addProjectDialog removeFromSuperview]; + self.projects = [RHDataModel getProjects]; + [self.tableView reloadData]; + projectNameField.text = @""; + +} + +-(IBAction) didTouchCancelAddProject:(id)sender{ + [self.addProjectDialog removeFromSuperview]; } @end