diff --git a/iphone/CoreApi/CoreApi/Bookmarks/MWMBookmarkGroup.h b/iphone/CoreApi/CoreApi/Bookmarks/MWMBookmarkGroup.h index f867bc2b41..6e5d34c8d8 100644 --- a/iphone/CoreApi/CoreApi/Bookmarks/MWMBookmarkGroup.h +++ b/iphone/CoreApi/CoreApi/Bookmarks/MWMBookmarkGroup.h @@ -28,6 +28,7 @@ NS_SWIFT_NAME(BookmarkGroup) @property(nonatomic, readonly, getter=isVisible) BOOL visible; @property(nonatomic, readonly, getter=isEmpty) BOOL empty; @property(nonatomic, readonly) BOOL hasDescription; +@property(nonatomic, readonly) BOOL isHtmlDescription; @property(nonatomic, readonly) MWMBookmarkGroupAccessStatus accessStatus; @property(nonatomic, readonly) NSArray *bookmarks; @property(nonatomic, readonly) NSArray *tracks; diff --git a/iphone/CoreApi/CoreApi/Bookmarks/MWMBookmarkGroup.m b/iphone/CoreApi/CoreApi/Bookmarks/MWMBookmarkGroup.m index 3c991fa6a7..7cfd57950b 100644 --- a/iphone/CoreApi/CoreApi/Bookmarks/MWMBookmarkGroup.m +++ b/iphone/CoreApi/CoreApi/Bookmarks/MWMBookmarkGroup.m @@ -84,4 +84,8 @@ return [self.manager getCategoryGroupType:self.categoryId]; } +- (BOOL)isHtmlDescription { + return [self.manager isHtmlDescription:self.categoryId]; +} + @end diff --git a/iphone/CoreApi/CoreApi/Bookmarks/MWMBookmarksManager.h b/iphone/CoreApi/CoreApi/Bookmarks/MWMBookmarksManager.h index 5afef3cc85..5898dc6d39 100644 --- a/iphone/CoreApi/CoreApi/Bookmarks/MWMBookmarksManager.h +++ b/iphone/CoreApi/CoreApi/Bookmarks/MWMBookmarksManager.h @@ -47,6 +47,7 @@ NS_SWIFT_NAME(BookmarksManager) - (MWMBookmarkGroupType)getCategoryGroupType:(MWMMarkGroupID)groupId; - (nullable NSURL *)getCategoryImageUrl:(MWMMarkGroupID)groupId; - (BOOL)hasExtraInfo:(MWMMarkGroupID)groupId; +- (BOOL)isHtmlDescription:(MWMMarkGroupID)groupId; - (MWMMarkGroupID)createCategoryWithName:(NSString *)name; - (void)setCategory:(MWMMarkGroupID)groupId name:(NSString *)name; diff --git a/iphone/CoreApi/CoreApi/Bookmarks/MWMBookmarksManager.mm b/iphone/CoreApi/CoreApi/Bookmarks/MWMBookmarksManager.mm index f784405dc8..e10dd71c17 100644 --- a/iphone/CoreApi/CoreApi/Bookmarks/MWMBookmarksManager.mm +++ b/iphone/CoreApi/CoreApi/Bookmarks/MWMBookmarksManager.mm @@ -287,6 +287,11 @@ static BookmarkManager::SortingType convertSortingTypeToCore(MWMBookmarksSorting return !data.m_description.empty() || !data.m_annotation.empty(); } +- (BOOL)isHtmlDescription:(MWMMarkGroupID)groupId { + auto const description = GetPreferredBookmarkStr(self.bm.GetCategoryData(groupId).m_description); + return strings::IsHTML(description); +} + - (MWMMarkGroupID)createCategoryWithName:(NSString *)name { auto groupId = self.bm.CreateBookmarkCategory(name.UTF8String); diff --git a/iphone/Maps/Bookmarks/BookmarksList/BookmarksListInfoViewController.swift b/iphone/Maps/Bookmarks/BookmarksList/BookmarksListInfoViewController.swift index 75771818db..762d8fc636 100644 --- a/iphone/Maps/Bookmarks/BookmarksList/BookmarksListInfoViewController.swift +++ b/iphone/Maps/Bookmarks/BookmarksList/BookmarksListInfoViewController.swift @@ -4,7 +4,7 @@ protocol BookmarksListInfoViewControllerDelegate: AnyObject { } final class BookmarksListInfoViewController: UIViewController { - var info: IBookmakrsListInfoViewModel? { + var info: IBookmarksListInfoViewModel? { didSet { guard isViewLoaded, let info = info else { return } updateInfo(info) @@ -26,17 +26,23 @@ final class BookmarksListInfoViewController: UIViewController { override func viewDidLoad() { super.viewDidLoad() - descriptionButton.setTitle(L("placepage_place_description").uppercased(), for: .normal) separatorsConstraints.forEach { $0.constant = 1 / UIScreen.main.scale } + descriptionButton.titleLabel?.numberOfLines = 2 guard let info = info else { return } updateInfo(info) } - private func updateInfo(_ info: IBookmakrsListInfoViewModel) { + private func updateInfo(_ info: IBookmarksListInfoViewModel) { titleLabel.text = info.title descriptionButton.isHidden = !info.hasDescription - + if info.hasDescription { + let description = info.isHtmlDescription + ? BookmarksListInfoViewController.getPlainText(info.description) + : info.description + descriptionButton.setTitle(description, for: .normal) + } + titleImageView.isHidden = true if let imageUrl = info.imageUrl { titleImageView.wi_setImage(with: imageUrl, transitionDuration: 0) { [weak self] (image, error) in @@ -46,4 +52,9 @@ final class BookmarksListInfoViewController: UIViewController { } } } + + private static func getPlainText(_ htmlText: String) -> String? { + let formattedText = NSAttributedString.string(withHtml: htmlText, defaultAttributes: [:]) + return formattedText?.string + } } diff --git a/iphone/Maps/Bookmarks/BookmarksList/BookmarksListInfoViewController.xib b/iphone/Maps/Bookmarks/BookmarksList/BookmarksListInfoViewController.xib index f79f370e30..aa13283583 100644 --- a/iphone/Maps/Bookmarks/BookmarksList/BookmarksListInfoViewController.xib +++ b/iphone/Maps/Bookmarks/BookmarksList/BookmarksListInfoViewController.xib @@ -60,7 +60,7 @@ -