From 5cba6cedc6cc8f1e6bba7d720fd7bd13e2cc322e Mon Sep 17 00:00:00 2001 From: Alexander Boriskov Date: Fri, 22 Nov 2019 18:08:28 +0300 Subject: [PATCH] [iOS] PP of outdoor sights https://jira.mail.ru/browse/MAPSME-12291 --- iphone/Maps/Maps.xcodeproj/project.pbxproj | 6 ---- .../UI/Discovery/MWMDiscoveryTableManager.mm | 10 +++--- .../MWMDiscoveryControllerViewModel.h | 4 +-- .../MWMDiscoveryControllerViewModel.mm | 12 +++---- .../View Models/MWMDiscoveryGuideViewModel.h | 19 ------------ .../View Models/MWMDiscoveryGuideViewModel.m | 31 ------------------- iphone/Maps/UI/PlacePage/MWMPlacePageData.h | 4 +-- iphone/Maps/UI/PlacePage/MWMPlacePageData.mm | 10 ++---- .../PlacePageLayout/MWMPlacePageLayout.mm | 10 +++--- 9 files changed, 21 insertions(+), 85 deletions(-) delete mode 100644 iphone/Maps/UI/Discovery/View Models/MWMDiscoveryGuideViewModel.h delete mode 100644 iphone/Maps/UI/Discovery/View Models/MWMDiscoveryGuideViewModel.m diff --git a/iphone/Maps/Maps.xcodeproj/project.pbxproj b/iphone/Maps/Maps.xcodeproj/project.pbxproj index 22f8a42e69..9b0007587c 100644 --- a/iphone/Maps/Maps.xcodeproj/project.pbxproj +++ b/iphone/Maps/Maps.xcodeproj/project.pbxproj @@ -653,7 +653,6 @@ CD96C70C22A681C400DB7CFE /* DiscoveryGuideCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = CD96C70A22A681C400DB7CFE /* DiscoveryGuideCell.swift */; }; CD96C70D22A681C400DB7CFE /* DiscoveryGuideCell.xib in Resources */ = {isa = PBXBuildFile; fileRef = CD96C70B22A681C400DB7CFE /* DiscoveryGuideCell.xib */; }; CD96C71122A6820800DB7CFE /* DiscoveryGuideCollectionHolderCell.xib in Resources */ = {isa = PBXBuildFile; fileRef = CD96C70F22A6820800DB7CFE /* DiscoveryGuideCollectionHolderCell.xib */; }; - CD96C71422A6CBFD00DB7CFE /* MWMDiscoveryGuideViewModel.m in Sources */ = {isa = PBXBuildFile; fileRef = CD96C71322A6CBFD00DB7CFE /* MWMDiscoveryGuideViewModel.m */; }; CD96C71722A7B5DE00DB7CFE /* MWMDiscoveryCityGalleryObjects.mm in Sources */ = {isa = PBXBuildFile; fileRef = CD96C71622A7B5DE00DB7CFE /* MWMDiscoveryCityGalleryObjects.mm */; }; CD96C71C22A8113100DB7CFE /* MWMDiscoveryControllerViewModel.mm in Sources */ = {isa = PBXBuildFile; fileRef = CDB92CEA229E9ADF00EC757C /* MWMDiscoveryControllerViewModel.mm */; }; CD9AD967228067F500EC174A /* MapInfo.swift in Sources */ = {isa = PBXBuildFile; fileRef = CD9AD966228067F500EC174A /* MapInfo.swift */; }; @@ -1780,8 +1779,6 @@ CD96C70A22A681C400DB7CFE /* DiscoveryGuideCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DiscoveryGuideCell.swift; sourceTree = ""; }; CD96C70B22A681C400DB7CFE /* DiscoveryGuideCell.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = DiscoveryGuideCell.xib; sourceTree = ""; }; CD96C70F22A6820800DB7CFE /* DiscoveryGuideCollectionHolderCell.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = DiscoveryGuideCollectionHolderCell.xib; sourceTree = ""; }; - CD96C71222A6CBFD00DB7CFE /* MWMDiscoveryGuideViewModel.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MWMDiscoveryGuideViewModel.h; sourceTree = ""; }; - CD96C71322A6CBFD00DB7CFE /* MWMDiscoveryGuideViewModel.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = MWMDiscoveryGuideViewModel.m; sourceTree = ""; }; CD96C71522A7B5DE00DB7CFE /* MWMDiscoveryCityGalleryObjects.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MWMDiscoveryCityGalleryObjects.h; sourceTree = ""; }; CD96C71622A7B5DE00DB7CFE /* MWMDiscoveryCityGalleryObjects.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = MWMDiscoveryCityGalleryObjects.mm; sourceTree = ""; }; CD9AD966228067F500EC174A /* MapInfo.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MapInfo.swift; sourceTree = ""; }; @@ -3920,8 +3917,6 @@ CDB92CF0229EB8A800EC757C /* MWMDiscoverySearchViewModel.m */, CDB92CF622A5350500EC757C /* MWMDiscoveryHotelViewModel.h */, CDB92CF722A5350500EC757C /* MWMDiscoveryHotelViewModel.m */, - CD96C71222A6CBFD00DB7CFE /* MWMDiscoveryGuideViewModel.h */, - CD96C71322A6CBFD00DB7CFE /* MWMDiscoveryGuideViewModel.m */, ); path = "View Models"; sourceTree = ""; @@ -5380,7 +5375,6 @@ 34AB665F1FC5AA330078E451 /* TransportTransitIntermediatePoint.swift in Sources */, 34B846A82029E8110081ECCD /* BMCDefaultViewModel.swift in Sources */, 470F5A7F2189C30800754295 /* InAppPurchase.swift in Sources */, - CD96C71422A6CBFD00DB7CFE /* MWMDiscoveryGuideViewModel.m in Sources */, 348A8DF51F66775A00D83026 /* RatingView.swift in Sources */, F63AF50F1EA6215100A1DB98 /* FilterPriceCategoryCell.swift in Sources */, 47A6F3C6235F47B90053FBA4 /* BookmarksSubscriptionViewController.swift in Sources */, diff --git a/iphone/Maps/UI/Discovery/MWMDiscoveryTableManager.mm b/iphone/Maps/UI/Discovery/MWMDiscoveryTableManager.mm index a4a841922c..9cd43afd3f 100644 --- a/iphone/Maps/UI/Discovery/MWMDiscoveryTableManager.mm +++ b/iphone/Maps/UI/Discovery/MWMDiscoveryTableManager.mm @@ -4,7 +4,7 @@ #import "MWMDiscoveryControllerViewModel.h" #import "MWMDiscoveryHotelViewModel.h" #import "MWMDiscoverySearchViewModel.h" -#import "MWMDiscoveryGuideViewModel.h" +#import "CatalogPromoItem+Core.h" #import "MWMNetworkPolicy+UI.h" #import "Statistics.h" #import "SwiftBridge.h" @@ -370,11 +370,11 @@ using namespace discovery; Class cls = [MWMDiscoveryGuideCell class]; MWMDiscoveryGuideCell *cell = (MWMDiscoveryGuideCell *) [collectionView dequeueReusableCellWithCellClass:cls indexPath:indexPath]; - MWMDiscoveryGuideViewModel *objectVM = [self.viewModel guideAtIndex:indexPath.item]; + CatalogPromoItem *objectVM = [self.viewModel guideAtIndex:indexPath.item]; __weak __typeof__(self) weakSelf = self; - [cell configWithAvatarURL:objectVM.imagePath - title:objectVM.title - subtitle:objectVM.subtitle + [cell configWithAvatarURL:objectVM.imageUrl + title:objectVM.guideName + subtitle:objectVM.guideAuthor label:objectVM.label labelHexColor:objectVM.labelHexColor onDetails:^{ diff --git a/iphone/Maps/UI/Discovery/View Models/MWMDiscoveryControllerViewModel.h b/iphone/Maps/UI/Discovery/View Models/MWMDiscoveryControllerViewModel.h index 3805766c14..8426f16eec 100644 --- a/iphone/Maps/UI/Discovery/View Models/MWMDiscoveryControllerViewModel.h +++ b/iphone/Maps/UI/Discovery/View Models/MWMDiscoveryControllerViewModel.h @@ -6,7 +6,7 @@ NS_ASSUME_NONNULL_BEGIN @class MWMDiscoveryCityGalleryObjects; @class MWMDiscoverySearchViewModel; @class MWMDiscoveryHotelViewModel; -@class MWMDiscoveryGuideViewModel; +@class CatalogPromoItem; @interface MWMDiscoveryControllerViewModel : NSObject @@ -23,7 +23,7 @@ NS_ASSUME_NONNULL_BEGIN - (MWMDiscoverySearchViewModel *)attractionAtIndex:(NSUInteger)index; - (MWMDiscoverySearchViewModel *)cafeAtIndex:(NSUInteger)index; - (MWMDiscoveryHotelViewModel *)hotelAtIndex:(NSUInteger)index; -- (MWMDiscoveryGuideViewModel *)guideAtIndex:(NSUInteger)index; +- (CatalogPromoItem *)guideAtIndex:(NSUInteger)index; @end diff --git a/iphone/Maps/UI/Discovery/View Models/MWMDiscoveryControllerViewModel.mm b/iphone/Maps/UI/Discovery/View Models/MWMDiscoveryControllerViewModel.mm index d76c75f7b5..b65c88947a 100644 --- a/iphone/Maps/UI/Discovery/View Models/MWMDiscoveryControllerViewModel.mm +++ b/iphone/Maps/UI/Discovery/View Models/MWMDiscoveryControllerViewModel.mm @@ -3,7 +3,7 @@ #import "MWMDiscoveryMapObjects.h" #import "MWMDiscoveryHotelViewModel.h" #import "MWMDiscoverySearchViewModel.h" -#import "MWMDiscoveryGuideViewModel.h" +#import "CatalogPromoItem+Core.h" #include "map/place_page_info.hpp" @@ -90,7 +90,7 @@ using namespace discovery; viewPortCenter:center]; } -- (MWMDiscoveryGuideViewModel *)guideAtIndex:(NSUInteger)index { +- (CatalogPromoItem *)guideAtIndex:(NSUInteger)index { promo::CityGallery::Item const &item = [self.guides galleryItemAtIndex:index]; return [self guideViewModelForItem:item]; } @@ -153,12 +153,8 @@ using namespace discovery; ratingType:ratingType]; } -- (MWMDiscoveryGuideViewModel *)guideViewModelForItem:(promo::CityGallery::Item const &)item { - return [[MWMDiscoveryGuideViewModel alloc] initWithTitle:@(item.m_name.c_str()) - subtitle:@(item.m_author.m_name.c_str()) - label:@(item.m_luxCategory.m_name.c_str()) - labelHexColor:@(item.m_luxCategory.m_color.c_str()) - imageURL:@(item.m_imageUrl.c_str())]; +- (CatalogPromoItem *)guideViewModelForItem:(promo::CityGallery::Item const &)item { + return [[CatalogPromoItem alloc] initWithCoreItem:item]; } #pragma mark - Helpers diff --git a/iphone/Maps/UI/Discovery/View Models/MWMDiscoveryGuideViewModel.h b/iphone/Maps/UI/Discovery/View Models/MWMDiscoveryGuideViewModel.h deleted file mode 100644 index 0148c0e654..0000000000 --- a/iphone/Maps/UI/Discovery/View Models/MWMDiscoveryGuideViewModel.h +++ /dev/null @@ -1,19 +0,0 @@ -NS_ASSUME_NONNULL_BEGIN - -@interface MWMDiscoveryGuideViewModel : NSObject - -@property(nonatomic, readonly) NSString *title; -@property(nonatomic, readonly) NSString *subtitle; -@property(nonatomic, nullable, readonly) NSString *label; -@property(nonatomic, nullable, readonly) NSString *labelHexColor; -@property(nonatomic, nullable, readonly) NSString *imagePath; - -- (instancetype)initWithTitle:(NSString *)title - subtitle:(NSString *)subtitle - label:(nullable NSString *)label - labelHexColor:(nullable NSString *)labelHexColor - imageURL:(nullable NSString *) imagePath; - -@end - -NS_ASSUME_NONNULL_END diff --git a/iphone/Maps/UI/Discovery/View Models/MWMDiscoveryGuideViewModel.m b/iphone/Maps/UI/Discovery/View Models/MWMDiscoveryGuideViewModel.m deleted file mode 100644 index a4ecacd4e3..0000000000 --- a/iphone/Maps/UI/Discovery/View Models/MWMDiscoveryGuideViewModel.m +++ /dev/null @@ -1,31 +0,0 @@ -#import "MWMDiscoveryGuideViewModel.h" - -@interface MWMDiscoveryGuideViewModel() - -@property(nonatomic, readwrite) NSString *title; -@property(nonatomic, readwrite) NSString *subtitle; -@property(nonatomic, readwrite) NSString *label; -@property(nonatomic, readwrite) NSString *labelHexColor; -@property(nonatomic, readwrite) NSString *imagePath; - -@end - -@implementation MWMDiscoveryGuideViewModel - -- (instancetype)initWithTitle:(NSString *)title - subtitle:(NSString *)subtitle - label:(NSString *)label - labelHexColor:(NSString *)labelHexColor - imageURL:(NSString *) imagePath { - self = [super init]; - if (self) { - self.title = title; - self.subtitle = subtitle; - self.label = label; - self.labelHexColor = labelHexColor; - self.imagePath = imagePath; - } - return self; -} - -@end diff --git a/iphone/Maps/UI/PlacePage/MWMPlacePageData.h b/iphone/Maps/UI/PlacePage/MWMPlacePageData.h index cce296f028..692be7f7f2 100644 --- a/iphone/Maps/UI/PlacePage/MWMPlacePageData.h +++ b/iphone/Maps/UI/PlacePage/MWMPlacePageData.h @@ -149,7 +149,7 @@ typedef void (^RefreshPromoCallbackBlock)(NSIndexSet *insertedSections); @class MWMUGCReviewModel; @class MWMUGCRatingValueType; @class MWMDiscoveryCityGalleryObjects; -@class MWMDiscoveryGuideViewModel; +@class CatalogPromoItem; @protocol MWMBanner; /// ViewModel for place page. @@ -243,7 +243,7 @@ typedef void (^RefreshPromoCallbackBlock)(NSIndexSet *insertedSections); // Promo Catalog - (void)fillPromoCatalogSection; -- (MWMDiscoveryGuideViewModel *)guideAtIndex:(NSUInteger)index; +- (CatalogPromoItem *)guideAtIndex:(NSUInteger)index; // Table view's data - (std::vector const &)sections; diff --git a/iphone/Maps/UI/PlacePage/MWMPlacePageData.mm b/iphone/Maps/UI/PlacePage/MWMPlacePageData.mm index fbd73f4fd2..240c25b3af 100644 --- a/iphone/Maps/UI/PlacePage/MWMPlacePageData.mm +++ b/iphone/Maps/UI/PlacePage/MWMPlacePageData.mm @@ -1,6 +1,6 @@ #import "MWMPlacePageData.h" #import "MWMDiscoveryCityGalleryObjects.h" -#import "MWMDiscoveryGuideViewModel.h" +#import "CatalogPromoItem+Core.h" #import "MWMBannerHelpers.h" #import "MWMUGCViewModel.h" #import "SwiftBridge.h" @@ -975,13 +975,9 @@ NSString * const kUserDefaultsLatLonAsDMSKey = @"UserDefaultsLatLonAsDMS"; } } -- (MWMDiscoveryGuideViewModel *)guideAtIndex:(NSUInteger)index { +- (CatalogPromoItem *)guideAtIndex:(NSUInteger)index { promo::CityGallery::Item const &item = [self.promoGallery galleryItemAtIndex:index]; - return [[MWMDiscoveryGuideViewModel alloc] initWithTitle:@(item.m_name.c_str()) - subtitle:@(item.m_author.m_name.c_str()) - label:@(item.m_luxCategory.m_name.c_str()) - labelHexColor:@(item.m_luxCategory.m_color.c_str()) - imageURL:@(item.m_imageUrl.c_str())]; + return [[CatalogPromoItem alloc] initWithCoreItem:item]; } @end diff --git a/iphone/Maps/UI/PlacePage/PlacePageLayout/MWMPlacePageLayout.mm b/iphone/Maps/UI/PlacePage/PlacePageLayout/MWMPlacePageLayout.mm index 9fa6f081fa..2f9f338d41 100644 --- a/iphone/Maps/UI/PlacePage/PlacePageLayout/MWMPlacePageLayout.mm +++ b/iphone/Maps/UI/PlacePage/PlacePageLayout/MWMPlacePageLayout.mm @@ -2,7 +2,7 @@ #import "MWMBookmarkCell.h" #import "MWMDiscoveryCityGalleryObjects.h" #import "MWMDiscoveryCollectionView.h" -#import "MWMDiscoveryGuideViewModel.h" +#import "CatalogPromoItem+Core.h" #import "MWMPlaceDescriptionCell.h" #import "MWMOpeningHoursLayoutHelper.h" #import "MWMPPPreviewLayoutHelper.h" @@ -858,11 +858,11 @@ std::map const kMetaInfoCells = { Class cls = [MWMDiscoveryGuideCell class]; MWMDiscoveryGuideCell *cell = (MWMDiscoveryGuideCell *) [collectionView dequeueReusableCellWithCellClass:cls indexPath:indexPath]; - MWMDiscoveryGuideViewModel *objectVM = [self.data guideAtIndex:indexPath.item]; + CatalogPromoItem *objectVM = [self.data guideAtIndex:indexPath.item]; __weak __typeof__(self) weakSelf = self; - [cell configWithAvatarURL:objectVM.imagePath - title:objectVM.title - subtitle:objectVM.subtitle + [cell configWithAvatarURL:objectVM.imageUrl + title:objectVM.guideName + subtitle:objectVM.guideAuthor label:objectVM.label labelHexColor:objectVM.labelHexColor onDetails:^{