diff --git a/iphone/CoreApi/CoreApi.xcodeproj/project.pbxproj b/iphone/CoreApi/CoreApi.xcodeproj/project.pbxproj index 21f7cb53c6..80a99db2d7 100644 --- a/iphone/CoreApi/CoreApi.xcodeproj/project.pbxproj +++ b/iphone/CoreApi/CoreApi.xcodeproj/project.pbxproj @@ -14,11 +14,8 @@ 470016082342541100EBF03D /* MWMTagGroup.m in Sources */ = {isa = PBXBuildFile; fileRef = 470016052342541000EBF03D /* MWMTagGroup.m */; }; 4700160F2342579000EBF03D /* MWMTag.h in Headers */ = {isa = PBXBuildFile; fileRef = 470016042342540F00EBF03D /* MWMTag.h */; settings = {ATTRIBUTES = (Public, ); }; }; 470016102342579200EBF03D /* MWMTagGroup.h in Headers */ = {isa = PBXBuildFile; fileRef = 470016032342540E00EBF03D /* MWMTagGroup.h */; settings = {ATTRIBUTES = (Public, ); }; }; - 470B3620244DD9E400C0EA9E /* GuidesGalleryData.h in Headers */ = {isa = PBXBuildFile; fileRef = 470B361E244DD9E400C0EA9E /* GuidesGalleryData.h */; settings = {ATTRIBUTES = (Public, ); }; }; - 470B3621244DD9E400C0EA9E /* GuidesGalleryData.mm in Sources */ = {isa = PBXBuildFile; fileRef = 470B361F244DD9E400C0EA9E /* GuidesGalleryData.mm */; }; 470B3624244DDA0A00C0EA9E /* GuidesGalleryItem.h in Headers */ = {isa = PBXBuildFile; fileRef = 470B3622244DDA0A00C0EA9E /* GuidesGalleryItem.h */; settings = {ATTRIBUTES = (Public, ); }; }; 470B3625244DDA0A00C0EA9E /* GuidesGalleryItem.mm in Sources */ = {isa = PBXBuildFile; fileRef = 470B3623244DDA0A00C0EA9E /* GuidesGalleryItem.mm */; }; - 470B3628244DDA2600C0EA9E /* GuidesGalleryData+Core.h in Headers */ = {isa = PBXBuildFile; fileRef = 470B3626244DDA2600C0EA9E /* GuidesGalleryData+Core.h */; }; 470B362C244DDBF600C0EA9E /* GuidesGalleryItem+Core.h in Headers */ = {isa = PBXBuildFile; fileRef = 470B362A244DDBF600C0EA9E /* GuidesGalleryItem+Core.h */; }; 4718C4322355FC3C00640DF1 /* MWMNetworkPolicy.h in Headers */ = {isa = PBXBuildFile; fileRef = 4718C4302355FC3C00640DF1 /* MWMNetworkPolicy.h */; settings = {ATTRIBUTES = (Public, ); }; }; 4718C4332355FC3C00640DF1 /* MWMNetworkPolicy.mm in Sources */ = {isa = PBXBuildFile; fileRef = 4718C4312355FC3C00640DF1 /* MWMNetworkPolicy.mm */; }; @@ -153,11 +150,8 @@ 470016062342541100EBF03D /* MWMTag.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = MWMTag.m; sourceTree = ""; }; 4700161223425CFD00EBF03D /* UIKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = UIKit.framework; path = System/Library/Frameworks/UIKit.framework; sourceTree = SDKROOT; }; 470016142342633D00EBF03D /* CoreApi.modulemap */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = "sourcecode.module-map"; path = CoreApi.modulemap; sourceTree = ""; }; - 470B361E244DD9E400C0EA9E /* GuidesGalleryData.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = GuidesGalleryData.h; sourceTree = ""; }; - 470B361F244DD9E400C0EA9E /* GuidesGalleryData.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = GuidesGalleryData.mm; sourceTree = ""; }; 470B3622244DDA0A00C0EA9E /* GuidesGalleryItem.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = GuidesGalleryItem.h; sourceTree = ""; }; 470B3623244DDA0A00C0EA9E /* GuidesGalleryItem.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = GuidesGalleryItem.mm; sourceTree = ""; }; - 470B3626244DDA2600C0EA9E /* GuidesGalleryData+Core.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "GuidesGalleryData+Core.h"; sourceTree = ""; }; 470B362A244DDBF600C0EA9E /* GuidesGalleryItem+Core.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "GuidesGalleryItem+Core.h"; sourceTree = ""; }; 4718C4302355FC3C00640DF1 /* MWMNetworkPolicy.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MWMNetworkPolicy.h; sourceTree = ""; }; 4718C4312355FC3C00640DF1 /* MWMNetworkPolicy.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = MWMNetworkPolicy.mm; sourceTree = ""; }; @@ -370,9 +364,6 @@ 470B361D244DD98B00C0EA9E /* GuidesGallery */ = { isa = PBXGroup; children = ( - 470B361E244DD9E400C0EA9E /* GuidesGalleryData.h */, - 470B3626244DDA2600C0EA9E /* GuidesGalleryData+Core.h */, - 470B361F244DD9E400C0EA9E /* GuidesGalleryData.mm */, 470B3622244DDA0A00C0EA9E /* GuidesGalleryItem.h */, 470B362A244DDBF600C0EA9E /* GuidesGalleryItem+Core.h */, 470B3623244DDA0A00C0EA9E /* GuidesGalleryItem.mm */, @@ -696,7 +687,6 @@ 47942D74237CC41A00DEFAE3 /* HotelBookingData.h in Headers */, 479F705F234FBB8F00011E2E /* MWMCategory.h in Headers */, 47EF73F9246E035C00D32AB8 /* MWMGuidesManager.h in Headers */, - 470B3620244DD9E400C0EA9E /* GuidesGalleryData.h in Headers */, 471AB99123AB931000F56D49 /* MWMMapSearchResult+Core.h in Headers */, 4738A8E0239FACE7007C0F43 /* CoreBanner.h in Headers */, 47942D6D237CC3E300DEFAE3 /* PlacePagePreviewData.h in Headers */, @@ -736,7 +726,6 @@ 47942D6E237CC3E800DEFAE3 /* PlacePagePreviewData+Core.h in Headers */, 4738A8E4239FB46E007C0F43 /* CoreBanner+Core.h in Headers */, 47942D7B237CC41A00DEFAE3 /* HotelRoom+Core.h in Headers */, - 470B3628244DDA2600C0EA9E /* GuidesGalleryData+Core.h in Headers */, 47942D94237D673E00DEFAE3 /* CatalogPromoItem.h in Headers */, 470016102342579200EBF03D /* MWMTagGroup.h in Headers */, 47942D87237CC55800DEFAE3 /* MWMOpeningHoursCommon.h in Headers */, @@ -891,7 +880,6 @@ 47E8163623B1889C008FD836 /* MWMStorage.mm in Sources */, 9957FAE9237AE5B000855F48 /* Logger.mm in Sources */, 999D3A65237B097C00C5F7A8 /* DeepLinkSubscriptionData.mm in Sources */, - 470B3621244DD9E400C0EA9E /* GuidesGalleryData.mm in Sources */, 47942D7C237CC41A00DEFAE3 /* HotelRoom.mm in Sources */, 47942D76237CC41A00DEFAE3 /* HotelBookingData.mm in Sources */, ); diff --git a/iphone/CoreApi/CoreApi/CoreApi-swift.h b/iphone/CoreApi/CoreApi/CoreApi-swift.h index 7f2c9e6dfb..86d7d2436c 100644 --- a/iphone/CoreApi/CoreApi/CoreApi-swift.h +++ b/iphone/CoreApi/CoreApi/CoreApi-swift.h @@ -56,5 +56,4 @@ FOUNDATION_EXPORT const unsigned char CoreApiVersionString[]; #import #import #import -#import #import diff --git a/iphone/CoreApi/CoreApi/GuidesGallery/MWMGuidesManager.h b/iphone/CoreApi/CoreApi/GuidesGallery/MWMGuidesManager.h index 0f61bd5b8d..35c77e79ac 100644 --- a/iphone/CoreApi/CoreApi/GuidesGallery/MWMGuidesManager.h +++ b/iphone/CoreApi/CoreApi/GuidesGallery/MWMGuidesManager.h @@ -1,5 +1,7 @@ #import +@class GuidesGalleryItem; + NS_ASSUME_NONNULL_BEGIN typedef void(^GalleryChangedBlock)(bool reloadGallery); @@ -9,6 +11,7 @@ NS_SWIFT_NAME(GuidesManager) + (instancetype)sharedManager; - (NSString *)activeGuideId; +- (NSArray *)galleryItems; - (void)setActiveGuide:(NSString *)guideId; - (void)setGalleryChangedCallback:(GalleryChangedBlock)callback; - (void)resetGalleryChangedCallback; diff --git a/iphone/CoreApi/CoreApi/GuidesGallery/MWMGuidesManager.mm b/iphone/CoreApi/CoreApi/GuidesGallery/MWMGuidesManager.mm index 46d97b8f4f..fb702bf81c 100644 --- a/iphone/CoreApi/CoreApi/GuidesGallery/MWMGuidesManager.mm +++ b/iphone/CoreApi/CoreApi/GuidesGallery/MWMGuidesManager.mm @@ -1,4 +1,5 @@ #import "MWMGuidesManager.h" +#import "GuidesGalleryItem+Core.h" #include "Framework.h" @@ -19,6 +20,24 @@ static GuidesManager & guidesManager() { return GetFramework().GetGuidesManager( return manager; } +- (NSArray *)galleryItems { + auto const &guidesGallery = guidesManager().GetGallery(); + NSMutableArray *itemsArray = [NSMutableArray arrayWithCapacity:guidesGallery.m_items.size()]; + for (auto const &item : guidesGallery.m_items) { + GuidesGalleryItem *galleryItem; + switch (item.m_type) { + case GuidesManager::GuidesGallery::Item::Type::City: + galleryItem = [[CityGalleryItem alloc] initWithGuidesGalleryItem:item]; + break; + case GuidesManager::GuidesGallery::Item::Type::Outdoor: + galleryItem = [[OutdoorGalleryItem alloc] initWithGuidesGalleryItem:item]; + break; + } + [itemsArray addObject:galleryItem]; + } + return [itemsArray copy]; +} + - (NSString *)activeGuideId { return @(guidesManager().GetActiveGuide().c_str()); } diff --git a/iphone/CoreApi/CoreApi/PlacePageData/GuidesGallery/GuidesGalleryData+Core.h b/iphone/CoreApi/CoreApi/PlacePageData/GuidesGallery/GuidesGalleryData+Core.h deleted file mode 100644 index 7f6b9ee653..0000000000 --- a/iphone/CoreApi/CoreApi/PlacePageData/GuidesGallery/GuidesGalleryData+Core.h +++ /dev/null @@ -1,14 +0,0 @@ -#import "GuidesGalleryData.h" - -#include - -NS_ASSUME_NONNULL_BEGIN - -@interface GuidesGalleryData (Core) - -- (instancetype)initWithGuidesGallery:(GuidesManager::GuidesGallery const &)guidesGallery - activeGuideId:(NSString *)activeGuideId; - -@end - -NS_ASSUME_NONNULL_END diff --git a/iphone/CoreApi/CoreApi/PlacePageData/GuidesGallery/GuidesGalleryData.h b/iphone/CoreApi/CoreApi/PlacePageData/GuidesGallery/GuidesGalleryData.h deleted file mode 100644 index 714f51031d..0000000000 --- a/iphone/CoreApi/CoreApi/PlacePageData/GuidesGallery/GuidesGalleryData.h +++ /dev/null @@ -1,14 +0,0 @@ -#import - -@class GuidesGalleryItem; - -NS_ASSUME_NONNULL_BEGIN - -@interface GuidesGalleryData : NSObject - -@property(nonatomic, readonly) NSArray *galleryItems; -@property(nonatomic, readonly) NSString *activeGuideId; - -@end - -NS_ASSUME_NONNULL_END diff --git a/iphone/CoreApi/CoreApi/PlacePageData/GuidesGallery/GuidesGalleryData.mm b/iphone/CoreApi/CoreApi/PlacePageData/GuidesGallery/GuidesGalleryData.mm deleted file mode 100644 index d205877620..0000000000 --- a/iphone/CoreApi/CoreApi/PlacePageData/GuidesGallery/GuidesGalleryData.mm +++ /dev/null @@ -1,33 +0,0 @@ -#import "GuidesGalleryData+Core.h" -#import "GuidesGalleryItem+Core.h" - -@implementation GuidesGalleryData - -@end - -@implementation GuidesGalleryData (Core) - -- (instancetype)initWithGuidesGallery:(GuidesManager::GuidesGallery const &)guidesGallery - activeGuideId:(NSString *)activeGuideId { - self = [super init]; - if (self) { - NSMutableArray *itemsArray = [NSMutableArray arrayWithCapacity:guidesGallery.m_items.size()]; - for (auto const &item : guidesGallery.m_items) { - GuidesGalleryItem *galleryItem; - switch (item.m_type) { - case GuidesManager::GuidesGallery::Item::Type::City: - galleryItem = [[CityGalleryItem alloc] initWithGuidesGalleryItem:item]; - break; - case GuidesManager::GuidesGallery::Item::Type::Outdoor: - galleryItem = [[OutdoorGalleryItem alloc] initWithGuidesGalleryItem:item]; - break; - } - [itemsArray addObject:galleryItem]; - } - _galleryItems = [itemsArray copy]; - _activeGuideId = [activeGuideId copy]; - } - return self; -} - -@end diff --git a/iphone/CoreApi/CoreApi/PlacePageData/PlacePageData.h b/iphone/CoreApi/CoreApi/PlacePageData/PlacePageData.h index 06635bbc7a..a01d741330 100644 --- a/iphone/CoreApi/CoreApi/PlacePageData/PlacePageData.h +++ b/iphone/CoreApi/CoreApi/PlacePageData/PlacePageData.h @@ -12,7 +12,6 @@ @class HotelRooms; @class UgcData; @class ElevationProfileData; -@class GuidesGalleryData; @class MWMMapNodeAttributes; typedef NS_ENUM(NSInteger, PlacePageSponsoredType) { @@ -64,7 +63,6 @@ NS_ASSUME_NONNULL_BEGIN @property(nonatomic, readonly, nullable) HotelRooms *hotelRooms; @property(nonatomic, readonly, nullable) UgcData *ugcData; @property(nonatomic, readonly, nullable) ElevationProfileData *elevationProfileData; -@property(nonatomic, readonly, nullable) GuidesGalleryData *guidesGalleryData; @property(nonatomic, readonly, nullable) MWMMapNodeAttributes *mapNodeAttributes; @property(nonatomic, readonly, nullable) NSString *bookingSearchUrl; @property(nonatomic, readonly) BOOL isLargeToponim; diff --git a/iphone/CoreApi/CoreApi/PlacePageData/PlacePageData.mm b/iphone/CoreApi/CoreApi/PlacePageData/PlacePageData.mm index 0cd263cc04..d3b2b6a288 100644 --- a/iphone/CoreApi/CoreApi/PlacePageData/PlacePageData.mm +++ b/iphone/CoreApi/CoreApi/PlacePageData/PlacePageData.mm @@ -9,7 +9,6 @@ #import "HotelRooms+Core.h" #import "UgcData+Core.h" #import "ElevationProfileData+Core.h" -#import "GuidesGalleryData+Core.h" #import "MWMMapNodeAttributes.h" #include @@ -151,13 +150,6 @@ static PlacePageRoadType convertRoadType(RoadWarningMarkType roadType) { _previewData = [[PlacePagePreviewData alloc] initWithRawData:rawData()]; } - if (rawData().IsGuide()) { - auto const &gm = GetFramework().GetGuidesManager(); - auto const &galleryData = gm.GetGallery(); - NSString *activeGuideId = @(gm.GetActiveGuide().c_str()); - _guidesGalleryData = [[GuidesGalleryData alloc] initWithGuidesGallery:galleryData activeGuideId:activeGuideId]; - } - auto const &countryId = rawData().GetCountryId(); if (!countryId.empty()) { _mapNodeAttributes = [[MWMStorage sharedStorage] attributesForCountry:@(rawData().GetCountryId().c_str())]; diff --git a/iphone/Maps/UI/PlacePage/Components/GuidesGallery/GuidesGalleryBuilder.swift b/iphone/Maps/UI/PlacePage/Components/GuidesGallery/GuidesGalleryBuilder.swift index 1cdbf7f03d..c83092dc60 100644 --- a/iphone/Maps/UI/PlacePage/Components/GuidesGallery/GuidesGalleryBuilder.swift +++ b/iphone/Maps/UI/PlacePage/Components/GuidesGallery/GuidesGalleryBuilder.swift @@ -1,15 +1,10 @@ @objc(MWMGuidesGalleryBuilder) final class GuidesGalleryBuilder: NSObject { @objc static func build() -> GuidesGalleryViewController { - let placePageData = PlacePageData(localizationProvider: OpeinigHoursLocalization()) - guard let guidesGalleryData = placePageData.guidesGalleryData else { - fatalError() - } - let storyboard = UIStoryboard.instance(.placePage) let viewController = storyboard.instantiateViewController(ofType: GuidesGalleryViewController.self); let router = GuidesGalleryRouter(MapViewController.shared()) - let interactor = GuidesGalleryInteractor(guidesGalleryData) + let interactor = GuidesGalleryInteractor() let presenter = GuidesGalleryPresenter(view: viewController, router: router, interactor: interactor) viewController.presenter = presenter return viewController diff --git a/iphone/Maps/UI/PlacePage/Components/GuidesGallery/GuidesGalleryInteractor.swift b/iphone/Maps/UI/PlacePage/Components/GuidesGallery/GuidesGalleryInteractor.swift index fcfc2409c4..ab968ee2dd 100644 --- a/iphone/Maps/UI/PlacePage/Components/GuidesGallery/GuidesGalleryInteractor.swift +++ b/iphone/Maps/UI/PlacePage/Components/GuidesGallery/GuidesGalleryInteractor.swift @@ -11,15 +11,12 @@ protocol IGuidesGalleryInteractor { } final class GuidesGalleryInteractor { - private var guidesGallery: GuidesGalleryData - init(_ guidesGallery: GuidesGalleryData) { - self.guidesGallery = guidesGallery - } + } extension GuidesGalleryInteractor: IGuidesGalleryInteractor { func galleryItems() -> [GuidesGalleryItem] { - guidesGallery.galleryItems + GuidesManager.shared().galleryItems() } func toggleItemVisibility(_ item: GuidesGalleryItem) { diff --git a/iphone/Maps/UI/PlacePage/Components/GuidesGallery/GuidesGalleryPresenter.swift b/iphone/Maps/UI/PlacePage/Components/GuidesGallery/GuidesGalleryPresenter.swift index 138bb43f77..585e790f8d 100644 --- a/iphone/Maps/UI/PlacePage/Components/GuidesGallery/GuidesGalleryPresenter.swift +++ b/iphone/Maps/UI/PlacePage/Components/GuidesGallery/GuidesGalleryPresenter.swift @@ -50,22 +50,10 @@ final class GuidesGalleryPresenter { } return model } -} -extension GuidesGalleryPresenter: IGuidesGalleryPresenter { - func viewDidLoad() { + private func reloadGallery() { galleryItems = interactor.galleryItems() - interactor.setGalleryChangedCallback { [weak self] (reloadGallery) in - self?.setActiveItem() - } - view.setGalleryItems(galleryItems.map({ makeViewModel($0) })) - setActiveItem() - - Statistics.logEvent(kStatPlacepageSponsoredShow, withParameters: [kStatProvider : kStatMapsmeGuides, - kStatPlacement : kStatMap, - kStatState : kStatOnline, - kStatCount : galleryItems.count]) } private func setActiveItem() { @@ -87,6 +75,26 @@ extension GuidesGalleryPresenter: IGuidesGalleryPresenter { kStatId : item.guideId], with: .realtime) } +} + +extension GuidesGalleryPresenter: IGuidesGalleryPresenter { + func viewDidLoad() { + reloadGallery() + setActiveItem() + + interactor.setGalleryChangedCallback { [weak self] (reloadGallery) in + if reloadGallery { + self?.reloadGallery() + } + self?.setActiveItem() + } + + + Statistics.logEvent(kStatPlacepageSponsoredShow, withParameters: [kStatProvider : kStatMapsmeGuides, + kStatPlacement : kStatMap, + kStatState : kStatOnline, + kStatCount : galleryItems.count]) + } func selectItemAtIndex(_ index: Int) { let galleryItem = galleryItems[index] diff --git a/iphone/Maps/UI/PlacePage/Components/GuidesGallery/GuidesGalleryViewController.swift b/iphone/Maps/UI/PlacePage/Components/GuidesGallery/GuidesGalleryViewController.swift index a367d851b1..57217d40fe 100644 --- a/iphone/Maps/UI/PlacePage/Components/GuidesGallery/GuidesGalleryViewController.swift +++ b/iphone/Maps/UI/PlacePage/Components/GuidesGallery/GuidesGalleryViewController.swift @@ -76,9 +76,6 @@ extension GuidesGalleryViewController: IGuidesGalleryView { func setGalleryItems(_ items: [IGuidesGalleryItemViewModel]) { galleryItems = items collectionView.reloadData() - collectionView.performBatchUpdates(nil) { [weak self] _ in - self?.applyTransform() - } } func setActiveItem(_ index: Int, animated: Bool) {