Welcome to mirror list, hosted at ThFree Co, Russian Federation.

MWMEditorViewController.mm « Editor « UI « Maps « iphone - github.com/mapsme/omim.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: f84a0a9a5fe28022e45aeda4664f5064c7a2e60f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
#import "MWMEditorViewController.h"
#import "MWMAlertViewController.h"
#import "MWMAuthorizationCommon.h"
#import "MWMButtonCell.h"
#import "MWMCuisineEditorViewController.h"
#import "MWMDropDown.h"
#import "MWMEditorAddAdditionalNameTableViewCell.h"
#import "MWMEditorAdditionalNameTableViewCell.h"
#import "MWMEditorAdditionalNamesHeader.h"
#import "MWMEditorAdditionalNamesTableViewController.h"
#import "MWMEditorCategoryCell.h"
#import "MWMEditorCellType.h"
#import "MWMEditorCommon.h"
#import "MWMEditorNotesFooter.h"
#import "MWMEditorSelectTableViewCell.h"
#import "MWMEditorSwitchTableViewCell.h"
#import "MWMEditorTextTableViewCell.h"
#import "MWMNoteCell.h"
#import "MWMObjectsCategorySelectorController.h"
#import "MWMOpeningHoursEditorViewController.h"
#import "MWMPlacePageOpeningHoursCell.h"
#import "MWMStreetEditorViewController.h"
#import "MapViewController.h"
#import "SwiftBridge.h"

#include "Framework.h"

#include "editor/osm_editor.hpp"

#include "indexer/classificator.hpp"
#include "indexer/feature_source.hpp"

#include "platform/localization.hpp"

namespace
{
NSString * const kAdditionalNamesEditorSegue = @"Editor2AdditionalNamesEditorSegue";
NSString * const kOpeningHoursEditorSegue = @"Editor2OpeningHoursEditorSegue";
NSString * const kCuisineEditorSegue = @"Editor2CuisineEditorSegue";
NSString * const kStreetEditorSegue = @"Editor2StreetEditorSegue";
NSString * const kCategoryEditorSegue = @"Editor2CategoryEditorSegue";

NSString * const kUDEditorPersonalInfoWarninWasShown = @"PersonalInfoWarningAlertWasShown";

CGFloat const kDefaultHeaderHeight = 28.;
CGFloat const kDefaultFooterHeight = 32.;

typedef NS_ENUM(NSUInteger, MWMEditorSection) {
  MWMEditorSectionCategory,
  MWMEditorSectionAdditionalNames,
  MWMEditorSectionAddress,
  MWMEditorSectionDetails,
  MWMEditorSectionNote,
  MWMEditorSectionButton
};

vector<MWMEditorCellType> const kSectionCategoryCellTypes{MWMEditorCellTypeCategory};
vector<MWMEditorCellType> const kSectionAddressCellTypes{
    MWMEditorCellTypeStreet, MWMEditorCellTypeBuilding, MWMEditorCellTypeZipCode};

vector<MWMEditorCellType> const kSectionNoteCellTypes{MWMEditorCellTypeNote};
vector<MWMEditorCellType> const kSectionButtonCellTypes{MWMEditorCellTypeReportButton};

using MWMEditorCellTypeClassMap = map<MWMEditorCellType, Class>;
MWMEditorCellTypeClassMap const kCellType2Class{
    {MWMEditorCellTypeCategory, [MWMEditorCategoryCell class]},
    {MWMEditorCellTypeAdditionalName, [MWMEditorAdditionalNameTableViewCell class]},
    {MWMEditorCellTypeAddAdditionalName, [MWMEditorAddAdditionalNameTableViewCell class]},
    {MWMEditorCellTypeAddAdditionalNamePlaceholder,
     [MWMEditorAdditionalNamePlaceholderTableViewCell class]},
    {MWMEditorCellTypeStreet, [MWMEditorSelectTableViewCell class]},
    {MWMEditorCellTypeBuilding, [MWMEditorTextTableViewCell class]},
    {MWMEditorCellTypeZipCode, [MWMEditorTextTableViewCell class]},
    {MWMEditorCellTypeBuildingLevels, [MWMEditorTextTableViewCell class]},
    {MWMEditorCellTypeOpenHours, [MWMPlacePageOpeningHoursCell class]},
    {MWMEditorCellTypePhoneNumber, [MWMEditorTextTableViewCell class]},
    {MWMEditorCellTypeWebsite, [MWMEditorTextTableViewCell class]},
    {MWMEditorCellTypeEmail, [MWMEditorTextTableViewCell class]},
    {MWMEditorCellTypeOperator, [MWMEditorTextTableViewCell class]},
    {MWMEditorCellTypeCuisine, [MWMEditorSelectTableViewCell class]},
    {MWMEditorCellTypeWiFi, [MWMEditorSwitchTableViewCell class]},
    {MWMEditorCellTypeNote, [MWMNoteCell class]},
    {MWMEditorCellTypeReportButton, [MWMButtonCell class]}};

Class cellClass(MWMEditorCellType cellType)
{
  auto const it = kCellType2Class.find(cellType);
  ASSERT(it != kCellType2Class.end(), ());
  return it->second;
}

void cleanupAdditionalLanguages(vector<osm::LocalizedName> const & names,
                                vector<NSInteger> & newAdditionalLanguages)
{
  newAdditionalLanguages.erase(
      remove_if(newAdditionalLanguages.begin(), newAdditionalLanguages.end(),
                [&names](NSInteger x) {
                  auto it =
                      find_if(names.begin(), names.end(),
                              [x](osm::LocalizedName const & name) { return name.m_code == x; });
                  return it != names.end();
                }),
      newAdditionalLanguages.end());
}

vector<MWMEditorCellType> cellsForAdditionalNames(osm::NamesDataSource const & ds,
                                                  vector<NSInteger> const & newAdditionalLanguages,
                                                  BOOL showAdditionalNames)
{
  vector<MWMEditorCellType> res;
  auto const allNamesSize = ds.names.size() + newAdditionalLanguages.size();
  if (allNamesSize != 0)
  {
    if (showAdditionalNames)
    {
      res.insert(res.begin(), allNamesSize, MWMEditorCellTypeAdditionalName);
    }
    else
    {
      auto const mandatoryNamesCount = ds.mandatoryNamesCount;
      res.insert(res.begin(), mandatoryNamesCount, MWMEditorCellTypeAdditionalName);
      if (allNamesSize > mandatoryNamesCount)
        res.push_back(MWMEditorCellTypeAddAdditionalNamePlaceholder);
    }
  }
  res.push_back(MWMEditorCellTypeAddAdditionalName);
  return res;
}

vector<MWMEditorCellType> cellsForProperties(vector<osm::Props> const & props)
{
  using namespace osm;
  vector<MWMEditorCellType> res;
  for (auto const p : props)
  {
    switch (p)
    {
    case Props::OpeningHours: res.push_back(MWMEditorCellTypeOpenHours); break;
    case Props::Phone: res.push_back(MWMEditorCellTypePhoneNumber); break;
    case Props::Website: res.push_back(MWMEditorCellTypeWebsite); break;
    case Props::Email: res.push_back(MWMEditorCellTypeEmail); break;
    case Props::Cuisine: res.push_back(MWMEditorCellTypeCuisine); break;
    case Props::Operator: res.push_back(MWMEditorCellTypeOperator); break;
    case Props::Internet: res.push_back(MWMEditorCellTypeWiFi); break;
    case Props::Wikipedia:
    case Props::Fax:
    case Props::Stars:
    case Props::Elevation:
    case Props::Flats:
    case Props::BuildingLevels:
    case Props::Level: break;
    }
  }
  return res;
}

void registerCellsForTableView(vector<MWMEditorCellType> const & cells, UITableView * tv)
{
  for (auto const c : cells)
    [tv registerWithCellClass:cellClass(c)];
}
}  // namespace

