Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Projects feature functional
  • Loading branch information
Deepwinter committed May 15, 2012
1 parent 84ee4ec commit b4233a9
Show file tree
Hide file tree
Showing 8 changed files with 301 additions and 64 deletions.
2 changes: 1 addition & 1 deletion Source/DataModels/RHDataModel.h
Expand Up @@ -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;
Expand Down
9 changes: 8 additions & 1 deletion Source/DataModels/RHDataModel.m
Expand Up @@ -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];
Expand Down Expand Up @@ -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];
Expand Down Expand Up @@ -376,6 +382,7 @@ + (void) addDocument: (NSDictionary *) document {
[self.instance.query start];
}];
[op start];
[op wait]; //kickin it synchronous for right now.

}

Expand Down
3 changes: 3 additions & 0 deletions Source/DataModels/RHSettings.h
Expand Up @@ -25,6 +25,9 @@
+ (BOOL) useRemoteServer;
+ (NSString *) couchRemoteServer;

//Other Settings
+ (BOOL) allowNewProjectCreation;

//Development

+ (BOOL) useCamera;
Expand Down
8 changes: 5 additions & 3 deletions Source/Views and Controllers/MapViewController.h
Expand Up @@ -10,12 +10,13 @@
#import <MapKit/MapKit.h>
#import "FullscreenTransitionDelegate.h"
#import "TimelineVisualizationView.h"
#import "ProjectsTableViewController.h"




@interface MapViewController : UIViewController
<MKMapViewDelegate, TimelineVisualizationViewDelegate, UIScrollViewDelegate>
<MKMapViewDelegate, TimelineVisualizationViewDelegate, UIScrollViewDelegate, ProjectsTableViewControllerDelegate>
{
id <FullscreenTransitionDelegate> fullscreenTransitionDelegate;

Expand All @@ -26,7 +27,7 @@
IBOutlet UIButton * syncButton;
IBOutlet UIView * spinnerContainerView;
IBOutlet UIView * overlayView;
IBOutlet UIViewController * projectsViewController;
IBOutlet ProjectsTableViewController * projectsViewController;


UIButton * mapInsetButton;
Expand All @@ -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;
Expand Down Expand Up @@ -105,6 +106,7 @@
- (void)showDetailViewForIndex: (NSInteger) index;

- (void)hideInfoView;
- (void) populate;


- (IBAction)didTouchThumbnail:(id)sender;
Expand Down
45 changes: 19 additions & 26 deletions Source/Views and Controllers/MapViewController.m
Expand Up @@ -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;
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -802,6 +791,10 @@ - (void)scrollViewDidScroll:(UIScrollView *)scrollView {
[self updateTimestampView];
}

#pragma mark - ProjectsTableViewControllerDelegate

-(void) didChangeProject {
[self populate];
}

@end

0 comments on commit b4233a9

Please sign in to comment.