128 lines
4.0 KiB
Objective-C
128 lines
4.0 KiB
Objective-C
//
|
|
// MenuSelezioneEntiViewController.m
|
|
// Earthquake Network
|
|
//
|
|
// Created by Luca Beretta on 06/02/2019.
|
|
// Copyright © 2019 Luca Beretta. All rights reserved.
|
|
//
|
|
|
|
#import "MenuSelezioneEntiViewController.h"
|
|
#import "PickerViewController.h"
|
|
#import "costanti.h"
|
|
#import "EQNUtility.h"
|
|
|
|
@interface MenuSelezioneEntiViewController () <PickerViewDelegate>
|
|
@property (nonatomic, strong) PickerViewController *pikerViewNazione;
|
|
@property (nonatomic, assign) EQNNazioneSelect indice;
|
|
@property (nonatomic, assign) EQNfiltroEnti tipoFiltro;
|
|
|
|
@end
|
|
|
|
@implementation MenuSelezioneEntiViewController
|
|
|
|
- (void)viewDidLoad {
|
|
[super viewDidLoad];
|
|
// Do any additional setup after loading the view.
|
|
|
|
NSArray *nazioniList = [EQNUtility arrayNazioni];
|
|
|
|
self.pikerViewNazione = [[PickerViewController alloc] initWithNibName:@"PickerViewController" bundle:nil dati:nazioniList];
|
|
self.pikerViewNazione.delegate = self;
|
|
self.textNazione.inputView = self.pikerViewNazione.view;
|
|
|
|
if ([[NSUserDefaults standardUserDefaults] integerForKey:IMPOSTAZIONE_NAZIONE_RETI_SISMICHEI]) {
|
|
self.textNazione.text = nazioniList[[[NSUserDefaults standardUserDefaults] integerForKey:IMPOSTAZIONE_NAZIONE_RETI_SISMICHEI]];
|
|
}
|
|
}
|
|
|
|
/*
|
|
#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.
|
|
}
|
|
*/
|
|
|
|
- (IBAction)selezionaNazione:(id)sender {
|
|
|
|
if (self.textNazione.text.length == 0) {
|
|
|
|
UIAlertController *messaggio = [UIAlertController alertControllerWithTitle:NSLocalizedString(@"Attenzione ", @"") message:NSLocalizedString(@"Non hai seleziato nessuna nazione", @"") preferredStyle:UIAlertControllerStyleAlert];
|
|
UIAlertAction* defaultAction = [UIAlertAction actionWithTitle:@"OK" style:UIAlertActionStyleDefault
|
|
handler:^(UIAlertAction * action) {
|
|
|
|
[self.textNazione becomeFirstResponder];
|
|
}];
|
|
|
|
[messaggio addAction:defaultAction];
|
|
[self presentViewController:messaggio animated:YES completion:nil];
|
|
|
|
|
|
}else{
|
|
|
|
NSArray *enti = [EQNUtility arrayEnti];
|
|
[[NSUserDefaults standardUserDefaults] setInteger:self.indice forKey:IMPOSTAZIONE_NAZIONE_RETI_SISMICHEI];
|
|
|
|
if (self.indice == 0) {
|
|
|
|
[[NSUserDefaults standardUserDefaults] setObject:enti forKey:IMPOSTAZIONE_ENTI_RETI_SISMICHEI];
|
|
}else{
|
|
|
|
NSArray *ente = @[enti[self.indice]];
|
|
[[NSUserDefaults standardUserDefaults] setObject:ente forKey:IMPOSTAZIONE_ENTI_RETI_SISMICHEI];
|
|
|
|
}
|
|
|
|
self.tipoFiltro = nazione;
|
|
[self chiudi];
|
|
}
|
|
}
|
|
|
|
- (IBAction)selezionaEnte:(id)sender {
|
|
|
|
self.tipoFiltro = enti;
|
|
if ([self.delegate respondsToSelector:@selector(menuSelezioneEntiWillOpenProviders:)]) {
|
|
[self.delegate menuSelezioneEntiWillOpenProviders:self];
|
|
}
|
|
[self annulla:sender];
|
|
|
|
}
|
|
|
|
- (IBAction)annulla:(id)sender {
|
|
|
|
// self.tipoFiltro = annulla;
|
|
[self dismissViewControllerAnimated:YES completion:nil];
|
|
|
|
}
|
|
|
|
- (void)chiudi
|
|
{
|
|
if ([self.delegate respondsToSelector:@selector(menuSelezioneEnti:willSendData:)]) {
|
|
[self.delegate menuSelezioneEnti:self willSendData:self.tipoFiltro];
|
|
}
|
|
[self dismissViewControllerAnimated:YES completion:nil];
|
|
|
|
}
|
|
|
|
# pragma mark pikerView string
|
|
|
|
-(void)inviaDati:(NSDictionary *)elementi{
|
|
|
|
NSString *elemento = elementi[@"elemento"];
|
|
self.indice = [elementi[@"indice"] intValue];
|
|
self.textNazione.text = elemento;
|
|
[self.view endEditing:YES];
|
|
|
|
}
|
|
|
|
-(void)chiudiView{
|
|
|
|
[self.view endEditing:YES];
|
|
|
|
}
|
|
|
|
|
|
@end
|