@interface MWMEditorViewController ()<
    UITableViewDelegate, UITableViewDataSource, UITextFieldDelegate, MWMOpeningHoursEditorProtocol,
    MWMPlacePageOpeningHoursCellProtocol, MWMEditorCellProtocol, MWMCuisineEditorProtocol,
    MWMStreetEditorProtocol, MWMObjectsCategorySelectorDelegate, MWMNoteCelLDelegate,
    MWMEditorAdditionalName, MWMButtonCellDelegate, MWMEditorAdditionalNamesProtocol>

@property(nonatomic) NSMutableDictionary<Class, UITableViewCell *> * offscreenCells;
@property(nonatomic) NSMutableArray<NSIndexPath *> * invalidCells;
@property(nonatomic) MWMEditorAdditionalNamesHeader * additionalNamesHeader;
@property(nonatomic) MWMEditorNotesFooter * notesFooter;
@property(copy, nonatomic) NSString * note;
@property(nonatomic) FeatureStatus featureStatus;
@property(nonatomic) BOOL isFeatureUploaded;

@property(nonatomic) BOOL showAdditionalNames;

@end

@implementation MWMEditorViewController
{
  vector<MWMEditorSection> m_sections;
  map<MWMEditorSection, vector<MWMEditorCellType>> m_cells;
  osm::EditableMapObject m_mapObject;
  vector<NSInteger> m_newAdditionalLanguages;
}

- (void)viewDidLoad
{
  [Statistics logEvent:kStatEventName(kStatEdit, kStatOpen)];
  [super viewDidLoad];
  [self configTable];
  [self configNavBar];
  auto const & fid = m_mapObject.GetID();
  self.featureStatus = osm::Editor::Instance().GetFeatureStatus(fid.m_mwmId, fid.m_index);
  self.isFeatureUploaded = osm::Editor::Instance().IsFeatureUploaded(fid.m_mwmId, fid.m_index);
  m_newAdditionalLanguages.clear();
  if (self.isCreating)
  {
    self.navigationItem.leftBarButtonItem =
    [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemCancel
                                                  target:self
                                                  action:@selector(onCancel)];
  }
}

- (void)setFeatureToEdit:(FeatureID const &)fid
{
  if (!GetFramework().GetEditableMapObject(fid, m_mapObject))
    NSAssert(false, @"Incorrect featureID.");
}

- (void)setEditableMapObject:(osm::EditableMapObject const &)emo
{
  NSAssert(self.isCreating, @"We should pass featureID to editor if we just editing");
  m_mapObject = emo;
}

- (void)viewWillAppear:(BOOL)animated
{
  [super viewWillAppear:animated];
  [self.tableView reloadData];
}

#pragma mark - Configuration

- (void)configNavBar
{
  self.title =
      L(self.isCreating ? @"editor_add_place_title" : @"editor_edit_place_title").capitalizedString;
  self.navigationItem.rightBarButtonItem =
      [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemSave
                                                    target:self
                                                    action:@selector(onSave)];
}

- (void)onCancel
{
  [self.navigationController popToRootViewControllerAnimated:YES];
}

#pragma mark - Actions

