diff --git a/FixaDaApp/.DS_Store b/FixaDaApp/.DS_Store new file mode 100644 index 0000000..a5a6646 Binary files /dev/null and b/FixaDaApp/.DS_Store differ diff --git a/FixaDaApp/FixaDaApp.xcodeproj/project.pbxproj b/FixaDaApp/FixaDaApp.xcodeproj/project.pbxproj index d7126a8..c24ff82 100644 --- a/FixaDaApp/FixaDaApp.xcodeproj/project.pbxproj +++ b/FixaDaApp/FixaDaApp.xcodeproj/project.pbxproj @@ -8,6 +8,8 @@ /* Begin PBXBuildFile section */ 79510F25E25C142657CE2DC4 /* libPods.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 5C1C5BEFC8D1D1F43B84295A /* libPods.a */; }; + 84624E5D1C79071D004B6077 /* MapTableViewCell.m in Sources */ = {isa = PBXBuildFile; fileRef = 84624E5C1C79071D004B6077 /* MapTableViewCell.m */; }; + 84624E5F1C79081E004B6077 /* MapTableViewCell.xib in Resources */ = {isa = PBXBuildFile; fileRef = 84624E5E1C79081D004B6077 /* MapTableViewCell.xib */; }; 8D4F05B61C710A8E003B3131 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 8D4F05B51C710A8E003B3131 /* main.m */; }; 8D4F05B91C710A8E003B3131 /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 8D4F05B81C710A8E003B3131 /* AppDelegate.m */; }; 8D4F05BC1C710A8E003B3131 /* ViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 8D4F05BB1C710A8E003B3131 /* ViewController.m */; }; @@ -22,6 +24,9 @@ /* Begin PBXFileReference section */ 51DA72322BD0057FB2DF45ED /* Pods.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = Pods.debug.xcconfig; path = "Pods/Target Support Files/Pods/Pods.debug.xcconfig"; sourceTree = ""; }; 5C1C5BEFC8D1D1F43B84295A /* libPods.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libPods.a; sourceTree = BUILT_PRODUCTS_DIR; }; + 84624E5B1C79071D004B6077 /* MapTableViewCell.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MapTableViewCell.h; sourceTree = ""; }; + 84624E5C1C79071D004B6077 /* MapTableViewCell.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MapTableViewCell.m; sourceTree = ""; }; + 84624E5E1C79081D004B6077 /* MapTableViewCell.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = MapTableViewCell.xib; sourceTree = ""; }; 8D4F05B11C710A8E003B3131 /* FixaDaApp.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = FixaDaApp.app; sourceTree = BUILT_PRODUCTS_DIR; }; 8D4F05B51C710A8E003B3131 /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; }; 8D4F05B71C710A8E003B3131 /* AppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = ""; }; @@ -89,6 +94,9 @@ 8D4F05B81C710A8E003B3131 /* AppDelegate.m */, 8D4F05BA1C710A8E003B3131 /* ViewController.h */, 8D4F05BB1C710A8E003B3131 /* ViewController.m */, + 84624E5B1C79071D004B6077 /* MapTableViewCell.h */, + 84624E5C1C79071D004B6077 /* MapTableViewCell.m */, + 84624E5E1C79081D004B6077 /* MapTableViewCell.xib */, 8DB9ED8E1C722B12003A03E0 /* FoursquareAPIManager.h */, 8DB9ED8F1C722B13003A03E0 /* FoursquareAPIManager.m */, 8D4F05BD1C710A8E003B3131 /* Main.storyboard */, @@ -178,6 +186,7 @@ files = ( 8D4F05C41C710A8E003B3131 /* LaunchScreen.storyboard in Resources */, 8D4F05C11C710A8E003B3131 /* Assets.xcassets in Resources */, + 84624E5F1C79081E004B6077 /* MapTableViewCell.xib in Resources */, 8D4F05BF1C710A8E003B3131 /* Main.storyboard in Resources */, ); runOnlyForDeploymentPostprocessing = 0; @@ -237,6 +246,7 @@ isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( + 84624E5D1C79071D004B6077 /* MapTableViewCell.m in Sources */, 8D4F05BC1C710A8E003B3131 /* ViewController.m in Sources */, 8D4F05B91C710A8E003B3131 /* AppDelegate.m in Sources */, 8D4F05B61C710A8E003B3131 /* main.m in Sources */, @@ -352,6 +362,7 @@ buildSettings = { ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; INFOPLIST_FILE = FixaDaApp/Info.plist; + IPHONEOS_DEPLOYMENT_TARGET = 9.1; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = com.mikekavouras.FixaDaApp; PRODUCT_NAME = "$(TARGET_NAME)"; @@ -364,6 +375,7 @@ buildSettings = { ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; INFOPLIST_FILE = FixaDaApp/Info.plist; + IPHONEOS_DEPLOYMENT_TARGET = 9.1; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = com.mikekavouras.FixaDaApp; PRODUCT_NAME = "$(TARGET_NAME)"; diff --git a/FixaDaApp/FixaDaApp/Assets.xcassets/Contents.json b/FixaDaApp/FixaDaApp/Assets.xcassets/Contents.json new file mode 100644 index 0000000..da4a164 --- /dev/null +++ b/FixaDaApp/FixaDaApp/Assets.xcassets/Contents.json @@ -0,0 +1,6 @@ +{ + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/FixaDaApp/FixaDaApp/Assets.xcassets/phoneIcon.imageset/Contents.json b/FixaDaApp/FixaDaApp/Assets.xcassets/phoneIcon.imageset/Contents.json new file mode 100644 index 0000000..16a0cb3 --- /dev/null +++ b/FixaDaApp/FixaDaApp/Assets.xcassets/phoneIcon.imageset/Contents.json @@ -0,0 +1,21 @@ +{ + "images" : [ + { + "idiom" : "universal", + "filename" : "phoneIcon.png", + "scale" : "1x" + }, + { + "idiom" : "universal", + "scale" : "2x" + }, + { + "idiom" : "universal", + "scale" : "3x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/FixaDaApp/FixaDaApp/Assets.xcassets/phoneIcon.imageset/phoneIcon.png b/FixaDaApp/FixaDaApp/Assets.xcassets/phoneIcon.imageset/phoneIcon.png new file mode 100644 index 0000000..f5b6410 Binary files /dev/null and b/FixaDaApp/FixaDaApp/Assets.xcassets/phoneIcon.imageset/phoneIcon.png differ diff --git a/FixaDaApp/FixaDaApp/Base.lproj/Main.storyboard b/FixaDaApp/FixaDaApp/Base.lproj/Main.storyboard index ed571b5..02d2700 100644 --- a/FixaDaApp/FixaDaApp/Base.lproj/Main.storyboard +++ b/FixaDaApp/FixaDaApp/Base.lproj/Main.storyboard @@ -1,8 +1,9 @@ - + - + + @@ -19,21 +20,22 @@ - + - + + - + + + - + + + + + + + + + + + + + + + diff --git a/FixaDaApp/FixaDaApp/FoursquareAPIManager.m b/FixaDaApp/FixaDaApp/FoursquareAPIManager.m index b0ee3ac..ef743a9 100644 --- a/FixaDaApp/FixaDaApp/FoursquareAPIManager.m +++ b/FixaDaApp/FixaDaApp/FoursquareAPIManager.m @@ -39,7 +39,10 @@ + (void)findSomething:(NSString *)query progress:nil success:^(NSURLSessionTask *task, id responseObject) { - + NSDictionary *response = [responseObject objectForKey:@"response"]; + NSMutableArray *venues = [response objectForKey:@"venues"]; + completion(venues); + } failure:^(NSURLSessionTask *operation, NSError *error) { NSLog(@"Error: %@", error); diff --git a/FixaDaApp/FixaDaApp/MapTableViewCell.h b/FixaDaApp/FixaDaApp/MapTableViewCell.h new file mode 100644 index 0000000..2e50d71 --- /dev/null +++ b/FixaDaApp/FixaDaApp/MapTableViewCell.h @@ -0,0 +1,17 @@ +// +// MapTableViewCell.h +// FixaDaApp +// +// Created by Diana Elezaj on 2/20/16. +// Copyright © 2016 Michael Kavouras. All rights reserved. +// + +#import + +@interface MapTableViewCell : UITableViewCell +@property (weak, nonatomic) IBOutlet UILabel *title; +@property (weak, nonatomic) IBOutlet UIButton *phoneNumber; +@property (weak, nonatomic) IBOutlet UILabel *anyoneHereLabel; + + +@end diff --git a/FixaDaApp/FixaDaApp/MapTableViewCell.m b/FixaDaApp/FixaDaApp/MapTableViewCell.m new file mode 100644 index 0000000..df1f0a7 --- /dev/null +++ b/FixaDaApp/FixaDaApp/MapTableViewCell.m @@ -0,0 +1,28 @@ +// +// MapTableViewCell.m +// FixaDaApp +// +// Created by Diana Elezaj on 2/20/16. +// Copyright © 2016 Michael Kavouras. All rights reserved. +// + +#import "MapTableViewCell.h" + +@implementation MapTableViewCell + +- (void)awakeFromNib { + // Initialization code +} +- (IBAction)phoneNumberClicked:(UIButton *)sender { + NSString *cleanedString = [[self.phoneNumber.titleLabel.text componentsSeparatedByCharactersInSet:[[NSCharacterSet characterSetWithCharactersInString:@"0123456789-+()"] invertedSet]] componentsJoinedByString:@""]; + NSURL *url = [NSURL URLWithString:[NSString stringWithFormat:@"telprompt://%@", cleanedString]]; + [[UIApplication sharedApplication] openURL:url]; +} + +- (void)setSelected:(BOOL)selected animated:(BOOL)animated { + [super setSelected:selected animated:animated]; + + // Configure the view for the selected state +} + +@end diff --git a/FixaDaApp/FixaDaApp/MapTableViewCell.xib b/FixaDaApp/FixaDaApp/MapTableViewCell.xib new file mode 100644 index 0000000..e51809a --- /dev/null +++ b/FixaDaApp/FixaDaApp/MapTableViewCell.xib @@ -0,0 +1,99 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/FixaDaApp/FixaDaApp/ViewController.m b/FixaDaApp/FixaDaApp/ViewController.m index f938005..8e1b7ef 100644 --- a/FixaDaApp/FixaDaApp/ViewController.m +++ b/FixaDaApp/FixaDaApp/ViewController.m @@ -9,6 +9,7 @@ #import "ViewController.h" #import #import "FoursquareAPIManager.h" +#import "MapTableViewCell.h" @interface ViewController () < @@ -19,6 +20,8 @@ @interface ViewController () @property (weak, nonatomic) IBOutlet MKMapView *mapView; @property (weak, nonatomic) IBOutlet UITableView *tableView; +@property (weak, nonatomic) IBOutlet UIButton *zoomInButton; +@property (weak, nonatomic) IBOutlet UIButton *zoomOutButton; @property (nonatomic) CLLocationManager *locationManager; @@ -35,17 +38,29 @@ - (void)viewDidLoad { self.tableView.delegate = self; self.tableView.dataSource = self; - self.mapView.delegate = self; - self.locationManager = [[CLLocationManager alloc] init]; + UINib *nib = [UINib nibWithNibName:@"MapTableViewCell" bundle:nil]; + [self.tableView registerNib:nib forCellReuseIdentifier:@"BeepBoopCellIdentifier"]; } -- (void)viewDidAppear:(BOOL)animated -{ +-(void)viewWillAppear:(BOOL)animated{ + [super viewWillAppear:animated]; + [self setupUI]; +} + +-(void)viewDidAppear:(BOOL)animated { [super viewDidAppear:animated]; + [self.locationManager requestWhenInUseAuthorization]; } +-(void)setupUI{ + [[self.zoomInButton layer] setBorderWidth:2.0f]; + [[self.zoomInButton layer] setBorderColor:[UIColor darkGrayColor].CGColor]; + + [[self.zoomOutButton layer] setBorderWidth:2.0f]; + [[self.zoomOutButton layer] setBorderColor:[UIColor darkGrayColor].CGColor]; +} # pragma mark - Table view datasource @@ -56,20 +71,42 @@ - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { + if (self.venues.count != 0) { + return self.venues.count; + } return 0; } - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { - UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"BeepBoopCellIdentifier"]; + MapTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"BeepBoopCellIdentifier"]; NSDictionary *venue = self.venues[indexPath.row]; NSString *name = venue[@"name"]; - cell.textLabel.text = name; - + cell.title.text = name; + cell.anyoneHereLabel.text = venue[@"hereNow"][@"summary"]; + if (venue[@"contact"][@"formattedPhone"]) { + [cell.phoneNumber setTintColor: [UIColor blueColor]]; + [cell.phoneNumber setTitle:venue[@"contact"][@"formattedPhone"] forState:UIControlStateNormal]; + } + cell.selectionStyle = UITableViewCellSelectionStyleNone; return cell; } +-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath { + return 70; +} + +-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { + MapTableViewCell *cell = [tableView cellForRowAtIndexPath:indexPath]; + + for(MKPointAnnotation *annotation in [self.mapView annotations]) { + if ([cell.title.text isEqualToString:annotation.title]) { + [self.mapView selectAnnotation:annotation animated:YES]; + } + } + } + # pragma mark - Map view delegate - (void)mapView:(MKMapView *)mapView didUpdateUserLocation:(MKUserLocation *)userLocation @@ -80,6 +117,7 @@ - (void)mapView:(MKMapView *)mapView didUpdateUserLocation:(MKUserLocation *)use [self zoomToLocation:userLocation.location]; [self fetchVenuesAtLocation:userLocation.location]; } + } - (void)zoomToLocation:(CLLocation *)location @@ -97,7 +135,7 @@ - (void)fetchVenuesAtLocation:(CLLocation *)location [FoursquareAPIManager findSomething:@"music" atLocation:location completion:^(NSArray *data){ - + NSLog(@"data %@",data); weakSelf.venues = data; [weakSelf.tableView reloadData]; [weakSelf showPins]; @@ -115,8 +153,24 @@ - (void)showPins MKPointAnnotation *point = [[MKPointAnnotation alloc] init]; point.coordinate = CLLocationCoordinate2DMake(lat, lng); + point.title = venue[@"name"]; [self.mapView addAnnotation:point]; } } +# pragma mark - IBActions + +- (IBAction)zoomInButtonPressed:(UIButton *)sender { + MKCoordinateRegion region = self.mapView.region; + region.span.latitudeDelta /= 2.0; + region.span.longitudeDelta /= 2.0; + [self.mapView setRegion:region animated:YES]; +} +- (IBAction)zoomOutButtonPressed:(UIButton *)sender { + MKCoordinateRegion region = self.mapView.region; + region.span.latitudeDelta = MIN(region.span.latitudeDelta * 2.0, 180.0); + region.span.longitudeDelta = MIN(region.span.longitudeDelta * 2.0, 180.0); + [self.mapView setRegion:region animated:YES]; +} + @end diff --git a/FixaDaApp/FixaDaApp/main.m b/FixaDaApp/FixaDaApp/main.m index 9e811a5..7b062a6 100644 --- a/FixaDaApp/FixaDaApp/main.m +++ b/FixaDaApp/FixaDaApp/main.m @@ -1,4 +1,4 @@ -// + // // main.m // FixaDaApp //