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

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

@interface MWMNightModeController ()

@property(weak, nonatomic) IBOutlet SettingsTableViewSelectableCell * autoSwitch;
@property(weak, nonatomic) IBOutlet SettingsTableViewSelectableCell * on;
@property(weak, nonatomic) IBOutlet SettingsTableViewSelectableCell * off;
@property(weak, nonatomic) SettingsTableViewSelectableCell * selectedCell;

@end

@implementation MWMNightModeController

- (void)viewDidLoad
{
  [super viewDidLoad];
  self.title = L(@"pref_map_style_title");
  SettingsTableViewSelectableCell * selectedCell = nil;
  switch ([MWMSettings theme])
  {
  case MWMThemeVehicleDay: NSAssert(false, @"Invalid case");
  case MWMThemeDay: selectedCell = self.off; break;
  case MWMThemeVehicleNight: NSAssert(false, @"Invalid case");
  case MWMThemeNight: selectedCell = self.on; break;
  case MWMThemeAuto: selectedCell = self.autoSwitch; break;
  }
  selectedCell.accessoryType = UITableViewCellAccessoryCheckmark;
  self.selectedCell = selectedCell;
}

- (void)setSelectedCell:(SettingsTableViewSelectableCell *)cell
{
  if ([_selectedCell isEqual:cell])
    return;

  _selectedCell = cell;
  NSString * statValue = nil;
  if ([cell isEqual:self.on])
  {
    [MWMSettings setTheme:MWMThemeNight];
    statValue = kStatOn;
  }
  else if ([cell isEqual:self.off])
  {
    [MWMSettings setTheme:MWMThemeDay];
    statValue = kStatOff;
  }
  else if ([cell isEqual:self.autoSwitch])
  {
    [MWMSettings setTheme:MWMThemeAuto];
    statValue = kStatValue;
  }
  [Statistics logEvent:kStatNightMode withParameters:@{kStatValue : statValue}];
}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
  SettingsTableViewSelectableCell * selectedCell = self.selectedCell;
  selectedCell.accessoryType = UITableViewCellAccessoryNone;
  selectedCell = [tableView cellForRowAtIndexPath:indexPath];
  selectedCell.accessoryType = UITableViewCellAccessoryCheckmark;
  selectedCell.selected = NO;
  self.selectedCell = selectedCell;
  [tableView deselectRowAtIndexPath:indexPath animated:YES];
}

@end