- (void)onSave
{
  if (![self.view endEditing:YES])
  {
    NSAssert(false, @"We can't save map object because one of text fields can't apply it's text!");
    return;
  }

  if (self.invalidCells.count)
  {
    NSIndexPath * ip = self.invalidCells.firstObject;
    MWMEditorTextTableViewCell * cell = [self.tableView cellForRowAtIndexPath:ip];
    [cell.textField becomeFirstResponder];
    return;
  }

  if ([self showPersonalInfoWarningAlertIfNeeded])
    return;

  auto & f = GetFramework();
  auto const & featureID = m_mapObject.GetID();
  NSDictionary * info = @{
    kStatEditorMWMName : @(featureID.GetMwmName().c_str()),
    kStatEditorMWMVersion : @(featureID.GetMwmVersion())
  };
  BOOL const haveNote = self.note.length;

  if (haveNote)
  {
    auto const latLon = m_mapObject.GetLatLon();
    NSMutableDictionary * noteInfo = [info mutableCopy];
    noteInfo[kStatProblem] = self.note;
    CLLocation * location = [[CLLocation alloc] initWithLatitude:latLon.lat longitude:latLon.lon];
    [Statistics logEvent:kStatEditorProblemReport withParameters:noteInfo atLocation:location];
    f.CreateNote(m_mapObject, osm::Editor::NoteProblemType::General, self.note.UTF8String);
  }

  switch (f.SaveEditedMapObject(m_mapObject))
  {
  case osm::Editor::SaveResult::NoUnderlyingMapError:
  case osm::Editor::SaveResult::SavingError:
    [self.navigationController popToRootViewControllerAnimated:YES];
    break;
  case osm::Editor::SaveResult::NothingWasChanged:
    [self.navigationController popToRootViewControllerAnimated:YES];
    if (haveNote)
      [self showDropDown];
    break;
  case osm::Editor::SaveResult::SavedSuccessfully:
    [Statistics logEvent:(self.isCreating ? kStatEditorAddSuccess : kStatEditorEditSuccess)
          withParameters:info];
    osm_auth_ios::AuthorizationSetNeedCheck(YES);
    f.UpdatePlacePageInfoForCurrentSelection();
    [self.navigationController popToRootViewControllerAnimated:YES];
    break;
  case osm::Editor::SaveResult::NoFreeSpaceError:
    [Statistics logEvent:(self.isCreating ? kStatEditorAddError : kStatEditorEditError)
          withParameters:info];
    [self.alertController presentNotEnoughSpaceAlert];
    break;
  }
}

- (void)showDropDown
{
  MWMDropDown * dd = [[MWMDropDown alloc] initWithSuperview:[MapViewController sharedController].view];
  [dd showWithMessage:L(@"editor_edits_sent_message")];
}

#pragma mark - Headers

- (MWMEditorAdditionalNamesHeader *)additionalNamesHeader
{
  if (!_additionalNamesHeader)
  {
    __weak auto weakSelf = self;
    _additionalNamesHeader = [MWMEditorAdditionalNamesHeader header:^{
      __strong auto self = weakSelf;
      self.showAdditionalNames = !self.showAdditionalNames;
    }];
  }
  return _additionalNamesHeader;
}

#pragma mark - Footers

- (MWMEditorNotesFooter *)notesFooter
{
  if (!_notesFooter)
    _notesFooter = [MWMEditorNotesFooter footerForController:self];
  return _notesFooter;
}

#pragma mark - Properties

- (void)setShowAdditionalNames:(BOOL)showAdditionalNames
{
  _showAdditionalNames = showAdditionalNames;
  [self.additionalNamesHeader setShowAdditionalNames:showAdditionalNames];
  [self configTable];
  auto const additionalNamesSectionIt =
      find(m_sections.begin(), m_sections.end(), MWMEditorSectionAdditionalNames);
  if (additionalNamesSectionIt == m_sections.end())
  {
    [self.tableView reloadData];
  }
  else
  {
    auto const sectionIndex = distance(m_sections.begin(), additionalNamesSectionIt);
    [self.tableView reloadSections:[[NSIndexSet alloc] initWithIndex:sectionIndex]
                  withRowAnimation:UITableViewRowAnimationAutomatic];
  }
}

#pragma mark - Offscreen cells

- (UITableViewCell *)offscreenCellForClass:(Class)cls
{
  auto cell = self.offscreenCells[cls];
  if (!cell)
  {
    cell = [NSBundle.mainBundle loadWithViewClass:cls owner:nil options:nil].firstObject;
    self.offscreenCells[cls] = cell;
  }
  return cell;
}

