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

121 lines
3.9 KiB
Objective-C

//
// PrioritaViewController.m
// Earthquake Network
//
// Created by Luca Beretta on 16/10/18.
// Copyright © 2018 Luca Beretta. All rights reserved.
//
#import "PrioritaViewController.h"
#import "ServerRequest.h"
#import "Costanti.h"
@interface PrioritaViewController () <UITableViewDelegate, UITableViewDataSource>
@property (nonatomic, strong) NSArray *lista;
@property (nonatomic, strong) IBOutlet UITableView *tableView;
@property (nonatomic, strong) NSString *top_10k_available;
@property (nonatomic, strong) NSString *top_100k_available;
@end
@implementation PrioritaViewController
- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view.
[self scaricautentiDisponibili];
UIView *viewNavigationBar = [[UIView alloc] initWithFrame:CGRectMake(-18, 5, 150, 44)];
UIImageView *imageLogo = [[UIImageView alloc] initWithFrame:CGRectMake(-18, 5, 38, 38)];
imageLogo.image = [UIImage imageNamed:@"distquake_app_wave"];
[viewNavigationBar addSubview:imageLogo];
UILabel *textForNavi = [[UILabel alloc] initWithFrame:CGRectMake(25, 5, 160, 38)];
textForNavi.text = NSLocalizedString(@"Rilevatore Terremoti", @"titolo navigation bar");
[viewNavigationBar addSubview:textForNavi];
self.navigationItem.titleView = viewNavigationBar;
}
-(void)scaricautentiDisponibili{
[[ServerRequest defaultServerConnectionSingleton] inviaInformazioniAlServerWithURL:[NSURL URLWithString:URL_SERVER_UTENTI_DISPONIBILI] richiesta:utentiDisponibili success:^(id result) {
NSArray *disp = result;
for (NSDictionary *dict in disp) {
if ([dict objectForKey:@"top_10k_available"]) {
self.top_10k_available = [dict objectForKey:@"top_10k_available"];
}
if ([dict objectForKey:@"top_100k_available"]) {
self.top_100k_available = [dict objectForKey:@"top_100k_available"];
}
}
self.lista = @[@"1",@"2"];
dispatch_async(dispatch_get_main_queue(), ^{
[self.tableView reloadData];
});
} failure:^(NSError * error) {
}];
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
#pragma table view
- (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 126;
break;
default:
return 372;
break;
}
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
// modalita base
switch (indexPath.row) {
case 0:{
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"sottoscrizioniAttive" forIndexPath:indexPath];
return cell;
}
break;
default:{
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"servizioPriorità" forIndexPath:indexPath];
UILabel *descrizione = (UILabel *)[cell viewWithTag:100];
descrizione.text = [NSString stringWithFormat:@"Top 10K: %@ %@\n\nTop 100K: %@ %@", self.top_10k_available, NSLocalizedString(@"sottoscrizioni ancora disponibiliper essere allertato in meno di 1 secondo dal rilevamento del sistema", @"descrizione Top 10K"), self.top_100k_available, NSLocalizedString(@"sottoscrizioni ancora disponibiliper essere allertato in meno di 5 secondi dal rilevamento del sistema", @"descrizione Top 100K")];
return cell;
}
break;
}
}
@end