forked from organicmaps/organicmaps
[ios] Added editable Description field into Place Page Dialog
This commit is contained in:
parent
67d312358b
commit
fda574cd67
7 changed files with 154 additions and 31 deletions
|
@ -10,8 +10,8 @@
|
|||
}
|
||||
|
||||
@property(nonatomic, retain) NSString * title;
|
||||
// Currently contains automatically updated address info
|
||||
//@property(nonatomic, retain) NSString * description;
|
||||
// Currently displays bookmark description
|
||||
@property(nonatomic, retain) NSString * description;
|
||||
// Contains feature type(s)
|
||||
//@property(nonatomic, retain) NSString * type;
|
||||
@property(nonatomic, retain) UIImageView * pinImage;
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
|
||||
@synthesize globalPosition;
|
||||
@synthesize title;
|
||||
//@synthesize description;
|
||||
@synthesize description;
|
||||
//@synthesize type;
|
||||
@synthesize pinImage;
|
||||
@synthesize color;
|
||||
|
@ -65,7 +65,7 @@
|
|||
self.color = nil;
|
||||
self.setName = nil;
|
||||
self.title = nil;
|
||||
// self.description = nil;
|
||||
self.description = nil;
|
||||
// self.type = nil;
|
||||
[super dealloc];
|
||||
}
|
||||
|
@ -223,9 +223,11 @@
|
|||
|
||||
- (void) addOrEditBookmark
|
||||
{
|
||||
Framework &f = GetFramework();
|
||||
Framework & f = GetFramework();
|
||||
Bookmark bm(m2::PointD(globalPosition.x, globalPosition.y),
|
||||
[title UTF8String], [color UTF8String]);
|
||||
if (description)
|
||||
bm.SetDescription([description UTF8String]);
|
||||
f.GetBmCategory(editedBookmark.first)->ReplaceBookmark(editedBookmark.second, bm);
|
||||
|
||||
BookmarkCategory * cat = f.GetBmCategory(editedBookmark.first);
|
||||
|
|
14
iphone/Maps/Bookmarks/EditDescriptionVC.h
Normal file
14
iphone/Maps/Bookmarks/EditDescriptionVC.h
Normal file
|
@ -0,0 +1,14 @@
|
|||
#import <UIKit/UIKit.h>
|
||||
|
||||
@class BalloonView;
|
||||
|
||||
@interface EditDescriptionVC : UIViewController
|
||||
{
|
||||
// @TODO store as a property to retain reference
|
||||
// Used to pass description for editing
|
||||
BalloonView * m_balloon;
|
||||
}
|
||||
|
||||
- (id) initWithBalloonView:(BalloonView *)view;
|
||||
|
||||
@end
|
94
iphone/Maps/Bookmarks/EditDescriptionVC.mm
Normal file
94
iphone/Maps/Bookmarks/EditDescriptionVC.mm
Normal file
|
@ -0,0 +1,94 @@
|
|||
#import "EditDescriptionVC.h"
|
||||
#import "BalloonView.h"
|
||||
|
||||
@implementation EditDescriptionVC
|
||||
|
||||
- (id) initWithBalloonView:(BalloonView *)view
|
||||
{
|
||||
self = [super init];
|
||||
if (self)
|
||||
{
|
||||
m_balloon = view;
|
||||
self.title = NSLocalizedString(@"description", @"EditDescription dialog title");
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
|
||||
{
|
||||
return YES;
|
||||
}
|
||||
|
||||
- (void)loadView
|
||||
{
|
||||
UITextView * tv = [[UITextView alloc] initWithFrame:CGRectMake(0, 0, 320, 480)];
|
||||
tv.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
|
||||
tv.editable = YES;
|
||||
tv.dataDetectorTypes = UIDataDetectorTypeAll;
|
||||
// Get specific font for text editor from table cell
|
||||
UITableViewCell * tmpCell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:@"tmpCell"];
|
||||
tmpCell.detailTextLabel.text = @"tmpText";
|
||||
[tmpCell layoutSubviews];
|
||||
tv.textColor = tmpCell.detailTextLabel.textColor;
|
||||
tv.font = tmpCell.detailTextLabel.font;
|
||||
[tmpCell release];
|
||||
self.view = tv;
|
||||
}
|
||||
|
||||
- (void)viewWillAppear:(BOOL)animated
|
||||
{
|
||||
[self registerForKeyboardNotifications];
|
||||
UITextView * tv = (UITextView *)self.view;
|
||||
tv.text = m_balloon.description;
|
||||
[tv becomeFirstResponder];
|
||||
}
|
||||
|
||||
- (void)viewWillDisappear:(BOOL)animated
|
||||
{
|
||||
UITextView * tv = (UITextView *)self.view;
|
||||
m_balloon.description = tv.text.length ? tv.text : nil;
|
||||
[tv resignFirstResponder];
|
||||
[self unregisterKeyboardNotifications];
|
||||
}
|
||||
|
||||
- (void)registerForKeyboardNotifications
|
||||
{
|
||||
[[NSNotificationCenter defaultCenter] addObserver:self
|
||||
selector:@selector(keyboardWasShown:)
|
||||
name:UIKeyboardDidShowNotification object:nil];
|
||||
[[NSNotificationCenter defaultCenter] addObserver:self
|
||||
selector:@selector(keyboardWillBeHidden:)
|
||||
name:UIKeyboardWillHideNotification object:nil];
|
||||
}
|
||||
|
||||
- (void)unregisterKeyboardNotifications
|
||||
{
|
||||
[[NSNotificationCenter defaultCenter] removeObserver:self];
|
||||
}
|
||||
|
||||
- (void)keyboardWasShown:(NSNotification*)aNotification
|
||||
{
|
||||
NSDictionary * info = [aNotification userInfo];
|
||||
CGSize kbSize = [[info objectForKey:UIKeyboardFrameBeginUserInfoKey] CGRectValue].size;
|
||||
|
||||
// Fix keyboard size if orientation was changed
|
||||
// (strange that iOS doesn't do it itself...)
|
||||
if (self.interfaceOrientation == UIInterfaceOrientationLandscapeLeft
|
||||
|| self.interfaceOrientation == UIInterfaceOrientationLandscapeRight)
|
||||
std::swap(kbSize.height, kbSize.width);
|
||||
|
||||
UIEdgeInsets contentInsets = UIEdgeInsetsMake(0.0, 0.0, kbSize.height, 0.0);
|
||||
UITextView * tv = (UITextView *)self.view;
|
||||
tv.contentInset = contentInsets;
|
||||
tv.scrollIndicatorInsets = contentInsets;
|
||||
}
|
||||
|
||||
- (void)keyboardWillBeHidden:(NSNotification*)aNotification
|
||||
{
|
||||
UIEdgeInsets contentInsets = UIEdgeInsetsZero;
|
||||
UITextView * tv = (UITextView *)self.view;
|
||||
tv.contentInset = contentInsets;
|
||||
tv.scrollIndicatorInsets = contentInsets;
|
||||
}
|
||||
|
||||
@end
|
|
@ -2,6 +2,7 @@
|
|||
#import "BalloonView.h"
|
||||
#import "SelectSetVC.h"
|
||||
#import "SelectColorVC.h"
|
||||
#import "EditDescriptionVC.h"
|
||||
#import "Statistics.h"
|
||||
|
||||
#define TEXTFIELD_TAG 999
|
||||
|
@ -49,7 +50,7 @@
|
|||
{
|
||||
UITableViewCell * cell = [self.tableView cellForRowAtIndexPath:[NSIndexPath indexPathForRow:0 inSection:0]];
|
||||
UITextField * f = (UITextField *)[cell viewWithTag:TEXTFIELD_TAG];
|
||||
if (f && f.text.length)
|
||||
if (f.text.length)
|
||||
m_balloon.title = f.text;
|
||||
|
||||
// We're going back to the map
|
||||
|
@ -85,29 +86,6 @@
|
|||
}
|
||||
}
|
||||
|
||||
//- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
|
||||
//{
|
||||
// if (section != 0)
|
||||
// return nil;
|
||||
// // Address and type text
|
||||
// UILabel * label = [[[UILabel alloc] initWithFrame:CGRectMake(0, 0, tableView.frame.size.width, 40)] autorelease];
|
||||
// label.autoresizingMask = UIViewAutoresizingFlexibleHeight | UIViewAutoresizingFlexibleWidth;
|
||||
// label.numberOfLines = 0;
|
||||
// label.lineBreakMode = UILineBreakModeWordWrap;
|
||||
// label.backgroundColor = [UIColor clearColor];
|
||||
// label.textColor = [UIColor darkGrayColor];
|
||||
// label.textAlignment = UITextAlignmentCenter;
|
||||
// label.text = [NSString stringWithFormat:@"%@\n%@", m_balloon.type, m_balloon.description];
|
||||
// return label;
|
||||
//}
|
||||
|
||||
//- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
|
||||
//{
|
||||
// if (section != 0)
|
||||
// return 0;
|
||||
// return 60;
|
||||
//}
|
||||
|
||||
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
|
||||
{
|
||||
UITableViewCell * cell = nil;
|
||||
|
@ -183,7 +161,19 @@
|
|||
break;
|
||||
}
|
||||
}
|
||||
else if (indexPath.section == 1 && [self canShare])
|
||||
else if (indexPath.section == 1)
|
||||
{
|
||||
NSString * cellLabelText = NSLocalizedString(@"description", nil);
|
||||
cell = [tableView dequeueReusableCellWithIdentifier:cellLabelText];
|
||||
if (!cell)
|
||||
{
|
||||
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:cellLabelText] autorelease];
|
||||
cell.textLabel.text = cellLabelText;
|
||||
cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
|
||||
}
|
||||
cell.detailTextLabel.text = m_balloon.notes;
|
||||
}
|
||||
else if (indexPath.section == 2 && [self canShare])
|
||||
{
|
||||
cell = [tableView dequeueReusableCellWithIdentifier:@"SharePin"];
|
||||
if (!cell)
|
||||
|
@ -240,7 +230,14 @@
|
|||
break;
|
||||
}
|
||||
}
|
||||
else if (indexPath.section == 1 && ([self canShare]))
|
||||
else if (indexPath.section == 1)
|
||||
{
|
||||
m_hideNavBar = NO;
|
||||
EditDescriptionVC * vc = [[EditDescriptionVC alloc] initWithBalloonView:m_balloon];
|
||||
[self.navigationController pushViewController:vc animated:YES];
|
||||
[vc release];
|
||||
}
|
||||
else if (indexPath.section == 2 && ([self canShare]))
|
||||
{
|
||||
UIActionSheet * as = [[UIActionSheet alloc] initWithTitle:NSLocalizedString(@"share", nil) delegate:self cancelButtonTitle:nil destructiveButtonTitle:nil otherButtonTitles:nil];
|
||||
if ([MFMessageComposeViewController canSendText])
|
||||
|
|
|
@ -293,6 +293,8 @@ const long long LITE_IDL = 431183278L;
|
|||
if (res.length == 0)
|
||||
res = NSLocalizedString(@"dropped_pin", nil);
|
||||
|
||||
// Reset description BEFORE title, as title's setter also takes it into an account for Balloon text generation
|
||||
m_balloonView.description = nil;
|
||||
m_balloonView.title = res;
|
||||
//m_balloonView.description = [NSString stringWithUTF8String:info.FormatAddress().c_str()];
|
||||
//m_balloonView.type = [NSString stringWithUTF8String:info.FormatTypes().c_str()];
|
||||
|
@ -708,6 +710,12 @@ NSInteger compareAddress(id l, id r, void * context)
|
|||
m_balloonView.editedBookmark = bmAndCat;
|
||||
m_balloonView.isCurrentPosition = NO;
|
||||
m_balloonView.globalPosition = CGPointMake(globalPos.x, globalPos.y);
|
||||
// Reset description BEFORE title, as title's setter also takes it into an account for Balloon text generation
|
||||
string const & descr = bm->GetDescription();
|
||||
if (!descr.empty())
|
||||
m_balloonView.description = [NSString stringWithUTF8String:descr.c_str()];
|
||||
else
|
||||
m_balloonView.description = nil;
|
||||
m_balloonView.title = [NSString stringWithUTF8String:bm->GetName().c_str()];
|
||||
m_balloonView.color = [NSString stringWithUTF8String:bm->GetType().c_str()];
|
||||
m_balloonView.setName = [NSString stringWithUTF8String:cat->GetName().c_str()];
|
||||
|
|
|
@ -243,6 +243,8 @@
|
|||
FAB2D51E15DAB53F00C706C3 /* tail.png in Resources */ = {isa = PBXBuildFile; fileRef = FAB2D51415DAB53F00C706C3 /* tail.png */; };
|
||||
FAB2D51F15DAB53F00C706C3 /* tail@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = FAB2D51515DAB53F00C706C3 /* tail@2x.png */; };
|
||||
FABF223E13FAA97A003D4D49 /* CompassView.mm in Sources */ = {isa = PBXBuildFile; fileRef = FABF223D13FAA97A003D4D49 /* CompassView.mm */; };
|
||||
FAC23543171B2C09003BED96 /* EditDescriptionVC.mm in Sources */ = {isa = PBXBuildFile; fileRef = FAC23542171B2C09003BED96 /* EditDescriptionVC.mm */; };
|
||||
FAC23544171B2C09003BED96 /* EditDescriptionVC.mm in Sources */ = {isa = PBXBuildFile; fileRef = FAC23542171B2C09003BED96 /* EditDescriptionVC.mm */; };
|
||||
FAD4906C13EFF61F005E7D43 /* search.png in Resources */ = {isa = PBXBuildFile; fileRef = FAD4906A13EFF61F005E7D43 /* search.png */; };
|
||||
FAD4906D13EFF61F005E7D43 /* search@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = FAD4906B13EFF61F005E7D43 /* search@2x.png */; };
|
||||
FAEA8B2A1437CA80002A6737 /* libjansson.a in Frameworks */ = {isa = PBXBuildFile; fileRef = FAEA8B291437CA80002A6737 /* libjansson.a */; };
|
||||
|
@ -1573,6 +1575,8 @@
|
|||
FAB2D51515DAB53F00C706C3 /* tail@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = "tail@2x.png"; path = "Bookmarks/tail@2x.png"; sourceTree = SOURCE_ROOT; };
|
||||
FABF223C13FAA97A003D4D49 /* CompassView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CompassView.h; sourceTree = "<group>"; };
|
||||
FABF223D13FAA97A003D4D49 /* CompassView.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = CompassView.mm; sourceTree = "<group>"; };
|
||||
FAC23541171B2C09003BED96 /* EditDescriptionVC.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = EditDescriptionVC.h; path = Bookmarks/EditDescriptionVC.h; sourceTree = SOURCE_ROOT; };
|
||||
FAC23542171B2C09003BED96 /* EditDescriptionVC.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = EditDescriptionVC.mm; path = Bookmarks/EditDescriptionVC.mm; sourceTree = SOURCE_ROOT; };
|
||||
FAD4906A13EFF61F005E7D43 /* search.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = search.png; sourceTree = "<group>"; };
|
||||
FAD4906B13EFF61F005E7D43 /* search@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "search@2x.png"; sourceTree = "<group>"; };
|
||||
FAEA8B291437CA80002A6737 /* libjansson.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; path = libjansson.a; sourceTree = SOURCE_ROOT; };
|
||||
|
@ -2408,6 +2412,8 @@
|
|||
FA36B8011540388B004560CC /* Bookmarks */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
FAC23541171B2C09003BED96 /* EditDescriptionVC.h */,
|
||||
FAC23542171B2C09003BED96 /* EditDescriptionVC.mm */,
|
||||
F785EB3E16386FC4003A38A8 /* BookmarkCell.h */,
|
||||
F785EB3F16386FC4003A38A8 /* BookmarkCell.mm */,
|
||||
FA36B8171540466A004560CC /* Images */,
|
||||
|
@ -4459,6 +4465,7 @@
|
|||
FAAEA7D5161D8D3100CCD661 /* BookmarksRootVC.mm in Sources */,
|
||||
F785EB4016386FC4003A38A8 /* BookmarkCell.mm in Sources */,
|
||||
CB252D6F16FF82C9001E41E9 /* Statistics.m in Sources */,
|
||||
FAC23543171B2C09003BED96 /* EditDescriptionVC.mm in Sources */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
|
@ -4494,6 +4501,7 @@
|
|||
FAAEA7D6161D8D3100CCD661 /* BookmarksRootVC.mm in Sources */,
|
||||
F785EB4116386FC4003A38A8 /* BookmarkCell.mm in Sources */,
|
||||
CB252D7016FF82C9001E41E9 /* Statistics.m in Sources */,
|
||||
FAC23544171B2C09003BED96 /* EditDescriptionVC.mm in Sources */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
|
|
Loading…
Add table
Reference in a new issue