- (void)configTable
{
  self.offscreenCells = [NSMutableDictionary dictionary];
  self.invalidCells = [NSMutableArray array];
  m_sections.clear();
  m_cells.clear();

  m_sections.push_back(MWMEditorSectionCategory);
  m_cells[MWMEditorSectionCategory] = kSectionCategoryCellTypes;
  registerCellsForTableView(kSectionCategoryCellTypes, self.tableView);
  BOOL const isNameEditable = m_mapObject.IsNameEditable();
  BOOL const isAddressEditable = m_mapObject.IsAddressEditable();
  BOOL const areEditablePropertiesEmpty = m_mapObject.GetEditableProperties().empty();
  BOOL const isCreating = self.isCreating;
  BOOL const isThereNotes =
      !isCreating && areEditablePropertiesEmpty && !isAddressEditable && !isNameEditable;

  if (isNameEditable)
  {
    auto const ds = m_mapObject.GetNamesDataSource();
    auto const & localizedNames = ds.names;
    cleanupAdditionalLanguages(localizedNames, m_newAdditionalLanguages);
    auto const cells =
        cellsForAdditionalNames(ds, m_newAdditionalLanguages, self.showAdditionalNames);
    m_sections.push_back(MWMEditorSectionAdditionalNames);
    m_cells[MWMEditorSectionAdditionalNames] = cells;
    registerCellsForTableView(cells, self.tableView);
    [self.additionalNamesHeader setAdditionalNamesVisible:cells.size() > ds.mandatoryNamesCount + 1];
  }

  if (isAddressEditable)
  {
    m_sections.push_back(MWMEditorSectionAddress);
    m_cells[MWMEditorSectionAddress] = kSectionAddressCellTypes;
    if (m_mapObject.IsBuilding() && !m_mapObject.IsPointType())
      m_cells[MWMEditorSectionAddress].push_back(MWMEditorCellTypeBuildingLevels);

    registerCellsForTableView(kSectionAddressCellTypes, self.tableView);
  }

  if (!areEditablePropertiesEmpty)
  {
    auto const cells = cellsForProperties(m_mapObject.GetEditableProperties());
    if (!cells.empty())
    {
      m_sections.push_back(MWMEditorSectionDetails);
      m_cells[MWMEditorSectionDetails] = cells;
      registerCellsForTableView(cells, self.tableView);
    }
  }

  if (isThereNotes)
  {
    m_sections.push_back(MWMEditorSectionNote);
    m_cells[MWMEditorSectionNote] = kSectionNoteCellTypes;
    registerCellsForTableView(kSectionNoteCellTypes, self.tableView);
  }

  if (isCreating)
    return;
  m_sections.push_back(MWMEditorSectionButton);
  m_cells[MWMEditorSectionButton] = kSectionButtonCellTypes;
  registerCellsForTableView(kSectionButtonCellTypes, self.tableView);
}

- (MWMEditorCellType)cellTypeForIndexPath:(NSIndexPath *)indexPath
{
  return m_cells[m_sections[indexPath.section]][indexPath.row];
}

- (Class)cellClassForIndexPath:(NSIndexPath *)indexPath
{
  return cellClass([self cellTypeForIndexPath:indexPath]);
}

#pragma mark - Fill cells with data

