mirror of
https://codeberg.org/comaps/comaps
synced 2025-12-21 13:53:37 +00:00
To expand with full Organic Maps and Maps.ME commits history run: git remote add om-historic [om-historic.git repo url] git fetch --tags om-historic git replace squashed-history historic-commits
50 lines
1.3 KiB
Plaintext
50 lines
1.3 KiB
Plaintext
#import "MWMUnitsController.h"
|
|
#import "MWMSettings.h"
|
|
#import "SwiftBridge.h"
|
|
|
|
@interface MWMUnitsController ()
|
|
|
|
@property(weak, nonatomic) IBOutlet SettingsTableViewSelectableCell * kilometers;
|
|
@property(weak, nonatomic) IBOutlet SettingsTableViewSelectableCell * miles;
|
|
@property(weak, nonatomic) SettingsTableViewSelectableCell * selectedCell;
|
|
|
|
@end
|
|
|
|
@implementation MWMUnitsController
|
|
|
|
- (void)viewDidLoad
|
|
{
|
|
[super viewDidLoad];
|
|
self.title = L(@"measurement_units");
|
|
|
|
switch ([MWMSettings measurementUnits])
|
|
{
|
|
case MWMUnitsMetric: self.selectedCell = self.kilometers; break;
|
|
case MWMUnitsImperial: self.selectedCell = self.miles; break;
|
|
}
|
|
}
|
|
|
|
- (void)setSelectedCell:(SettingsTableViewSelectableCell *)cell
|
|
{
|
|
SettingsTableViewSelectableCell * selectedCell = _selectedCell;
|
|
if (selectedCell == cell)
|
|
return;
|
|
|
|
selectedCell.accessoryType = UITableViewCellAccessoryNone;
|
|
cell.accessoryType = UITableViewCellAccessoryCheckmark;
|
|
cell.selected = NO;
|
|
_selectedCell = cell;
|
|
if (cell == self.kilometers)
|
|
[MWMSettings setMeasurementUnits:MWMUnitsMetric];
|
|
else
|
|
[MWMSettings setMeasurementUnits:MWMUnitsImperial];
|
|
}
|
|
|
|
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
|
|
{
|
|
self.selectedCell = [tableView cellForRowAtIndexPath:indexPath];
|
|
[tableView deselectRowAtIndexPath:indexPath animated:YES];
|
|
}
|
|
|
|
@end
|