[iOS] Fixed crash in hotel filters in search and pp

https://jira.mail.ru/browse/MAPSME-13124
This commit is contained in:
Alexander Boriskov 2020-02-21 17:54:34 +03:00 committed by Aleksey Belousov
parent 066b7615a4
commit 97c9de0235
8 changed files with 29 additions and 18 deletions

View file

@ -31,6 +31,7 @@ NS_ASSUME_NONNULL_BEGIN
@property(nonatomic, readonly, nullable) NSString *subtitle;
@property(nonatomic, readonly, nullable) NSString *address;
@property(nonatomic, readonly, nullable) NSString *pricing;
@property(nonatomic, readonly, nullable) NSNumber *rawPricing;
@property(nonatomic, readonly) PlacePageDataSchedule schedule;
@property(nonatomic, readonly) PlacePageDataHotelType hotelType;
@property(nonatomic, readonly) BOOL hasBanner;

View file

@ -68,6 +68,7 @@ static PlacePageDataHotelType convertHotelType(std::optional<ftypes::IsHotelChec
_subtitle = rawData.GetSubtitle().empty() ? nil : @(rawData.GetSubtitle().c_str());
_address = rawData.GetAddress().empty() ? nil : @(rawData.GetAddress().c_str());
_pricing = rawData.GetApproximatePricing().empty() ? nil : @(rawData.GetApproximatePricing().c_str());
_rawPricing = rawData.GetRawApproximatePricing() ? nil : [[NSNumber alloc] initWithInt: *(rawData.GetRawApproximatePricing())];
_hasBanner = rawData.HasBanner();
_isPopular = rawData.GetPopularity() > 0;
_isBookingPlace = rawData.GetSponsoredType() == place_page::SponsoredType::Booking;

View file

@ -405,12 +405,12 @@ void RegisterEventIfPossible(eye::MapObject::Event::Type const type)
[[MapViewController sharedController].navigationController pushViewController:ugcVC animated:YES];
}
- (void)searchSimilar
- (void)searchSimilar:(PlacePageData *)data
{
// [Statistics logEvent:@"Placepage_Hotel_search_similar"
// withParameters:@{kStatProvider : self.data.isBooking ? kStatBooking : kStatOSM}];
[Statistics logEvent:@"Placepage_Hotel_search_similar"
withParameters:@{kStatProvider : data.sponsoredType == PlacePageSponsoredTypeBooking ? kStatBooking : kStatOSM}];
MWMHotelParams * params = [[MWMHotelParams alloc] init];
MWMHotelParams * params = [[MWMHotelParams alloc] initWithPlacePageData:data];
[[MWMSearchManager manager] showHotelFilterWithParams:params
onFinishCallback:^{
[MWMMapViewControlsManager.manager searchTextOnMap:[L(@"booking_hotel") stringByAppendingString:@" "]

View file

@ -9,7 +9,7 @@
+ (void)showUGCAddReview:(PlacePageData *)data
rating:(UgcSummaryRatingType)value
fromSource:(MWMUGCReviewSource)source;
+ (void)searchSimilar;
+ (void)searchSimilar:(PlacePageData *)data;
+ (void)editPlace;
+ (void)addBusiness;
+ (void)addPlace:(CLLocationCoordinate2D)coordinate;

View file

@ -12,7 +12,7 @@
- (void)updateAvailableArea:(CGRect)frame;
- (void)showUGCAddReview:(PlacePageData *)data rating:(UgcSummaryRatingType)value fromSource:(MWMUGCReviewSource)source;
- (void)searchSimilar;
- (void)searchSimilar:(PlacePageData *)data;
- (void)editPlace;
- (void)addBusiness;
- (void)addPlace:(CLLocationCoordinate2D)coordinate;
@ -55,9 +55,9 @@
[[MWMMapViewControlsManager manager].placePageManager showUGCAddReview:data rating:value fromSource:source];
}
+ (void)searchSimilar
+ (void)searchSimilar:(PlacePageData *)data
{
[[MWMMapViewControlsManager manager].placePageManager searchSimilar];
[[MWMMapViewControlsManager manager].placePageManager searchSimilar:data];
}
+ (void)editPlace {

View file

@ -369,7 +369,7 @@ extension PlacePageViewController: PlacePagePreviewViewControllerDelegate {
}
func previewDidPressSimilarHotels() {
MWMPlacePageManagerHelper.searchSimilar()
MWMPlacePageManagerHelper.searchSimilar(placePageData)
}
}
@ -534,7 +534,7 @@ extension PlacePageViewController: ActionBarViewControllerDelegate {
case .booking:
MWMPlacePageManagerHelper.book(placePageData)
case .bookingSearch:
MWMPlacePageManagerHelper.searchSimilar()
MWMPlacePageManagerHelper.searchSimilar(placePageData)
case .bookmark:
if placePageData.bookmarkData != nil {
MWMPlacePageManagerHelper.removeBookmark(placePageData)

View file

@ -14,6 +14,8 @@ enum class Price {
Three
};
@class PlacePageData;
@interface MWMHotelParams : NSObject
@property (nonatomic) std::unordered_set<Price> price;
@ -22,6 +24,7 @@ enum class Price {
@property (nonatomic) NSDate * checkInDate;
@property (nonatomic) NSDate * checkOutDate;
- (instancetype)initWithPlacePageData:(PlacePageData *)data;
- (std::shared_ptr<search::hotels_filter::Rule>)rules;
- (booking::filter::Params)availabilityParams;

View file

@ -1,30 +1,36 @@
#import "MWMHotelParams.h"
#include <CoreApi/Framework.h>
#include <CoreApi/PlacePageData.h>
#include <CoreApi/PlacePagePreviewData.h>
#include <CoreApi/HotelBookingData.h>
static uint8_t kAdultsCount = 2;
static int8_t kAgeOfChild = 5;
@implementation MWMHotelParams
- (instancetype)init
- (instancetype)initWithPlacePageData:(PlacePageData *)data
{
self = [super init];
if (self)
{
_types.insert(ftypes::IsHotelChecker::Type::Hotel);
auto const & data = GetFramework().GetCurrentPlacePageInfo();
CHECK(data.GetHotelType(), ("Incorrect hotel type at coordinate:", data.GetLatLon().m_lat, data.GetLatLon().m_lon));
PlacePagePreviewData *previewData = data.previewData;
HotelBookingData *hotelBookingData = data.hotelBooking;
CHECK(previewData && hotelBookingData,
("Incorrect hotel type at coordinate:", data.locationCoordinate.latitude, data.locationCoordinate.longitude));
if (data.GetSponsoredType() == place_page::SponsoredType::Booking)
if (data.sponsoredType == PlacePageSponsoredTypeBooking)
{
if (auto const price = data.GetRawApproximatePricing())
if (auto const price = [previewData.rawPricing intValue])
{
CHECK_LESS_OR_EQUAL(*price, base::Underlying(Price::Three), ());
_price.insert(static_cast<Price>(*price));
CHECK_LESS_OR_EQUAL(price, base::Underlying(Price::Three), ());
_price.insert(static_cast<Price>(price));
}
self.rating = place_page::rating::GetFilterRating(data.GetRatingRawValue());
self.rating = place_page::rating::GetFilterRating(hotelBookingData.score);
}
}