From e1851e1123a42d3dfad90db10ed1dc34b5006798 Mon Sep 17 00:00:00 2001 From: Alex Zolotarev Date: Tue, 8 May 2012 15:36:45 +0300 Subject: [PATCH] [ios] Added additional bookmarks controllers --- iphone/Maps/Bookmarks/AddBookmarkVC.h | 5 + iphone/Maps/Bookmarks/AddBookmarkVC.mm | 72 ++++++++++++++ iphone/Maps/Bookmarks/PlacePageVC.h | 12 +-- iphone/Maps/Bookmarks/PlacePageVC.mm | 131 +++++++------------------ 4 files changed, 118 insertions(+), 102 deletions(-) create mode 100644 iphone/Maps/Bookmarks/AddBookmarkVC.h create mode 100644 iphone/Maps/Bookmarks/AddBookmarkVC.mm diff --git a/iphone/Maps/Bookmarks/AddBookmarkVC.h b/iphone/Maps/Bookmarks/AddBookmarkVC.h new file mode 100644 index 0000000000..58841fa71e --- /dev/null +++ b/iphone/Maps/Bookmarks/AddBookmarkVC.h @@ -0,0 +1,5 @@ +#import + +@interface AddBookmarkVC : UITableViewController + +@end diff --git a/iphone/Maps/Bookmarks/AddBookmarkVC.mm b/iphone/Maps/Bookmarks/AddBookmarkVC.mm new file mode 100644 index 0000000000..c508361531 --- /dev/null +++ b/iphone/Maps/Bookmarks/AddBookmarkVC.mm @@ -0,0 +1,72 @@ +#import "AddBookmarkVC.h" + +@implementation AddBookmarkVC + +- (id)initWithStyle:(UITableViewStyle)style +{ + self = [super initWithStyle:style]; + if (self) + { + self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemAdd target:self action:@selector(onAddClicked)]; + self.title = NSLocalizedString(@"Add Bookmark", @"Add bookmark dialog title"); + } + return self; +} + +- (void)onAddClicked:(id)sender +{ +} + +- (void)viewWillAppear:(BOOL)animated +{ + [self.navigationController setNavigationBarHidden:NO animated:YES]; + [super viewWillAppear:animated]; +} + +- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation +{ + return YES; +} + +- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView +{ + return 1; +} + +- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section +{ + return 3; +} + +- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath +{ + UITableViewCell * cell = [tableView dequeueReusableCellWithIdentifier:@"AddBMCell"]; + if (cell == nil) + cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:@"AddBMCell"] autorelease]; + + switch (indexPath.row) + { + case 0: + cell.textLabel.text = NSLocalizedString(@"Name", @"Add bookmark dialog - bookmark name"); + cell.detailTextLabel.text = @"Washington"; + break; + + case 1: + cell.textLabel.text = NSLocalizedString(@"Set", @"Add bookmark dialog - bookmark set"); + cell.detailTextLabel.text = @"Default"; + break; + + case 2: + cell.textLabel.text = NSLocalizedString(@"Color", @"Add bookmark dialog - bookmark color"); + cell.detailTextLabel.text = @"Blue"; + break; + } + return cell; +} + +- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath +{ + [[tableView cellForRowAtIndexPath:indexPath] setSelected:NO animated:YES]; +} + +@end diff --git a/iphone/Maps/Bookmarks/PlacePageVC.h b/iphone/Maps/Bookmarks/PlacePageVC.h index 5675ce947f..a6057b3d29 100644 --- a/iphone/Maps/Bookmarks/PlacePageVC.h +++ b/iphone/Maps/Bookmarks/PlacePageVC.h @@ -1,13 +1,7 @@ -// -// PlacePageVC.h -// Maps -// -// Created by Alexander Zolotarev on 19/04/2012. -// Copyright (c) 2012 MapsWithMe. All rights reserved. -// - #import @interface PlacePageVC : UITableViewController - +{ + BOOL m_hideNavBar; +} @end diff --git a/iphone/Maps/Bookmarks/PlacePageVC.mm b/iphone/Maps/Bookmarks/PlacePageVC.mm index a2c0c4d4c4..b7768905de 100644 --- a/iphone/Maps/Bookmarks/PlacePageVC.mm +++ b/iphone/Maps/Bookmarks/PlacePageVC.mm @@ -1,128 +1,73 @@ -// -// PlacePageVC.m -// Maps -// -// Created by Alexander Zolotarev on 19/04/2012. -// Copyright (c) 2012 MapsWithMe. All rights reserved. -// - #import "PlacePageVC.h" - -@interface PlacePageVC () - -@end +#import "AddBookmarkVC.h" @implementation PlacePageVC - (id)initWithStyle:(UITableViewStyle)style { - self = [super initWithStyle:style]; - if (self) { - // Custom initialization - } - return self; + self = [super initWithStyle:style]; + if (self) + { + self.title = NSLocalizedString(@"Place Page", @"Add bookmark dialog title"); + } + return self; } -- (void)viewDidLoad +- (void)viewWillAppear:(BOOL)animated { - [super viewDidLoad]; - - // Uncomment the following line to preserve selection between presentations. - // self.clearsSelectionOnViewWillAppear = NO; - - // Uncomment the following line to display an Edit button in the navigation bar for this view controller. - // self.navigationItem.rightBarButtonItem = self.editButtonItem; + m_hideNavBar = YES; + [self.navigationController setNavigationBarHidden:NO animated:YES]; + [super viewWillAppear:animated]; } -- (void)viewDidUnload +- (void)viewWillDisappear:(BOOL)animated { - [super viewDidUnload]; - // Release any retained subviews of the main view. - // e.g. self.myOutlet = nil; + if (m_hideNavBar) + [self.navigationController setNavigationBarHidden:YES animated:YES]; + [super viewWillDisappear:animated]; } - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation { - return (interfaceOrientation == UIInterfaceOrientationPortrait); + return YES; } -#pragma mark - Table view data source - - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView { -#warning Potentially incomplete method implementation. - // Return the number of sections. - return 0; + return 2; } - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { -#warning Incomplete method implementation. - // Return the number of rows in the section. - return 0; + return 1; } - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { - static NSString *CellIdentifier = @"Cell"; - UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier]; - - // Configure the cell... - - return cell; + UITableViewCell * cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"cell"] autorelease]; + cell.textLabel.textAlignment = UITextAlignmentCenter; + if (indexPath.section == 0) + cell.textLabel.text = NSLocalizedString(@"Add To Bookmarks", @"Place Page - Add To Bookmarks button"); + else + cell.textLabel.text = NSLocalizedString(@"Remove Pin", @"Place Page - Remove Pin button"); + return cell; } -/* -// Override to support conditional editing of the table view. -- (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath -{ - // Return NO if you do not want the specified item to be editable. - return YES; -} -*/ - -/* -// Override to support editing the table view. -- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath -{ - if (editingStyle == UITableViewCellEditingStyleDelete) { - // Delete the row from the data source - [tableView deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:UITableViewRowAnimationFade]; - } - else if (editingStyle == UITableViewCellEditingStyleInsert) { - // Create a new instance of the appropriate class, insert it into the array, and add a new row to the table view - } -} -*/ - -/* -// Override to support rearranging the table view. -- (void)tableView:(UITableView *)tableView moveRowAtIndexPath:(NSIndexPath *)fromIndexPath toIndexPath:(NSIndexPath *)toIndexPath -{ -} -*/ - -/* -// Override to support conditional rearranging of the table view. -- (BOOL)tableView:(UITableView *)tableView canMoveRowAtIndexPath:(NSIndexPath *)indexPath -{ - // Return NO if you do not want the item to be re-orderable. - return YES; -} -*/ - -#pragma mark - Table view delegate - - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { - // Navigation logic may go here. Create and push another view controller. - /* - <#DetailViewController#> *detailViewController = [[<#DetailViewController#> alloc] initWithNibName:@"<#Nib name#>" bundle:nil]; - // ... - // Pass the selected object to the new view controller. - [self.navigationController pushViewController:detailViewController animated:YES]; - [detailViewController release]; - */ + [[tableView cellForRowAtIndexPath:indexPath] setSelected:NO animated:YES]; + + if (indexPath.section == 0) + { + AddBookmarkVC * addVC = [[AddBookmarkVC alloc] initWithStyle:UITableViewStyleGrouped]; + m_hideNavBar = NO; + [self.navigationController pushViewController:addVC animated:YES]; + [addVC release]; + } + else + { + [self.navigationController popViewControllerAnimated:YES]; + } } @end