diff options
author | VladiMihaylenko <vxmihaylenko@gmail.com> | 2016-01-11 16:36:55 +0300 |
---|---|---|
committer | Constantin Shalnev <c.shalnev@corp.mail.ru> | 2016-01-13 15:55:36 +0300 |
commit | 0942833752b0fe27c7994d7843425de531c5acc5 (patch) | |
tree | 774c35c6b601f4400b874afa63160bfb6c8a7b1f /iphone/Maps/Settings | |
parent | 4520c61518e99c70112d21ca33f24e940fd31358 (diff) |
[ios] Night mode (implementation).
Diffstat (limited to 'iphone/Maps/Settings')
-rw-r--r-- | iphone/Maps/Settings/LinkCell.h | 5 | ||||
-rw-r--r-- | iphone/Maps/Settings/LinkCell.mm | 8 | ||||
-rw-r--r-- | iphone/Maps/Settings/SelectableCell.h | 5 | ||||
-rw-r--r-- | iphone/Maps/Settings/SelectableCell.mm | 8 | ||||
-rw-r--r-- | iphone/Maps/Settings/SettingsViewController.mm | 87 | ||||
-rw-r--r-- | iphone/Maps/Settings/SwitchCell.h | 7 | ||||
-rw-r--r-- | iphone/Maps/Settings/SwitchCell.mm | 3 |
7 files changed, 79 insertions, 44 deletions
diff --git a/iphone/Maps/Settings/LinkCell.h b/iphone/Maps/Settings/LinkCell.h index 3be026f45f..84839c0db5 100644 --- a/iphone/Maps/Settings/LinkCell.h +++ b/iphone/Maps/Settings/LinkCell.h @@ -1,7 +1,6 @@ +#import "MWMTableViewCell.h" -#import <UIKit/UIKit.h> - -@interface LinkCell : UITableViewCell +@interface LinkCell : MWMTableViewCell @property (nonatomic) IBOutlet UILabel * titleLabel; diff --git a/iphone/Maps/Settings/LinkCell.mm b/iphone/Maps/Settings/LinkCell.mm index 4c5c5883f6..1ca486d125 100644 --- a/iphone/Maps/Settings/LinkCell.mm +++ b/iphone/Maps/Settings/LinkCell.mm @@ -1,6 +1,12 @@ - #import "LinkCell.h" +#import "UIColor+MapsMeColor.h" @implementation LinkCell +- (void)awakeFromNib +{ + [super awakeFromNib]; + self.backgroundColor = [UIColor white]; +} + @end diff --git a/iphone/Maps/Settings/SelectableCell.h b/iphone/Maps/Settings/SelectableCell.h index a1025d4dc2..d86d8819d1 100644 --- a/iphone/Maps/Settings/SelectableCell.h +++ b/iphone/Maps/Settings/SelectableCell.h @@ -1,7 +1,6 @@ +#import "MWMTableViewCell.h" -#import <UIKit/UIKit.h> - -@interface SelectableCell : UITableViewCell +@interface SelectableCell : MWMTableViewCell @property (weak, nonatomic) IBOutlet UILabel * titleLabel; diff --git a/iphone/Maps/Settings/SelectableCell.mm b/iphone/Maps/Settings/SelectableCell.mm index 7ad1ee80f5..289e5c7b23 100644 --- a/iphone/Maps/Settings/SelectableCell.mm +++ b/iphone/Maps/Settings/SelectableCell.mm @@ -1,6 +1,12 @@ - #import "SelectableCell.h" +#import "UIColor+MapsMeColor.h" @implementation SelectableCell +- (void)awakeFromNib +{ + [super awakeFromNib]; + self.backgroundColor = [UIColor white]; +} + @end diff --git a/iphone/Maps/Settings/SettingsViewController.mm b/iphone/Maps/Settings/SettingsViewController.mm index 88491c0d27..2d5bea0ad8 100644 --- a/iphone/Maps/Settings/SettingsViewController.mm +++ b/iphone/Maps/Settings/SettingsViewController.mm @@ -9,6 +9,7 @@ #import "Statistics.h" #import "SwitchCell.h" #import "WebViewController.h" +#import "UIColor+MapsMeColor.h" #include "Framework.h" @@ -45,7 +46,6 @@ typedef NS_ENUM(NSUInteger, Section) [super viewDidLoad]; self.title = L(@"settings"); self.tableView.backgroundView = nil; - self.tableView.backgroundColor = [UIColor applicationBackgroundColor]; bool adServerForbidden = false; (void)Settings::Get(kAdServerForbiddenKey, adServerForbidden); if (isIOSVersionLessThan(8) || adServerForbidden) @@ -66,8 +66,8 @@ typedef NS_ENUM(NSUInteger, Section) switch (sections[section]) { case SectionMetrics: - case SectionMap: return 2; + case SectionMap: case SectionRouting: return 3; case SectionAd: @@ -117,23 +117,36 @@ typedef NS_ENUM(NSUInteger, Section) } case SectionMap: { - cell = [tableView dequeueReusableCellWithIdentifier:[SwitchCell className]]; - SwitchCell * customCell = (SwitchCell *)cell; - bool on = true; - if (indexPath.row == 0) + switch (indexPath.row) + { + case 0: { - bool _ = true; + cell = [tableView dequeueReusableCellWithIdentifier:[LinkCell className]]; + LinkCell * customCell = static_cast<LinkCell *>(cell); + customCell.titleLabel.text = L(@"pref_night_mode"); + break; + } + case 1: + { + cell = [tableView dequeueReusableCellWithIdentifier:[SwitchCell className]]; + SwitchCell * customCell = static_cast<SwitchCell *>(cell); + bool on = true, _ = true; GetFramework().Load3dMode(_, on); customCell.titleLabel.text = L(@"pref_map_3d_buildings_title"); } - else + case 2: { + cell = [tableView dequeueReusableCellWithIdentifier:[SwitchCell className]]; + SwitchCell * customCell = static_cast<SwitchCell *>(cell); + bool on = true; (void)Settings::Get("ZoomButtonsEnabled", on); customCell.titleLabel.text = L(@"pref_zoom_title"); + customCell.switchButton.on = on; + customCell.delegate = self; + break; } - customCell.switchButton.on = on; - customCell.delegate = self; - break; + } + break; } case SectionRouting: { @@ -216,23 +229,30 @@ typedef NS_ENUM(NSUInteger, Section) break; case SectionMap: - if (indexPath.row == 0) - { - [[Statistics instance] logEvent:kStatEventName(kStatSettings, kStat3DBuildings) - withParameters:@{kStatValue : (value ? kStatOn : kStatOff)}]; - auto & f = GetFramework(); - bool _ = true, is3dBuildings = true; - f.Load3dMode(_, is3dBuildings); - is3dBuildings = static_cast<bool>(value); - f.Save3dMode(_, is3dBuildings); - f.Allow3dMode(_, is3dBuildings); - } - else + switch (indexPath.row) { - [stat logEvent:kStatEventName(kStatSettings, kStatToggleZoomButtonsVisibility) - withParameters:@{kStatValue : (value ? kStatVisible : kStatHidden)}]; - Settings::Set("ZoomButtonsEnabled", (bool)value); - [MapsAppDelegate theApp].mapViewController.controlsManager.zoomHidden = !value; + case 0: + break; + case 1: + { + [[Statistics instance] logEvent:kStatEventName(kStatSettings, kStat3DBuildings) + withParameters:@{kStatValue : (value ? kStatOn : kStatOff)}]; + auto & f = GetFramework(); + bool _ = true, is3dBuildings = true; + f.Load3dMode(_, is3dBuildings); + is3dBuildings = static_cast<bool>(value); + f.Save3dMode(_, is3dBuildings); + f.Allow3dMode(_, is3dBuildings); + break; + } + case 2: + { + [stat logEvent:kStatEventName(kStatSettings, kStatToggleZoomButtonsVisibility) + withParameters:@{kStatValue : (value ? kStatVisible : kStatHidden)}]; + Settings::Set("ZoomButtonsEnabled", (bool)value); + [MapsAppDelegate theApp].mapViewController.controlsManager.zoomHidden = !value; + break; + } } break; @@ -289,12 +309,17 @@ Settings::Units unitsForIndex(NSInteger index) break; } case SectionRouting: - [[Statistics instance] logEvent:kStatEventName(kStatSettings, kStatTTS) - withParameters:@{kStatAction : kStatChangeLanguage}]; - [self performSegueWithIdentifier:@"SettingsToTTSSegue" sender:nil]; + if (indexPath.row == 3) + { + [[Statistics instance] logEvent:kStatEventName(kStatSettings, kStatTTS) + withParameters:@{kStatAction : kStatChangeLanguage}]; + [self performSegueWithIdentifier:@"SettingsToTTSSegue" sender:nil]; + } break; - case SectionMap: + if (indexPath.row == 0) + [self performSegueWithIdentifier:@"SettingsToNightMode" sender:nil]; + break; case SectionAd: case SectionCalibration: case SectionStatistics: diff --git a/iphone/Maps/Settings/SwitchCell.h b/iphone/Maps/Settings/SwitchCell.h index 0102fc91a2..ca1803e6bb 100644 --- a/iphone/Maps/Settings/SwitchCell.h +++ b/iphone/Maps/Settings/SwitchCell.h @@ -1,5 +1,4 @@ - -#import <UIKit/UIKit.h> +#import "MWMTableViewCell.h" @class SwitchCell; @protocol SwitchCellDelegate <NSObject> @@ -8,11 +7,11 @@ @end -@interface SwitchCell : UITableViewCell +@interface SwitchCell : MWMTableViewCell @property (weak, nonatomic) IBOutlet UILabel * titleLabel; @property (weak, nonatomic) IBOutlet UISwitch * switchButton; -@property (weak) id <SwitchCellDelegate> delegate; +@property (weak) id<SwitchCellDelegate> delegate; @end diff --git a/iphone/Maps/Settings/SwitchCell.mm b/iphone/Maps/Settings/SwitchCell.mm index 8ca7d4c4e5..e1e8b199f8 100644 --- a/iphone/Maps/Settings/SwitchCell.mm +++ b/iphone/Maps/Settings/SwitchCell.mm @@ -1,11 +1,12 @@ - #import "SwitchCell.h" +#import "UIColor+MapsMeColor.h" @implementation SwitchCell - (void)awakeFromNib { [self.switchButton addTarget:self action:@selector(switchChanged:) forControlEvents:UIControlEventValueChanged]; + self.backgroundColor = [UIColor white]; } - (void)switchChanged:(UISwitch *)sender |