- (void)fillCell:(UITableViewCell * _Nonnull)cell atIndexPath:(NSIndexPath * _Nonnull)indexPath
{
  BOOL const isValid = ![self.invalidCells containsObject:indexPath];
  switch ([self cellTypeForIndexPath:indexPath])
  {
  case MWMEditorCellTypeCategory:
  {
    auto types = m_mapObject.GetTypes();
    types.SortBySpec();
    auto const readableType = classif().GetReadableObjectName(*(types.begin()));
    MWMEditorCategoryCell * cCell = static_cast<MWMEditorCategoryCell *>(cell);
    [cCell configureWithDelegate:self
                     detailTitle:@(platform::GetLocalizedTypeName(readableType).c_str())
                      isCreating:self.isCreating];
    break;
  }
  case MWMEditorCellTypePhoneNumber:
  {
    MWMEditorTextTableViewCell * tCell = static_cast<MWMEditorTextTableViewCell *>(cell);
    [tCell configWithDelegate:self
                         icon:[UIImage imageNamed:@"ic_placepage_phone_number"]
                         text:@(m_mapObject.GetPhone().c_str())
                  placeholder:L(@"phone")
                 errorMessage:L(@"error_enter_correct_phone")
                      isValid:isValid
                 keyboardType:UIKeyboardTypeNamePhonePad
               capitalization:UITextAutocapitalizationTypeNone];
    break;
  }
  case MWMEditorCellTypeWebsite:
  {
    MWMEditorTextTableViewCell * tCell = static_cast<MWMEditorTextTableViewCell *>(cell);
    [tCell configWithDelegate:self
                         icon:[UIImage imageNamed:@"ic_placepage_website"]
                         text:@(m_mapObject.GetWebsite().c_str())
                  placeholder:L(@"website")
                 errorMessage:L(@"error_enter_correct_web")
                      isValid:isValid
                 keyboardType:UIKeyboardTypeURL
               capitalization:UITextAutocapitalizationTypeNone];
    break;
  }
  case MWMEditorCellTypeEmail:
  {
    MWMEditorTextTableViewCell * tCell = static_cast<MWMEditorTextTableViewCell *>(cell);
    [tCell configWithDelegate:self
                         icon:[UIImage imageNamed:@"ic_placepage_email"]
                         text:@(m_mapObject.GetEmail().c_str())
                  placeholder:L(@"email")
                 errorMessage:L(@"error_enter_correct_email")
                      isValid:isValid
                 keyboardType:UIKeyboardTypeEmailAddress
               capitalization:UITextAutocapitalizationTypeNone];
    break;
  }
  case MWMEditorCellTypeOperator:
  {
    MWMEditorTextTableViewCell * tCell = static_cast<MWMEditorTextTableViewCell *>(cell);
    [tCell configWithDelegate:self
                         icon:[UIImage imageNamed:@"ic_operator"]
                         text:@(m_mapObject.GetOperator().c_str())
                  placeholder:L(@"editor_operator")
                 keyboardType:UIKeyboardTypeDefault
               capitalization:UITextAutocapitalizationTypeSentences];
    break;
  }
  case MWMEditorCellTypeOpenHours:
  {
    MWMPlacePageOpeningHoursCell * tCell = static_cast<MWMPlacePageOpeningHoursCell *>(cell);
    NSString * text = @(m_mapObject.GetOpeningHours().c_str());
    [tCell configWithDelegate:self info:(text.length ? text : L(@"add_opening_hours"))];
    break;
  }
  case MWMEditorCellTypeWiFi:
  {
    MWMEditorSwitchTableViewCell * tCell = static_cast<MWMEditorSwitchTableViewCell *>(cell);
    // TODO(Vlad, IgorTomko): Support all other possible Internet statuses.
    [tCell configWithDelegate:self
                         icon:[UIImage imageNamed:@"ic_placepage_wifi"]
                         text:L(@"wifi")
                           on:m_mapObject.GetInternet() == osm::Internet::Wlan];
    break;
  }
  case MWMEditorCellTypeAdditionalName:
  {
    MWMEditorAdditionalNameTableViewCell * tCell =
        static_cast<MWMEditorAdditionalNameTableViewCell *>(cell);

    // When default name is added - remove fake names from datasource.
    auto const it = std::find(m_newAdditionalLanguages.begin(), m_newAdditionalLanguages.end(),
                              StringUtf8Multilang::kDefaultCode);
    auto const needFakes = it == m_newAdditionalLanguages.end();
    auto const & localizedNames = m_mapObject.GetNamesDataSource(needFakes).names;

    if (indexPath.row < localizedNames.size())
    {
      osm::LocalizedName const & name = localizedNames[indexPath.row];
      [tCell configWithDelegate:self
                       langCode:name.m_code
                       langName:@(name.m_langName)
                           name:@(name.m_name.c_str())
                   errorMessage:L(@"error_enter_correct_name")
                        isValid:isValid
                   keyboardType:UIKeyboardTypeDefault];
    }
    else
    {
      NSInteger const newAdditionalNameIndex = indexPath.row - localizedNames.size();
      NSInteger const langCode = m_newAdditionalLanguages[newAdditionalNameIndex];

      string name;
      // Default name can be changed in advanced mode.
      if (langCode == StringUtf8Multilang::kDefaultCode)
      {
        name = m_mapObject.GetDefaultName();
        m_mapObject.EnableNamesAdvancedMode();
      }

      [tCell configWithDelegate:self
                       langCode:langCode
                       langName:@(StringUtf8Multilang::GetLangNameByCode(langCode))
                           name:@(name.c_str())
                   errorMessage:L(@"error_enter_correct_name")
                        isValid:isValid
                   keyboardType:UIKeyboardTypeDefault];
    }
    break;
  }
  case MWMEditorCellTypeAddAdditionalName:
  {
    MWMEditorAddAdditionalNameTableViewCell * tCell =
        static_cast<MWMEditorAddAdditionalNameTableViewCell *>(cell);
    [tCell configWithDelegate:self];
    break;
  }
  case MWMEditorCellTypeAddAdditionalNamePlaceholder: break;
  case MWMEditorCellTypeStreet:
  {
    MWMEditorSelectTableViewCell * tCell = static_cast<MWMEditorSelectTableViewCell *>(cell);
    [tCell configWithDelegate:self
                         icon:[UIImage imageNamed:@"ic_placepage_adress"]
                         text:@(m_mapObject.GetStreet().m_defaultName.c_str())
                  placeholder:L(@"add_street")];
    break;
  }
  case MWMEditorCellTypeBuilding:
  {
    MWMEditorTextTableViewCell * tCell = static_cast<MWMEditorTextTableViewCell *>(cell);
    [tCell configWithDelegate:self
                         icon:nil
                         text:@(m_mapObject.GetHouseNumber().c_str())
                  placeholder:L(@"house_number")
                 errorMessage:L(@"error_enter_correct_house_number")
                      isValid:isValid
                 keyboardType:UIKeyboardTypeDefault
               capitalization:UITextAutocapitalizationTypeNone];
    break;
  }
  case MWMEditorCellTypeZipCode:
  {
    MWMEditorTextTableViewCell * tCell = static_cast<MWMEditorTextTableViewCell *>(cell);
    [tCell configWithDelegate:self
                         icon:nil
                         text:@(m_mapObject.GetPostcode().c_str())
                  placeholder:L(@"editor_zip_code")
                 errorMessage:L(@"error_enter_correct_zip_code")
                      isValid:isValid
                 keyboardType:UIKeyboardTypeDefault
               capitalization:UITextAutocapitalizationTypeAllCharacters];
    break;
  }
  case MWMEditorCellTypeBuildingLevels:
  {
    NSString * placeholder =
        [NSString stringWithFormat:L(@"editor_storey_number"),
                                   osm::EditableMapObject::kMaximumLevelsEditableByUsers];
    NSString * errorMessage =
        [NSString stringWithFormat:L(@"error_enter_correct_storey_number"),
                                   osm::EditableMapObject::kMaximumLevelsEditableByUsers];
    MWMEditorTextTableViewCell * tCell = static_cast<MWMEditorTextTableViewCell *>(cell);
    [tCell configWithDelegate:self
                         icon:nil
                         text:@(m_mapObject.GetBuildingLevels().c_str())
                  placeholder:placeholder
                 errorMessage:errorMessage
                      isValid:isValid
                 keyboardType:UIKeyboardTypeNumberPad
               capitalization:UITextAutocapitalizationTypeNone];
    break;
  }
  case MWMEditorCellTypeCuisine:
  {
    MWMEditorSelectTableViewCell * tCell = static_cast<MWMEditorSelectTableViewCell *>(cell);
    [tCell configWithDelegate:self
                         icon:[UIImage imageNamed:@"ic_placepage_cuisine"]
                         text:@(m_mapObject.FormatCuisines().c_str())
                  placeholder:L(@"select_cuisine")];
    break;
  }
  case MWMEditorCellTypeNote:
  {
    MWMNoteCell * tCell = static_cast<MWMNoteCell *>(cell);
    [tCell configWithDelegate:self
                     noteText:self.note
                  placeholder:L(@"editor_detailed_description_hint")];
    break;
  }
  case MWMEditorCellTypeReportButton:
  {
    MWMButtonCell * tCell = static_cast<MWMButtonCell *>(cell);

    auto title = ^NSString *(FeatureStatus s, BOOL isUploaded)
    {
      if (isUploaded)
        return L(@"editor_place_doesnt_exist");
      switch (s)
      {
      case FeatureStatus::Untouched: return L(@"editor_place_doesnt_exist");
      case FeatureStatus::Deleted:
      case FeatureStatus::Obsolete:  // TODO(Vlad): Either make a valid button or disable it.
        NSAssert(false, @"Incorrect feature status!");
        return L(@"editor_place_doesnt_exist");
      case FeatureStatus::Modified: return L(@"editor_reset_edits_button");
      case FeatureStatus::Created: return L(@"editor_remove_place_button");
      }
    };

    [tCell configureWithDelegate:self title:title(self.featureStatus, self.isFeatureUploaded)];
    break;
  }
  default: NSAssert(false, @"Invalid field for editor"); break;
  }
}

