[iOS] Fixed the price filter for search hotel filters

This commit is contained in:
Zoia Pribytkova 2019-05-20 18:12:56 +03:00 committed by Zoia
parent fea434edeb
commit 7126093c2a
3 changed files with 31 additions and 25 deletions

View file

@ -9,16 +9,16 @@
#include <memory>
typedef enum {
enum class Price {
Any,
One,
Two,
Three
} Price;
};
@interface MWMHotelParams : NSObject
@property (nonatomic) Price price;
@property (nonatomic) std::unordered_set<Price> price;
@property (nonatomic) std::unordered_set<ftypes::IsHotelChecker::Type> types;
@property (nonatomic) place_page::rating::FilterRating rating;
@property (nonatomic) NSDate * checkInDate;

View file

@ -18,7 +18,7 @@ static int8_t kAgeOfChild = 5;
if (auto const price = data.hotelRawApproximatePricing)
{
CHECK_LESS_OR_EQUAL(*price, base::Underlying(Price::Three), ());
_price = static_cast<Price>(*price);
_price.insert(static_cast<Price>(*price));
}
self.rating = place_page::rating::GetFilterRating(data.ratingRawValue);
@ -43,8 +43,10 @@ static int8_t kAgeOfChild = 5;
}
std::shared_ptr<Rule> priceRule;
if (self.price != Any)
priceRule = Or(priceRule, Eq<PriceRate>(self.price));
for (auto const filter : self.price) {
if (filter != Price::Any)
priceRule = Or(priceRule, Eq<PriceRate>(static_cast<unsigned>(filter)));
}
std::shared_ptr<Rule> typeRule;
if (!self.types.empty())

View file

@ -142,19 +142,21 @@ void configButton(UIButton * button, NSString * primaryText, NSString * secondar
}
auto priceCell = self.price;
switch (params.price)
{
case Any:
break;
case One:
priceCell.one.selected = YES;
break;
case Two:
priceCell.two.selected = YES;
break;
case Three:
priceCell.three.selected = YES;
break;
for (auto const filter : params.price) {
switch (filter)
{
case Price::Any:
break;
case Price::One:
priceCell.one.selected = YES;
break;
case Price::Two:
priceCell.two.selected = YES;
break;
case Price::Three:
priceCell.three.selected = YES;
break;
}
}
}
@ -235,13 +237,15 @@ void configButton(UIButton * button, NSString * primaryText, NSString * secondar
params.rating = FilterRating::Excellent;
MWMFilterPriceCategoryCell * price = self.price;
std::unordered_set<Price>priceFilter;
if (price.one.selected)
params.price = One;
else if (price.two.selected)
params.price = Two;
else if (price.three.selected)
params.price = Three;
priceFilter.insert(Price::One);
if (price.two.selected)
priceFilter.insert(Price::Two);
if (price.three.selected)
priceFilter.insert(Price::Three);
params.price = priceFilter;
return params;
}