[MAPSME-6951] [ios] Added storage Applying state handling, clang-format.

This commit is contained in:
Ilya Grechuhin 2018-03-02 18:50:21 +03:00 committed by Aleksandr Zatsepin
parent 7e6962cd14
commit 27ba40b55d
5 changed files with 340 additions and 311 deletions

View file

@ -132,10 +132,10 @@ using namespace storage;
{
[Statistics logEvent:kStatDownloaderMapAction
withParameters:@{
kStatAction : kStatDownload,
kStatIsAuto : kStatYes,
kStatFrom : kStatMap,
kStatScenario : kStatDownload
kStatAction: kStatDownload,
kStatIsAuto: kStatYes,
kStatFrom: kStatMap,
kStatScenario: kStatDownload
}];
m_autoDownloadCountryId = m_countryId;
[MWMStorage downloadNode:m_countryId
@ -149,20 +149,21 @@ using namespace storage;
[self showDownloadRequest];
}
break;
}
case NodeStatus::Downloading:
if (nodeAttrs.m_downloadingProgress.second != 0)
[self showDownloading:static_cast<CGFloat>(nodeAttrs.m_downloadingProgress.first) /
nodeAttrs.m_downloadingProgress.second];
break;
case NodeStatus::InQueue: [self showInQueue]; break;
case NodeStatus::Undefined:
case NodeStatus::Error:
if (p.IsAutoRetryDownloadFailed())
[self showError:nodeAttrs.m_error];
break;
case NodeStatus::OnDisk:
case NodeStatus::OnDiskOutOfDate: [self removeFromSuperview]; break;
}
case NodeStatus::Downloading:
if (nodeAttrs.m_downloadingProgress.second != 0)
[self showDownloading:static_cast<CGFloat>(nodeAttrs.m_downloadingProgress.first) /
nodeAttrs.m_downloadingProgress.second];
break;
case NodeStatus::Applying:
case NodeStatus::InQueue: [self showInQueue]; break;
case NodeStatus::Undefined:
case NodeStatus::Error:
if (p.IsAutoRetryDownloadFailed())
[self showError:nodeAttrs.m_error];
break;
case NodeStatus::OnDisk:
case NodeStatus::OnDiskOutOfDate: [self removeFromSuperview]; break;
}
}
else
@ -208,10 +209,10 @@ using namespace storage;
auto const retryBlock = ^{
[Statistics logEvent:kStatDownloaderMapAction
withParameters:@{
kStatAction : kStatRetry,
kStatIsAuto : kStatNo,
kStatFrom : kStatMap,
kStatScenario : kStatDownload
kStatAction: kStatRetry,
kStatIsAuto: kStatNo,
kStatFrom: kStatMap,
kStatScenario: kStatDownload
}];
[self showInQueue];
[MWMStorage retryDownloadNode:self->m_countryId];
@ -297,10 +298,10 @@ using namespace storage;
{
[Statistics logEvent:kStatDownloaderMapAction
withParameters:@{
kStatAction : kStatRetry,
kStatIsAuto : kStatNo,
kStatFrom : kStatMap,
kStatScenario : kStatDownload
kStatAction: kStatRetry,
kStatIsAuto: kStatNo,
kStatFrom: kStatMap,
kStatScenario: kStatDownload
}];
[self showInQueue];
[MWMStorage retryDownloadNode:m_countryId];
@ -328,10 +329,10 @@ using namespace storage;
{
[Statistics logEvent:kStatDownloaderMapAction
withParameters:@{
kStatAction : kStatDownload,
kStatIsAuto : kStatNo,
kStatFrom : kStatMap,
kStatScenario : kStatDownload
kStatAction: kStatDownload,
kStatIsAuto: kStatNo,
kStatFrom: kStatMap,
kStatScenario: kStatDownload
}];
[MWMStorage downloadNode:m_countryId
onSuccess:^{

View file

@ -77,10 +77,10 @@
size = isModeDownloaded ? nodeAttrs.m_downloadingMwmSize
: nodeAttrs.m_mwmSize - nodeAttrs.m_downloadingMwmSize;
break;
case storage::NodeStatus::Applying:
case storage::NodeStatus::InQueue:
case storage::NodeStatus::Partly:
size = isModeDownloaded ? nodeAttrs.m_localMwmSize
: nodeAttrs.m_mwmSize;
size = isModeDownloaded ? nodeAttrs.m_localMwmSize : nodeAttrs.m_mwmSize;
break;
case storage::NodeStatus::OnDisk: size = isModeDownloaded ? nodeAttrs.m_mwmSize : 0; break;
}
@ -102,7 +102,8 @@
MWMCircularProgressStateVec const affectedStates = {MWMCircularProgressStateNormal,
MWMCircularProgressStateSelected};
NSString * imageName = [self isKindOfClass:[MWMMapDownloaderLargeCountryTableViewCell class]]
? @"ic_folder" : @"ic_download";
? @"ic_folder"
: @"ic_download";
[progress setImageName:imageName forStates:affectedStates];
[progress setColoring:coloring forStates:affectedStates];
progress.state = MWMCircularProgressStateNormal;
@ -114,6 +115,7 @@
progress.progress = kMaxProgress * static_cast<CGFloat>(prg.first) / prg.second;
break;
}
case NodeStatus::Applying:
case NodeStatus::InQueue: progress.state = MWMCircularProgressStateSpinner; break;
case NodeStatus::Undefined:
case NodeStatus::Error: progress.state = MWMCircularProgressStateFailed; break;
@ -169,6 +171,7 @@
case NodeStatus::Error: [delegate retryDownloadNode:m_countryId]; break;
case NodeStatus::OnDiskOutOfDate: [delegate updateNode:m_countryId]; break;
case NodeStatus::Downloading:
case NodeStatus::Applying:
case NodeStatus::InQueue: [delegate cancelNode:m_countryId]; break;
case NodeStatus::OnDisk: break;
}

View file

@ -23,16 +23,14 @@
namespace
{
typedef NS_OPTIONS(NSUInteger, ActionButtons)
{
NoAction = 0,
ShowOnMapAction = 1 << 1,
DownloadAction = 1 << 2,
UpdateAction = 1 << 3,
typedef NS_OPTIONS(NSUInteger, ActionButtons) {
NoAction = 0,
ShowOnMapAction = 1 << 1,
DownloadAction = 1 << 2,
UpdateAction = 1 << 3,
CancelDownloadAction = 1 << 4,
RetryDownloadAction = 1 << 5,
DeleteAction = 1 << 6
RetryDownloadAction = 1 << 5,
DeleteAction = 1 << 6
};
NSString * const kAllMapsLabelFormat = @"%@ (%@)";
@ -326,16 +324,15 @@ using namespace storage;
self.allMapsView.hidden = hide;
[self.view layoutIfNeeded];
self.allMapsViewBottomOffset.constant = hide ? self.allMapsView.height : 0.0;
[UIView animateWithDuration:kDefaultAnimationDuration animations:^
{
self.allMapsView.alpha = hide ? 0.0 : 1.0;
[self.view layoutIfNeeded];
}
completion:^(BOOL finished)
{
if (hide)
self.allMapsView.hidden = hide;
}];
[UIView animateWithDuration:kDefaultAnimationDuration
animations:^{
self.allMapsView.alpha = hide ? 0.0 : 1.0;
[self.view layoutIfNeeded];
}
completion:^(BOOL finished) {
if (hide)
self.allMapsView.hidden = hide;
}];
}
- (IBAction)allMapsAction
@ -346,10 +343,10 @@ using namespace storage;
{
[Statistics logEvent:kStatDownloaderMapAction
withParameters:@{
kStatAction : kStatUpdate,
kStatIsAuto : kStatNo,
kStatFrom : kStatDownloader,
kStatScenario : kStatUpdateAll
kStatAction: kStatUpdate,
kStatIsAuto: kStatNo,
kStatFrom: kStatDownloader,
kStatScenario: kStatUpdateAll
}];
[MWMStorage updateNode:parentCountryId];
}
@ -489,8 +486,7 @@ using namespace storage;
break;
case NodeStatus::Downloading:
case NodeStatus::InQueue:
buttons |= CancelDownloadAction;
break;
case NodeStatus::Applying: buttons |= CancelDownloadAction; break;
case NodeStatus::OnDiskOutOfDate:
buttons |= ShowOnMapAction;
buttons |= UpdateAction;
@ -632,10 +628,10 @@ using namespace storage;
{
[Statistics logEvent:kStatDownloaderMapAction
withParameters:@{
kStatAction : kStatDownload,
kStatIsAuto : kStatNo,
kStatFrom : kStatDownloader,
kStatScenario : kStatDownload
kStatAction: kStatDownload,
kStatIsAuto: kStatNo,
kStatFrom: kStatDownloader,
kStatScenario: kStatDownload
}];
self.skipCountryEventProcessing = YES;
[MWMStorage downloadNode:countryId onSuccess:nil];
@ -647,10 +643,10 @@ using namespace storage;
{
[Statistics logEvent:kStatDownloaderMapAction
withParameters:@{
kStatAction : kStatRetry,
kStatIsAuto : kStatNo,
kStatFrom : kStatDownloader,
kStatScenario : kStatDownload
kStatAction: kStatRetry,
kStatIsAuto: kStatNo,
kStatFrom: kStatDownloader,
kStatScenario: kStatDownload
}];
self.skipCountryEventProcessing = YES;
[MWMStorage retryDownloadNode:countryId];
@ -662,10 +658,10 @@ using namespace storage;
{
[Statistics logEvent:kStatDownloaderMapAction
withParameters:@{
kStatAction : kStatUpdate,
kStatIsAuto : kStatNo,
kStatFrom : kStatDownloader,
kStatScenario : kStatUpdate
kStatAction: kStatUpdate,
kStatIsAuto: kStatNo,
kStatFrom: kStatDownloader,
kStatScenario: kStatUpdate
}];
self.skipCountryEventProcessing = YES;
[MWMStorage updateNode:countryId];
@ -677,10 +673,10 @@ using namespace storage;
{
[Statistics logEvent:kStatDownloaderMapAction
withParameters:@{
kStatAction : kStatDelete,
kStatIsAuto : kStatNo,
kStatFrom : kStatDownloader,
kStatScenario : kStatDelete
kStatAction: kStatDelete,
kStatIsAuto: kStatNo,
kStatFrom: kStatDownloader,
kStatScenario: kStatDelete
}];
self.skipCountryEventProcessing = YES;
[MWMStorage deleteNode:countryId];
@ -701,8 +697,8 @@ using namespace storage;
{
[Statistics logEvent:kStatDownloaderMapAction
withParameters:@{
kStatAction : kStatExplore,
kStatFrom : kStatDownloader,
kStatAction: kStatExplore,
kStatFrom: kStatDownloader,
}];
[self.navigationController popToRootViewControllerAnimated:YES];
[MWMStorage showNode:countryId];

View file

@ -57,7 +57,7 @@ void logSponsoredEvent(MWMPlacePageData * data, NSString * eventName)
}
[Statistics logEvent:eventName withParameters:stat atLocation:[MWMLocationManager lastLocation]];
}
}
} // namespace
@interface MWMPlacePageManager ()<MWMFrameworkStorageObserver, MWMPlacePageLayoutDelegate,
@ -151,6 +151,7 @@ void logSponsoredEvent(MWMPlacePageData * data, NSString * eventName)
case NodeStatus::Error: [MWMStorage retryDownloadNode:countryId]; break;
case NodeStatus::OnDiskOutOfDate: [MWMStorage updateNode:countryId]; break;
case NodeStatus::Downloading:
case NodeStatus::Applying:
case NodeStatus::InQueue: [MWMStorage cancelDownloadNode:countryId]; break;
case NodeStatus::OnDisk: break;
}
@ -529,8 +530,9 @@ void logSponsoredEvent(MWMPlacePageData * data, NSString * eventName)
}
- (void)showPhotoAtIndex:(NSInteger)index
referenceView:(UIView *)referenceView
referenceViewWhenDismissingHandler:(MWMPlacePageButtonsDismissBlock)referenceViewWhenDismissingHandler
referenceView:(UIView *)referenceView
referenceViewWhenDismissingHandler:
(MWMPlacePageButtonsDismissBlock)referenceViewWhenDismissingHandler
{
auto data = self.data;
if (!data)

View file

@ -33,8 +33,8 @@ map<MetainfoRows, Class> const kMetaInfoCells = {
{MetainfoRows::Internet, [MWMPlacePageInfoCell class]}};
} // namespace
@interface MWMPlacePageLayout () <UITableViewDataSource,
MWMPlacePageCellUpdateProtocol, MWMPlacePageViewUpdateProtocol>
@interface MWMPlacePageLayout ()<UITableViewDataSource, MWMPlacePageCellUpdateProtocol,
MWMPlacePageViewUpdateProtocol>
@property(weak, nonatomic) MWMPlacePageData * data;
@ -231,6 +231,7 @@ map<MetainfoRows, Class> const kMetaInfoCells = {
break;
}
case NodeStatus::InQueue:
case NodeStatus::Applying:
{
self.actionBar.isAreaNotDownloaded = YES;
self.actionBar.downloadingState = MWMCircularProgressStateSpinner;
@ -312,253 +313,279 @@ map<MetainfoRows, Class> const kMetaInfoCells = {
case Sections::Preview:
{
return [self.previewLayoutHelper cellForRowAtIndexPath:indexPath withData:data];
}
case Sections::Bookmark:
{
Class cls = [MWMBookmarkCell class];
auto c = static_cast<MWMBookmarkCell *>(
[tableView dequeueReusableCellWithCellClass:cls indexPath:indexPath]);
[c configureWithText:data.bookmarkDescription
updateCellDelegate:self
editBookmarkDelegate:delegate
isHTML:data.isHTMLDescription];
return c;
}
case Sections::Metainfo:
{
auto const row = data.metainfoRows[indexPath.row];
switch (row)
{
case MetainfoRows::OpeningHours:
case MetainfoRows::ExtendedOpeningHours:
{
auto const & metaInfo = data.metainfoRows;
NSAssert(std::find(metaInfo.cbegin(), metaInfo.cend(), MetainfoRows::OpeningHours) !=
metaInfo.cend(),
@"OpeningHours is not available");
return [self.openingHoursLayoutHelper cellForRowAtIndexPath:indexPath];
}
case MetainfoRows::Phone:
case MetainfoRows::Address:
case MetainfoRows::Website:
case MetainfoRows::Email:
case MetainfoRows::Cuisine:
case MetainfoRows::Operator:
case MetainfoRows::Internet:
case MetainfoRows::Coordinate:
case Sections::Bookmark:
{
Class cls = kMetaInfoCells.at(row);
auto c = static_cast<MWMPlacePageRegularCell *>(
Class cls = [MWMBookmarkCell class];
auto c = static_cast<MWMBookmarkCell *>(
[tableView dequeueReusableCellWithCellClass:cls indexPath:indexPath]);
[c configWithRow:row data:data];
[c configureWithText:data.bookmarkDescription
updateCellDelegate:self
editBookmarkDelegate:delegate
isHTML:data.isHTMLDescription];
return c;
}
case MetainfoRows::LocalAdsCustomer:
case MetainfoRows::LocalAdsCandidate:
case Sections::Metainfo:
{
Class cls = [MWMPlacePageButtonCell class];
auto c = static_cast<MWMPlacePageButtonCell *>([tableView dequeueReusableCellWithCellClass:cls
indexPath:indexPath]);
[c configWithTitle:[data stringForRow:row] action:^{ [delegate openLocalAdsURL]; } isInsetButton:NO];
return c;
}
}
}
case Sections::Ad:
{
Class cls = [MWMPlacePageTaxiCell class];
auto c = static_cast<MWMPlacePageTaxiCell *>([tableView dequeueReusableCellWithCellClass:cls indexPath:indexPath]);
auto const & taxiProviders = [data taxiProviders];
NSAssert(!taxiProviders.empty(), @"TaxiProviders can not be empty");
auto const & provider = taxiProviders.front();
auto type = MWMPlacePageTaxiProviderTaxi;
switch (provider)
{
case taxi::Provider::Uber: type = MWMPlacePageTaxiProviderUber; break;
case taxi::Provider::Yandex: type = MWMPlacePageTaxiProviderYandex; break;
case taxi::Provider::Maxim: type = MWMPlacePageTaxiProviderMaxim; break;
}
[c configWithType:type delegate:delegate];
self.taxiCell = c;
return c;
}
case Sections::Buttons:
{
Class cls = [MWMPlacePageButtonCell class];
auto c = static_cast<MWMPlacePageButtonCell *>(
[tableView dequeueReusableCellWithCellClass:cls indexPath:indexPath]);
auto const row = data.buttonsRows[indexPath.row];
[c configForRow:row withAction:^{
auto const row = data.metainfoRows[indexPath.row];
switch (row)
{
case ButtonsRows::AddPlace: [delegate addPlace]; break;
case ButtonsRows::EditPlace: [delegate editPlace]; break;
case ButtonsRows::AddBusiness: [delegate addBusiness]; break;
case ButtonsRows::HotelDescription: [delegate book:YES]; break;
case ButtonsRows::Other: NSAssert(false, @"Incorrect row");
case MetainfoRows::OpeningHours:
case MetainfoRows::ExtendedOpeningHours:
{
auto const & metaInfo = data.metainfoRows;
NSAssert(std::find(metaInfo.cbegin(), metaInfo.cend(), MetainfoRows::OpeningHours) !=
metaInfo.cend(),
@"OpeningHours is not available");
return [self.openingHoursLayoutHelper cellForRowAtIndexPath:indexPath];
}
}];
// Hotel description button is always enabled.
c.enabled = self.buttonsSectionEnabled || (row == ButtonsRows::HotelDescription);
return c;
}
case Sections::SpecialProjects:
{
switch (data.specialProjectRows[indexPath.row])
case MetainfoRows::Phone:
case MetainfoRows::Address:
case MetainfoRows::Website:
case MetainfoRows::Email:
case MetainfoRows::Cuisine:
case MetainfoRows::Operator:
case MetainfoRows::Internet:
case MetainfoRows::Coordinate:
{
Class cls = kMetaInfoCells.at(row);
auto c = static_cast<MWMPlacePageRegularCell *>(
[tableView dequeueReusableCellWithCellClass:cls indexPath:indexPath]);
[c configWithRow:row data:data];
return c;
}
case MetainfoRows::LocalAdsCustomer:
case MetainfoRows::LocalAdsCandidate:
{
Class cls = [MWMPlacePageButtonCell class];
auto c = static_cast<MWMPlacePageButtonCell *>(
[tableView dequeueReusableCellWithCellClass:cls indexPath:indexPath]);
[c configWithTitle:[data stringForRow:row]
action:^{
[delegate openLocalAdsURL];
}
isInsetButton:NO];
return c;
}
}
}
case Sections::Ad:
{
case SpecialProject::Viator:
{
Class cls = [MWMPPViatorCarouselCell class];
auto c = static_cast<MWMPPViatorCarouselCell *>(
Class cls = [MWMPlacePageTaxiCell class];
auto c = static_cast<MWMPlacePageTaxiCell *>(
[tableView dequeueReusableCellWithCellClass:cls indexPath:indexPath]);
[c configWith:data.viatorItems delegate:delegate];
self.viatorCell = c;
auto const & taxiProviders = [data taxiProviders];
NSAssert(!taxiProviders.empty(), @"TaxiProviders can not be empty");
auto const & provider = taxiProviders.front();
auto type = MWMPlacePageTaxiProviderTaxi;
switch (provider)
{
case taxi::Provider::Uber: type = MWMPlacePageTaxiProviderUber; break;
case taxi::Provider::Yandex: type = MWMPlacePageTaxiProviderYandex; break;
case taxi::Provider::Maxim: type = MWMPlacePageTaxiProviderMaxim; break;
}
[c configWithType:type delegate:delegate];
self.taxiCell = c;
return c;
}
}
}
case Sections::HotelPhotos:
{
Class cls = [MWMPPHotelCarouselCell class];
auto c = static_cast<MWMPPHotelCarouselCell *>([tableView dequeueReusableCellWithCellClass:cls indexPath:indexPath]);
[c configWith:data.photos delegate:delegate];
return c;
}
case Sections::HotelFacilities:
{
auto const row = data.hotelFacilitiesRows[indexPath.row];
switch (row)
{
case HotelFacilitiesRow::Regular:
{
Class cls = [MWMPPFacilityCell class];
auto c = static_cast<MWMPPFacilityCell *>([tableView dequeueReusableCellWithCellClass:cls indexPath:indexPath]);
[c configWith:@(data.facilities[indexPath.row].m_name.c_str())];
return c;
}
case HotelFacilitiesRow::ShowMore:
Class cls = [MWMPlacePageButtonCell class];
auto c = static_cast<MWMPlacePageButtonCell *>([tableView dequeueReusableCellWithCellClass:cls indexPath:indexPath]);
[c configWithTitle:L(@"booking_show_more") action:^{ [delegate showAllFacilities]; } isInsetButton:NO];
return c;
}
}
case Sections::HotelReviews:
{
auto const row = data.hotelReviewsRows[indexPath.row];
switch (row)
{
case HotelReviewsRow::Header:
{
Class cls = [MWMPPReviewHeaderCell class];
auto c = static_cast<MWMPPReviewHeaderCell *>([tableView dequeueReusableCellWithCellClass:cls indexPath:indexPath]);
[c configWithRating:data.bookingRating numberOfReviews:data.numberOfHotelReviews];
return c;
}
case HotelReviewsRow::Regular:
{
Class cls = [MWMPPReviewCell class];
auto c = static_cast<MWMPPReviewCell *>([tableView dequeueReusableCellWithCellClass:cls indexPath:indexPath]);
[c configWithReview:data.hotelReviews[indexPath.row - 1]];
return c;
}
case HotelReviewsRow::ShowMore:
{
Class cls = [MWMPlacePageButtonCell class];
auto c = static_cast<MWMPlacePageButtonCell *>([tableView dequeueReusableCellWithCellClass:cls indexPath:indexPath]);
[c configWithTitle:L(@"reviews_on_bookingcom") action:^{ [delegate showAllReviews]; } isInsetButton:NO];
return c;
}
}
}
case Sections::HotelDescription:
{
auto const row = data.descriptionRows[indexPath.row];
switch (row)
{
case HotelDescriptionRow::Regular:
{
Class cls = [MWMPPHotelDescriptionCell class];
auto c = static_cast<MWMPPHotelDescriptionCell *>(
[tableView dequeueReusableCellWithCellClass:cls indexPath:indexPath]);
[c configWith:data.hotelDescription delegate:self];
return c;
}
case HotelDescriptionRow::ShowMore:
{
Class cls = [MWMPlacePageButtonCell class];
auto c = static_cast<MWMPlacePageButtonCell *>([tableView dequeueReusableCellWithCellClass:cls indexPath:indexPath]);
[c configWithTitle:L(@"more_on_bookingcom") action:^{ [delegate book:YES];; } isInsetButton:NO];
return c;
}
}
}
case Sections::UGCRating:
{
Class cls = [MWMUGCSummaryRatingCell class];
auto c = static_cast<MWMUGCSummaryRatingCell *>(
[tableView dequeueReusableCellWithCellClass:cls indexPath:indexPath]);
auto ugc = data.ugc;
[c configWithReviewsCount:[ugc totalReviewsCount]
summaryRating:[ugc summaryRating]
ratings:[ugc ratings]];
return c;
}
case Sections::UGCAddReview:
{
Class cls = [MWMUGCAddReviewCell class];
auto c = static_cast<MWMUGCAddReviewCell *>(
[tableView dequeueReusableCellWithCellClass:cls indexPath:indexPath]);
c.onRateTap = ^(MWMRatingSummaryViewValueType value) {
[delegate showUGCAddReview:value fromPreview:NO];
};
return c;
}
case Sections::UGCReviews:
{
auto ugc = data.ugc;
auto const & reviewRows = ugc.reviewRows;
using namespace ugc::view_model;
auto onUpdate = ^{
[tableView refresh];
};
switch (reviewRows[indexPath.row])
{
case ReviewRow::YourReview:
{
Class cls = [MWMUGCYourReviewCell class];
auto c = static_cast<MWMUGCYourReviewCell *>(
[tableView dequeueReusableCellWithCellClass:cls indexPath:indexPath]);
[c configWithYourReview:static_cast<MWMUGCYourReview *>([ugc reviewWithIndex:indexPath.row])
onUpdate:onUpdate];
return c;
}
case ReviewRow::Review:
{
Class cls = [MWMUGCReviewCell class];
auto c = static_cast<MWMUGCReviewCell *>(
[tableView dequeueReusableCellWithCellClass:cls indexPath:indexPath]);
[c configWithReview:static_cast<MWMUGCReview *>([ugc reviewWithIndex:indexPath.row])
onUpdate:onUpdate];
return c;
}
case ReviewRow::MoreReviews:
case Sections::Buttons:
{
Class cls = [MWMPlacePageButtonCell class];
auto c = static_cast<MWMPlacePageButtonCell *>(
[tableView dequeueReusableCellWithCellClass:cls indexPath:indexPath]);
[c configWithTitle:L(@"placepage_more_reviews_button")
action:^{
[delegate openReviews:ugc];
}
isInsetButton:NO];
auto const row = data.buttonsRows[indexPath.row];
[c configForRow:row
withAction:^{
switch (row)
{
case ButtonsRows::AddPlace: [delegate addPlace]; break;
case ButtonsRows::EditPlace: [delegate editPlace]; break;
case ButtonsRows::AddBusiness: [delegate addBusiness]; break;
case ButtonsRows::HotelDescription: [delegate book:YES]; break;
case ButtonsRows::Other: NSAssert(false, @"Incorrect row");
}
}];
// Hotel description button is always enabled.
c.enabled = self.buttonsSectionEnabled || (row == ButtonsRows::HotelDescription);
return c;
}
case Sections::SpecialProjects:
{
switch (data.specialProjectRows[indexPath.row])
{
case SpecialProject::Viator:
{
Class cls = [MWMPPViatorCarouselCell class];
auto c = static_cast<MWMPPViatorCarouselCell *>(
[tableView dequeueReusableCellWithCellClass:cls indexPath:indexPath]);
[c configWith:data.viatorItems delegate:delegate];
self.viatorCell = c;
return c;
}
}
}
case Sections::HotelPhotos:
{
Class cls = [MWMPPHotelCarouselCell class];
auto c = static_cast<MWMPPHotelCarouselCell *>(
[tableView dequeueReusableCellWithCellClass:cls indexPath:indexPath]);
[c configWith:data.photos delegate:delegate];
return c;
}
case Sections::HotelFacilities:
{
auto const row = data.hotelFacilitiesRows[indexPath.row];
switch (row)
{
case HotelFacilitiesRow::Regular:
{
Class cls = [MWMPPFacilityCell class];
auto c = static_cast<MWMPPFacilityCell *>(
[tableView dequeueReusableCellWithCellClass:cls indexPath:indexPath]);
[c configWith:@(data.facilities[indexPath.row].m_name.c_str())];
return c;
}
case HotelFacilitiesRow::ShowMore:
Class cls = [MWMPlacePageButtonCell class];
auto c = static_cast<MWMPlacePageButtonCell *>(
[tableView dequeueReusableCellWithCellClass:cls indexPath:indexPath]);
[c configWithTitle:L(@"booking_show_more")
action:^{
[delegate showAllFacilities];
}
isInsetButton:NO];
return c;
}
}
case Sections::HotelReviews:
{
auto const row = data.hotelReviewsRows[indexPath.row];
switch (row)
{
case HotelReviewsRow::Header:
{
Class cls = [MWMPPReviewHeaderCell class];
auto c = static_cast<MWMPPReviewHeaderCell *>(
[tableView dequeueReusableCellWithCellClass:cls indexPath:indexPath]);
[c configWithRating:data.bookingRating numberOfReviews:data.numberOfHotelReviews];
return c;
}
case HotelReviewsRow::Regular:
{
Class cls = [MWMPPReviewCell class];
auto c = static_cast<MWMPPReviewCell *>(
[tableView dequeueReusableCellWithCellClass:cls indexPath:indexPath]);
[c configWithReview:data.hotelReviews[indexPath.row - 1]];
return c;
}
case HotelReviewsRow::ShowMore:
{
Class cls = [MWMPlacePageButtonCell class];
auto c = static_cast<MWMPlacePageButtonCell *>(
[tableView dequeueReusableCellWithCellClass:cls indexPath:indexPath]);
[c configWithTitle:L(@"reviews_on_bookingcom")
action:^{
[delegate showAllReviews];
}
isInsetButton:NO];
return c;
}
}
}
case Sections::HotelDescription:
{
auto const row = data.descriptionRows[indexPath.row];
switch (row)
{
case HotelDescriptionRow::Regular:
{
Class cls = [MWMPPHotelDescriptionCell class];
auto c = static_cast<MWMPPHotelDescriptionCell *>(
[tableView dequeueReusableCellWithCellClass:cls indexPath:indexPath]);
[c configWith:data.hotelDescription delegate:self];
return c;
}
case HotelDescriptionRow::ShowMore:
{
Class cls = [MWMPlacePageButtonCell class];
auto c = static_cast<MWMPlacePageButtonCell *>(
[tableView dequeueReusableCellWithCellClass:cls indexPath:indexPath]);
[c configWithTitle:L(@"more_on_bookingcom")
action:^{
[delegate book:YES];
;
}
isInsetButton:NO];
return c;
}
}
}
case Sections::UGCRating:
{
Class cls = [MWMUGCSummaryRatingCell class];
auto c = static_cast<MWMUGCSummaryRatingCell *>(
[tableView dequeueReusableCellWithCellClass:cls indexPath:indexPath]);
auto ugc = data.ugc;
[c configWithReviewsCount:[ugc totalReviewsCount]
summaryRating:[ugc summaryRating]
ratings:[ugc ratings]];
return c;
}
case Sections::UGCAddReview:
{
Class cls = [MWMUGCAddReviewCell class];
auto c = static_cast<MWMUGCAddReviewCell *>(
[tableView dequeueReusableCellWithCellClass:cls indexPath:indexPath]);
c.onRateTap = ^(MWMRatingSummaryViewValueType value) {
[delegate showUGCAddReview:value fromPreview:NO];
};
return c;
}
case Sections::UGCReviews:
{
auto ugc = data.ugc;
auto const & reviewRows = ugc.reviewRows;
using namespace ugc::view_model;
auto onUpdate = ^{
[tableView refresh];
};
switch (reviewRows[indexPath.row])
{
case ReviewRow::YourReview:
{
Class cls = [MWMUGCYourReviewCell class];
auto c = static_cast<MWMUGCYourReviewCell *>(
[tableView dequeueReusableCellWithCellClass:cls indexPath:indexPath]);
[c configWithYourReview:static_cast<MWMUGCYourReview *>([ugc reviewWithIndex:indexPath.row])
onUpdate:onUpdate];
return c;
}
case ReviewRow::Review:
{
Class cls = [MWMUGCReviewCell class];
auto c = static_cast<MWMUGCReviewCell *>(
[tableView dequeueReusableCellWithCellClass:cls indexPath:indexPath]);
[c configWithReview:static_cast<MWMUGCReview *>([ugc reviewWithIndex:indexPath.row])
onUpdate:onUpdate];
return c;
}
case ReviewRow::MoreReviews:
{
Class cls = [MWMPlacePageButtonCell class];
auto c = static_cast<MWMPlacePageButtonCell *>(
[tableView dequeueReusableCellWithCellClass:cls indexPath:indexPath]);
[c configWithTitle:L(@"placepage_more_reviews_button")
action:^{
[delegate openReviews:ugc];
}
isInsetButton:NO];
return c;
}
}
}
}
}
}
@ -604,7 +631,7 @@ map<MetainfoRows, Class> const kMetaInfoCells = {
checkCell(self.viatorCell, ^{
self.viatorCell = nil;
auto viatorItems = data.viatorItems;
if (viatorItems.count == 0)
{
@ -693,7 +720,7 @@ map<MetainfoRows, Class> const kMetaInfoCells = {
data.sectionsAreReadyCallback = ^(NSRange const & range, MWMPlacePageData * d, BOOL isSection) {
if (![self.data isEqual:d])
return;
auto tv = self.placePageView.tableView;
if (isSection) {
[tv insertSections:[NSIndexSet indexSetWithIndexesInRange:range]
@ -704,7 +731,7 @@ map<MetainfoRows, Class> const kMetaInfoCells = {
NSMutableArray<NSIndexPath *> * indexPaths = [@[] mutableCopy];
for (auto i = 1; i < range.length + 1; i++)
[indexPaths addObject:[NSIndexPath indexPathForRow:i inSection:range.location]];
[tv insertRowsAtIndexPaths:indexPaths withRowAnimation:UITableViewRowAnimationAutomatic];
}
};