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

MWMUnitsController.mm « Maps « iphone - github.com/mapsme/omim.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 859b99e12c352134636be621d84f69fda076945d (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
#import "MWMUnitsController.h"
#import "MWMSettings.h"
#import "SelectableCell.h"
#import "Statistics.h"

@interface MWMUnitsController ()

@property(weak, nonatomic) IBOutlet SelectableCell * kilometers;
@property(weak, nonatomic) IBOutlet SelectableCell * miles;
@property(weak, nonatomic) SelectableCell * selectedCell;

@end

@implementation MWMUnitsController

- (void)viewDidLoad
{
  [super viewDidLoad];
  self.title = L(@"measurement_units");

  switch ([MWMSettings measurementUnits])
  {
  case measurement_utils::Units::Metric: self.selectedCell = self.kilometers; break;
  case measurement_utils::Units::Imperial: self.selectedCell = self.miles; break;
  }
}

- (void)setSelectedCell:(SelectableCell *)cell
{
  SelectableCell * selectedCell = _selectedCell;
  if (selectedCell == cell)
    return;

  selectedCell.accessoryType = UITableViewCellAccessoryNone;
  cell.accessoryType = UITableViewCellAccessoryCheckmark;
  cell.selected = NO;
  _selectedCell = cell;
  if (cell == self.kilometers)
  {
    [Statistics logEvent:kStatEventName(kStatSettings, kStatChangeMeasureUnits)
          withParameters:@{kStatValue : kStatKilometers}];
    [MWMSettings setMeasurementUnits:measurement_utils::Units::Metric];
  }
  else
  {
    [Statistics logEvent:kStatEventName(kStatSettings, kStatChangeMeasureUnits)
          withParameters:@{kStatValue : kStatMiles}];
    [MWMSettings setMeasurementUnits:measurement_utils::Units::Imperial];
  }
}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
  self.selectedCell = [tableView cellForRowAtIndexPath:indexPath];
}

@end