Files
eqn.ios/Sources/Earthquake Network/ViewController/impostazioniNotifiche/ManuTableViewController.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

228 lines
7.6 KiB
Objective-C

//
// ManuTableViewController.m
// Earthquake Network
//
// Created by Luca Beretta on 08/01/2019.
// Copyright © 2019 Luca Beretta. All rights reserved.
//
#import "ManuTableViewController.h"
#import "EQNUser.h"
#import "Costanti.h"
#import "SWRevealViewController.h"
@interface ManuTableViewController ()
@property (nonatomic, strong) NSArray *lista;
@end
@implementation ManuTableViewController
- (void)viewDidLoad {
[super viewDidLoad];
// Uncomment the following line to preserve selection between presentations.
// self.clearsSelectionOnViewWillAppear = NO;
// Uncomment the following line to display an Edit button in the navigation bar for this view controller.
// self.navigationItem.rightBarButtonItem = self.editButtonItem;
self.lista = @[@"presentazione",
NSLocalizedString(@"Impostazioni", @"voce menu"),
NSLocalizedString(@"Informazioni", @"voce menu"),
NSLocalizedString(@"F.A.Q.", @"voce menu"),
/*NSLocalizedString(@"Lista notifiche", @"voce menu"),*/
NSLocalizedString(@"Disclaimer", @"voce menu"),
NSLocalizedString(@"Autore", @"voce menu"),
NSLocalizedString(@"Privacy", @"voce menu")];
}
#pragma mark - Table view data source
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
return 1;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
return self.lista.count;
}
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
switch (indexPath.row) {
case 0:
return 160;
break;
default:
return 61;
break;
}
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
switch (indexPath.row) {
case 0:{
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"presentazioneMenu" forIndexPath:indexPath];
NSString *versioneString = NSLocalizedString(@"Versione", @"etichetta versione app");
UILabel *versione = (UILabel *)[cell viewWithTag:1];
versione.text = [NSString stringWithFormat:@"%@: %@", versioneString,[[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleShortVersionString"]];
UILabel *idUtente = (UILabel *)[cell viewWithTag:2];
idUtente.text = [NSString stringWithFormat:@"ID: %@", [EQNUser defaultUser].user_ID];
CAGradientLayer *gradient = [CAGradientLayer layer];
UIColor *blueColor = [UIColor colorWithRed:0.47 green:0.72 blue:0.98 alpha:1];
gradient.frame = cell.bounds;
gradient.colors = @[(id)blueColor.CGColor, (id)[UIColor whiteColor].CGColor];
[cell.layer insertSublayer:gradient atIndex:0];
return cell;
}
break;
default:{
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"vociMenu" forIndexPath:indexPath];
UILabel *titolo = (UILabel *)[cell viewWithTag:1];
titolo.text = self.lista[indexPath.row];
UIImageView *icona = (UIImageView *)[cell viewWithTag:2];
NSString *iconaString = @"";
switch (indexPath.row) {
case 1:
iconaString = @"ic_settings_black_24dp";
break;
case 2:
iconaString = @"ic_info_outline_black_24dp";
break;
case 3:
iconaString = @"ic_help_outline_black_24dp";
break;
case 4:
iconaString = @"ic_star_border_black_24dp";
break;
case 5:
iconaString = @"ic_verified_user_black_24dp";
break;
case 6:
iconaString = @"ic_person_black_24dp";
break;
case 7:
iconaString = @"ic_shield_half_full_black_24dp";
break;
default:
break;
}
icona.image = [UIImage imageNamed:iconaString];
return cell;
}
break;
}
}
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
//SWRevealViewController *revealViewController = self.revealViewController;
// if ( revealViewController )
[self.revealViewController revealToggleAnimated:YES];
NSString *indirizzo = @"";
NSString * language = [[NSLocale preferredLanguages] firstObject];
language = [language substringToIndex:2];
if ([language isEqualToString:@"it"])
indirizzo = INDIRIZZO_ITALIANO;
else if ([language isEqualToString:@"es"])
indirizzo = INDIRIZZO_SPAGNOLO;
else
indirizzo = INDIRIZZO_INGLESE;
switch (indexPath.row) {
case 0:
return;
break;
case 1:
[[NSNotificationCenter defaultCenter] postNotificationName:NOTIFICHE_SISMI object:nil];
return;
break;
case 3:
indirizzo = [indirizzo stringByAppendingString:@"/f-a-q/"];
break;
case 4:
indirizzo = [indirizzo stringByAppendingString:@"/terms-conditions/"];
break;
case 5:
indirizzo = [indirizzo stringByAppendingString:@"/contact/"];
break;
case 6:
indirizzo = [indirizzo stringByAppendingString:@"/privacy/"];
break;
/* default:
[[NSNotificationCenter defaultCenter] postNotificationName:INFORMAZIONI_APP_MENU object:nil userInfo:@{@"indice" : indexPath}];
break;*/
}
NSLog(@"indirizzo %@ %@", indirizzo, language);
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:indirizzo] options:@{} completionHandler:nil];
}
/*
// Override to support conditional editing of the table view.
- (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath {
// Return NO if you do not want the specified item to be editable.
return YES;
}
*/
/*
// Override to support editing the table view.
- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath {
if (editingStyle == UITableViewCellEditingStyleDelete) {
// Delete the row from the data source
[tableView deleteRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationFade];
} else if (editingStyle == UITableViewCellEditingStyleInsert) {
// Create a new instance of the appropriate class, insert it into the array, and add a new row to the table view
}
}
*/
/*
// Override to support rearranging the table view.
- (void)tableView:(UITableView *)tableView moveRowAtIndexPath:(NSIndexPath *)fromIndexPath toIndexPath:(NSIndexPath *)toIndexPath {
}
*/
/*
// Override to support conditional rearranging of the table view.
- (BOOL)tableView:(UITableView *)tableView canMoveRowAtIndexPath:(NSIndexPath *)indexPath {
// Return NO if you do not want the item to be re-orderable.
return YES;
}
*/
#pragma mark - Navigation
// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
// Get the new view controller using [segue destinationViewController].
// Pass the selected object to the new view controller.
}
@end