#pragma mark - UITableViewDataSource

- (UITableViewCell * _Nonnull)tableView:(UITableView * _Nonnull)tableView
                  cellForRowAtIndexPath:(NSIndexPath * _Nonnull)indexPath
{
  Class cls = [self cellClassForIndexPath:indexPath];
  auto cell = [tableView dequeueReusableCellWithCellClass:cls indexPath:indexPath];
  [self fillCell:cell atIndexPath:indexPath];
  return cell;
}

- (NSInteger)numberOfSectionsInTableView:(UITableView * _Nonnull)tableView
{
  return m_sections.size();
}

- (NSInteger)tableView:(UITableView * _Nonnull)tableView numberOfRowsInSection:(NSInteger)section
{
  return m_cells[m_sections[section]].size();
}

#pragma mark - UITableViewDelegate

- (CGFloat)tableView:(UITableView * _Nonnull)tableView
    heightForRowAtIndexPath:(NSIndexPath * _Nonnull)indexPath
{
  Class cls = [self cellClassForIndexPath:indexPath];
  auto cell = [self offscreenCellForClass:cls];
  [self fillCell:cell atIndexPath:indexPath];
  MWMEditorCellType const cellType = [self cellTypeForIndexPath:indexPath];
  switch (cellType)
  {
  case MWMEditorCellTypeOpenHours: return ((MWMPlacePageOpeningHoursCell *)cell).cellHeight;
  case MWMEditorCellTypeCategory:
  case MWMEditorCellTypeReportButton: return self.tableView.rowHeight;
  case MWMEditorCellTypeNote: return static_cast<MWMNoteCell *>(cell).cellHeight;
  default:
  {
    [cell setNeedsUpdateConstraints];
    [cell updateConstraintsIfNeeded];
    cell.bounds = {{}, {CGRectGetWidth(tableView.bounds), CGRectGetHeight(cell.bounds)}};
    [cell setNeedsLayout];
    [cell layoutIfNeeded];
    CGSize const size =
        [cell.contentView systemLayoutSizeFittingSize:UILayoutFittingCompressedSize];
    return size.height;
  }
  }
}

