[ios] Fixed title and subtitle when add/remove bookmark.

This commit is contained in:
Alex Zolotarev 2016-02-23 07:58:21 +02:00 committed by Sergey Yershov
parent e33e1f961e
commit b5aa727457
4 changed files with 13 additions and 3 deletions

View file

@ -123,14 +123,14 @@ static NSString * const kPlacePageViewCenterKeyPath = @"center";
- (void)addBookmark
{
[self.basePlacePageView addBookmark];
[self.manager addBookmark];
[self.basePlacePageView addBookmark];
}
- (void)removeBookmark
{
[self.basePlacePageView removeBookmark];
[self.manager removeBookmark];
[self.basePlacePageView removeBookmark];
}
- (void)editPlace

View file

@ -49,6 +49,7 @@ using MWMPlacePageCellTypeValueMap = map<MWMPlacePageCellType, string>;
- (ms::LatLon)latlon;
- (m2::PointD const &)mercator;
- (NSString *)apiURL;
- (string)titleForNewBookmark;
- (instancetype)initWithInfo:(place_page::Info const &)info;
- (void)synchronize;

View file

@ -240,6 +240,11 @@ void initFieldsMap()
return @(m_info.GetApiUrl().c_str());
}
- (string)titleForNewBookmark
{
return m_info.FormatNewBookmarkName();
}
- (NSString *)coordinate
{
BOOL const useDMSFormat =

View file

@ -252,10 +252,12 @@ extern NSString * const kBookmarksChangedNotification;
[[Statistics instance] logEvent:kStatEventName(kStatPlacePage, kStatBookmarks)
withParameters:@{kStatValue : kStatAdd}];
Framework & f = GetFramework();
BookmarkData bmData = { self.entity.title.UTF8String, f.LastEditedBMType() };
BookmarkData bmData = { self.entity.titleForNewBookmark, f.LastEditedBMType() };
size_t const categoryIndex = f.LastEditedBMCategory();
size_t const bookmarkIndex = f.GetBookmarkManager().AddBookmark(categoryIndex, self.entity.mercator, bmData);
self.entity.bac = {categoryIndex, bookmarkIndex};
self.entity.bookmarkTitle = @(bmData.GetName().c_str());
self.entity.bookmarkCategory = @(f.GetBmCategory(categoryIndex)->GetName().c_str());
[NSNotificationCenter.defaultCenter postNotificationName:kBookmarksChangedNotification
object:nil
userInfo:nil];
@ -277,6 +279,8 @@ extern NSString * const kBookmarksChangedNotification;
bookmarkCategory->SaveToKMLFile();
}
self.entity.bac = MakeEmptyBookmarkAndCategory();
self.entity.bookmarkTitle = nil;
self.entity.bookmarkCategory = nil;
[NSNotificationCenter.defaultCenter postNotificationName:kBookmarksChangedNotification
object:nil
userInfo:nil];