From 1c0a449c058105cecf78e4ae07e8317b2f429cdd Mon Sep 17 00:00:00 2001 From: Andrea Busi Date: Wed, 26 Aug 2020 14:00:56 +0200 Subject: [PATCH] refactor: Add a type inside the SettingItem model --- .../NotificheSismiTableViewController.m | 4 +- .../SegnalazioniUtentiTableViewController.m | 8 +- .../Settings/SettingsViewController.m | 4 +- .../Models/Settings/SettingItem.swift | 18 +- .../RetiSismicheTableViewController.h | 17 - .../RetiSismicheTableViewController.m | 514 ------------------ 6 files changed, 18 insertions(+), 547 deletions(-) delete mode 100644 Sources/Earthquake Network/ViewController/impostazioniNotifiche/RetiSismicheTableViewController.h delete mode 100644 Sources/Earthquake Network/ViewController/impostazioniNotifiche/RetiSismicheTableViewController.m diff --git a/Sources/Earthquake Network/Controllers/Settings/NotificheSismiTableViewController.m b/Sources/Earthquake Network/Controllers/Settings/NotificheSismiTableViewController.m index 04feba9..0398f88 100644 --- a/Sources/Earthquake Network/Controllers/Settings/NotificheSismiTableViewController.m +++ b/Sources/Earthquake Network/Controllers/Settings/NotificheSismiTableViewController.m @@ -39,8 +39,8 @@ static NSString * const SegueIdentifierRetiSismiche = @"retiSismiche"; [super viewDidLoad]; self.settings = @[ - [[SettingItem alloc] initWithTitle:NSLocalizedString(@"Notifiche segnalazioni utente", @"voce menu") segue:SegueIdentifierSegnalazioniUtente], - [[SettingItem alloc] initWithTitle:NSLocalizedString(@"Notifiche da reti sismiche", @"voce menu") segue:SegueIdentifierRetiSismiche] + [[SettingItem alloc] initWithType:SettingTypeDetail title:NSLocalizedString(@"Notifiche segnalazioni utente", @"voce menu") subtitle:nil icon:nil segue:SegueIdentifierSegnalazioniUtente], + [[SettingItem alloc] initWithType:SettingTypeDetail title:NSLocalizedString(@"Notifiche da reti sismiche", @"voce menu") subtitle:nil icon:nil segue:SegueIdentifierRetiSismiche] ]; [self.tableView registerClass:[SettingDetailTableViewCell class] forCellReuseIdentifier:SettingDetailTableViewCell.Identifier]; diff --git a/Sources/Earthquake Network/Controllers/Settings/SegnalazioniUtentiTableViewController.m b/Sources/Earthquake Network/Controllers/Settings/SegnalazioniUtentiTableViewController.m index 5ea2e75..ef73541 100644 --- a/Sources/Earthquake Network/Controllers/Settings/SegnalazioniUtentiTableViewController.m +++ b/Sources/Earthquake Network/Controllers/Settings/SegnalazioniUtentiTableViewController.m @@ -32,8 +32,8 @@ [self.tableView registerClass:[SettingSliderTableViewCell class] forCellReuseIdentifier:SettingSliderTableViewCell.Identifier]; self.settings = @[ - [[SettingItem alloc] initWithTitle:NSLocalizedString(@"Abilitato", @"voce menu") subtitle:@"Ricevi le notifiche dei suoni segnalati manualmente dagli utenti" icon:nil segue:nil], - [[SettingItem alloc] initWithTitle:NSLocalizedString(@"Raggio dalla tua posizione", @"voce menu") subtitle:nil icon:nil segue:nil], + [[SettingItem alloc] initWithType:SettingTypeEnable title:NSLocalizedString(@"Abilitato", @"voce menu") subtitle:NSLocalizedString(@"Ricevi le notifiche dei suoni segnalati manualmente dagli utenti", @"") icon:nil segue:nil], + [[SettingItem alloc] initWithType:SettingTypeSlider title:NSLocalizedString(@"Raggio dalla tua posizione", @"voce menu") subtitle:nil icon:nil segue:nil] ]; if (![EQNNotificheSegnalazioniUtente center].distanzaPosizione) @@ -97,7 +97,7 @@ { SettingItem *setting = self.settings[indexPath.row]; - if (indexPath.row == 0) { + if (setting.type == SettingTypeEnable) { SettingEnableTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:SettingEnableTableViewCell.Identifier forIndexPath:indexPath]; cell.toggleSwitch.on = self.notificationsEnabled; cell.isDisabled = !self.notificationsEnabled; @@ -114,7 +114,7 @@ }; return cell; - } else if (indexPath.row == 1) { + } else if (setting.type == SettingTypeSlider) { SettingSliderTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:SettingSliderTableViewCell.Identifier forIndexPath:indexPath]; cell.isDisabled = !self.notificationsEnabled; cell.titleLabel.text = setting.displayTitle; diff --git a/Sources/Earthquake Network/Controllers/Settings/SettingsViewController.m b/Sources/Earthquake Network/Controllers/Settings/SettingsViewController.m index 1eab388..b32db62 100644 --- a/Sources/Earthquake Network/Controllers/Settings/SettingsViewController.m +++ b/Sources/Earthquake Network/Controllers/Settings/SettingsViewController.m @@ -29,8 +29,8 @@ static NSString * const SegueIdentifierNotificheSismi = @"ShowNotificheSismi"; [self.tableView registerClass:[SettingDetailTableViewCell class] forCellReuseIdentifier:SettingDetailTableViewCell.Identifier]; self.settings = @[ - [[SettingItem alloc] initWithTitle:NSLocalizedString(@"Allerta in tempo reale", @"voce menu") subtitle:nil icon:@"🚨" segue:SegueIdentifierAllertaSismica], - [[SettingItem alloc] initWithTitle:NSLocalizedString(@"Notifiche sismi", @"voce menu") subtitle:nil icon:@"🔔" segue:SegueIdentifierNotificheSismi] + [[SettingItem alloc] initWithType:SettingTypeDetail title:NSLocalizedString(@"Allerta in tempo reale", @"voce menu") subtitle:nil icon:@"🚨" segue:SegueIdentifierAllertaSismica], + [[SettingItem alloc] initWithType:SettingTypeDetail title:NSLocalizedString(@"Notifiche sismi", @"voce menu") subtitle:nil icon:@"🔔" segue:SegueIdentifierNotificheSismi] ]; } diff --git a/Sources/Earthquake Network/Models/Settings/SettingItem.swift b/Sources/Earthquake Network/Models/Settings/SettingItem.swift index 9a65271..86c0f49 100644 --- a/Sources/Earthquake Network/Models/Settings/SettingItem.swift +++ b/Sources/Earthquake Network/Models/Settings/SettingItem.swift @@ -9,12 +9,20 @@ import Foundation +@objc enum SettingType: Int { + case detail + case enable + case slider + case multiValues +} + @objcMembers class SettingItem: NSObject { let title: String let subtitle: String? let icon: String? let segue: String? + let type: SettingType var displayTitle: String { if let icon = icon { @@ -25,17 +33,11 @@ class SettingItem: NSObject { // MARK: - Init - init(title: String, segue: String) { - self.title = title - self.subtitle = nil - self.icon = nil - self.segue = segue - } - - init(title: String, subtitle: String?, icon: String?, segue: String?) { + init(type: SettingType, title: String, subtitle: String? = nil, icon: String? = nil, segue: String? = nil) { self.title = title self.subtitle = subtitle self.icon = icon self.segue = segue + self.type = type } } diff --git a/Sources/Earthquake Network/ViewController/impostazioniNotifiche/RetiSismicheTableViewController.h b/Sources/Earthquake Network/ViewController/impostazioniNotifiche/RetiSismicheTableViewController.h deleted file mode 100644 index 493160a..0000000 --- a/Sources/Earthquake Network/ViewController/impostazioniNotifiche/RetiSismicheTableViewController.h +++ /dev/null @@ -1,17 +0,0 @@ -// -// RetiSismicheTableViewController.h -// Earthquake Network -// -// Created by Luca Beretta on 13/01/2019. -// Copyright © 2019 Luca Beretta. All rights reserved. -// - -#import - -NS_ASSUME_NONNULL_BEGIN - -@interface RetiSismicheTableViewController : UITableViewController - -@end - -NS_ASSUME_NONNULL_END diff --git a/Sources/Earthquake Network/ViewController/impostazioniNotifiche/RetiSismicheTableViewController.m b/Sources/Earthquake Network/ViewController/impostazioniNotifiche/RetiSismicheTableViewController.m deleted file mode 100644 index 022e46f..0000000 --- a/Sources/Earthquake Network/ViewController/impostazioniNotifiche/RetiSismicheTableViewController.m +++ /dev/null @@ -1,514 +0,0 @@ -// -// RetiSismicheTableViewController.m -// Earthquake Network -// -// Created by Luca Beretta on 13/01/2019. -// Copyright © 2019 Luca Beretta. All rights reserved. -// - -#import "RetiSismicheTableViewController.h" -#import "EQNNotificeReteSismiche.h" -#import "EQNUtility.h" -#import "PickerViewController.h" - -@interface RetiSismicheTableViewController () - -@property (nonatomic, strong) NSArray *lista; -@property (nonatomic, strong) NSArray *listaVibrazioni; -@property (nonatomic, assign) BOOL isAbilitato; -@property (nonatomic, assign) BOOL isAbilitaVicini; -@property (nonatomic, assign) BOOL isTerremortiForti; - -@property (nonatomic, strong) PickerViewController *pikerViewDistanza; -@property (nonatomic, strong) PickerViewController *pikerViewMagnitudoDebole; -@property (nonatomic, strong) PickerViewController *pikerViewMagnitudoForte; - -@property (nonatomic, strong) UITextField *textRaggioPosizione; -@property (nonatomic, strong) NSString *stringRaggioPosizione; -@property (nonatomic, strong) UITextField *textEnergiaSisma; -@property (nonatomic, strong) NSString *stringEnergiaSisma; -@property (nonatomic, strong) UITextField *textDistanzaVicini; -@property (nonatomic, strong) NSString *stringDistanzaVicini; -@property (nonatomic, strong) UITextField *textEnergiaTerremotiForti; -@property (nonatomic, strong) NSString *stringEnergiaTerremotiForti; -@property (nonatomic, strong) UITextField *textFild; - -@property (nonatomic, strong) UIColor *coloreTesto; - -@end - -@implementation RetiSismicheTableViewController - -- (void)viewDidLoad { - [super viewDidLoad]; - - self.lista = @[NSLocalizedString(@"Abilitato", @"voce menu"), NSLocalizedString(@"Reti sismiche", @"voce menu"), NSLocalizedString(@"Raggio dalla tua posizione", @"voce menu"), NSLocalizedString(@"Energia sisma", @"voce menu"), NSLocalizedString(@"Terremoti vicini", @"voce menu"), NSLocalizedString(@"Distanza", @"voce menu"), NSLocalizedString(@"Terremoti forti", @"voce menu"), NSLocalizedString(@"Magnitudo", @"voce menu")]; - - self.listaVibrazioni = @[NSLocalizedString(@"Modifica impostazioni", @"voce menu")]; - - self.pikerViewDistanza = [[PickerViewController alloc] initWithNibName:@"PickerViewController" bundle:nil dati:[EQNUtility arrayRaggioSismi]]; - self.pikerViewDistanza.delegate = self; - - self.pikerViewMagnitudoDebole = [[PickerViewController alloc] initWithNibName:@"PickerViewController" bundle:nil dati:@[NSLocalizedString(@"Magnitudo >= 2.0", @"voce menu"), NSLocalizedString(@"Magnitudo >= 3.0", @"voce menu"), NSLocalizedString(@"Magnitudo >= 3.5", @"voce menu"), NSLocalizedString(@"Magnitudo >= 4.5", @"voce menu"), NSLocalizedString(@"Magnitudo >= 5.5", @"voce menu")]]; - self.pikerViewMagnitudoDebole.delegate = self; - - self.pikerViewMagnitudoForte = [[PickerViewController alloc] initWithNibName:@"PickerViewController" bundle:nil dati:@[NSLocalizedString(@"Magnitudo >= 5.5", @"voce menu"), NSLocalizedString(@"Magnitudo >= 6.0", @"voce menu"), NSLocalizedString(@"Magnitudo >= 6.5", @"voce menu"), NSLocalizedString(@"Magnitudo >= 7.5", @"voce menu"), NSLocalizedString(@"Magnitudo >= 7.5", @"voce menu")]]; - self.pikerViewMagnitudoForte.delegate = self; - - if (![EQNNotificeReteSismiche center].distanzaPosizione) - [EQNNotificeReteSismiche center].distanzaPosizione = @"100000"; - if (![EQNNotificeReteSismiche center].distanzaVicini) - [EQNNotificeReteSismiche center].distanzaVicini = @"100000"; //NSLocalizedString(@"Qualsiasi distanza", @"voce elenco raggio sismi"); - - if (![EQNNotificeReteSismiche center].listaEnti) { - [EQNNotificeReteSismiche center].listaEnti = [[EQNUtility arrayEnti] copy]; - [[EQNNotificeReteSismiche center] saveUserInfo]; - } - - [[EQNNotificeReteSismiche center] saveUserInfo]; - - self.coloreTesto = [UIColor colorWithRed:0 green:0.5647 blue:0.317 alpha:1]; - - [self setupView]; -} - --(void)viewDidAppear:(BOOL)animated{ - - [super viewDidAppear:animated]; - [self.tableView reloadData]; -} --(void)setupView{ - - self.isAbilitato = [EQNNotificeReteSismiche center].isAbilitato; - self.isAbilitaVicini = [EQNNotificeReteSismiche center].isAbilitaVicini; - self.isTerremortiForti = [EQNNotificeReteSismiche center].isTerremortiForti; - - if ([[EQNNotificeReteSismiche center].distanzaPosizione isEqualToString:@"100000"]) - self.stringRaggioPosizione = NSLocalizedString(@"Qualsiasi distanza", @"voce elenco raggio sismi"); - else - self.stringRaggioPosizione = [EQNNotificeReteSismiche center].distanzaPosizione; - - if ([[EQNNotificeReteSismiche center].distanzaVicini isEqualToString:@"100000"]) - self.stringDistanzaVicini = NSLocalizedString(@"Qualsiasi distanza", @"voce elenco raggio sismi") ; - else - self.stringDistanzaVicini = [EQNNotificeReteSismiche center].distanzaVicini; - - if ([EQNNotificeReteSismiche center].energiaSisma) - self.stringEnergiaSisma = [NSString stringWithFormat:@"%@ >= %@", NSLocalizedString(@"Magnitudo", @""),[EQNNotificeReteSismiche center].energiaSisma]; - else{ - [EQNNotificeReteSismiche center].energiaSisma = @"2.0"; - - self.stringEnergiaSisma = [NSString stringWithFormat:@"%@ >= %@", NSLocalizedString(@"Magnitudo", @""), [EQNNotificeReteSismiche center].energiaSisma]; - } - - if ([EQNNotificeReteSismiche center].energiaTerremotiForti) - self.stringEnergiaTerremotiForti = [NSString stringWithFormat:@"%@ >= %@", NSLocalizedString(@"Magnitudo", @""),[EQNNotificeReteSismiche center].energiaTerremotiForti]; - else{ - [EQNNotificeReteSismiche center].energiaTerremotiForti = @"5.5"; - - self.stringEnergiaTerremotiForti = [NSString stringWithFormat:@"%@ >= %@", NSLocalizedString(@"Magnitudo", @""), [EQNNotificeReteSismiche center].energiaTerremotiForti]; - } - - [self.tableView reloadData]; -} - - -#pragma mark - Table view data source - -- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView { - return 1; -} - -- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { - - if (section == 0) - return self.lista.count; - else - return self.listaVibrazioni.count; -} - -- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section{ - - UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"cellSection"]; - UILabel *titolo = (UILabel *)[cell viewWithTag:1]; - if (section == 0) - titolo.text = NSLocalizedString(@"Notifiche da reti sismiche", @"titolo impostazioni notifiche"); - else - titolo.text = NSLocalizedString(@"Vibrazioni e suono", @"titolo impostazioni notifiche"); - - return cell; - -} - -- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{ - - if (indexPath.section == 0) - return 90; - return 50; - -} - -- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { - - if (indexPath.section == 0) { - - switch (indexPath.row) { - case 0:{ - UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"cellaSelezioneAbilita"]; - UILabel *titolo = (UILabel *)[cell viewWithTag:1]; - titolo.text = self.lista[indexPath.row]; - UILabel *stato = (UILabel *)[cell viewWithTag:2]; - stato.text = NSLocalizedString(@"Ricevi le notifiche dei sismi rilevati dalle agenzie nazionalie internazionali", @"voce menu"); - - if (self.isAbilitato){ - cell.accessoryType = UITableViewCellAccessoryCheckmark; - titolo.textColor = [UIColor blackColor]; - stato.textColor = [UIColor blackColor]; - } - else{ - cell.accessoryType = UITableViewCellAccessoryNone; - titolo.textColor = [UIColor grayColor]; - stato.textColor = [UIColor grayColor]; - } - return cell; - - } - break; - case 1:{ - - UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"cellaEnti"]; - UILabel *titolo = (UILabel *)[cell viewWithTag:1]; - titolo.text = self.lista[indexPath.row]; - UILabel *enti = (UILabel *)[cell viewWithTag:2]; - NSString *elencoEnti = @""; - int i = 1; - for (NSString *ente in [EQNNotificeReteSismiche center].listaEnti){ - - NSString *formato = [NSString stringWithFormat:@"%@, ",ente ]; - if (i == [EQNNotificeReteSismiche center].listaEnti.count) - formato = ente; - elencoEnti = [elencoEnti stringByAppendingString:formato]; - i++; - - } - - - enti.text = elencoEnti; - - if (self.isAbilitato){ - titolo.textColor = [UIColor blackColor]; - enti.textColor = self.coloreTesto; - } - else{ - titolo.textColor = [UIColor grayColor]; - enti.textColor = [UIColor grayColor]; - } - - - return cell; - - } - break; - case 2:{ - UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"vociDettagli"]; - - UILabel *titolo = (UILabel *)[cell viewWithTag:1]; - titolo.text = self.lista[indexPath.row]; - // Configure the cell... - self.textRaggioPosizione = (UITextField *)[cell viewWithTag:2]; - self.textRaggioPosizione.inputView = self.pikerViewDistanza.view; - self.textRaggioPosizione.text = self.stringRaggioPosizione; - self.textRaggioPosizione.delegate = self; - if (self.isAbilitato){ - self.textRaggioPosizione.textColor = self.coloreTesto; - titolo.textColor = [UIColor blackColor]; - - } - else{ - self.textRaggioPosizione.textColor = [UIColor grayColor]; - titolo.textColor = [UIColor grayColor]; - - } - - self.textRaggioPosizione.enabled = self.isAbilitato; - return cell; - - } - break; - case 4:{ - UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"cellaSelezioneAbilita"]; - UILabel *titolo = (UILabel *)[cell viewWithTag:1]; - titolo.text = self.lista[indexPath.row]; - UILabel *stato = (UILabel *)[cell viewWithTag:2]; - stato.text = NSLocalizedString(@"Notifica sismi di qualsiasi magnitudo se la distanza è inferiore a", @"voce menu"); - - if (self.isAbilitaVicini && self.isAbilitato){ - cell.accessoryType = UITableViewCellAccessoryCheckmark; - titolo.textColor = [UIColor blackColor]; - stato.textColor = [UIColor blackColor]; - } - else{ - cell.accessoryType = UITableViewCellAccessoryNone; - titolo.textColor = [UIColor grayColor]; - stato.textColor = [UIColor grayColor]; - } - return cell; - - } - break; - - case 3:{ - UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"vociDettagli"]; - - UILabel *titolo = (UILabel *)[cell viewWithTag:1]; - titolo.text = self.lista[indexPath.row]; - // Configure the cell... - self.textEnergiaSisma = (UITextField *)[cell viewWithTag:2]; - self.textEnergiaSisma.inputView = self.pikerViewMagnitudoDebole.view; - self.textEnergiaSisma.text = self.stringEnergiaSisma; - self.textEnergiaSisma.delegate = self; - - if (self.isAbilitato){ - self.textEnergiaSisma.textColor = self.coloreTesto; - titolo.textColor = [UIColor blackColor]; - - } - else{ - self.textEnergiaSisma.textColor = [UIColor grayColor]; - titolo.textColor = [UIColor grayColor]; - - } - - self.textEnergiaSisma.enabled = self.isAbilitato; - - return cell; - - } - break; - case 5:{ - UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"vociDettagli"]; - - UILabel *titolo = (UILabel *)[cell viewWithTag:1]; - titolo.text = self.lista[indexPath.row]; - // Configure the cell... - self.textDistanzaVicini = (UITextField *)[cell viewWithTag:2]; - self.textDistanzaVicini.inputView = self.pikerViewDistanza.view; - self.textDistanzaVicini.text = self.stringDistanzaVicini; - self.textDistanzaVicini.delegate = self; - - if (self.isAbilitaVicini && self.isAbilitato){ - self.textDistanzaVicini.textColor = self.coloreTesto; - titolo.textColor = [UIColor blackColor]; - } - else{ - self.textDistanzaVicini.textColor = [UIColor grayColor]; - titolo.textColor = [UIColor grayColor]; - } - self.textDistanzaVicini.enabled = self.isAbilitaVicini; - self.textDistanzaVicini.enabled = self.isAbilitato; - - - - return cell; - - } - break; - case 6:{ - UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"cellaSelezioneAbilita"]; - UILabel *titolo = (UILabel *)[cell viewWithTag:1]; - titolo.text = self.lista[indexPath.row]; - UILabel *stato = (UILabel *)[cell viewWithTag:2]; - stato.text = NSLocalizedString(@"Notifica sismi forti a qualsiasi distanza se la magnitudo è maggiore a", @"voce menu"); - - if (self.isTerremortiForti && self.isAbilitato){ - cell.accessoryType = UITableViewCellAccessoryCheckmark; - titolo.textColor = [UIColor blackColor]; - stato.textColor = [UIColor blackColor]; - } - else{ - cell.accessoryType = UITableViewCellAccessoryNone; - titolo.textColor = [UIColor grayColor]; - stato.textColor = [UIColor grayColor]; - } - return cell; - - } - break; - case 7:{ - UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"vociDettagli"]; - - UILabel *titolo = (UILabel *)[cell viewWithTag:1]; - titolo.text = self.lista[indexPath.row]; - // Configure the cell... - self.textEnergiaTerremotiForti = (UITextField *)[cell viewWithTag:2]; - self.textEnergiaTerremotiForti.inputView = self.pikerViewMagnitudoForte.view; - self.textEnergiaTerremotiForti.text = self.stringEnergiaTerremotiForti; - self.textEnergiaTerremotiForti.delegate = self; - - if (self.isTerremortiForti && self.isAbilitato){ - self.textEnergiaTerremotiForti.textColor = self.coloreTesto; - titolo.textColor = [UIColor blackColor]; - } - else{ - self.textEnergiaTerremotiForti.textColor = [UIColor grayColor]; - titolo.textColor = [UIColor grayColor]; - } - self.textEnergiaTerremotiForti.enabled = self.isAbilitaVicini; - self.textEnergiaTerremotiForti.enabled = self.isAbilitato; - - return cell; - - } - break; - default:{ - - }break; - } - - } - - // Configure the cell... - - UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"cellaEtichettaRossa"]; - UILabel *titolo = (UILabel *)[cell viewWithTag:1]; - titolo.text = self.listaVibrazioni[indexPath.row]; - titolo.textColor = [UIColor blackColor]; - - return cell; -} - --(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{ - - if(indexPath.section == 0) - switch (indexPath.row) { - case 0:{ - self.isAbilitato = !self.isAbilitato; - [EQNNotificeReteSismiche center].isAbilitato = self.isAbilitato; - [[EQNNotificeReteSismiche center] saveUserInfo]; - [self.tableView reloadData]; - }break; - case 1: - [self performSegueWithIdentifier:@"listaEventi" sender:nil]; - break; - case 4:{ - self.isAbilitaVicini = !self.isAbilitaVicini; - [EQNNotificeReteSismiche center].isAbilitaVicini = self.isAbilitaVicini; - [[EQNNotificeReteSismiche center] saveUserInfo]; - [self.tableView reloadData]; - }break; - case 6:{ - self.isTerremortiForti = !self.isTerremortiForti; - [EQNNotificeReteSismiche center].isTerremortiForti = self.isTerremortiForti; - [[EQNNotificeReteSismiche center] saveUserInfo]; - [self.tableView reloadData]; - }break; - default: - break; - } - - else{ - - } - -} - - -# pragma textFild delegate -- (BOOL)textFieldShouldBeginEditing:(UITextField *)textField{ - - self.textFild = textField; - - return YES; -} - -# pragma mark pikerView string - --(void)inviaDati:(NSDictionary *)elementi{ - - NSString *elemento = elementi[@"elemento"]; - NSNumber *indice = elementi[@"indice"]; - - if ([elemento isEqualToString:NSLocalizedString(@"Qualsiasi distanza", @"voce elenco raggio sismi")]) { - elemento = @"100000"; - } - - if (self.textFild == self.textRaggioPosizione) - [EQNNotificeReteSismiche center].distanzaPosizione = elemento; - - if (self.textFild == self.textDistanzaVicini) - [EQNNotificeReteSismiche center].distanzaVicini = elemento; - - if (self.textFild == self.textEnergiaSisma){ - - NSString *intesita = @""; - switch ([indice intValue]) { - case 0: - intesita = @"2.0"; - break; - case 1: - intesita = @"3.0"; - break; - case 2: - intesita = @"3.5"; - break; - case 3: - intesita = @"4.0"; - break; - case 4: - intesita = @"4.5"; - break; - case 5: - intesita = @"5.0"; - break; - case 6: - intesita = @"5.5"; - break; - default: - break; - } - - [EQNNotificeReteSismiche center].energiaSisma = intesita; - - } - - if (self.textFild == self.textEnergiaTerremotiForti) { - - NSString *intesita = @""; - switch ([indice intValue]) { - case 0: - intesita = @"5.5"; - break; - case 1: - intesita = @"6.0"; - break; - case 2: - intesita = @"6.5"; - break; - case 3: - intesita = @"7.0"; - break; - case 4: - intesita = @"7.5"; - break; - default: - break; - } - - [EQNNotificeReteSismiche center].energiaTerremotiForti = intesita; - - } - [[EQNNotificeReteSismiche center] saveUserInfo]; - - [self setupView]; - - [self.tableView endEditing:YES]; - -} - --(void)chiudiView{ - - [self.tableView endEditing:YES]; - -} - -@end