- (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section
{
  switch (m_sections[section])
  {
  case MWMEditorSectionAdditionalNames:
  case MWMEditorSectionCategory:
  case MWMEditorSectionButton: return nil;
  case MWMEditorSectionNote: return L(@"editor_other_info");
  case MWMEditorSectionAddress: return L(@"address");
  case MWMEditorSectionDetails: return L(@"details");
  }
}

- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
{
  switch (m_sections[section])
  {
  case MWMEditorSectionAdditionalNames: return self.additionalNamesHeader;
  case MWMEditorSectionCategory:
  case MWMEditorSectionButton:
  case MWMEditorSectionNote:
  case MWMEditorSectionAddress:
  case MWMEditorSectionDetails: return nil;
  }
}

- (UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section
{
  switch (m_sections[section])
  {
  case MWMEditorSectionAddress:
  case MWMEditorSectionCategory:
  case MWMEditorSectionAdditionalNames:
  case MWMEditorSectionButton: return nil;
  case MWMEditorSectionDetails:
    if (find(m_sections.begin(), m_sections.end(), MWMEditorSectionNote) == m_sections.end())
      return self.notesFooter;
    return nil;
  case MWMEditorSectionNote: return self.notesFooter;
  }
}

- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
{
  return kDefaultHeaderHeight;
}

- (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section
{
  switch (m_sections[section])
  {
  case MWMEditorSectionAddress:
      return 1.0;
  case MWMEditorSectionDetails:
    if (find(m_sections.begin(), m_sections.end(), MWMEditorSectionNote) == m_sections.end())
      return self.notesFooter.height;
    return 1.0;
  case MWMEditorSectionNote: return self.notesFooter.height;
  case MWMEditorSectionCategory:
  case MWMEditorSectionAdditionalNames:
  case MWMEditorSectionButton: return kDefaultFooterHeight;
  }
}

#pragma mark - MWMPlacePageOpeningHoursCellProtocol

- (BOOL)forcedButton { return YES; }
- (BOOL)isPlaceholder { return m_mapObject.GetOpeningHours().empty(); }
- (BOOL)isEditor { return YES; }
- (BOOL)openingHoursCellExpanded { return YES; }
- (void)setOpeningHoursCellExpanded:(BOOL)openingHoursCellExpanded
{
  [self performSegueWithIdentifier:kOpeningHoursEditorSegue sender:nil];
}

- (void)markCellAsInvalid:(NSIndexPath *)indexPath
{
  if (![self.invalidCells containsObject:indexPath])
    [self.invalidCells addObject:indexPath];

  [self.tableView reloadRowsAtIndexPaths:@[ indexPath ]
                        withRowAnimation:UITableViewRowAnimationFade];
}

#pragma mark - MWMNoteCellDelegate

- (void)cellShouldChangeSize:(MWMNoteCell *)cell text:(NSString *)text
{
  self.offscreenCells[cellClass(MWMEditorCellTypeNote)] = cell;
  self.note = text;
  [self.tableView refresh];
  NSIndexPath * ip = [self.tableView indexPathForCell:cell];
  [self.tableView scrollToRowAtIndexPath:ip
                        atScrollPosition:UITableViewScrollPositionBottom
                                animated:YES];
}

- (void)cell:(MWMNoteCell *)cell didFinishEditingWithText:(NSString *)text { self.note = text; }
#pragma mark - MWMEditorAdditionalName

- (void)editAdditionalNameLanguage:(NSInteger)selectedLangCode
{
  [self performSegueWithIdentifier:kAdditionalNamesEditorSegue sender:@(selectedLangCode)];
}

#pragma mark - MWMEditorAdditionalNamesProtocol

- (void)addAdditionalName:(NSInteger)languageIndex
{
  m_newAdditionalLanguages.push_back(languageIndex);
  self.showAdditionalNames = YES;
  auto additionalNamesSectionIt =
      find(m_sections.begin(), m_sections.end(), MWMEditorSectionAdditionalNames);
  assert(additionalNamesSectionIt != m_sections.end());
  auto const section = distance(m_sections.begin(), additionalNamesSectionIt);
  NSInteger const row = [self tableView:self.tableView numberOfRowsInSection:section];
  assert(row > 0);
  NSIndexPath * indexPath = [NSIndexPath indexPathForRow:row - 1 inSection:section];
  [self.tableView scrollToRowAtIndexPath:indexPath
                        atScrollPosition:UITableViewScrollPositionMiddle
                                animated:NO];
}

#pragma mark - MWMEditorCellProtocol

- (void)tryToChangeInvalidStateForCell:(MWMTableViewCell *)cell
{
  [self.tableView update:^{
    NSIndexPath * indexPath = [self.tableView indexPathForCell:cell];
    [self.invalidCells removeObject:indexPath];
  }];
}

- (void)cell:(MWMTableViewCell *)cell changedText:(NSString *)changeText
{
  NSAssert(changeText != nil, @"String can't be nil!");
  NSIndexPath * indexPath = [self.tableView indexPathForRowAtPoint:cell.center];
  MWMEditorCellType const cellType = [self cellTypeForIndexPath:indexPath];
  string const val = changeText.UTF8String;
  BOOL isFieldValid = YES;
  switch (cellType)
  {
  case MWMEditorCellTypePhoneNumber:
    m_mapObject.SetPhone(val);
    isFieldValid = osm::EditableMapObject::ValidatePhoneList(val);
    break;
  case MWMEditorCellTypeWebsite:
    m_mapObject.SetWebsite(val);
    isFieldValid = osm::EditableMapObject::ValidateWebsite(val);
    break;
  case MWMEditorCellTypeEmail:
    m_mapObject.SetEmail(val);
    isFieldValid = osm::EditableMapObject::ValidateEmail(val);
    break;
  case MWMEditorCellTypeOperator: m_mapObject.SetOperator(val); break;
  case MWMEditorCellTypeBuilding:
    m_mapObject.SetHouseNumber(val);
    isFieldValid = osm::EditableMapObject::ValidateHouseNumber(val);
    break;
  case MWMEditorCellTypeZipCode:
    m_mapObject.SetPostcode(val);
    isFieldValid = osm::EditableMapObject::ValidatePostCode(val);
    break;
  case MWMEditorCellTypeBuildingLevels:
    m_mapObject.SetBuildingLevels(val);
    isFieldValid = osm::EditableMapObject::ValidateBuildingLevels(val);
    break;
  case MWMEditorCellTypeAdditionalName:
    m_mapObject.SetName(val, static_cast<MWMEditorAdditionalNameTableViewCell *>(cell).code);
    isFieldValid = osm::EditableMapObject::ValidateName(val);
    break;
  default: NSAssert(false, @"Invalid field for changeText");
  }
  if (!isFieldValid)
    [self markCellAsInvalid:indexPath];
}

- (void)cell:(UITableViewCell *)cell changeSwitch:(BOOL)changeSwitch
{
  NSIndexPath * indexPath = [self.tableView indexPathForCell:cell];
  MWMEditorCellType const cellType = [self cellTypeForIndexPath:indexPath];
  switch (cellType)
  {
  case MWMEditorCellTypeWiFi:
    m_mapObject.SetInternet(changeSwitch ? osm::Internet::Wlan : osm::Internet::Unknown);
    break;
  default: NSAssert(false, @"Invalid field for changeSwitch"); break;
  }
}

#pragma mark - MWMEditorCellProtocol && MWMButtonCellDelegate

- (void)cellSelect:(UITableViewCell *)cell
{
  NSIndexPath * indexPath = [self.tableView indexPathForCell:cell];
  MWMEditorCellType const cellType = [self cellTypeForIndexPath:indexPath];
  switch (cellType)
  {
  case MWMEditorCellTypeStreet:
    [self performSegueWithIdentifier:kStreetEditorSegue sender:nil];
    break;
  case MWMEditorCellTypeCuisine:
    [self performSegueWithIdentifier:kCuisineEditorSegue sender:nil];
    break;
  case MWMEditorCellTypeCategory:
    [self performSegueWithIdentifier:kCategoryEditorSegue sender:nil];
    break;
  case MWMEditorCellTypeReportButton: [self tapOnButtonCell:cell]; break;
  default: NSAssert(false, @"Invalid field for cellSelect"); break;
  }
}

- (void)tapOnButtonCell:(UITableViewCell *)cell
{
  auto const & fid = m_mapObject.GetID();
  auto const latLon = m_mapObject.GetLatLon();
  CLLocation * location = [[CLLocation alloc] initWithLatitude:latLon.lat longitude:latLon.lon];
  self.isFeatureUploaded = osm::Editor::Instance().IsFeatureUploaded(fid.m_mwmId, fid.m_index);
  NSIndexPath * ip = [self.tableView indexPathForCell:cell];
  [self.tableView reloadRowsAtIndexPaths:@[ ip ] withRowAnimation:UITableViewRowAnimationFade];

  auto placeDoesntExistAction = ^{
    [self.alertController presentPlaceDoesntExistAlertWithBlock:^(NSString * additionalMessage) {
      string const additional = additionalMessage.length ? additionalMessage.UTF8String : "";
      [Statistics logEvent:kStatEditorProblemReport
            withParameters:@{
              kStatEditorMWMName : @(fid.GetMwmName().c_str()),
              kStatEditorMWMVersion : @(fid.GetMwmVersion()),
              kStatProblem : @(osm::Editor::kPlaceDoesNotExistMessage)
            }
                atLocation:location];
      GetFramework().CreateNote(self->m_mapObject, osm::Editor::NoteProblemType::PlaceDoesNotExist,
                                additional);
      [self goBack];
      [self showDropDown];
    }];
  };

  auto revertAction = ^(BOOL isCreated) {
    [Statistics logEvent:isCreated ? kStatEditorAddCancel : kStatEditorEditCancel
          withParameters:@{
            kStatEditorMWMName : @(fid.GetMwmName().c_str()),
            kStatEditorMWMVersion : @(fid.GetMwmVersion())
          }
              atLocation:location];
    auto & f = GetFramework();
    if (!f.RollBackChanges(fid))
      NSAssert(false, @"We shouldn't call this if we can't roll back!");

    f.PokeSearchInViewport();
    [self goBack];
  };

  if (self.isFeatureUploaded)
  {
    placeDoesntExistAction();
  }
  else
  {
    switch (self.featureStatus)
    {
    case FeatureStatus::Untouched: placeDoesntExistAction(); break;
    case FeatureStatus::Modified:
    {
      [self.alertController presentResetChangesAlertWithBlock:^{
        revertAction(NO);
      }];
      break;
    }
    case FeatureStatus::Created:
    {
      [self.alertController presentDeleteFeatureAlertWithBlock:^{
        revertAction(YES);
      }];
      break;
    }
    case FeatureStatus::Deleted: break;
    case FeatureStatus::Obsolete: break;
    }
  }
}

#pragma mark - MWMOpeningHoursEditorProtocol

- (void)setOpeningHours:(NSString *)openingHours
{
  m_mapObject.SetOpeningHours(openingHours.UTF8String);
}

#pragma mark - MWMObjectsCategorySelectorDelegate

- (void)reloadObject:(osm::EditableMapObject const &)object
{
  [self setEditableMapObject:object];
  [self configTable];
}

#pragma mark - MWMCuisineEditorProtocol

- (vector<string>)selectedCuisines { return m_mapObject.GetCuisines(); }
- (void)setSelectedCuisines:(vector<string> const &)cuisines { m_mapObject.SetCuisines(cuisines); }
#pragma mark - MWMStreetEditorProtocol

- (void)setNearbyStreet:(osm::LocalizedStreet const &)street { m_mapObject.SetStreet(street); }
- (osm::LocalizedStreet const &)currentStreet { return m_mapObject.GetStreet(); }
- (vector<osm::LocalizedStreet> const &)nearbyStreets { return m_mapObject.GetNearbyStreets(); }
#pragma mark - Segue

- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
  if ([segue.identifier isEqualToString:kOpeningHoursEditorSegue])
  {
    MWMOpeningHoursEditorViewController * dvc = segue.destinationViewController;
    dvc.openingHours = @(m_mapObject.GetOpeningHours().c_str());
    dvc.delegate = self;
  }
  else if ([segue.identifier isEqualToString:kCuisineEditorSegue])
  {
    MWMCuisineEditorViewController * dvc = segue.destinationViewController;
    dvc.delegate = self;
  }
  else if ([segue.identifier isEqualToString:kStreetEditorSegue])
  {
    MWMStreetEditorViewController * dvc = segue.destinationViewController;
    dvc.delegate = self;
  }
  else if ([segue.identifier isEqualToString:kCategoryEditorSegue])
  {
    NSAssert(self.isCreating, @"Invalid state! We'll be able to change feature category only if we "
                              @"are creating feature!");
    MWMObjectsCategorySelectorController * dvc = segue.destinationViewController;
    dvc.delegate = self;
    auto const type = *(m_mapObject.GetTypes().begin());
    auto const readableType = classif().GetReadableObjectName(type);
    [dvc setSelectedCategory:readableType];
  }
  else if ([segue.identifier isEqualToString:kAdditionalNamesEditorSegue])
  {
    MWMEditorAdditionalNamesTableViewController * dvc = segue.destinationViewController;
    [dvc configWithDelegate:self
                               name:m_mapObject.GetNameMultilang()
        additionalSkipLanguageCodes:m_newAdditionalLanguages
               selectedLanguageCode:((NSNumber *)sender).integerValue];
  }
}

#pragma mark - Alert

- (BOOL)showPersonalInfoWarningAlertIfNeeded
{
  NSUserDefaults * ud = NSUserDefaults.standardUserDefaults;
  if ([ud boolForKey:kUDEditorPersonalInfoWarninWasShown])
    return NO;

  [self.alertController presentPersonalInfoWarningAlertWithBlock:^
  {
    [ud setBool:YES forKey:kUDEditorPersonalInfoWarninWasShown];
    [ud synchronize];
    [self onSave];
  }];

  return YES;
}

@end