forked from organicmaps/organicmaps-tmp
[ios] Opentable.
This commit is contained in:
parent
ac813860e6
commit
0d5a084579
12 changed files with 99 additions and 52 deletions
|
@ -2,6 +2,7 @@ enum class EButton // Required button's order
|
|||
{
|
||||
Api,
|
||||
Booking,
|
||||
Opentable,
|
||||
Call,
|
||||
Bookmark,
|
||||
RouteFrom,
|
||||
|
|
|
@ -10,6 +10,7 @@ NSString * titleForButton(EButton type, BOOL isSelected)
|
|||
case EButton::Api:
|
||||
return L(@"back");
|
||||
case EButton::Booking:
|
||||
case EButton::Opentable:
|
||||
return L(@"bookingcom_book_button");
|
||||
case EButton::Call:
|
||||
return L(@"placepage_call_button");
|
||||
|
@ -60,6 +61,11 @@ NSString * titleForButton(EButton type, BOOL isSelected)
|
|||
self.label.textColor = [UIColor whiteColor];
|
||||
self.backgroundColor = [UIColor bookingBackground];
|
||||
break;
|
||||
case EButton::Opentable:
|
||||
[self.button setImage:[UIImage imageNamed:@"ic_opentable"] forState:UIControlStateNormal];
|
||||
self.label.textColor = [UIColor whiteColor];
|
||||
self.backgroundColor = [UIColor opentableBackground];
|
||||
break;
|
||||
case EButton::Call:
|
||||
[self.button setImage:[UIImage imageNamed:@"ic_placepage_phone_number"] forState:UIControlStateNormal];
|
||||
break;
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
@protocol MWMActionBarSharedData<NSObject>
|
||||
|
||||
- (BOOL)isBookmark;
|
||||
- (BOOL)isOpentable;
|
||||
- (BOOL)isBooking;
|
||||
- (BOOL)isApi;
|
||||
- (BOOL)isMyPosition;
|
||||
|
|
|
@ -77,11 +77,15 @@ extern NSString * const kAlohalyticsTapEventKey;
|
|||
BOOL const isIphone = [[UIDevice currentDevice].model isEqualToString:@"iPhone"];
|
||||
BOOL const isPhoneNotEmpty = phone.length > 0;
|
||||
BOOL const isBooking = data.isBooking;
|
||||
BOOL const isOpentable = data.isOpentable;
|
||||
BOOL const isSponsored = isBooking || isOpentable;
|
||||
BOOL const itHasPhoneNumber = isIphone && isPhoneNotEmpty;
|
||||
BOOL const isApi = data.isApi;
|
||||
BOOL const isP2P = self.isPrepareRouteMode;
|
||||
BOOL const isMyPosition = data.isMyPosition;
|
||||
|
||||
EButton const sponsoredButton = isBooking ? EButton::Booking : EButton::Opentable;
|
||||
|
||||
if (isMyPosition)
|
||||
{
|
||||
m_visibleButtons.push_back(EButton::Spacer);
|
||||
|
@ -89,10 +93,10 @@ extern NSString * const kAlohalyticsTapEventKey;
|
|||
m_visibleButtons.push_back(EButton::Share);
|
||||
m_visibleButtons.push_back(EButton::Spacer);
|
||||
}
|
||||
else if (isApi && isBooking)
|
||||
else if (isApi && isSponsored)
|
||||
{
|
||||
m_visibleButtons.push_back(EButton::Api);
|
||||
m_visibleButtons.push_back(EButton::Booking);
|
||||
m_visibleButtons.push_back(sponsoredButton);
|
||||
m_additionalButtons.push_back(EButton::Bookmark);
|
||||
m_additionalButtons.push_back(EButton::RouteFrom);
|
||||
m_additionalButtons.push_back(EButton::Share);
|
||||
|
@ -119,11 +123,11 @@ extern NSString * const kAlohalyticsTapEventKey;
|
|||
m_additionalButtons.push_back(EButton::RouteFrom);
|
||||
m_additionalButtons.push_back(EButton::Share);
|
||||
}
|
||||
else if (isBooking && isP2P)
|
||||
else if (isSponsored && isP2P)
|
||||
{
|
||||
m_visibleButtons.push_back(EButton::Bookmark);
|
||||
m_visibleButtons.push_back(EButton::RouteFrom);
|
||||
m_additionalButtons.push_back(EButton::Booking);
|
||||
m_additionalButtons.push_back(sponsoredButton);
|
||||
m_additionalButtons.push_back(EButton::Share);
|
||||
}
|
||||
else if (itHasPhoneNumber && isP2P)
|
||||
|
@ -133,9 +137,9 @@ extern NSString * const kAlohalyticsTapEventKey;
|
|||
m_additionalButtons.push_back(EButton::Call);
|
||||
m_additionalButtons.push_back(EButton::Share);
|
||||
}
|
||||
else if (isBooking)
|
||||
else if (isSponsored)
|
||||
{
|
||||
m_visibleButtons.push_back(EButton::Booking);
|
||||
m_visibleButtons.push_back(sponsoredButton);
|
||||
m_visibleButtons.push_back(EButton::Bookmark);
|
||||
m_additionalButtons.push_back(EButton::RouteFrom);
|
||||
m_additionalButtons.push_back(EButton::Share);
|
||||
|
@ -191,6 +195,7 @@ extern NSString * const kAlohalyticsTapEventKey;
|
|||
switch (type)
|
||||
{
|
||||
case EButton::Api: [delegate apiBack]; break;
|
||||
case EButton::Opentable:
|
||||
case EButton::Booking: [delegate book:NO]; break;
|
||||
case EButton::Call: [delegate call]; break;
|
||||
case EButton::Bookmark:
|
||||
|
|
|
@ -64,9 +64,9 @@ enum class OpeningHours
|
|||
// Booking
|
||||
- (NSString *)bookingRating;
|
||||
- (NSString *)bookingApproximatePricing;
|
||||
- (NSURL *)bookingURL;
|
||||
- (NSURL *)bookingDescriptionURL;
|
||||
- (NSString *)hotelId;
|
||||
- (NSURL *)sponsoredURL;
|
||||
- (NSURL *)sponsoredDescriptionURL;
|
||||
- (NSString *)sponsoredId;
|
||||
- (void)assignOnlinePriceToLabel:(UILabel *)label;
|
||||
|
||||
// API
|
||||
|
@ -92,6 +92,7 @@ enum class OpeningHours
|
|||
- (BOOL)isBookmark;
|
||||
- (BOOL)isApi;
|
||||
- (BOOL)isBooking;
|
||||
- (BOOL)isOpentable;
|
||||
- (BOOL)isHTMLDescription;
|
||||
- (BOOL)isMyPosition;
|
||||
|
||||
|
|
|
@ -53,7 +53,7 @@ using namespace place_page;
|
|||
|
||||
// There is at least one of these buttons.
|
||||
if (m_info.ShouldShowAddPlace() || m_info.ShouldShowEditPlace() ||
|
||||
m_info.ShouldShowAddBusiness() || m_info.IsSponsoredHotel())
|
||||
m_info.ShouldShowAddBusiness() || m_info.IsSponsored())
|
||||
{
|
||||
m_sections.push_back(Sections::Buttons);
|
||||
[self fillButtonsSection];
|
||||
|
@ -97,7 +97,7 @@ using namespace place_page;
|
|||
- (void)fillButtonsSection
|
||||
{
|
||||
// We don't have to show edit, add place or business if it's booking object.
|
||||
if (m_info.IsSponsoredHotel())
|
||||
if (self.isBooking)
|
||||
{
|
||||
m_buttonsRows.push_back(ButtonsRows::HotelDescription);
|
||||
return;
|
||||
|
@ -177,30 +177,30 @@ using namespace place_page;
|
|||
|
||||
- (NSString *)bookingRating
|
||||
{
|
||||
return m_info.IsSponsoredHotel() ? @(m_info.GetRatingFormatted().c_str()) : nil;
|
||||
return self.isBooking ? @(m_info.GetRatingFormatted().c_str()) : nil;
|
||||
}
|
||||
|
||||
- (NSString *)bookingApproximatePricing
|
||||
{
|
||||
return m_info.IsSponsoredHotel() ? @(m_info.GetApproximatePricing().c_str()) : nil;
|
||||
return self.isBooking ? @(m_info.GetApproximatePricing().c_str()) : nil;
|
||||
}
|
||||
|
||||
- (NSURL *)bookingURL
|
||||
- (NSURL *)sponsoredURL
|
||||
{
|
||||
return m_info.IsSponsoredHotel() ? [NSURL URLWithString:@(m_info.m_sponsoredBookingUrl.c_str())]
|
||||
return m_info.IsSponsored() ? [NSURL URLWithString:@(m_info.GetSponsoredUrl().c_str())]
|
||||
: nil;
|
||||
}
|
||||
|
||||
- (NSURL *)bookingDescriptionURL
|
||||
- (NSURL *)sponsoredDescriptionURL
|
||||
{
|
||||
return m_info.IsSponsoredHotel()
|
||||
? [NSURL URLWithString:@(m_info.m_sponsoredDescriptionUrl.c_str())]
|
||||
return m_info.IsSponsored()
|
||||
? [NSURL URLWithString:@(m_info.GetSponsoredDescriptionUrl().c_str())]
|
||||
: nil;
|
||||
}
|
||||
|
||||
- (NSString *)hotelId
|
||||
- (NSString *)sponsoredId
|
||||
{
|
||||
return m_info.IsSponsoredHotel()
|
||||
return m_info.IsSponsored()
|
||||
? @(m_info.GetMetadata().Get(feature::Metadata::FMD_SPONSORED_ID).c_str())
|
||||
: nil;
|
||||
}
|
||||
|
@ -208,7 +208,7 @@ using namespace place_page;
|
|||
- (void)assignOnlinePriceToLabel:(UILabel *)label
|
||||
{
|
||||
// TODO(Vlad): Remove similar code from MWMPlacePageEntity.mm when new iPAD place page will be finished.
|
||||
NSAssert(m_info.IsSponsoredHotel(), @"Online price must be assigned to booking object!");
|
||||
NSAssert(self.isBooking, @"Online price must be assigned to booking object!");
|
||||
if (Platform::ConnectionStatus() == Platform::EConnectionType::CONNECTION_NONE)
|
||||
return;
|
||||
|
||||
|
@ -247,7 +247,7 @@ using namespace place_page;
|
|||
});
|
||||
};
|
||||
|
||||
api.GetMinPrice(self.hotelId.UTF8String, currency, func);
|
||||
api.GetMinPrice(self.sponsoredId.UTF8String, currency, func);
|
||||
}
|
||||
|
||||
- (NSString *)address { return @(m_info.GetAddress().c_str()); }
|
||||
|
@ -310,7 +310,8 @@ using namespace place_page;
|
|||
- (NSString *)phoneNumber { return @(m_info.GetPhone().c_str()); }
|
||||
- (BOOL)isBookmark { return m_info.IsBookmark(); }
|
||||
- (BOOL)isApi { return m_info.HasApiUrl(); }
|
||||
- (BOOL)isBooking { return m_info.IsSponsoredHotel(); }
|
||||
- (BOOL)isBooking { return m_info.m_sponsoredType == SponsoredType::Booking; }
|
||||
- (BOOL)isOpentable { return m_info.m_sponsoredType == SponsoredType::Opentable; }
|
||||
- (BOOL)isMyPosition { return m_info.IsMyPosition(); }
|
||||
- (BOOL)isHTMLDescription { return strings::IsHTML(m_info.m_bookmarkDescription); }
|
||||
|
||||
|
|
|
@ -61,12 +61,13 @@ using MWMPlacePageCellTypeValueMap = map<MWMPlacePageCellType, string>;
|
|||
- (BOOL)isBookmark;
|
||||
- (BOOL)isApi;
|
||||
- (BOOL)isBooking;
|
||||
- (BOOL)isOpentable;
|
||||
- (ms::LatLon)latLon;
|
||||
- (m2::PointD const &)mercator;
|
||||
- (NSString *)apiURL;
|
||||
- (NSURL *)bookingURL;
|
||||
- (NSURL *)bookingDescriptionURL;
|
||||
- (NSString * )hotelId;
|
||||
- (NSURL *)sponsoredURL;
|
||||
- (NSURL *)sponsoredDescriptionURL;
|
||||
- (NSString *)sponsoredId;
|
||||
- (NSString *)phoneNumber;
|
||||
- (string)titleForNewBookmark;
|
||||
|
||||
|
|
|
@ -200,9 +200,9 @@ void initFieldsMap()
|
|||
case MWMPlacePageCellTypeAddBusinessButton:
|
||||
return navigationIsHidden && m_info.ShouldShowAddBusiness() ? @"" : nil;
|
||||
case MWMPlacePageCellTypeWebsite:
|
||||
return m_info.IsSponsoredHotel() ? nil : [self getDefaultField:cellType];
|
||||
return self.isBooking ? nil : [self getDefaultField:cellType];
|
||||
case MWMPlacePageCellTypeBookingMore:
|
||||
return m_info.IsSponsoredHotel() ? @(m_info.GetSponsoredDescriptionUrl().c_str()) : nil;
|
||||
return self.isBooking ? @(m_info.GetSponsoredDescriptionUrl().c_str()) : nil;
|
||||
default: return [self getDefaultField:cellType];
|
||||
}
|
||||
}
|
||||
|
@ -214,12 +214,12 @@ void initFieldsMap()
|
|||
return haveField ? @(it->second.c_str()) : nil;
|
||||
}
|
||||
|
||||
- (NSURL *)bookingURL { return [self sponsoredUrl:NO]; }
|
||||
- (NSURL *)bookingDescriptionURL { return [self sponsoredUrl:YES]; }
|
||||
- (NSURL *)sponsoredURL { return [self sponsoredUrl:NO]; }
|
||||
- (NSURL *)sponsoredDescriptionURL { return [self sponsoredUrl:YES]; }
|
||||
- (NSURL *)sponsoredUrl:(BOOL)isDescription
|
||||
{
|
||||
auto const & url =
|
||||
isDescription ? m_info.GetSponsoredDescriptionUrl() : m_info.GetSponsoredBookingUrl();
|
||||
isDescription ? m_info.GetSponsoredDescriptionUrl() : m_info.GetSponsoredUrl();
|
||||
return url.empty() ? nil : [NSURL URLWithString:@(url.c_str())];
|
||||
}
|
||||
|
||||
|
@ -229,10 +229,12 @@ void initFieldsMap()
|
|||
- (BOOL)isMyPosition { return m_info.IsMyPosition(); }
|
||||
- (BOOL)isBookmark { return m_info.IsBookmark(); }
|
||||
- (BOOL)isApi { return m_info.HasApiUrl(); }
|
||||
- (BOOL)isBooking { return m_info.IsSponsoredHotel(); }
|
||||
- (NSString *)hotelId
|
||||
- (BOOL)isBooking { return m_info.m_sponsoredType == SponsoredType::Booking; }
|
||||
- (BOOL)isOpentable { return m_info.m_sponsoredType == SponsoredType::Opentable; }
|
||||
- (BOOL)isSponsored { return m_info.IsSponsored(); }
|
||||
- (NSString *)sponsoredId
|
||||
{
|
||||
return self.isBooking ? @(m_info.GetMetadata().Get(Metadata::FMD_SPONSORED_ID).c_str()) : nil;
|
||||
return self.isSponsored ? @(m_info.GetMetadata().Get(Metadata::FMD_SPONSORED_ID).c_str()) : nil;
|
||||
}
|
||||
|
||||
- (NSString *)phoneNumber { return [self getCellValue:MWMPlacePageCellTypePhoneNumber]; }
|
||||
|
|
|
@ -247,19 +247,34 @@
|
|||
- (void)editBookmark { [[MapViewController controller] openBookmarkEditorWithData:self.data]; }
|
||||
- (void)book:(BOOL)isDescription
|
||||
{
|
||||
NSMutableDictionary * stat = [@{ kStatProvider : kStatBooking } mutableCopy];
|
||||
// TODO(Vlad): remove the same code from MWMPlacePageViewManager.mm
|
||||
MWMPlacePageData * data = self.data;
|
||||
BOOL const isBooking = data.isBooking;
|
||||
auto const & latLon = data.latLon;
|
||||
stat[kStatHotel] = data.hotelId;
|
||||
stat[kStatHotelLat] = @(latLon.lat);
|
||||
stat[kStatHotelLon] = @(latLon.lon);
|
||||
[Statistics logEvent:isDescription ? kPlacePageHotelDetails : kPlacePageHotelBook
|
||||
NSMutableDictionary * stat = [@{} mutableCopy];
|
||||
if (isBooking)
|
||||
{
|
||||
stat[kStatProvider] = kStatBooking;
|
||||
stat[kStatHotel] = data.sponsoredId;
|
||||
stat[kStatHotelLat] = @(latLon.lat);
|
||||
stat[kStatHotelLon] = @(latLon.lon);
|
||||
}
|
||||
else
|
||||
{
|
||||
stat[kStatProvider] = kStatOpentable;
|
||||
stat[kStatRestaurant] = data.sponsoredId;
|
||||
stat[kStatRestaurantLat] = @(latLon.lat);
|
||||
stat[kStatRestaurantLon] = @(latLon.lon);
|
||||
}
|
||||
|
||||
NSString * eventName = isBooking ? kPlacePageHotelBook : kPlacePageRestaurantBook;
|
||||
[Statistics logEvent:isDescription ? kPlacePageHotelDetails : eventName
|
||||
withParameters:stat
|
||||
atLocation:[MWMLocationManager lastLocation]];
|
||||
|
||||
UIViewController * vc = static_cast<UIViewController *>([MapViewController controller]);
|
||||
NSURL * url = isDescription ? self.data.bookingDescriptionURL : self.data.bookingURL;
|
||||
NSAssert(url, @"Booking url can't be nil!");
|
||||
NSURL * url = isDescription ? self.data.sponsoredDescriptionURL : self.data.sponsoredURL;
|
||||
NSAssert(url, @"Sponsored url can't be nil!");
|
||||
[vc openUrl:url];
|
||||
}
|
||||
|
||||
|
|
|
@ -210,19 +210,33 @@ extern NSString * const kBookmarksChangedNotification;
|
|||
|
||||
- (void)book:(BOOL)isDescription
|
||||
{
|
||||
NSMutableDictionary * stat = [@{ kStatProvider : kStatBooking } mutableCopy];
|
||||
MWMPlacePageEntity * en = self.entity;
|
||||
auto const & latLon = en.latLon;
|
||||
stat[kStatHotel] = en.hotelId;
|
||||
stat[kStatHotelLat] = @(latLon.lat);
|
||||
stat[kStatHotelLon] = @(latLon.lon);
|
||||
[Statistics logEvent:isDescription ? kPlacePageHotelDetails : kPlacePageHotelBook
|
||||
MWMPlacePageEntity * data = self.entity;
|
||||
BOOL const isBooking = data.isBooking;
|
||||
auto const & latLon = data.latLon;
|
||||
NSMutableDictionary * stat = [@{} mutableCopy];
|
||||
if (isBooking)
|
||||
{
|
||||
stat[kStatProvider] = kStatBooking;
|
||||
stat[kStatHotel] = data.sponsoredId;
|
||||
stat[kStatHotelLat] = @(latLon.lat);
|
||||
stat[kStatHotelLon] = @(latLon.lon);
|
||||
}
|
||||
else
|
||||
{
|
||||
stat[kStatProvider] = kStatOpentable;
|
||||
stat[kStatRestaurant] = data.sponsoredId;
|
||||
stat[kStatRestaurantLat] = @(latLon.lat);
|
||||
stat[kStatRestaurantLon] = @(latLon.lon);
|
||||
}
|
||||
|
||||
NSString * eventName = isBooking ? kPlacePageHotelBook : kPlacePageRestaurantBook;
|
||||
[Statistics logEvent:isDescription ? kPlacePageHotelDetails : eventName
|
||||
withParameters:stat
|
||||
atLocation:[MWMLocationManager lastLocation]];
|
||||
|
||||
UIViewController * vc = static_cast<UIViewController *>([MapViewController controller]);
|
||||
NSURL * url = isDescription ? self.entity.bookingDescriptionURL : self.entity.bookingURL;
|
||||
NSAssert(url, @"Booking url can't be nil!");
|
||||
NSURL * url = isDescription ? self.entity.sponsoredDescriptionURL : self.entity.sponsoredURL;
|
||||
NSAssert(url, @"Sponsored url can't be nil!");
|
||||
[vc openUrl:url];
|
||||
}
|
||||
|
||||
|
|
|
@ -10,7 +10,7 @@ class LatLon;
|
|||
- (NSString *)title;
|
||||
- (NSString *)subtitle;
|
||||
- (NSString *)address;
|
||||
- (NSURL *)bookingDescriptionURL;
|
||||
- (NSURL *)sponsoredDescriptionURL;
|
||||
- (NSString *)phoneNumber;
|
||||
- (ms::LatLon)latLon;
|
||||
|
||||
|
|
|
@ -130,7 +130,7 @@ NSString * httpGe0Url(NSString * shortUrl)
|
|||
if (self.object.isBooking)
|
||||
{
|
||||
strings.push_back(L(@"sharing_booking"));
|
||||
strings.push_back(self.object.bookingDescriptionURL.absoluteString);
|
||||
strings.push_back(self.object.sponsoredDescriptionURL.absoluteString);
|
||||
}
|
||||
|
||||
for (auto const str : strings)
|
||||
|
|
Loading…
Add table
Reference in a new issue