forked from organicmaps/organicmaps
[ios] Added Bookmark Sets visibility switch
This commit is contained in:
parent
fc4f838cb6
commit
fd76ea5c48
2 changed files with 40 additions and 10 deletions
|
@ -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
|
||||
{
|
||||
|
|
|
@ -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; }
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue