forked from organicmaps/organicmaps
[ios] Changed pp buttons position.
This commit is contained in:
parent
302e13a43f
commit
4374ad7826
6 changed files with 96 additions and 76 deletions
|
@ -1,13 +1,11 @@
|
|||
#import "SwiftBridge.h"
|
||||
|
||||
#include "local_ads/event.hpp"
|
||||
|
||||
#include "partners_api/booking_api.hpp"
|
||||
|
||||
#include "map/place_page_info.hpp"
|
||||
|
||||
#include "std/vector.hpp"
|
||||
|
||||
#include "partners_api/booking_api.hpp"
|
||||
|
||||
@class MWMPlacePageData;
|
||||
|
||||
namespace place_page
|
||||
|
@ -16,12 +14,13 @@ enum class Sections
|
|||
{
|
||||
Preview,
|
||||
Bookmark,
|
||||
Metainfo,
|
||||
Buttons,
|
||||
HotelPhotos,
|
||||
HotelDescription,
|
||||
HotelFacilities,
|
||||
HotelReviews
|
||||
HotelReviews,
|
||||
Metainfo,
|
||||
Ad,
|
||||
Buttons
|
||||
};
|
||||
|
||||
enum class PreviewRows
|
||||
|
@ -72,6 +71,12 @@ enum class MetainfoRows
|
|||
Operator,
|
||||
Internet,
|
||||
Coordinate,
|
||||
LocalAdsCandidate,
|
||||
LocalAdsCustomer
|
||||
};
|
||||
|
||||
enum class AdRows
|
||||
{
|
||||
Taxi
|
||||
};
|
||||
|
||||
|
@ -81,11 +86,7 @@ enum class ButtonsRows
|
|||
EditPlace,
|
||||
AddPlace,
|
||||
HotelDescription,
|
||||
BookingShowMoreFacilities,
|
||||
BookingShowMoreOnSite,
|
||||
BookingShowMoreReviews,
|
||||
LocalAdsCandidate,
|
||||
LocalAdsCustomer
|
||||
Other
|
||||
};
|
||||
|
||||
enum class OpeningHours
|
||||
|
@ -103,6 +104,7 @@ using BannerIsReady = void (^)();
|
|||
|
||||
|
||||
@class MWMGalleryItemModel;
|
||||
@protocol MWMBanner;
|
||||
|
||||
/// ViewModel for place page.
|
||||
@interface MWMPlacePageData : NSObject
|
||||
|
@ -168,6 +170,7 @@ using BannerIsReady = void (^)();
|
|||
- (vector<place_page::HotelFacilitiesRow> const &)hotelFacilitiesRows;
|
||||
- (vector<place_page::HotelReviewsRow> const &)hotelReviewsRows;
|
||||
- (vector<place_page::MetainfoRows> const &)metainfoRows;
|
||||
- (vector<place_page::AdRows> const &)adRows;
|
||||
- (vector<place_page::ButtonsRows> const &)buttonsRows;
|
||||
|
||||
// Table view metainfo rows
|
||||
|
|
|
@ -40,6 +40,7 @@ using namespace place_page;
|
|||
vector<Sections> m_sections;
|
||||
vector<PreviewRows> m_previewRows;
|
||||
vector<MetainfoRows> m_metainfoRows;
|
||||
vector<AdRows> m_adRows;
|
||||
vector<ButtonsRows> m_buttonsRows;
|
||||
vector<HotelPhotosRow> m_hotelPhotosRows;
|
||||
vector<HotelDescriptionRow> m_hotelDescriptionRows;
|
||||
|
@ -63,6 +64,7 @@ using namespace place_page;
|
|||
m_sections.clear();
|
||||
m_previewRows.clear();
|
||||
m_metainfoRows.clear();
|
||||
m_adRows.clear();
|
||||
m_buttonsRows.clear();
|
||||
m_hotelPhotosRows.clear();
|
||||
m_hotelDescriptionRows.clear();
|
||||
|
@ -80,6 +82,12 @@ using namespace place_page;
|
|||
m_sections.push_back(Sections::Metainfo);
|
||||
[self fillMetaInfoSection];
|
||||
|
||||
if (m_info.IsReachableByTaxi())
|
||||
{
|
||||
m_sections.push_back(Sections::Ad);
|
||||
m_adRows.push_back(AdRows::Taxi);
|
||||
}
|
||||
|
||||
// There is at least one of these buttons.
|
||||
if (m_info.ShouldShowAddPlace() || m_info.ShouldShowEditPlace() ||
|
||||
m_info.ShouldShowAddBusiness() || m_info.IsSponsored())
|
||||
|
@ -155,8 +163,18 @@ using namespace place_page;
|
|||
m_metainfoRows.push_back(MetainfoRows::Address);
|
||||
|
||||
m_metainfoRows.push_back(MetainfoRows::Coordinate);
|
||||
if (m_info.IsReachableByTaxi())
|
||||
m_metainfoRows.push_back(MetainfoRows::Taxi);
|
||||
|
||||
switch (m_info.GetLocalAdsStatus())
|
||||
{
|
||||
case place_page::LocalAdsStatus::NotAvailable: break;
|
||||
case place_page::LocalAdsStatus::Candidate:
|
||||
m_metainfoRows.push_back(MetainfoRows::LocalAdsCandidate);
|
||||
break;
|
||||
case place_page::LocalAdsStatus::Customer:
|
||||
m_metainfoRows.push_back(MetainfoRows::LocalAdsCustomer);
|
||||
[self logLocalAdsEvent:local_ads::EventType::OpenInfo];
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
- (void)fillButtonsSection
|
||||
|
@ -176,18 +194,6 @@ using namespace place_page;
|
|||
|
||||
if (m_info.ShouldShowAddBusiness())
|
||||
m_buttonsRows.push_back(ButtonsRows::AddBusiness);
|
||||
|
||||
switch (m_info.GetLocalAdsStatus())
|
||||
{
|
||||
case place_page::LocalAdsStatus::NotAvailable: break;
|
||||
case place_page::LocalAdsStatus::Candidate:
|
||||
m_buttonsRows.push_back(ButtonsRows::LocalAdsCandidate);
|
||||
break;
|
||||
case place_page::LocalAdsStatus::Customer:
|
||||
m_buttonsRows.push_back(ButtonsRows::LocalAdsCustomer);
|
||||
[self logLocalAdsEvent:local_ads::EventType::OpenInfo];
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
- (void)fillOnlineBookingSections
|
||||
|
@ -521,6 +527,7 @@ using namespace place_page;
|
|||
- (vector<PreviewRows> const &)previewRows { return m_previewRows; }
|
||||
- (vector<MetainfoRows> const &)metainfoRows { return m_metainfoRows; }
|
||||
- (vector<MetainfoRows> &)mutableMetainfoRows { return m_metainfoRows; }
|
||||
- (vector<AdRows> const &)adRows { return m_adRows; }
|
||||
- (vector<ButtonsRows> const &)buttonsRows { return m_buttonsRows; }
|
||||
- (vector<HotelPhotosRow> const &)photosRows { return m_hotelPhotosRows; }
|
||||
- (vector<HotelDescriptionRow> const &)descriptionRows { return m_hotelDescriptionRows; }
|
||||
|
@ -530,7 +537,7 @@ using namespace place_page;
|
|||
{
|
||||
switch (row)
|
||||
{
|
||||
case MetainfoRows::Taxi:
|
||||
|
||||
case MetainfoRows::ExtendedOpeningHours: return nil;
|
||||
case MetainfoRows::OpeningHours: return @(m_info.GetOpeningHours().c_str());
|
||||
case MetainfoRows::Phone: return @(m_info.GetPhone().c_str());
|
||||
|
@ -541,6 +548,8 @@ using namespace place_page;
|
|||
return @(strings::JoinStrings(m_info.GetLocalizedCuisines(), Info::kSubtitleSeparator).c_str());
|
||||
case MetainfoRows::Operator: return @(m_info.GetOperator().c_str());
|
||||
case MetainfoRows::Internet: return L(@"WiFi_available");
|
||||
case MetainfoRows::LocalAdsCandidate: return L(@"create_campaign_button");
|
||||
case MetainfoRows::LocalAdsCustomer: return L(@"view_campaign_button");
|
||||
case MetainfoRows::Coordinate:
|
||||
return @(m_info
|
||||
.GetFormattedCoordinate(
|
||||
|
|
|
@ -1,12 +1,17 @@
|
|||
#import "MWMPlacePageData.h"
|
||||
#import "MWMTableViewCell.h"
|
||||
#import "MWMTypes.h"
|
||||
|
||||
@protocol MWMPlacePageButtonsProtocol;
|
||||
|
||||
@interface MWMPlacePageButtonCell : MWMTableViewCell
|
||||
|
||||
- (void)configWithTitle:(NSString *)title
|
||||
action:(MWMVoidBlock)action
|
||||
isInsetButton:(BOOL)isInsetButton;
|
||||
|
||||
- (void)configForRow:(place_page::ButtonsRows)row
|
||||
withDelegate:(id<MWMPlacePageButtonsProtocol>)delegate;
|
||||
withAction:(MWMVoidBlock)action;
|
||||
|
||||
- (void)setEnabled:(BOOL)enabled;
|
||||
- (BOOL)isEnabled;
|
||||
|
|
|
@ -7,8 +7,8 @@
|
|||
|
||||
@property(weak, nonatomic) IBOutlet MWMBorderedButton * titleButton;
|
||||
|
||||
@property(weak, nonatomic) id<MWMPlacePageButtonsProtocol> delegate;
|
||||
@property(nonatomic) place_page::ButtonsRows rowType;
|
||||
@property(copy, nonatomic) MWMVoidBlock action;
|
||||
|
||||
@property(weak, nonatomic) IBOutlet NSLayoutConstraint * buttonTop;
|
||||
@property(weak, nonatomic) IBOutlet NSLayoutConstraint * buttonTrailing;
|
||||
|
@ -31,13 +31,24 @@
|
|||
|
||||
- (void)setEnabled:(BOOL)enabled { self.titleButton.enabled = enabled; }
|
||||
- (BOOL)isEnabled { return self.titleButton.isEnabled; }
|
||||
|
||||
- (void)configWithTitle:(NSString *)title
|
||||
action:(MWMVoidBlock)action
|
||||
isInsetButton:(BOOL)isInsetButton
|
||||
{
|
||||
self.rowType = place_page::ButtonsRows::Other;
|
||||
self.action = action;
|
||||
self.isInsetButton = isInsetButton;
|
||||
[self.titleButton setTitle:title forState:UIControlStateNormal];
|
||||
}
|
||||
|
||||
- (void)configForRow:(place_page::ButtonsRows)row
|
||||
withDelegate:(id<MWMPlacePageButtonsProtocol>)delegate
|
||||
withAction:(MWMVoidBlock)action
|
||||
{
|
||||
using place_page::ButtonsRows;
|
||||
|
||||
self.delegate = delegate;
|
||||
self.rowType = row;
|
||||
self.action = action;
|
||||
NSString * title = nil;
|
||||
BOOL isInsetButton = NO;
|
||||
switch (row)
|
||||
|
@ -56,23 +67,9 @@
|
|||
break;
|
||||
case ButtonsRows::HotelDescription:
|
||||
title = L(@"details_on_bookingcom");
|
||||
break;
|
||||
case ButtonsRows::BookingShowMoreFacilities:
|
||||
title = L(@"booking_show_more");
|
||||
break;
|
||||
case ButtonsRows::BookingShowMoreReviews:
|
||||
title = L(@"reviews_on_bookingcom");
|
||||
break;
|
||||
case ButtonsRows::BookingShowMoreOnSite:
|
||||
title = L(@"more_on_bookingcom");
|
||||
break;
|
||||
case ButtonsRows::LocalAdsCandidate:
|
||||
title = L(@"create_campaign_button");
|
||||
isInsetButton = YES;
|
||||
break;
|
||||
case ButtonsRows::LocalAdsCustomer:
|
||||
title = L(@"view_campaign_button");
|
||||
isInsetButton = YES;
|
||||
case ButtonsRows::Other:
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -82,21 +79,8 @@
|
|||
|
||||
- (IBAction)buttonTap
|
||||
{
|
||||
using place_page::ButtonsRows;
|
||||
|
||||
auto d = self.delegate;
|
||||
switch (self.rowType)
|
||||
{
|
||||
case ButtonsRows::AddPlace: [d addPlace]; break;
|
||||
case ButtonsRows::EditPlace: [d editPlace]; break;
|
||||
case ButtonsRows::AddBusiness: [d addBusiness]; break;
|
||||
case ButtonsRows::BookingShowMoreOnSite:
|
||||
case ButtonsRows::HotelDescription: [d book:YES]; break;
|
||||
case ButtonsRows::BookingShowMoreFacilities: [d showAllFacilities]; break;
|
||||
case ButtonsRows::BookingShowMoreReviews: [d showAllReviews]; break;
|
||||
case ButtonsRows::LocalAdsCandidate:
|
||||
case ButtonsRows::LocalAdsCustomer: [d openLocalAdsURL]; break;
|
||||
}
|
||||
if (self.action)
|
||||
self.action();
|
||||
}
|
||||
|
||||
#pragma mark - Properties
|
||||
|
|
|
@ -77,8 +77,7 @@
|
|||
name = @"coordinate";
|
||||
break;
|
||||
case MetainfoRows::ExtendedOpeningHours:
|
||||
case MetainfoRows::OpeningHours:
|
||||
case MetainfoRows::Taxi: NSAssert(false, @"Incorrect cell type!"); break;
|
||||
case MetainfoRows::OpeningHours: break;
|
||||
}
|
||||
[self configWithIconName:name data:[data stringForRow:row]];
|
||||
}
|
||||
|
@ -154,8 +153,7 @@
|
|||
case MetainfoRows::Operator:
|
||||
case MetainfoRows::OpeningHours:
|
||||
case MetainfoRows::Address:
|
||||
case MetainfoRows::Internet:
|
||||
case MetainfoRows::Taxi: break;
|
||||
case MetainfoRows::Internet: break;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -31,8 +31,7 @@ map<MetainfoRows, Class> const kMetaInfoCells = {
|
|||
{MetainfoRows::Cuisine, [MWMPlacePageInfoCell class]},
|
||||
{MetainfoRows::Operator, [MWMPlacePageInfoCell class]},
|
||||
{MetainfoRows::Coordinate, [MWMPlacePageInfoCell class]},
|
||||
{MetainfoRows::Internet, [MWMPlacePageInfoCell class]},
|
||||
{MetainfoRows::Taxi, [MWMPlacePageTaxiCell class]}};
|
||||
{MetainfoRows::Internet, [MWMPlacePageInfoCell class]}};
|
||||
} // namespace
|
||||
|
||||
@interface MWMPlacePageLayout () <UITableViewDataSource,
|
||||
|
@ -102,6 +101,7 @@ map<MetainfoRows, Class> const kMetaInfoCells = {
|
|||
[tv registerWithCellClass:[MWMPPReviewHeaderCell class]];
|
||||
[tv registerWithCellClass:[MWMPPReviewCell class]];
|
||||
[tv registerWithCellClass:[MWMPPFacilityCell class]];
|
||||
[tv registerWithCellClass:[MWMPlacePageTaxiCell class]];
|
||||
|
||||
// Register all meta info cells.
|
||||
for (auto const & pair : kMetaInfoCells)
|
||||
|
@ -316,6 +316,7 @@ map<MetainfoRows, Class> const kMetaInfoCells = {
|
|||
case Sections::Bookmark: return 1;
|
||||
case Sections::Preview: return data.previewRows.size();
|
||||
case Sections::Metainfo: return data.metainfoRows.size();
|
||||
case Sections::Ad: return data.adRows.size();
|
||||
case Sections::Buttons: return data.buttonsRows.size();
|
||||
case Sections::HotelPhotos: return data.photosRows.size();
|
||||
case Sections::HotelDescription: return data.descriptionRows.size();
|
||||
|
@ -373,24 +374,43 @@ map<MetainfoRows, Class> const kMetaInfoCells = {
|
|||
[c configWithRow:row data:data];
|
||||
return c;
|
||||
}
|
||||
case MetainfoRows::Taxi:
|
||||
case MetainfoRows::LocalAdsCustomer:
|
||||
case MetainfoRows::LocalAdsCandidate:
|
||||
{
|
||||
Class cls = kMetaInfoCells.at(row);
|
||||
auto c = static_cast<MWMPlacePageTaxiCell *>(
|
||||
[tableView dequeueReusableCellWithCellClass:cls indexPath:indexPath]);
|
||||
c.delegate = delegate;
|
||||
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]);
|
||||
c.delegate = delegate;
|
||||
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 withDelegate:delegate];
|
||||
|
||||
[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");
|
||||
}
|
||||
}];
|
||||
|
||||
if (row != ButtonsRows::HotelDescription)
|
||||
[c setEnabled:self.isPlacePageButtonsEnabled];
|
||||
else
|
||||
|
@ -420,7 +440,7 @@ map<MetainfoRows, Class> const kMetaInfoCells = {
|
|||
case HotelFacilitiesRow::ShowMore:
|
||||
Class cls = [MWMPlacePageButtonCell class];
|
||||
auto c = static_cast<MWMPlacePageButtonCell *>([tableView dequeueReusableCellWithCellClass:cls indexPath:indexPath]);
|
||||
[c configForRow:ButtonsRows::BookingShowMoreFacilities withDelegate:delegate];
|
||||
[c configWithTitle:L(@"booking_show_more") action:^{ [delegate showAllFacilities]; } isInsetButton:NO];
|
||||
return c;
|
||||
}
|
||||
}
|
||||
|
@ -447,7 +467,8 @@ map<MetainfoRows, Class> const kMetaInfoCells = {
|
|||
{
|
||||
Class cls = [MWMPlacePageButtonCell class];
|
||||
auto c = static_cast<MWMPlacePageButtonCell *>([tableView dequeueReusableCellWithCellClass:cls indexPath:indexPath]);
|
||||
[c configForRow:ButtonsRows::BookingShowMoreReviews withDelegate:delegate];
|
||||
|
||||
[c configWithTitle:L(@"reviews_on_bookingcom") action:^{ [delegate showAllReviews]; } isInsetButton:NO];
|
||||
return c;
|
||||
}
|
||||
}
|
||||
|
@ -469,7 +490,7 @@ map<MetainfoRows, Class> const kMetaInfoCells = {
|
|||
{
|
||||
Class cls = [MWMPlacePageButtonCell class];
|
||||
auto c = static_cast<MWMPlacePageButtonCell *>([tableView dequeueReusableCellWithCellClass:cls indexPath:indexPath]);
|
||||
[c configForRow:ButtonsRows::BookingShowMoreOnSite withDelegate:delegate];
|
||||
[c configWithTitle:L(@"more_on_bookingcom") action:^{ [delegate book:YES];; } isInsetButton:NO];
|
||||
return c;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue