<commit_before>#import "MWMPlacePageActionBar.h"
#import "AppInfo.h"
#import "MWMActionBarButton.h"
#import "MWMCommon.h"
#import "MWMPlacePageProtocol.h"
#import "MWMRouter.h"
#import "MapViewController.h"
#import "MapsAppDelegate.h"

#include "Framework.h"

#include "std/vector.hpp"

extern NSString * const kAlohalyticsTapEventKey;

@interface MWMPlacePageActionBar ()<MWMActionBarButtonDelegate>
{
  vector<EButton> m_visibleButtons;
  vector<EButton> m_additionalButtons;
}

@property(copy, nonatomic) IBOutletCollection(UIView) NSArray<UIView *> * buttons;
@property(weak, nonatomic) IBOutlet UIImageView * separator;

@property(weak, nonatomic) id<MWMActionBarSharedData> data;
@property(weak, nonatomic) id<MWMActionBarProtocol> delegate;

@end

@implementation MWMPlacePageActionBar

+ (MWMPlacePageActionBar *)actionBarWithDelegate:(id<MWMActionBarProtocol>)delegate
{
  MWMPlacePageActionBar * bar =
      [[NSBundle.mainBundle loadNibNamed:[self className] owner:nil options:nil] firstObject];
  bar.delegate = delegate;
  return bar;
}

- (void)configureWithData:(id<MWMActionBarSharedData>)data
{
  self.data = data;
  self.isBookmark = data.isBookmark;
  [self configureButtons];
  self.autoresizingMask = UIViewAutoresizingNone;
  [self setNeedsLayout];
}

- (void)configureButtons
{
  m_visibleButtons.clear();
  m_additionalButtons.clear();
  auto data = self.data;

  BOOL const isBooking = data.isBooking;
  BOOL const isOpentable = data.isOpentable;
  BOOL const isBookingSearch = data.isBookingSearch;
  BOOL const isSponsored = isBooking || isOpentable || isBookingSearch;
  BOOL const isPhoneCallAvailable =
      [AppInfo sharedInfo].canMakeCalls && data.phoneNumber.length > 0;
  BOOL const isApi = data.isApi;
  BOOL const isP2P =
      [MWMNavigationDashboardManager manager].state != MWMNavigationDashboardStateHidden;
  BOOL const isMyPosition = data.isMyPosition;
  BOOL const isRoutePoint = data.isRoutePoint;
  BOOL const isNeedToAddIntermediatePoint = [MWMRouter canAddIntermediatePoint];

  EButton sponsoredButton = EButton::BookingSearch;
  if (isBooking)
    sponsoredButton = EButton::Booking;
  else if (isOpentable)
    sponsoredButton = EButton::Opentable;
  BOOL thereAreExtraButtons = true;

  if (isRoutePoint)
  {
    thereAreExtraButtons = false;
    m_visibleButtons.push_back(EButton::RemoveStop);
  }
  else if (isNeedToAddIntermediatePoint)
  {
    thereAreExtraButtons = false;
    m_visibleButtons.push_back(EButton::RouteFrom);
    m_visibleButtons.push_back(EButton::RouteTo);
    m_visibleButtons.push_back(EButton::AddStop);
    m_visibleButtons.push_back(EButton::More);

    m_additionalButtons.push_back(EButton::Bookmark);
    if (isSponsored)
      m_additionalButtons.push_back(sponsoredButton);
    if (isPhoneCallAvailable)
      m_additionalButtons.push_back(EButton::Call);
    if (isApi)
      m_additionalButtons.push_back(EButton::Api);
    m_additionalButtons.push_back(EButton::Share);
  }
  else if (self.isAreaNotDownloaded)
  {
    thereAreExtraButtons = false;
    m_visibleButtons.push_back(EButton::Download);
    m_visibleButtons.push_back(EButton::Bookmark);
    m_visibleButtons.push_back(EButton::RouteTo);
    m_visibleButtons.push_back(EButton::Share);
  }
  else if (isMyPosition && isP2P)
  {
    thereAreExtraButtons = false;
    m_visibleButtons.push_back(EButton::Bookmark);
    m_visibleButtons.push_back(EButton::RouteFrom);
    m_visibleButtons.push_back(EButton::RouteTo);
    m_visibleButtons.push_back(EButton::More);
    m_additionalButtons.push_back(EButton::Share);
  }
  else if (isMyPosition)
  {
    thereAreExtraButtons = false;
    m_visibleButtons.push_back(EButton::Spacer);
    m_visibleButtons.push_back(EButton::Bookmark);
    m_visibleButtons.push_back(EButton::Share);
    m_visibleButtons.push_back(EButton::Spacer);
  }
  else if (isApi && isSponsored)
  {
    m_visibleButtons.push_back(EButton::Api);
    m_visibleButtons.push_back(sponsoredButton);
    m_additionalButtons.push_back(EButton::Bookmark);
    m_additionalButtons.push_back(EButton::RouteFrom);<commit_msg>[MAPSME-5032] [ios] Added «RouteFrom» button to MyPosition place page action bar.<commit_after>#import "MWMPlacePageActionBar.h"
#import "AppInfo.h"
#import "MWMActionBarButton.h"
#import "MWMCommon.h"
#import "MWMPlacePageProtocol.h"
#import "MWMRouter.h"
#import "MapViewController.h"
#import "MapsAppDelegate.h"

#include "Framework.h"

#include "std/vector.hpp"

extern NSString * const kAlohalyticsTapEventKey;

@interface MWMPlacePageActionBar ()<MWMActionBarButtonDelegate>
{
  vector<EButton> m_visibleButtons;
  vector<EButton> m_additionalButtons;
}

@property(copy, nonatomic) IBOutletCollection(UIView) NSArray<UIView *> * buttons;
@property(weak, nonatomic) IBOutlet UIImageView * separator;

@property(weak, nonatomic) id<MWMActionBarSharedData> data;
@property(weak, nonatomic) id<MWMActionBarProtocol> delegate;

@end

@implementation MWMPlacePageActionBar

+ (MWMPlacePageActionBar *)actionBarWithDelegate:(id<MWMActionBarProtocol>)delegate
{
  MWMPlacePageActionBar * bar =
      [[NSBundle.mainBundle loadNibNamed:[self className] owner:nil options:nil] firstObject];
  bar.delegate = delegate;
  return bar;
}

- (void)configureWithData:(id<MWMActionBarSharedData>)data
{
  self.data = data;
  self.isBookmark = data.isBookmark;
  [self configureButtons];
  self.autoresizingMask = UIViewAutoresizingNone;
  [self setNeedsLayout];
}

- (void)configureButtons
{
  m_visibleButtons.clear();
  m_additionalButtons.clear();
  auto data = self.data;

  BOOL const isBooking = data.isBooking;
  BOOL const isOpentable = data.isOpentable;
  BOOL const isBookingSearch = data.isBookingSearch;
  BOOL const isSponsored = isBooking || isOpentable || isBookingSearch;
  BOOL const isPhoneCallAvailable =
      [AppInfo sharedInfo].canMakeCalls && data.phoneNumber.length > 0;
  BOOL const isApi = data.isApi;
  BOOL const isP2P =
      [MWMNavigationDashboardManager manager].state != MWMNavigationDashboardStateHidden;
  BOOL const isMyPosition = data.isMyPosition;
  BOOL const isRoutePoint = data.isRoutePoint;
  BOOL const isNeedToAddIntermediatePoint = [MWMRouter canAddIntermediatePoint];

  EButton sponsoredButton = EButton::BookingSearch;
  if (isBooking)
    sponsoredButton = EButton::Booking;
  else if (isOpentable)
    sponsoredButton = EButton::Opentable;
  BOOL thereAreExtraButtons = true;

  if (isRoutePoint)
  {
    thereAreExtraButtons = false;
    m_visibleButtons.push_back(EButton::RemoveStop);
  }
  else if (isNeedToAddIntermediatePoint)
  {
    thereAreExtraButtons = false;
    m_visibleButtons.push_back(EButton::RouteFrom);
    m_visibleButtons.push_back(EButton::RouteTo);
    m_visibleButtons.push_back(EButton::AddStop);
    m_visibleButtons.push_back(EButton::More);

    m_additionalButtons.push_back(EButton::Bookmark);
    if (isSponsored)
      m_additionalButtons.push_back(sponsoredButton);
    if (isPhoneCallAvailable)
      m_additionalButtons.push_back(EButton::Call);
    if (isApi)
      m_additionalButtons.push_back(EButton::Api);
    m_additionalButtons.push_back(EButton::Share);
  }
  else if (self.isAreaNotDownloaded)
  {
    thereAreExtraButtons = false;
    m_visibleButtons.push_back(EButton::Download);
    m_visibleButtons.push_back(EButton::Bookmark);
    m_visibleButtons.push_back(EButton::RouteTo);
    m_visibleButtons.push_back(EButton::Share);
  }
  else if (isMyPosition && isP2P)
  {
    thereAreExtraButtons = false;
    m_visibleButtons.push_back(EButton::Bookmark);
    m_visibleButtons.push_back(EButton::RouteFrom);
    m_visibleButtons.push_back(EButton::RouteTo);
    m_visibleButtons.push_back(EButton::More);
    m_additionalButtons.push_back(EButton::Share);
  }
  else if (isMyPosition)
  {
    thereAreExtraButtons = false;
    m_visibleButtons.push_back(EButton::Bookmark);
    m_visibleButtons.push_back(EButton::RouteFrom);
    m_visibleButtons.push_back(EButton::Share);
  }
  else if (isApi && isSponsored)
  {
    m_visibleButtons.push_back(EButton::Api);
    m_visibleButtons.push_back(sponsoredButton);
    m_additionalButtons.push_back(EButton::Bookmark);
    m_additionalButtons.push_back(EButton::RouteFrom);
{'fraction_non_alphanumeric': 0.104248046875, 'fraction_numerical': 0.001220703125, 'mean_word_length': 5.787903893951947, 'pattern_counts': {'":': 0, '<': 19, '<?xml version=': 0, '>': 21, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6126445', 'n_tokens_mistral': 2804, 'n_tokens_neox': 2772, 'n_words': 426}