From fd76ea5c4862625033780226f1907a3eaa0634c7 Mon Sep 17 00:00:00 2001 From: Alex Zolotarev Date: Mon, 14 May 2012 18:36:05 +0300 Subject: [PATCH] [ios] Added Bookmark Sets visibility switch --- iphone/Maps/Bookmarks/BookmarksVC.mm | 49 ++++++++++++++++++++++------ map/bookmark.hpp | 1 + 2 files changed, 40 insertions(+), 10 deletions(-) diff --git a/iphone/Maps/Bookmarks/BookmarksVC.mm b/iphone/Maps/Bookmarks/BookmarksVC.mm index a23cdd4f78..3564e5639e 100644 --- a/iphone/Maps/Bookmarks/BookmarksVC.mm +++ b/iphone/Maps/Bookmarks/BookmarksVC.mm @@ -33,6 +33,13 @@ [self dismissModalViewControllerAnimated:YES]; } +- (void)onVisibilitySwitched:(id)sender +{ + BookmarkCategory * cat = GetFramework().GetBmCategory([m_balloon.setName UTF8String]); + if (cat) + cat->SetVisible(((UISwitch *)sender).on); +} + - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation { return YES; @@ -46,7 +53,7 @@ - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { if (section == 0) - return 1; + return 2; BookmarkCategory * cat = GetFramework().GetBmCategory([m_balloon.setName UTF8String]); if (cat) return cat->GetBookmarksCount(); @@ -57,14 +64,33 @@ { if (indexPath.section == 0) { - UITableViewCell * cell = [tableView dequeueReusableCellWithIdentifier:@"CategoryCell"]; - if (!cell) + UITableViewCell * cell; + if (indexPath.row == 0) { - cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:@"CategoryCell"] autorelease]; - cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator; - cell.textLabel.text = NSLocalizedString(@"Set", @"Bookmarks dialog - Bookmark set cell"); + cell = [tableView dequeueReusableCellWithIdentifier:@"BookmarkSetCell"]; + if (!cell) + { + cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:@"BookmarkSetCell"] autorelease]; + cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator; + cell.textLabel.text = NSLocalizedString(@"Set", @"Bookmarks dialog - Bookmark set cell"); + } + cell.detailTextLabel.text = m_balloon.setName; + } + else + { + cell = [tableView dequeueReusableCellWithIdentifier:@"BookmarkSetVisibilityCell"]; + if (!cell) + { + cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:@"BookmarkSetVisibilityCell"] autorelease]; + UISwitch * onOffSwitch = [[[UISwitch alloc] init] autorelease]; + [onOffSwitch addTarget:self action:@selector(onVisibilitySwitched:) forControlEvents:UIControlEventValueChanged]; + cell.accessoryView = onOffSwitch; + cell.textLabel.text = NSLocalizedString(@"Show on the map", @"Bookmarks dialog - Show on the map on/off switch"); + cell.selectionStyle = UITableViewCellSelectionStyleNone; + } + BookmarkCategory const * cat = GetFramework().GetBmCategory([m_balloon.setName UTF8String]); + ((UISwitch *)cell.accessoryView).on = cat ? cat->IsVisible() : YES; } - cell.detailTextLabel.text = m_balloon.setName; return cell; } else @@ -95,9 +121,12 @@ { if (indexPath.section == 0) { - SelectSetVC * ssVC = [[SelectSetVC alloc] initWithBalloonView:m_balloon andEditMode:NO]; - [self.navigationController pushViewController:ssVC animated:YES]; - [ssVC release]; + if (indexPath.row == 0) + { + SelectSetVC * ssVC = [[SelectSetVC alloc] initWithBalloonView:m_balloon andEditMode:NO]; + [self.navigationController pushViewController:ssVC animated:YES]; + [ssVC release]; + } } else { diff --git a/map/bookmark.hpp b/map/bookmark.hpp index 676fcfaa27..f9fc9ed235 100644 --- a/map/bookmark.hpp +++ b/map/bookmark.hpp @@ -41,6 +41,7 @@ public: void AddBookmark(Bookmark const & bm); + void SetVisible(bool isVisible) { m_visible = isVisible; } bool IsVisible() const { return m_visible; } string GetName() const { return m_name; }