From f7262cabd47b39cbda2a610081b27aec380fe5e4 Mon Sep 17 00:00:00 2001 From: Alex Zolotarev Date: Mon, 14 May 2012 18:57:07 +0300 Subject: [PATCH] [ios] Added Select Bookmark Color dialog. @TODO save color in bookmark implementation --- iphone/Maps/Bookmarks/AddBookmarkVC.mm | 22 +++++-- iphone/Maps/Bookmarks/SelectColorVC.h | 13 +++++ iphone/Maps/Bookmarks/SelectColorVC.mm | 67 ++++++++++++++++++++++ iphone/Maps/Maps.xcodeproj/project.pbxproj | 8 +++ 4 files changed, 105 insertions(+), 5 deletions(-) create mode 100644 iphone/Maps/Bookmarks/SelectColorVC.h create mode 100644 iphone/Maps/Bookmarks/SelectColorVC.mm diff --git a/iphone/Maps/Bookmarks/AddBookmarkVC.mm b/iphone/Maps/Bookmarks/AddBookmarkVC.mm index 17462e430e..ae31180c6e 100644 --- a/iphone/Maps/Bookmarks/AddBookmarkVC.mm +++ b/iphone/Maps/Bookmarks/AddBookmarkVC.mm @@ -2,7 +2,7 @@ #import "BalloonView.h" #import "Framework.h" #import "SelectSetVC.h" - +#import "SelectColorVC.h" @implementation AddBookmarkVC @@ -116,11 +116,23 @@ { [[tableView cellForRowAtIndexPath:indexPath] setSelected:NO animated:YES]; - if (indexPath.row == 1) + switch (indexPath.row) { - SelectSetVC * vc = [[SelectSetVC alloc] initWithBalloonView:m_balloon andEditMode:YES]; - [self.navigationController pushViewController:vc animated:YES]; - [vc release]; + case 1: + { + SelectSetVC * vc = [[SelectSetVC alloc] initWithBalloonView:m_balloon andEditMode:YES]; + [self.navigationController pushViewController:vc animated:YES]; + [vc release]; + } + break; + + case 2: + { + SelectColorVC * vc = [[SelectColorVC alloc] initWithBalloonView:m_balloon]; + [self.navigationController pushViewController:vc animated:YES]; + [vc release]; + } + break; } } diff --git a/iphone/Maps/Bookmarks/SelectColorVC.h b/iphone/Maps/Bookmarks/SelectColorVC.h new file mode 100644 index 0000000000..25b73b1061 --- /dev/null +++ b/iphone/Maps/Bookmarks/SelectColorVC.h @@ -0,0 +1,13 @@ +#import + +@class BalloonView; + +@interface SelectColorVC : UITableViewController +{ + // @TODO store as a property to retain reference + BalloonView * m_balloon; +} + +- (id) initWithBalloonView:(BalloonView *)view; + +@end diff --git a/iphone/Maps/Bookmarks/SelectColorVC.mm b/iphone/Maps/Bookmarks/SelectColorVC.mm new file mode 100644 index 0000000000..e4a198ebb6 --- /dev/null +++ b/iphone/Maps/Bookmarks/SelectColorVC.mm @@ -0,0 +1,67 @@ +#import "SelectColorVC.h" +#import "BalloonView.h" + +static NSString * g_colors [] = { + @"blue", + @"brown", + @"green", + @"orange", + @"pink", + @"purple", + @"red", + @"yellow" +}; + +@implementation SelectColorVC + +- (id) initWithBalloonView:(BalloonView *)view +{ + self = [super initWithStyle:UITableViewStyleGrouped]; + if (self) + { + m_balloon = view; + + self.title = NSLocalizedString(@"Bookmark Color", @"Bookmark Color dialog title"); + } + return self; +} + +- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation +{ + return YES; +} + +- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView +{ + return 1; +} + +- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section +{ + // Number of supported bookmark colors + return sizeof(g_colors)/sizeof(g_colors[0]); +} + +- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath +{ + static NSString * kCellId = @"SelectColorCell"; + UITableViewCell * cell = [tableView dequeueReusableCellWithIdentifier:kCellId]; + if (cell == nil) + cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:kCellId] autorelease]; + + // Customize cell + cell.imageView.image = [UIImage imageNamed:g_colors[indexPath.row]]; + if (cell.imageView.image == m_balloon.pinImage.image) + cell.accessoryType = UITableViewCellAccessoryCheckmark; + return cell; +} + +- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath +{ + UITableViewCell * cell = [tableView cellForRowAtIndexPath:indexPath]; + [cell setSelected:NO animated:YES]; + m_balloon.pinImage = cell.imageView; + [self.navigationController popViewControllerAnimated:YES]; +} + +@end diff --git a/iphone/Maps/Maps.xcodeproj/project.pbxproj b/iphone/Maps/Maps.xcodeproj/project.pbxproj index d58d10c817..68e2da587e 100644 --- a/iphone/Maps/Maps.xcodeproj/project.pbxproj +++ b/iphone/Maps/Maps.xcodeproj/project.pbxproj @@ -125,6 +125,8 @@ FA68E1681525F92700077B9E /* Default-Landscape@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = FA68E1651525F92700077B9E /* Default-Landscape@2x.png */; }; FA68E1691525F92700077B9E /* Default-Portrait@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = FA68E1661525F92700077B9E /* Default-Portrait@2x.png */; }; FA68E16A1525F92700077B9E /* Default-Portrait@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = FA68E1661525F92700077B9E /* Default-Portrait@2x.png */; }; + FA77353C15615E2300DB495F /* SelectColorVC.mm in Sources */ = {isa = PBXBuildFile; fileRef = FA77353B15615E2300DB495F /* SelectColorVC.mm */; }; + FA77353D15615E2300DB495F /* SelectColorVC.mm in Sources */ = {isa = PBXBuildFile; fileRef = FA77353B15615E2300DB495F /* SelectColorVC.mm */; }; FA81AE3314D061BF00A0D70D /* SearchCell.mm in Sources */ = {isa = PBXBuildFile; fileRef = FA81AE3214D061BF00A0D70D /* SearchCell.mm */; }; FA85F633145DDDC20090E1A0 /* packed_polygons.bin in Resources */ = {isa = PBXBuildFile; fileRef = FA85F632145DDDC20090E1A0 /* packed_polygons.bin */; }; FA87151B12B1518F00592DAF /* SystemConfiguration.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = FA87151A12B1518F00592DAF /* SystemConfiguration.framework */; }; @@ -1416,6 +1418,8 @@ FA64D9A813F975AD00350ECF /* types.txt */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; name = types.txt; path = ../../data/types.txt; sourceTree = SOURCE_ROOT; }; FA68E1651525F92700077B9E /* Default-Landscape@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "Default-Landscape@2x.png"; sourceTree = ""; }; FA68E1661525F92700077B9E /* Default-Portrait@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "Default-Portrait@2x.png"; sourceTree = ""; }; + FA77353A15615E2300DB495F /* SelectColorVC.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = SelectColorVC.h; path = Bookmarks/SelectColorVC.h; sourceTree = SOURCE_ROOT; }; + FA77353B15615E2300DB495F /* SelectColorVC.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = SelectColorVC.mm; path = Bookmarks/SelectColorVC.mm; sourceTree = SOURCE_ROOT; }; FA81AE3114D061BF00A0D70D /* SearchCell.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SearchCell.h; sourceTree = ""; }; FA81AE3214D061BF00A0D70D /* SearchCell.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = SearchCell.mm; sourceTree = ""; }; FA85F632145DDDC20090E1A0 /* packed_polygons.bin */ = {isa = PBXFileReference; lastKnownFileType = archive.macbinary; name = packed_polygons.bin; path = ../../data/packed_polygons.bin; sourceTree = SOURCE_ROOT; }; @@ -2274,6 +2278,8 @@ isa = PBXGroup; children = ( FA36B8171540466A004560CC /* Images */, + FA77353A15615E2300DB495F /* SelectColorVC.h */, + FA77353B15615E2300DB495F /* SelectColorVC.mm */, FAA614B6155F16950031C345 /* AddSetVC.h */, FAA614B7155F16950031C345 /* AddSetVC.mm */, FA054610155C465E001F4E37 /* SelectSetVC.h */, @@ -4215,6 +4221,7 @@ FAF457E715597D4600DCCC49 /* Framework.cpp in Sources */, FA054612155C465E001F4E37 /* SelectSetVC.mm in Sources */, FAA614B8155F16950031C345 /* AddSetVC.mm in Sources */, + FA77353C15615E2300DB495F /* SelectColorVC.mm in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -4247,6 +4254,7 @@ FAF457E815597D4600DCCC49 /* Framework.cpp in Sources */, FA054613155C465E001F4E37 /* SelectSetVC.mm in Sources */, FAA614B9155F16950031C345 /* AddSetVC.mm in Sources */, + FA77353D15615E2300DB495F /* SelectColorVC.mm in Sources */, ); runOnlyForDeploymentPostprocessing = 0; };