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

MWMBookmarkColorViewController.mm « Classes « Maps « iphone - github.com/mapsme/omim.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 620662d2ee867af29e383b5b8e8143361c376389 (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
#import "MWMBookmarkColorViewController.h"
#import "Statistics.h"
#import "UIColor+MapsMeColor.h"
#import "UIViewController+Navigation.h"

#include "std/array.hpp"

namespace
{
array<NSString *, 8> const kBookmarkColorsVariant
{{
  @"placemark-red",
  @"placemark-yellow",
  @"placemark-blue",
  @"placemark-green",
  @"placemark-purple",
  @"placemark-orange",
  @"placemark-brown",
  @"placemark-pink"
}};

} // namespace

@interface MWMBookmarkColorViewController ()

@property (copy, nonatomic) NSString * bookmarkColor;
@property (weak, nonatomic) id<MWMBookmarkColorDelegate> delegate;

@end

@implementation MWMBookmarkColorViewController

- (instancetype)initWithColor:(NSString *)color delegate:(id<MWMBookmarkColorDelegate>)delegate
{
  self = [super init];
  if (self)
  {
    _bookmarkColor = color;
    _delegate = delegate;
  }
  return self;
}

- (void)viewDidLoad
{
  [super viewDidLoad];
  NSAssert(self.bookmarkColor, @"Color can't be nil!");
  NSAssert(self.delegate, @"Delegate can't be nil!");
  self.title = L(@"bookmark_color");
}

@end

@implementation MWMBookmarkColorViewController (TableView)

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
  UITableViewCell * cell = [tableView dequeueReusableCellWithIdentifier:[UITableViewCell className]];
  NSString * currentColor = kBookmarkColorsVariant[indexPath.row];
  cell.textLabel.text = ios_bookmark_ui_helper::LocalizedTitleForBookmarkColor(currentColor);
  BOOL const isSelected = [currentColor isEqualToString:self.bookmarkColor];
  cell.imageView.image = ios_bookmark_ui_helper::ImageForBookmarkColor(currentColor, isSelected);
  cell.accessoryType = isSelected ? UITableViewCellAccessoryCheckmark : UITableViewCellAccessoryNone;
  return cell;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
  return kBookmarkColorsVariant.size();
}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
  NSString * bookmarkColor = kBookmarkColorsVariant[indexPath.row];
  [Statistics logEvent:kStatEventName(kStatPlacePage, kStatChangeBookmarkColor)
                   withParameters:@{kStatValue : bookmarkColor}];
  [self.delegate didSelectColor:bookmarkColor];
  [self backTap];
}

@end