[iOS] fix PP buttons for route points

This commit is contained in:
Aleksey Belousov 2020-03-13 06:05:11 +03:00 committed by Alexander Boriskov
parent 2906535c55
commit d59a6ca8e6
3 changed files with 43 additions and 4 deletions

View file

@ -32,6 +32,13 @@ typedef NS_ENUM(NSInteger, PlacePageTaxiProvider) {
PlacePageTaxiProviderRutaxi
};
typedef NS_ENUM(NSInteger, PlacePageRoadType) {
PlacePageRoadTypeToll,
PlacePageRoadTypeFerry,
PlacePageRoadTypeDirty,
PlacePageRoadTypeNone
};
@protocol IOpeningHoursLocalization;
NS_ASSUME_NONNULL_BEGIN
@ -44,6 +51,7 @@ NS_ASSUME_NONNULL_BEGIN
@property(nonatomic, readonly, nullable) PlacePageBookmarkData *bookmarkData;
@property(nonatomic, readonly) PlacePageSponsoredType sponsoredType;
@property(nonatomic, readonly) PlacePageTaxiProvider taxiProvider;
@property(nonatomic, readonly) PlacePageRoadType roadType;
@property(nonatomic, readonly, nullable) NSString *wikiDescriptionHtml;
@property(nonatomic, readonly, nullable) CatalogPromoData *catalogPromo;
@property(nonatomic, readonly, nullable) HotelBookingData *hotelBooking;
@ -59,6 +67,7 @@ NS_ASSUME_NONNULL_BEGIN
@property(nonatomic, readonly) BOOL shouldShowUgc;
@property(nonatomic, readonly) BOOL isMyPosition;
@property(nonatomic, readonly) BOOL isPreviewPlus;
@property(nonatomic, readonly) BOOL isRoutePoint;
@property(nonatomic, readonly) NSInteger partnerIndex;
@property(nonatomic, readonly, nullable) NSString *partnerName;
@property(nonatomic, readonly) CLLocationCoordinate2D locationCoordinate;

View file

@ -51,6 +51,19 @@ static PlacePageTaxiProvider convertTaxiProvider(taxi::Provider::Type providerTy
}
}
static PlacePageRoadType convertRoadType(RoadWarningMarkType roadType) {
switch (roadType) {
case RoadWarningMarkType::Toll:
return PlacePageRoadTypeToll;
case RoadWarningMarkType::Ferry:
return PlacePageRoadTypeFerry;
case RoadWarningMarkType::Dirty:
return PlacePageRoadTypeDirty;
case RoadWarningMarkType::Count:
return PlacePageRoadTypeNone;
}
}
@implementation PlacePageData
- (instancetype)initWithLocalizationProvider:(id<IOpeningHoursLocalization>)localization {
@ -70,6 +83,7 @@ static PlacePageTaxiProvider convertTaxiProvider(taxi::Provider::Type providerTy
}
_sponsoredType = convertSponsoredType(rawData().GetSponsoredType());
_roadType = convertRoadType(rawData().GetRoadType());
auto const &taxiProviders = rawData().ReachableByTaxiProviders();
if (!taxiProviders.empty()) {
@ -82,6 +96,7 @@ static PlacePageTaxiProvider convertTaxiProvider(taxi::Provider::Type providerTy
_isPromoCatalog = _isLargeToponim || _isSightseeing || _isOutdoor;
_shouldShowUgc = rawData().ShouldShowUGC();
_isMyPosition = rawData().IsMyPosition();
_isRoutePoint = rawData().IsRoutePoint();
_isPreviewPlus = rawData().GetOpeningMode() == place_page::OpeningMode::PreviewPlus;
_isPartner = rawData().GetSponsoredType() == place_page::SponsoredType::Partner;
_partnerIndex = _isPartner ? rawData().GetPartnerIndex() : -1;

View file

@ -17,10 +17,25 @@ class ActionBarViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
configButton1()
configButton2()
configButton3()
configButton4()
if placePageData.isRoutePoint {
visibleButtons.append(.routeRemoveStop)
} else if placePageData.roadType != .none {
switch placePageData.roadType {
case .toll:
visibleButtons.append(.avoidToll)
case .ferry:
visibleButtons.append(.avoidFerry)
case .dirty:
visibleButtons.append(.avoidDirty)
default:
fatalError()
}
} else {
configButton1()
configButton2()
configButton3()
configButton4()
}
for buttonType in visibleButtons {
var selected = false