forked from organicmaps/organicmaps
[ios] Added street editor.
This commit is contained in:
parent
0b767c36ed
commit
a04b216c15
17 changed files with 424 additions and 44 deletions
|
@ -31,7 +31,7 @@ namespace
|
|||
|
||||
- (void)configNavBar
|
||||
{
|
||||
self.title = L(@"edit_poi");
|
||||
self.title = L(@"cuisine");
|
||||
self.navigationItem.leftBarButtonItem =
|
||||
[[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemCancel
|
||||
target:self
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
@protocol MWMEditorCellProtocol <NSObject>
|
||||
|
||||
- (void)actionForCell:(UITableViewCell *)cell;
|
||||
- (void)cell:(UITableViewCell *)cell changeText:(NSString *)changeText;
|
||||
- (void)cell:(UITableViewCell *)cell changeSwitch:(BOOL)changeSwitch;
|
||||
- (void)cellSelect:(UITableViewCell *)cell;
|
||||
|
||||
@end
|
||||
|
|
|
@ -40,7 +40,7 @@
|
|||
|
||||
- (IBAction)selectAction
|
||||
{
|
||||
[self.delegate actionForCell:self];
|
||||
[self.delegate cellSelect:self];
|
||||
}
|
||||
|
||||
@end
|
||||
|
|
|
@ -2,8 +2,6 @@
|
|||
|
||||
@interface MWMEditorSwitchTableViewCell : UITableViewCell
|
||||
|
||||
@property (nonatomic, readonly) BOOL on;
|
||||
|
||||
- (void)configWithDelegate:(id<MWMEditorCellProtocol>)delegate
|
||||
icon:(UIImage *)icon
|
||||
text:(NSString *)text
|
||||
|
|
|
@ -28,14 +28,7 @@
|
|||
|
||||
- (IBAction)valueChanged
|
||||
{
|
||||
[self.delegate actionForCell:self];
|
||||
}
|
||||
|
||||
#pragma mark - Properties
|
||||
|
||||
- (BOOL)on
|
||||
{
|
||||
return self.switchControl.on;
|
||||
[self.delegate cell:self changeSwitch:self.switchControl.on];
|
||||
}
|
||||
|
||||
@end
|
||||
|
|
|
@ -2,8 +2,6 @@
|
|||
|
||||
@interface MWMEditorTextTableViewCell : UITableViewCell
|
||||
|
||||
@property (nonatomic, readonly) NSString * text;
|
||||
|
||||
- (void)configWithDelegate:(id<MWMEditorCellProtocol>)delegate
|
||||
icon:(UIImage *)icon
|
||||
text:(NSString *)text
|
||||
|
|
|
@ -33,11 +33,10 @@
|
|||
shouldChangeCharactersInRange:(NSRange)range
|
||||
replacementString:(NSString *)string
|
||||
{
|
||||
NSString * newString =
|
||||
[textField.text stringByReplacingCharactersInRange:range withString:string];
|
||||
NSString * newString = [textField.text stringByReplacingCharactersInRange:range withString:string];
|
||||
BOOL const isCorrect = [textField.validator validateString:newString];
|
||||
if (isCorrect)
|
||||
[self.delegate actionForCell:self];
|
||||
[self.delegate cell:self changeText:newString];
|
||||
return YES;
|
||||
}
|
||||
|
||||
|
|
|
@ -7,11 +7,17 @@
|
|||
#import "MWMEditorViewController.h"
|
||||
#import "MWMOpeningHoursEditorViewController.h"
|
||||
#import "MWMPlacePageOpeningHoursCell.h"
|
||||
#import "MWMStreetEditorViewController.h"
|
||||
|
||||
#include "std/algorithm.hpp"
|
||||
|
||||
namespace
|
||||
{
|
||||
|
||||
NSString * const kOpeningHoursEditorSegue = @"Editor2OpeningHoursEditorSegue";
|
||||
NSString * const kCuisineEditorSegue = @"Editor2CuisineEditorSegue";
|
||||
NSString * const kStreetEditorSegue = @"Editor2StreetEditorSegue";
|
||||
|
||||
typedef NS_ENUM(NSUInteger, MWMEditorSection)
|
||||
{
|
||||
MWMEditorSectionName,
|
||||
|
@ -57,12 +63,10 @@ NSString * reuseIdentifier(MWMPlacePageCellType cellType)
|
|||
}
|
||||
} // namespace
|
||||
|
||||
static NSString * const kOpeningHoursEditorSegue = @"Editor2OpeningHoursEditorSegue";
|
||||
static NSString * const kCuisineEditorSegue = @"Editor2CuisineEditorSegue";
|
||||
|
||||
@interface MWMEditorViewController ()<UITableViewDelegate, UITableViewDataSource,
|
||||
UITextFieldDelegate, MWMPlacePageOpeningHoursCellProtocol,
|
||||
MWMEditorCellProtocol, MWMCuisineEditorProtocol>
|
||||
MWMEditorCellProtocol, MWMCuisineEditorProtocol,
|
||||
MWMStreetEditorProtocol>
|
||||
|
||||
@property (weak, nonatomic) IBOutlet UITableView * tableView;
|
||||
|
||||
|
@ -150,6 +154,8 @@ static NSString * const kCuisineEditorSegue = @"Editor2CuisineEditorSegue";
|
|||
|
||||
- (void)setCell:(MWMPlacePageCellType)cellType value:(NSString *)value
|
||||
{
|
||||
if ([value isEqualToString:[self getCellValue:cellType]])
|
||||
return;
|
||||
self.needsReload = YES;
|
||||
m_edited_cells[cellType] = value.UTF8String;
|
||||
}
|
||||
|
@ -195,8 +201,18 @@ static NSString * const kCuisineEditorSegue = @"Editor2CuisineEditorSegue";
|
|||
|
||||
- (BOOL)isLastCellInSection:(NSIndexPath *)indexPath
|
||||
{
|
||||
MWMEditorSection const section = m_sections[indexPath.section];
|
||||
return m_cells[section].size() - 1 == indexPath.row;
|
||||
NSUInteger const row = indexPath.row;
|
||||
NSUInteger const section = indexPath.section;
|
||||
NSUInteger const rowsInSection = m_cells[m_sections[section]].size();
|
||||
BOOL const isLastCell = rowsInSection - 1 == row;
|
||||
if (isLastCell)
|
||||
return YES;
|
||||
BOOL const isPenultimateCell = rowsInSection - 2 == row;
|
||||
if (!isPenultimateCell)
|
||||
return NO;
|
||||
NSIndexPath * lastIndexPath = [NSIndexPath indexPathForRow:row + 1 inSection:section];
|
||||
BOOL const isLastCellSeparator = ([self cellTypeForIndexPath:lastIndexPath] == MWMPlacePageCellTypeSpacer);
|
||||
return isLastCellSeparator;
|
||||
}
|
||||
|
||||
#pragma mark - Fill cells with data
|
||||
|
@ -415,7 +431,7 @@ static NSString * const kCuisineEditorSegue = @"Editor2CuisineEditorSegue";
|
|||
|
||||
#pragma mark - MWMEditorCellProtocol
|
||||
|
||||
- (void)actionForCell:(UITableViewCell *)cell
|
||||
- (void)cell:(UITableViewCell *)cell changeText:(NSString *)changeText
|
||||
{
|
||||
NSIndexPath * indexPath = [self.tableView indexPathForCell:cell];
|
||||
MWMPlacePageCellType const cellType = [self cellTypeForIndexPath:indexPath];
|
||||
|
@ -426,30 +442,47 @@ static NSString * const kCuisineEditorSegue = @"Editor2CuisineEditorSegue";
|
|||
case MWMPlacePageCellTypeWebsite:
|
||||
case MWMPlacePageCellTypeEmail:
|
||||
case MWMPlacePageCellTypeBuilding:
|
||||
{
|
||||
NSString * editedFieldValue = ((MWMEditorTextTableViewCell *)cell).text;
|
||||
if (![editedFieldValue isEqualToString:[self getCellValue:cellType]])
|
||||
[self setCell:cellType value:editedFieldValue];
|
||||
[self setCell:cellType value:changeText];
|
||||
break;
|
||||
}
|
||||
default:
|
||||
NSAssert(false, @"Invalid field for changeText");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
- (void)cell:(UITableViewCell *)cell changeSwitch:(BOOL)changeSwitch
|
||||
{
|
||||
NSIndexPath * indexPath = [self.tableView indexPathForCell:cell];
|
||||
MWMPlacePageCellType const cellType = [self cellTypeForIndexPath:indexPath];
|
||||
switch (cellType)
|
||||
{
|
||||
case MWMPlacePageCellTypeWiFi:
|
||||
{
|
||||
BOOL const editedOn = ((MWMEditorSwitchTableViewCell *)cell).on;
|
||||
BOOL const on = ([self getCellValue:cellType] != nil);
|
||||
if (editedOn != on)
|
||||
[self setCell:cellType value:editedOn ? @"wlan" : @""];
|
||||
if (changeSwitch != on)
|
||||
[self setCell:cellType value:changeSwitch ? @"wlan" : @""];
|
||||
break;
|
||||
}
|
||||
default:
|
||||
NSAssert(false, @"Invalid field for changeSwitch");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
- (void)cellSelect:(UITableViewCell *)cell
|
||||
{
|
||||
NSIndexPath * indexPath = [self.tableView indexPathForCell:cell];
|
||||
MWMPlacePageCellType const cellType = [self cellTypeForIndexPath:indexPath];
|
||||
switch (cellType)
|
||||
{
|
||||
case MWMPlacePageCellTypeStreet:
|
||||
// TODO
|
||||
[self performSegueWithIdentifier:kStreetEditorSegue sender:nil];
|
||||
break;
|
||||
case MWMPlacePageCellTypeCuisine:
|
||||
[self performSegueWithIdentifier:kCuisineEditorSegue sender:nil];
|
||||
break;
|
||||
case MWMPlacePageCellTypeSpacer:
|
||||
break;
|
||||
default:
|
||||
NSAssert(false, @"Invalid field for editor");
|
||||
NSAssert(false, @"Invalid field for cellSelect");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -458,8 +491,7 @@ static NSString * const kCuisineEditorSegue = @"Editor2CuisineEditorSegue";
|
|||
|
||||
- (void)setOpeningHours:(NSString *)openingHours
|
||||
{
|
||||
if (![openingHours isEqualToString:[self getCellValue:MWMPlacePageCellTypeOpenHours]])
|
||||
[self setCell:MWMPlacePageCellTypeOpenHours value:openingHours];
|
||||
[self setCell:MWMPlacePageCellTypeOpenHours value:openingHours];
|
||||
}
|
||||
|
||||
#pragma mark - MWMCuisineEditorProtocol
|
||||
|
@ -480,6 +512,23 @@ static NSString * const kCuisineEditorSegue = @"Editor2CuisineEditorSegue";
|
|||
[self setCell:MWMPlacePageCellTypeCuisine value:updatedValue];
|
||||
}
|
||||
|
||||
#pragma mark - MWMStreetEditorProtocol
|
||||
|
||||
- (NSString *)getStreet
|
||||
{
|
||||
return [self getCellValue:MWMPlacePageCellTypeStreet];
|
||||
}
|
||||
|
||||
- (void)setStreet:(NSString *)street
|
||||
{
|
||||
[self setCell:MWMPlacePageCellTypeStreet value:street];
|
||||
}
|
||||
|
||||
- (NSArray<NSString *> *)getNearbyStreets
|
||||
{
|
||||
return self.entity.nearbyStreets;
|
||||
}
|
||||
|
||||
#pragma mark - Segue
|
||||
|
||||
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
|
||||
|
@ -495,6 +544,11 @@ static NSString * const kCuisineEditorSegue = @"Editor2CuisineEditorSegue";
|
|||
MWMCuisineEditorViewController * dvc = segue.destinationViewController;
|
||||
dvc.delegate = self;
|
||||
}
|
||||
else if ([segue.identifier isEqualToString:kStreetEditorSegue])
|
||||
{
|
||||
MWMStreetEditorViewController * dvc = segue.destinationViewController;
|
||||
dvc.delegate = self;
|
||||
}
|
||||
}
|
||||
|
||||
@end
|
||||
|
|
|
@ -0,0 +1,11 @@
|
|||
@protocol MWMStreetEditorCommonTableViewCellProtocol <NSObject>
|
||||
|
||||
- (void)selectCell:(UITableViewCell *)selectedCell;
|
||||
|
||||
@end
|
||||
|
||||
@interface MWMStreetEditorCommonTableViewCell : UITableViewCell
|
||||
|
||||
- (void)configWithDelegate:(id<MWMStreetEditorCommonTableViewCellProtocol>)delegate street:(NSString *)street selected:(BOOL)selected;
|
||||
|
||||
@end
|
|
@ -0,0 +1,29 @@
|
|||
#import "MWMStreetEditorCommonTableViewCell.h"
|
||||
|
||||
@interface MWMStreetEditorCommonTableViewCell ()
|
||||
|
||||
@property (weak, nonatomic) IBOutlet UILabel * label;
|
||||
@property (weak, nonatomic) IBOutlet UIImageView * selectedIcon;
|
||||
|
||||
@property (weak, nonatomic) id<MWMStreetEditorCommonTableViewCellProtocol> delegate;
|
||||
|
||||
@end
|
||||
|
||||
@implementation MWMStreetEditorCommonTableViewCell
|
||||
|
||||
- (void)configWithDelegate:(id<MWMStreetEditorCommonTableViewCellProtocol>)delegate street:(NSString *)street selected:(BOOL)selected
|
||||
{
|
||||
self.delegate = delegate;
|
||||
self.label.text = street;
|
||||
self.selectedIcon.hidden = !selected;
|
||||
}
|
||||
|
||||
#pragma mark - Actions
|
||||
|
||||
- (IBAction)selectAction
|
||||
{
|
||||
self.selectedIcon.hidden = !self.selectedIcon.hidden;
|
||||
[self.delegate selectCell:self];
|
||||
}
|
||||
|
||||
@end
|
|
@ -0,0 +1,11 @@
|
|||
@protocol MWMStreetEditorEditCellProtocol <NSObject>
|
||||
|
||||
- (void)editCellTextChanged:(NSString *)text;
|
||||
|
||||
@end
|
||||
|
||||
@interface MWMStreetEditorEditTableViewCell : UITableViewCell
|
||||
|
||||
- (void)configWithDelegate:(id<MWMStreetEditorEditCellProtocol>)delegate street:(NSString *)street;
|
||||
|
||||
@end
|
|
@ -0,0 +1,31 @@
|
|||
#import "MWMStreetEditorEditTableViewCell.h"
|
||||
#import "UITextField+RuntimeAttributes.h"
|
||||
|
||||
@interface MWMStreetEditorEditTableViewCell () <UITextFieldDelegate>
|
||||
|
||||
@property (weak, nonatomic) IBOutlet UITextField * textField;
|
||||
|
||||
@property (weak, nonatomic) id<MWMStreetEditorEditCellProtocol> delegate;
|
||||
|
||||
@end
|
||||
|
||||
@implementation MWMStreetEditorEditTableViewCell
|
||||
|
||||
- (void)configWithDelegate:(id<MWMStreetEditorEditCellProtocol>)delegate street:(NSString *)street
|
||||
{
|
||||
self.delegate = delegate;
|
||||
self.textField.text = street;
|
||||
}
|
||||
|
||||
#pragma mark - UITextFieldDelegate
|
||||
|
||||
- (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string
|
||||
{
|
||||
NSString * newString = [textField.text stringByReplacingCharactersInRange:range withString:string];
|
||||
BOOL const isCorrect = [textField.validator validateString:newString];
|
||||
if (isCorrect)
|
||||
[self.delegate editCellTextChanged:newString];
|
||||
return YES;
|
||||
}
|
||||
|
||||
@end
|
|
@ -0,0 +1,16 @@
|
|||
#import "ViewController.h"
|
||||
|
||||
@protocol MWMStreetEditorProtocol <NSObject>
|
||||
|
||||
- (NSString *)getStreet;
|
||||
- (void)setStreet:(NSString *)street;
|
||||
|
||||
- (NSArray<NSString *> *)getNearbyStreets;
|
||||
|
||||
@end
|
||||
|
||||
@interface MWMStreetEditorViewController : ViewController
|
||||
|
||||
@property (weak, nonatomic) id<MWMStreetEditorProtocol> delegate;
|
||||
|
||||
@end
|
|
@ -0,0 +1,180 @@
|
|||
#import "MWMStreetEditorCommonTableViewCell.h"
|
||||
#import "MWMStreetEditorEditTableViewCell.h"
|
||||
#import "MWMStreetEditorViewController.h"
|
||||
|
||||
namespace
|
||||
{
|
||||
NSString * const kStreetEditorCommonCell = @"MWMStreetEditorCommonTableViewCell";
|
||||
NSString * const kStreetEditorSpacerCell = @"MWMEditorSpacerCell";
|
||||
NSString * const kStreetEditorEditCell = @"MWMStreetEditorEditTableViewCell";
|
||||
} // namespace
|
||||
|
||||
@interface MWMStreetEditorViewController ()<UITableViewDelegate, UITableViewDataSource,
|
||||
MWMStreetEditorCommonTableViewCellProtocol,
|
||||
MWMStreetEditorEditCellProtocol>
|
||||
|
||||
@property (weak, nonatomic) IBOutlet UITableView * tableView;
|
||||
|
||||
@property (nonatomic) NSMutableArray<NSString *> * streets;
|
||||
|
||||
@property (nonatomic) NSUInteger selectedStreet;
|
||||
@property (nonatomic) NSUInteger lastSelectedStreet;
|
||||
|
||||
@property (nonatomic) NSString * editedStreetName;
|
||||
|
||||
@end
|
||||
|
||||
@implementation MWMStreetEditorViewController
|
||||
|
||||
- (void)viewDidLoad
|
||||
{
|
||||
[super viewDidLoad];
|
||||
[self configNavBar];
|
||||
[self configData];
|
||||
[self configTable];
|
||||
}
|
||||
|
||||
#pragma mark - Configuration
|
||||
|
||||
- (void)configNavBar
|
||||
{
|
||||
self.title = L(@"street");
|
||||
self.navigationItem.leftBarButtonItem =
|
||||
[[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemCancel
|
||||
target:self
|
||||
action:@selector(onCancel)];
|
||||
self.navigationItem.rightBarButtonItem =
|
||||
[[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemDone
|
||||
target:self
|
||||
action:@selector(onDone)];
|
||||
self.navigationController.navigationBar.barStyle = UIBarStyleBlack;
|
||||
}
|
||||
|
||||
- (void)configData
|
||||
{
|
||||
self.streets = [[self.delegate getNearbyStreets] mutableCopy];
|
||||
NSString * currentStreet = [self.delegate getStreet];
|
||||
if (currentStreet)
|
||||
{
|
||||
[self.streets removeObject:currentStreet];
|
||||
[self.streets insertObject:currentStreet atIndex:0];
|
||||
}
|
||||
self.editedStreetName = @"";
|
||||
self.selectedStreet = 0;
|
||||
}
|
||||
|
||||
- (void)configTable
|
||||
{
|
||||
[self.tableView registerNib:[UINib nibWithNibName:kStreetEditorCommonCell bundle:nil]
|
||||
forCellReuseIdentifier:kStreetEditorCommonCell];
|
||||
[self.tableView registerNib:[UINib nibWithNibName:kStreetEditorSpacerCell bundle:nil]
|
||||
forCellReuseIdentifier:kStreetEditorSpacerCell];
|
||||
[self.tableView registerNib:[UINib nibWithNibName:kStreetEditorEditCell bundle:nil]
|
||||
forCellReuseIdentifier:kStreetEditorEditCell];
|
||||
}
|
||||
|
||||
#pragma mark - Actions
|
||||
|
||||
- (void)onCancel
|
||||
{
|
||||
[self.navigationController popViewControllerAnimated:YES];
|
||||
}
|
||||
|
||||
- (void)onDone
|
||||
{
|
||||
NSString * street = (self.selectedStreet == NSNotFound ? self.editedStreetName : self.streets[self.selectedStreet]);
|
||||
[self.delegate setStreet:street];
|
||||
[self onCancel];
|
||||
}
|
||||
|
||||
#pragma mark - MWMStreetEditorCommonTableViewCellProtocol
|
||||
|
||||
- (void)selectCell:(UITableViewCell *)selectedCell
|
||||
{
|
||||
self.editedStreetName = @"";
|
||||
self.selectedStreet = [self.tableView indexPathForCell:selectedCell].row;
|
||||
for (UITableViewCell * cell in self.tableView.visibleCells)
|
||||
{
|
||||
if ([cell isEqual:selectedCell])
|
||||
continue;
|
||||
NSIndexPath * indexPath = [self.tableView indexPathForCell:cell];
|
||||
[self fillCell:cell indexPath:indexPath];
|
||||
}
|
||||
}
|
||||
|
||||
- (void)fillCell:(UITableViewCell *)cell indexPath:(NSIndexPath *)indexPath
|
||||
{
|
||||
if ([cell isKindOfClass:[MWMStreetEditorEditTableViewCell class]])
|
||||
{
|
||||
MWMStreetEditorEditTableViewCell * tCell = (MWMStreetEditorEditTableViewCell *)cell;
|
||||
[tCell configWithDelegate:self street:self.editedStreetName];
|
||||
}
|
||||
else if ([cell isKindOfClass:[MWMStreetEditorCommonTableViewCell class]])
|
||||
{
|
||||
NSUInteger const index = indexPath.row;
|
||||
MWMStreetEditorCommonTableViewCell * tCell = (MWMStreetEditorCommonTableViewCell *)cell;
|
||||
NSString * street = self.streets[index];
|
||||
BOOL const selected = (self.selectedStreet == index);
|
||||
[tCell configWithDelegate:self street:street selected:selected];
|
||||
}
|
||||
}
|
||||
|
||||
#pragma mark - MWMStreetEditorEditCellProtocol
|
||||
|
||||
- (void)editCellTextChanged:(NSString *)text
|
||||
{
|
||||
if (text && text.length != 0)
|
||||
{
|
||||
self.editedStreetName = text;
|
||||
if (self.selectedStreet != NSNotFound)
|
||||
{
|
||||
self.lastSelectedStreet = self.selectedStreet;
|
||||
self.selectedStreet = NSNotFound;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
self.selectedStreet = self.lastSelectedStreet;
|
||||
}
|
||||
for (UITableViewCell * cell in self.tableView.visibleCells)
|
||||
{
|
||||
if (![cell isKindOfClass:[MWMStreetEditorCommonTableViewCell class]])
|
||||
continue;
|
||||
NSIndexPath * indexPath = [self.tableView indexPathForCell:cell];
|
||||
[self fillCell:cell indexPath:indexPath];
|
||||
}
|
||||
}
|
||||
|
||||
#pragma mark - UITableViewDataSource
|
||||
|
||||
- (UITableViewCell * _Nonnull)tableView:(UITableView * _Nonnull)tableView cellForRowAtIndexPath:(NSIndexPath * _Nonnull)indexPath
|
||||
{
|
||||
NSUInteger const streetsCount = self.streets.count;
|
||||
if (streetsCount == 0)
|
||||
return [tableView dequeueReusableCellWithIdentifier:kStreetEditorEditCell];
|
||||
NSUInteger const index = indexPath.row;
|
||||
if (index < streetsCount)
|
||||
return [tableView dequeueReusableCellWithIdentifier:kStreetEditorCommonCell];
|
||||
else if (index == streetsCount)
|
||||
return [tableView dequeueReusableCellWithIdentifier:kStreetEditorSpacerCell];
|
||||
else
|
||||
return [tableView dequeueReusableCellWithIdentifier:kStreetEditorEditCell];
|
||||
}
|
||||
|
||||
- (NSInteger)tableView:(UITableView * _Nonnull)tableView numberOfRowsInSection:(NSInteger)section
|
||||
{
|
||||
NSUInteger count = self.streets.count;
|
||||
if (count != 0)
|
||||
count++; // Spacer cell;
|
||||
count++;
|
||||
return count;
|
||||
}
|
||||
|
||||
#pragma mark - UITableViewDelegate
|
||||
|
||||
- (void)tableView:(UITableView * _Nonnull)tableView willDisplayCell:(UITableViewCell * _Nonnull)cell forRowAtIndexPath:(NSIndexPath * _Nonnull)indexPath
|
||||
{
|
||||
[self fillCell:cell indexPath:indexPath];
|
||||
}
|
||||
|
||||
@end
|
|
@ -53,6 +53,7 @@ using MWMPlacePageCellTypeValueMap = map<MWMPlacePageCellType, string>;
|
|||
@property (nonatomic, readonly) BOOL isHTMLDescription;
|
||||
@property (copy, nonatomic) NSString * bookmarkColor;
|
||||
@property (copy, nonatomic) NSSet<NSString *> * cuisines;
|
||||
@property (copy, nonatomic) NSArray<NSString *> * nearbyStreets;
|
||||
|
||||
@property (nonatomic) MWMPlacePageEntityType type;
|
||||
|
||||
|
|
|
@ -193,10 +193,10 @@ void initFieldsMap()
|
|||
{
|
||||
case Metadata::FMD_CUISINE:
|
||||
{
|
||||
[self deserializeCuisine:@(metadata.Get(type).c_str())];
|
||||
NSString * cuisine = [self getCellValue:MWMPlacePageCellTypeCuisine];
|
||||
if (![self.category isEqualToString:cuisine])
|
||||
self.category = [NSString stringWithFormat:@"%@, %@", self.category, cuisine];
|
||||
[self deserializeCuisine:@(metadata.Get(type).c_str())];
|
||||
NSString * cuisine = [self getCellValue:MWMPlacePageCellTypeCuisine];
|
||||
if (![self.category isEqualToString:cuisine])
|
||||
self.category = [NSString stringWithFormat:@"%@, %@", self.category, cuisine];
|
||||
break;
|
||||
}
|
||||
case Metadata::FMD_ELE:
|
||||
|
@ -237,6 +237,8 @@ void initFieldsMap()
|
|||
break;
|
||||
}
|
||||
}
|
||||
|
||||
[self processStreets];
|
||||
}
|
||||
|
||||
[self addMetaField:MWMPlacePageCellTypeCoordinate];
|
||||
|
@ -275,6 +277,15 @@ void initFieldsMap()
|
|||
return [self.cuisines.allObjects componentsJoinedByString:kOSMCuisineSeparator];
|
||||
}
|
||||
|
||||
- (void)processStreets
|
||||
{
|
||||
// TODO Replace with real Getters
|
||||
// FeatureType * feature = self.delegate.userMark->GetFeature();
|
||||
string featureString = "street#2";
|
||||
self.nearbyStreets = @[@"street#1", @(featureString.c_str()), @"street#3"];
|
||||
[self addMetaField:MWMPlacePageCellTypeStreet value:featureString];
|
||||
}
|
||||
|
||||
#pragma mark - Editing
|
||||
|
||||
- (void)setEditableTypes
|
||||
|
@ -287,7 +298,7 @@ void initFieldsMap()
|
|||
[self addEditField];
|
||||
for (auto const & type : editableTypes)
|
||||
{
|
||||
NSAssert(kMetaFieldsMap[type] >= Metadata::FMD_COUNT, @"Incorrect enum value");
|
||||
NSAssert(kMetaFieldsMap[type] >= Metadata::FMD_COUNT || kMetaFieldsMap[type] == 0, @"Incorrect enum value");
|
||||
MWMPlacePageCellType const field = static_cast<MWMPlacePageCellType>(kMetaFieldsMap[type]);
|
||||
m_editableFields.insert(field);
|
||||
}
|
||||
|
@ -295,6 +306,7 @@ void initFieldsMap()
|
|||
|
||||
- (BOOL)isCellEditable:(MWMPlacePageCellType)cellType
|
||||
{
|
||||
return YES;
|
||||
return m_editableFields.count(cellType) == 1;
|
||||
}
|
||||
|
||||
|
@ -336,6 +348,7 @@ void initFieldsMap()
|
|||
case MWMPlacePageCellTypeStreet:
|
||||
{
|
||||
// TODO Add implementation
|
||||
// Save cell.second
|
||||
break;
|
||||
}
|
||||
case MWMPlacePageCellTypeBuilding:
|
||||
|
|
|
@ -241,6 +241,16 @@
|
|||
34F45E8E1B96E88100AC93F8 /* MWMSearchTabButtonsView.mm in Sources */ = {isa = PBXBuildFile; fileRef = 34F45E8D1B96E88100AC93F8 /* MWMSearchTabButtonsView.mm */; };
|
||||
34F45E901B96E8B100AC93F8 /* MWMSearchTabButtonsView.xib in Resources */ = {isa = PBXBuildFile; fileRef = 34F45E8F1B96E8B100AC93F8 /* MWMSearchTabButtonsView.xib */; };
|
||||
34F8ADD91B97229A004184CC /* MWMSearchTableView.mm in Sources */ = {isa = PBXBuildFile; fileRef = 34F8ADD81B97229A004184CC /* MWMSearchTableView.mm */; };
|
||||
34F9FB871C438ADB00F71201 /* MWMStreetEditorCommonTableViewCell.mm in Sources */ = {isa = PBXBuildFile; fileRef = 34F9FB831C438ADB00F71201 /* MWMStreetEditorCommonTableViewCell.mm */; };
|
||||
34F9FB881C438ADB00F71201 /* MWMStreetEditorCommonTableViewCell.mm in Sources */ = {isa = PBXBuildFile; fileRef = 34F9FB831C438ADB00F71201 /* MWMStreetEditorCommonTableViewCell.mm */; };
|
||||
34F9FB891C438ADB00F71201 /* MWMStreetEditorCommonTableViewCell.xib in Resources */ = {isa = PBXBuildFile; fileRef = 34F9FB841C438ADB00F71201 /* MWMStreetEditorCommonTableViewCell.xib */; };
|
||||
34F9FB8A1C438ADB00F71201 /* MWMStreetEditorCommonTableViewCell.xib in Resources */ = {isa = PBXBuildFile; fileRef = 34F9FB841C438ADB00F71201 /* MWMStreetEditorCommonTableViewCell.xib */; };
|
||||
34F9FB8B1C438ADB00F71201 /* MWMStreetEditorViewController.mm in Sources */ = {isa = PBXBuildFile; fileRef = 34F9FB861C438ADB00F71201 /* MWMStreetEditorViewController.mm */; };
|
||||
34F9FB8C1C438ADB00F71201 /* MWMStreetEditorViewController.mm in Sources */ = {isa = PBXBuildFile; fileRef = 34F9FB861C438ADB00F71201 /* MWMStreetEditorViewController.mm */; };
|
||||
34F9FB901C43AF2400F71201 /* MWMStreetEditorEditTableViewCell.mm in Sources */ = {isa = PBXBuildFile; fileRef = 34F9FB8E1C43AF2400F71201 /* MWMStreetEditorEditTableViewCell.mm */; };
|
||||
34F9FB911C43AF2400F71201 /* MWMStreetEditorEditTableViewCell.mm in Sources */ = {isa = PBXBuildFile; fileRef = 34F9FB8E1C43AF2400F71201 /* MWMStreetEditorEditTableViewCell.mm */; };
|
||||
34F9FB921C43AF2400F71201 /* MWMStreetEditorEditTableViewCell.xib in Resources */ = {isa = PBXBuildFile; fileRef = 34F9FB8F1C43AF2400F71201 /* MWMStreetEditorEditTableViewCell.xib */; };
|
||||
34F9FB931C43AF2400F71201 /* MWMStreetEditorEditTableViewCell.xib in Resources */ = {isa = PBXBuildFile; fileRef = 34F9FB8F1C43AF2400F71201 /* MWMStreetEditorEditTableViewCell.xib */; };
|
||||
34FE4C451BCC013500066718 /* MWMMapWidgets.mm in Sources */ = {isa = PBXBuildFile; fileRef = 34FE4C441BCC013500066718 /* MWMMapWidgets.mm */; };
|
||||
34FF2CB51C0F13FA007A6FD2 /* MWMOpeningHoursTableViewCell.mm in Sources */ = {isa = PBXBuildFile; fileRef = 34FF2CB41C0F13FA007A6FD2 /* MWMOpeningHoursTableViewCell.mm */; };
|
||||
34FF2CB61C0F13FA007A6FD2 /* MWMOpeningHoursTableViewCell.mm in Sources */ = {isa = PBXBuildFile; fileRef = 34FF2CB41C0F13FA007A6FD2 /* MWMOpeningHoursTableViewCell.mm */; };
|
||||
|
@ -1243,6 +1253,14 @@
|
|||
34F45E8F1B96E8B100AC93F8 /* MWMSearchTabButtonsView.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = MWMSearchTabButtonsView.xib; sourceTree = "<group>"; };
|
||||
34F8ADD71B97229A004184CC /* MWMSearchTableView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MWMSearchTableView.h; sourceTree = "<group>"; };
|
||||
34F8ADD81B97229A004184CC /* MWMSearchTableView.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = MWMSearchTableView.mm; sourceTree = "<group>"; };
|
||||
34F9FB821C438ADB00F71201 /* MWMStreetEditorCommonTableViewCell.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MWMStreetEditorCommonTableViewCell.h; sourceTree = "<group>"; };
|
||||
34F9FB831C438ADB00F71201 /* MWMStreetEditorCommonTableViewCell.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = MWMStreetEditorCommonTableViewCell.mm; sourceTree = "<group>"; };
|
||||
34F9FB841C438ADB00F71201 /* MWMStreetEditorCommonTableViewCell.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = MWMStreetEditorCommonTableViewCell.xib; sourceTree = "<group>"; };
|
||||
34F9FB851C438ADB00F71201 /* MWMStreetEditorViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MWMStreetEditorViewController.h; sourceTree = "<group>"; };
|
||||
34F9FB861C438ADB00F71201 /* MWMStreetEditorViewController.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = MWMStreetEditorViewController.mm; sourceTree = "<group>"; };
|
||||
34F9FB8D1C43AF2400F71201 /* MWMStreetEditorEditTableViewCell.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MWMStreetEditorEditTableViewCell.h; sourceTree = "<group>"; };
|
||||
34F9FB8E1C43AF2400F71201 /* MWMStreetEditorEditTableViewCell.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = MWMStreetEditorEditTableViewCell.mm; sourceTree = "<group>"; };
|
||||
34F9FB8F1C43AF2400F71201 /* MWMStreetEditorEditTableViewCell.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = MWMStreetEditorEditTableViewCell.xib; sourceTree = "<group>"; };
|
||||
34FE4C431BCC013500066718 /* MWMMapWidgets.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MWMMapWidgets.h; sourceTree = "<group>"; };
|
||||
34FE4C441BCC013500066718 /* MWMMapWidgets.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = MWMMapWidgets.mm; sourceTree = "<group>"; };
|
||||
34FF2CB31C0F13FA007A6FD2 /* MWMOpeningHoursTableViewCell.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MWMOpeningHoursTableViewCell.h; sourceTree = "<group>"; };
|
||||
|
@ -2497,6 +2515,7 @@
|
|||
34EB84501C0738D30004689F /* Editor */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
34F9FB811C4389EE00F71201 /* Street */,
|
||||
340C20E01C3E563500111D22 /* Cuisine */,
|
||||
34EB84551C073DF70004689F /* OpeningHours */,
|
||||
340C20E51C3E58B000111D22 /* MWMEditorCommon.h */,
|
||||
|
@ -2537,6 +2556,21 @@
|
|||
path = OpeningHours;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
34F9FB811C4389EE00F71201 /* Street */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
34F9FB851C438ADB00F71201 /* MWMStreetEditorViewController.h */,
|
||||
34F9FB861C438ADB00F71201 /* MWMStreetEditorViewController.mm */,
|
||||
34F9FB821C438ADB00F71201 /* MWMStreetEditorCommonTableViewCell.h */,
|
||||
34F9FB831C438ADB00F71201 /* MWMStreetEditorCommonTableViewCell.mm */,
|
||||
34F9FB841C438ADB00F71201 /* MWMStreetEditorCommonTableViewCell.xib */,
|
||||
34F9FB8D1C43AF2400F71201 /* MWMStreetEditorEditTableViewCell.h */,
|
||||
34F9FB8E1C43AF2400F71201 /* MWMStreetEditorEditTableViewCell.mm */,
|
||||
34F9FB8F1C43AF2400F71201 /* MWMStreetEditorEditTableViewCell.xib */,
|
||||
);
|
||||
path = Street;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
34FE4C421BCC013500066718 /* Widgets */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
|
@ -3490,6 +3524,7 @@
|
|||
9DA46A141C47E95700EF52BA /* resources-6plus_legacy in Resources */,
|
||||
B0DFE6311A1B78A200B6C35E /* LocalNotifications.plist in Resources */,
|
||||
34B82ABB1B837FFD00180497 /* MWMSearchHistoryRequestCell.xib in Resources */,
|
||||
34F9FB921C43AF2400F71201 /* MWMStreetEditorEditTableViewCell.xib in Resources */,
|
||||
34B6CF5D1BBBFC6B009203C6 /* LaunchScreen.storyboard in Resources */,
|
||||
3476B8DC1BFDD30B00874594 /* tts-how-to-set-up-voice.html in Resources */,
|
||||
978D4A31199A11E600D72CA7 /* faq.html in Resources */,
|
||||
|
@ -3517,6 +3552,7 @@
|
|||
34181E9F1C0ECF210081B586 /* MWMOpeningHoursDaysSelectorTableViewCell.xib in Resources */,
|
||||
34CFFE8D1B7DE71C009D0C9F /* MWMSearchView.xib in Resources */,
|
||||
3401CD711C3C0C420028C6F8 /* MWMEditorNameTableViewCell.xib in Resources */,
|
||||
34F9FB891C438ADB00F71201 /* MWMStreetEditorCommonTableViewCell.xib in Resources */,
|
||||
F7FDD823147F30CC005900FA /* drules_proto.bin in Resources */,
|
||||
F6588E381B15D87A00EE1E58 /* MWMBookmarkColorCell.xib in Resources */,
|
||||
3401CD691C3C03A80028C6F8 /* MWMEditorTextTableViewCell.xib in Resources */,
|
||||
|
@ -3666,6 +3702,7 @@
|
|||
6741A9641BF340DE002C974C /* MWMSearchDownloadViewController.xib in Resources */,
|
||||
9DA46A151C47E95700EF52BA /* resources-6plus_legacy in Resources */,
|
||||
345FDD2E1C3BF98D0070C459 /* MWMEditorTableViewHeader.xib in Resources */,
|
||||
34F9FB931C43AF2400F71201 /* MWMStreetEditorEditTableViewCell.xib in Resources */,
|
||||
6741A9651BF340DE002C974C /* LocalNotifications.plist in Resources */,
|
||||
6741A9661BF340DE002C974C /* MWMSearchHistoryRequestCell.xib in Resources */,
|
||||
6741A9671BF340DE002C974C /* LaunchScreen.storyboard in Resources */,
|
||||
|
@ -3695,6 +3732,7 @@
|
|||
6741A9781BF340DE002C974C /* AddSetTableViewCell.xib in Resources */,
|
||||
6741A9791BF340DE002C974C /* Localizable.strings in Resources */,
|
||||
9DA46A091C47E92100EF52BA /* resources-hdpi_legacy in Resources */,
|
||||
34F9FB8A1C438ADB00F71201 /* MWMStreetEditorCommonTableViewCell.xib in Resources */,
|
||||
34CCFDD81C22915600F28959 /* MWMPlacePageOpeningHoursWeekDayView.xib in Resources */,
|
||||
6741A97A1BF340DE002C974C /* MWMSearchView.xib in Resources */,
|
||||
6741A97C1BF340DE002C974C /* MWMBookmarkColorCell.xib in Resources */,
|
||||
|
@ -3833,6 +3871,7 @@
|
|||
1D60589B0D05DD56006BFB54 /* main.mm in Sources */,
|
||||
34CC4C091B81F3B500E44C1F /* MWMSearchTabbedViewController.mm in Sources */,
|
||||
340837161B72451A00B5C185 /* MWMShareLocationActivityItem.mm in Sources */,
|
||||
34F9FB901C43AF2400F71201 /* MWMStreetEditorEditTableViewCell.mm in Sources */,
|
||||
978D4A291996C17300D72CA7 /* RichTextVC.mm in Sources */,
|
||||
9747278418338F0C006B7CB7 /* UIViewController+Navigation.mm in Sources */,
|
||||
F6BC1E521ACBF98600EF0360 /* MWMFacebookAlert.mm in Sources */,
|
||||
|
@ -3855,6 +3894,7 @@
|
|||
560634F21B78806100F3D670 /* MWMTextToSpeech.mm in Sources */,
|
||||
F6791B131C43DEA7007A8A6E /* MWMStartButton.mm in Sources */,
|
||||
46F26CD810F623BA00ECCA39 /* EAGLView.mm in Sources */,
|
||||
34F9FB8B1C438ADB00F71201 /* MWMStreetEditorViewController.mm in Sources */,
|
||||
EED10A4511F78D120095FAD4 /* MapViewController.mm in Sources */,
|
||||
34CCFDD11C21945500F28959 /* MWMPlacePageOpeningHoursDayView.mm in Sources */,
|
||||
3445CEAE1C2D9E08006F4226 /* MWMAuthorizationSignupViewController.mm in Sources */,
|
||||
|
@ -3991,6 +4031,7 @@
|
|||
978F9244183B660F000D6C7C /* SwitchCell.mm in Sources */,
|
||||
342AD7721B53D32F00E0B997 /* UIView+RuntimeAttributes.mm in Sources */,
|
||||
F626D52E1C3E6CAA00C17D15 /* MWMTableViewCell.mm in Sources */,
|
||||
34F9FB871C438ADB00F71201 /* MWMStreetEditorCommonTableViewCell.mm in Sources */,
|
||||
F64F4B6D1B46A51F0081A24A /* MWMDownloaderDialogCell.mm in Sources */,
|
||||
3491E7CB1C06F1F10042FE24 /* MWMPlacePageButtonCell.mm in Sources */,
|
||||
97508423199522D300A7457D /* SettingsAndMoreVC.mm in Sources */,
|
||||
|
@ -4053,6 +4094,7 @@
|
|||
6741A9A31BF340DE002C974C /* main.mm in Sources */,
|
||||
6741A9A41BF340DE002C974C /* MWMSearchTabbedViewController.mm in Sources */,
|
||||
6741A9A51BF340DE002C974C /* MWMShareLocationActivityItem.mm in Sources */,
|
||||
34F9FB911C43AF2400F71201 /* MWMStreetEditorEditTableViewCell.mm in Sources */,
|
||||
6741A9A61BF340DE002C974C /* RichTextVC.mm in Sources */,
|
||||
6741A9A71BF340DE002C974C /* UIViewController+Navigation.mm in Sources */,
|
||||
6741A9A81BF340DE002C974C /* MWMFacebookAlert.mm in Sources */,
|
||||
|
@ -4074,6 +4116,7 @@
|
|||
34ABA6291C2D567B00FE1BEC /* MWMInputLoginValidator.mm in Sources */,
|
||||
6741A9B71BF340DE002C974C /* EAGLView.mm in Sources */,
|
||||
6741A9B81BF340DE002C974C /* MapViewController.mm in Sources */,
|
||||
34F9FB8C1C438ADB00F71201 /* MWMStreetEditorViewController.mm in Sources */,
|
||||
34181E8E1C0ECF210081B586 /* MWMOpeningHoursAddClosedTableViewCell.mm in Sources */,
|
||||
34CCFDD21C21945500F28959 /* MWMPlacePageOpeningHoursDayView.mm in Sources */,
|
||||
3445CEAF1C2D9E08006F4226 /* MWMAuthorizationSignupViewController.mm in Sources */,
|
||||
|
@ -4213,6 +4256,7 @@
|
|||
6741AA191BF340DE002C974C /* MWMDownloaderDialogCell.mm in Sources */,
|
||||
6741AA1A1BF340DE002C974C /* SettingsAndMoreVC.mm in Sources */,
|
||||
6741AA1B1BF340DE002C974C /* MWMDirectionView.mm in Sources */,
|
||||
34F9FB881C438ADB00F71201 /* MWMStreetEditorCommonTableViewCell.mm in Sources */,
|
||||
3491E7CC1C06F1F10042FE24 /* MWMPlacePageButtonCell.mm in Sources */,
|
||||
6741AA1C1BF340DE002C974C /* MWMRoutingDisclaimerAlert.mm in Sources */,
|
||||
6741AA1D1BF340DE002C974C /* MWMDownloadTransitMapAlert.mm in Sources */,
|
||||
|
|
Loading…
Add table
Reference in a new issue