Files
eqn.ios/Sources/Earthquake Network/ViewController/impostazioniNotifiche/AreaInteresseTableViewController.m
T
Andrea Busi 4d8bbdc7ef Production version
Add to Git the current app version (the same available in the OriginalZip folder)
2020-07-24 15:33:53 +02:00

86 lines
2.8 KiB
Objective-C

//
// AreaInteresseTableViewController.m
// Earthquake Network
//
// Created by Luca Beretta on 14/01/2019.
// Copyright © 2019 Luca Beretta. All rights reserved.
//
#import "AreaInteresseTableViewController.h"
#import "EQNUtility.h"
#import "EQNNotificheTsunami.h"
@interface AreaInteresseTableViewController ()
@end
@implementation AreaInteresseTableViewController
- (void)viewDidLoad {
[super viewDidLoad];
if (![EQNNotificheTsunami center].listaAreeInteresse) {
[EQNNotificheTsunami center].listaAreeInteresse = [[EQNUtility arrayAreeInteresseTsunami] copy];
[[EQNNotificheTsunami center] saveUserInfo];
}
}
#pragma mark - Table view data source
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
return 1;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
return [EQNUtility arrayAreeInteresseTsunami].count;;
}
- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section{
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"cellSection"];
UILabel *titolo = (UILabel *)[cell viewWithTag:1];
titolo.text = NSLocalizedString(@"Area di interesse", @"titolo impostazioni notifiche");
return cell;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"cellaSelezioneAbilita" forIndexPath:indexPath];
UILabel *titolo = (UILabel *)[cell viewWithTag:1];
titolo.text = [EQNUtility arrayAreeInteresseTsunami][indexPath.row];
UILabel *stato = (UILabel *)[cell viewWithTag:2];
stato.text = NSLocalizedString(@"Ricevi le notifiche dei sismi rilevati dalle agenzie nazionalie internazionali", @"voce menu");
if ([[EQNNotificheTsunami center].listaAreeInteresse containsObject:titolo.text]){
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;
}
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
NSMutableArray *array = [[EQNNotificheTsunami center].listaAreeInteresse mutableCopy];
NSString *selezioneEnete = [EQNUtility arrayAreeInteresseTsunami][indexPath.row];
if ([array containsObject:selezioneEnete])
[array removeObject:selezioneEnete];
else
[array addObject:selezioneEnete];
[EQNNotificheTsunami center].listaAreeInteresse = [NSArray arrayWithArray:array];
[[EQNNotificheTsunami center] saveUserInfo];
[self.tableView reloadData];
}
@end