From bfe01f311044d27b3c4b6639e9a5a5f464bd7803 Mon Sep 17 00:00:00 2001 From: Alexander Boriskov Date: Wed, 30 Oct 2019 11:38:21 +0300 Subject: [PATCH] [iOS] Fix tracks/objects count in bookmarks https://jira.mail.ru/browse/MAPSME-12064 --- .../Bookmarks/Catalog/CatalogCategoryCell.swift | 2 +- .../Categories/Categories/BMCCategoryCell.swift | 2 +- .../Categories/MWMCategory+PlacesCountTitle.swift | 14 ++++++++++++++ .../Template Builders/ListTemplateBuilder.swift | 2 +- iphone/Maps/Maps.xcodeproj/project.pbxproj | 4 ++++ 5 files changed, 21 insertions(+), 3 deletions(-) create mode 100644 iphone/Maps/Categories/MWMCategory+PlacesCountTitle.swift diff --git a/iphone/Maps/Bookmarks/Catalog/CatalogCategoryCell.swift b/iphone/Maps/Bookmarks/Catalog/CatalogCategoryCell.swift index ff7c1eb5a0..bc7459c8ca 100644 --- a/iphone/Maps/Bookmarks/Catalog/CatalogCategoryCell.swift +++ b/iphone/Maps/Bookmarks/Catalog/CatalogCategoryCell.swift @@ -37,7 +37,7 @@ final class CatalogCategoryCell: MWMTableViewCell { func update(with category: MWMCategory, delegate: CatalogCategoryCellDelegate?) { titleLabel.text = category.title - let placesString = String(format: L("bookmarks_places"), category.bookmarksCount) + let placesString = category.placesCountTitle() let authorString = String(coreFormat: L("author_name_by_prefix"), arguments: [category.author]) subtitleLabel.text = "\(placesString) • \(authorString)" visibleCheckmark.isChecked = category.isVisible diff --git a/iphone/Maps/Bookmarks/Categories/Categories/BMCCategoryCell.swift b/iphone/Maps/Bookmarks/Categories/Categories/BMCCategoryCell.swift index a02aa5d8da..06c5b0be94 100644 --- a/iphone/Maps/Bookmarks/Categories/Categories/BMCCategoryCell.swift +++ b/iphone/Maps/Bookmarks/Categories/Categories/BMCCategoryCell.swift @@ -79,7 +79,7 @@ final class BMCCategoryCell: MWMTableViewCell { accessString = "" } - let placesString = String(format: L("bookmarks_places"), category.bookmarksCount + category.trackCount) + let placesString = category.placesCountTitle() subtitleLabel.text = accessString.count > 0 ? "\(accessString) • \(placesString)" : placesString visibleCheckmark.isChecked = category.isVisible } diff --git a/iphone/Maps/Categories/MWMCategory+PlacesCountTitle.swift b/iphone/Maps/Categories/MWMCategory+PlacesCountTitle.swift new file mode 100644 index 0000000000..2d7cc31eaf --- /dev/null +++ b/iphone/Maps/Categories/MWMCategory+PlacesCountTitle.swift @@ -0,0 +1,14 @@ +import Foundation + +extension MWMCategory { + @objc func placesCountTitle() -> String { + if (bookmarksCount > 0 && trackCount > 0) || + (bookmarksCount == 0 && trackCount == 0) { + return String(format: L("objects"), bookmarksCount + trackCount) + } else if (bookmarksCount > 0) { + return String(format: L("bookmarks_places"), bookmarksCount) + } else { + return String(format: L("tracks"), trackCount) + } + } +} diff --git a/iphone/Maps/Classes/CarPlay/Template Builders/ListTemplateBuilder.swift b/iphone/Maps/Classes/CarPlay/Template Builders/ListTemplateBuilder.swift index b842e32c0a..24b9c562f0 100644 --- a/iphone/Maps/Classes/CarPlay/Template Builders/ListTemplateBuilder.swift +++ b/iphone/Maps/Classes/CarPlay/Template Builders/ListTemplateBuilder.swift @@ -79,7 +79,7 @@ final class ListTemplateBuilder { let categories = bookmarkManager.userCategories() let items: [CPListItem] = categories.compactMap({ category in if category.bookmarksCount == 0 { return nil } - let placesString = String(format: L("bookmarks_places"), category.bookmarksCount) + let placesString = category.placesCountTitle() let item = CPListItem(text: category.title, detailText: placesString) item.userInfo = ListItemInfo(type: CPConstants.ListItemType.bookmarkLists, metadata: CategoryInfo(category: category)) diff --git a/iphone/Maps/Maps.xcodeproj/project.pbxproj b/iphone/Maps/Maps.xcodeproj/project.pbxproj index 0d38539ee8..ffda66ce17 100644 --- a/iphone/Maps/Maps.xcodeproj/project.pbxproj +++ b/iphone/Maps/Maps.xcodeproj/project.pbxproj @@ -570,6 +570,7 @@ 99D363172358647700941BF4 /* SubscriptionGroup.swift in Sources */ = {isa = PBXBuildFile; fileRef = 99D363162358647700941BF4 /* SubscriptionGroup.swift */; }; 99D363192358685300941BF4 /* SubscriptionGroupItem.swift in Sources */ = {isa = PBXBuildFile; fileRef = 99D363182358685300941BF4 /* SubscriptionGroupItem.swift */; }; 99D3631E23589BE800941BF4 /* FredokaOne-Regular.ttf in Resources */ = {isa = PBXBuildFile; fileRef = 99D3631D23589BE800941BF4 /* FredokaOne-Regular.ttf */; }; + 99E2B0122368A8C700FFABC5 /* MWMCategory+PlacesCountTitle.swift in Sources */ = {isa = PBXBuildFile; fileRef = 99E2B0112368A8C700FFABC5 /* MWMCategory+PlacesCountTitle.swift */; }; A630D1EA207CA95900976DEA /* Localizable.stringsdict in Resources */ = {isa = PBXBuildFile; fileRef = A630D1E8207CA95900976DEA /* Localizable.stringsdict */; }; B32FE74020D2844600EF7446 /* DownloadedBookmarksViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = B32FE73E20D2844600EF7446 /* DownloadedBookmarksViewController.swift */; }; B32FE74120D2844600EF7446 /* DownloadedBookmarksViewController.xib in Resources */ = {isa = PBXBuildFile; fileRef = B32FE73F20D2844600EF7446 /* DownloadedBookmarksViewController.xib */; }; @@ -1608,6 +1609,7 @@ 99D363162358647700941BF4 /* SubscriptionGroup.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SubscriptionGroup.swift; sourceTree = ""; }; 99D363182358685300941BF4 /* SubscriptionGroupItem.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SubscriptionGroupItem.swift; sourceTree = ""; }; 99D3631D23589BE800941BF4 /* FredokaOne-Regular.ttf */ = {isa = PBXFileReference; lastKnownFileType = file; path = "FredokaOne-Regular.ttf"; sourceTree = ""; }; + 99E2B0112368A8C700FFABC5 /* MWMCategory+PlacesCountTitle.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "MWMCategory+PlacesCountTitle.swift"; sourceTree = ""; }; 9DF04B231B71010E00DACAF1 /* 02_droidsans-fallback.ttf */ = {isa = PBXFileReference; lastKnownFileType = file; name = "02_droidsans-fallback.ttf"; path = "../../data/02_droidsans-fallback.ttf"; sourceTree = ""; }; A367C93A1B17334800E2B6E7 /* resources-default */ = {isa = PBXFileReference; lastKnownFileType = folder; name = "resources-default"; path = "../../data/resources-default"; sourceTree = ""; }; A630D1E9207CA95900976DEA /* ar */ = {isa = PBXFileReference; lastKnownFileType = text.plist.stringsdict; name = ar; path = ar.lproj/Localizable.stringsdict; sourceTree = ""; }; @@ -2769,6 +2771,7 @@ 4767CDA320AAF66B00BD8166 /* NSAttributedString+HTML.swift */, 47699A0621F08E37009E6585 /* NSDate+TimeDistance.h */, 47699A0721F08E37009E6585 /* NSDate+TimeDistance.m */, + 99E2B0112368A8C700FFABC5 /* MWMCategory+PlacesCountTitle.swift */, ); path = Categories; sourceTree = ""; @@ -5590,6 +5593,7 @@ F6E2FE731E097BA00083EBEC /* MWMOpeningHours.mm in Sources */, CD96C70C22A681C400DB7CFE /* DiscoveryGuideCell.swift in Sources */, 47E3C7312111F4C2008B3B27 /* CoverVerticalPresentationAnimator.swift in Sources */, + 99E2B0122368A8C700FFABC5 /* MWMCategory+PlacesCountTitle.swift in Sources */, F6D67CDC2062B9C00032FD38 /* BCCreateCategoryAlert.swift in Sources */, F6E2FF601E097BA00083EBEC /* MWMSettingsViewController.mm in Sources */, F6E2FE2B1E097BA00083EBEC /* MWMStreetEditorEditTableViewCell.mm in Sources */,