refactor: Move settings as tab section
- Rewrite Settings controller in Swift - Move settings as tab bar item - Force settings save when user change tab or back from a sub-setting controller
This commit is contained in:
@@ -52,7 +52,6 @@
|
||||
8C7CD64821F7D0F800835812 /* ReteSismicaAnnotation.m in Sources */ = {isa = PBXBuildFile; fileRef = 8CD08637218B3BEE0000CB5E /* ReteSismicaAnnotation.m */; };
|
||||
8C7CD64921F7D11700835812 /* ReteSismicaAnnotation.m in Frameworks */ = {isa = PBXBuildFile; fileRef = 8CD08637218B3BEE0000CB5E /* ReteSismicaAnnotation.m */; };
|
||||
8C7CD64A21F7D11700835812 /* ReteSismicaAnnotation.h in Frameworks */ = {isa = PBXBuildFile; fileRef = 8CD08636218B3BEE0000CB5E /* ReteSismicaAnnotation.h */; };
|
||||
8C7E945A21E548A600B0B770 /* SettingsViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 8C7E945921E548A600B0B770 /* SettingsViewController.m */; };
|
||||
8C8EBBA721540039002784BA /* EQNUser.m in Sources */ = {isa = PBXBuildFile; fileRef = 8C8EBBA621540039002784BA /* EQNUser.m */; };
|
||||
8C9B755C2233A25100F8FDEE /* MenuFiltroEntiViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 8C9B755B2233A25100F8FDEE /* MenuFiltroEntiViewController.m */; };
|
||||
8C9B755F2233BFDE00F8FDEE /* FiltroEnti.m in Sources */ = {isa = PBXBuildFile; fileRef = 8C9B755E2233BFDE00F8FDEE /* FiltroEnti.m */; };
|
||||
@@ -111,6 +110,7 @@
|
||||
DC27EB2F24F6EBE000ACBFE0 /* SettingsSeismicNetworksViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = DC27EB2E24F6EBE000ACBFE0 /* SettingsSeismicNetworksViewController.swift */; };
|
||||
DC3ADD3924CB2F3D00737919 /* alert_star_trek.wav in Resources */ = {isa = PBXBuildFile; fileRef = 8CF12CC721DE43A400613AC5 /* alert_star_trek.wav */; };
|
||||
DC3BA11124D1A9C90062EE7F /* SubscriptionsViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = DC3BA11024D1A9C90062EE7F /* SubscriptionsViewController.swift */; };
|
||||
DC52B8A224FC145500ABEBA6 /* SettingsBaseViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = DC52B8A124FC145500ABEBA6 /* SettingsBaseViewController.m */; };
|
||||
DC886A5D24E92D5500F7A5D3 /* EQNBaseViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = DC886A5C24E92D5500F7A5D3 /* EQNBaseViewController.m */; };
|
||||
DC99A50324E66E270071BC9F /* EQNCommandProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = DC99A50224E66E270071BC9F /* EQNCommandProtocol.swift */; };
|
||||
DC99A50524E66E430071BC9F /* EQNAppearanceCommand.swift in Sources */ = {isa = PBXBuildFile; fileRef = DC99A50424E66E430071BC9F /* EQNAppearanceCommand.swift */; };
|
||||
@@ -119,6 +119,7 @@
|
||||
DCAB01E324CEBFE800E8B54C /* MenuViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = DCAB01E224CEBFE800E8B54C /* MenuViewController.swift */; };
|
||||
DCAB01E524CEC12E00E8B54C /* MenuHeaderTableViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = DCAB01E424CEC12E00E8B54C /* MenuHeaderTableViewCell.swift */; };
|
||||
DCAB01E724CEC22100E8B54C /* MenuItemTableViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = DCAB01E624CEC22100E8B54C /* MenuItemTableViewCell.swift */; };
|
||||
DCB28CEE24FB8400001F557E /* SettingsViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = DCB28CED24FB8400001F557E /* SettingsViewController.swift */; };
|
||||
DCB6FBEC24D0B40600ED23B8 /* Colors.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = DCB6FBEB24D0B40600ED23B8 /* Colors.xcassets */; };
|
||||
DCBB267A24D1E7F500F04559 /* SubscriptionsHeaderTableViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = DCBB267924D1E7F500F04559 /* SubscriptionsHeaderTableViewCell.swift */; };
|
||||
DCBB267C24D1E98300F04559 /* EQNBaseTableViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = DCBB267B24D1E98300F04559 /* EQNBaseTableViewCell.swift */; };
|
||||
@@ -232,8 +233,6 @@
|
||||
8C6CBAE421597E79005C426A /* GoogleService-Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = "GoogleService-Info.plist"; sourceTree = "<group>"; };
|
||||
8C7A3B64225A5EA30045B266 /* NSDictionary+BVJSONString.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "NSDictionary+BVJSONString.m"; sourceTree = "<group>"; };
|
||||
8C7A3B65225A5EA40045B266 /* NSDictionary+BVJSONString.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "NSDictionary+BVJSONString.h"; sourceTree = "<group>"; };
|
||||
8C7E945821E548A600B0B770 /* SettingsViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = SettingsViewController.h; sourceTree = "<group>"; };
|
||||
8C7E945921E548A600B0B770 /* SettingsViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = SettingsViewController.m; sourceTree = "<group>"; };
|
||||
8C8EBBA521540039002784BA /* EQNUser.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = EQNUser.h; sourceTree = "<group>"; };
|
||||
8C8EBBA621540039002784BA /* EQNUser.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = EQNUser.m; sourceTree = "<group>"; };
|
||||
8C9B755A2233A25100F8FDEE /* MenuFiltroEntiViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MenuFiltroEntiViewController.h; sourceTree = "<group>"; };
|
||||
@@ -333,6 +332,8 @@
|
||||
DC27EB2E24F6EBE000ACBFE0 /* SettingsSeismicNetworksViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SettingsSeismicNetworksViewController.swift; sourceTree = "<group>"; };
|
||||
DC3BA11024D1A9C90062EE7F /* SubscriptionsViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SubscriptionsViewController.swift; sourceTree = "<group>"; };
|
||||
DC414C0024CDA09A008D9AE4 /* CHANGELOG.md */ = {isa = PBXFileReference; lastKnownFileType = net.daringfireball.markdown; name = CHANGELOG.md; path = ../CHANGELOG.md; sourceTree = "<group>"; };
|
||||
DC52B8A024FC145500ABEBA6 /* SettingsBaseViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = SettingsBaseViewController.h; sourceTree = "<group>"; };
|
||||
DC52B8A124FC145500ABEBA6 /* SettingsBaseViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = SettingsBaseViewController.m; sourceTree = "<group>"; };
|
||||
DC886A5B24E92D5500F7A5D3 /* EQNBaseViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = EQNBaseViewController.h; sourceTree = "<group>"; };
|
||||
DC886A5C24E92D5500F7A5D3 /* EQNBaseViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = EQNBaseViewController.m; sourceTree = "<group>"; };
|
||||
DC99A50224E66E270071BC9F /* EQNCommandProtocol.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = EQNCommandProtocol.swift; sourceTree = "<group>"; };
|
||||
@@ -342,6 +343,7 @@
|
||||
DCAB01E224CEBFE800E8B54C /* MenuViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MenuViewController.swift; sourceTree = "<group>"; };
|
||||
DCAB01E424CEC12E00E8B54C /* MenuHeaderTableViewCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MenuHeaderTableViewCell.swift; sourceTree = "<group>"; };
|
||||
DCAB01E624CEC22100E8B54C /* MenuItemTableViewCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MenuItemTableViewCell.swift; sourceTree = "<group>"; };
|
||||
DCB28CED24FB8400001F557E /* SettingsViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SettingsViewController.swift; sourceTree = "<group>"; };
|
||||
DCB6FBEB24D0B40600ED23B8 /* Colors.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Colors.xcassets; sourceTree = "<group>"; };
|
||||
DCBB267924D1E7F500F04559 /* SubscriptionsHeaderTableViewCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SubscriptionsHeaderTableViewCell.swift; sourceTree = "<group>"; };
|
||||
DCBB267B24D1E98300F04559 /* EQNBaseTableViewCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = EQNBaseTableViewCell.swift; sourceTree = "<group>"; };
|
||||
@@ -786,8 +788,9 @@
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
DCEFF21124F581F9009D3FE1 /* Cells */,
|
||||
8C7E945821E548A600B0B770 /* SettingsViewController.h */,
|
||||
8C7E945921E548A600B0B770 /* SettingsViewController.m */,
|
||||
DCB28CED24FB8400001F557E /* SettingsViewController.swift */,
|
||||
DC52B8A024FC145500ABEBA6 /* SettingsBaseViewController.h */,
|
||||
DC52B8A124FC145500ABEBA6 /* SettingsBaseViewController.m */,
|
||||
8CCE165321EA378800173CD9 /* SettingsUserReportAlertsViewController.h */,
|
||||
8CCE165421EA378800173CD9 /* SettingsUserReportAlertsViewController.m */,
|
||||
8CCE165621EB1E0000173CD9 /* SettingsSeismicNetworkAlertsViewController.h */,
|
||||
@@ -1104,6 +1107,7 @@
|
||||
DCAB01E524CEC12E00E8B54C /* MenuHeaderTableViewCell.swift in Sources */,
|
||||
8CCE165121E7BAEC00173CD9 /* EQNNotificeReteSismiche.m in Sources */,
|
||||
8C13E84B220B2E7E0009CFE4 /* MenuSelezioneEntiViewController.m in Sources */,
|
||||
DC52B8A224FC145500ABEBA6 /* SettingsBaseViewController.m in Sources */,
|
||||
8CF4F4DB216D44930057110B /* EQNPastquakes.m in Sources */,
|
||||
8CCE165821EB1E0000173CD9 /* SettingsSeismicNetworkAlertsViewController.m in Sources */,
|
||||
8CCE165521EA378800173CD9 /* SettingsUserReportAlertsViewController.m in Sources */,
|
||||
@@ -1114,7 +1118,6 @@
|
||||
8CCE164E21E7BACE00173CD9 /* EQNNotificheSegnalazioniUtente.m in Sources */,
|
||||
DCD4571C24F6CF0D00B58304 /* EQNGenericValue.swift in Sources */,
|
||||
8C4E343F215012FA008B0D2A /* EQNManager.m in Sources */,
|
||||
8C7E945A21E548A600B0B770 /* SettingsViewController.m in Sources */,
|
||||
8CABD7212194B7C700C3E09C /* ImpostazioniViewController.m in Sources */,
|
||||
DCAA913F24F68A1D00145A3D /* SettingMultivaluesTableViewCell.swift in Sources */,
|
||||
DCF9E14F24F6EA07002B6B1D /* EQNSeismicNetwork.swift in Sources */,
|
||||
@@ -1176,6 +1179,7 @@
|
||||
8C9B755C2233A25100F8FDEE /* MenuFiltroEntiViewController.m in Sources */,
|
||||
8CBD3DC72149B9AD0070C963 /* AppDelegate.m in Sources */,
|
||||
8CA46BA12194532E00C63C16 /* SismaAnnotation.m in Sources */,
|
||||
DCB28CEE24FB8400001F557E /* SettingsViewController.swift in Sources */,
|
||||
8C602246218D9DB200C799C2 /* PastquakesDettagliMappa.m in Sources */,
|
||||
8CAFD7C82182648600F8BD29 /* EQNRetiSismiViewController.m in Sources */,
|
||||
DCEFF21A24F587E3009D3FE1 /* SettingItem.swift in Sources */,
|
||||
|
||||
@@ -123,6 +123,17 @@ static NSString * const SegueIdentifierLogs = @"ShowLogs";
|
||||
self.selectedIndex = index;
|
||||
}
|
||||
|
||||
#pragma mark - Private
|
||||
|
||||
- (void)saveSettings
|
||||
{
|
||||
[[ServerRequest defaultServerConnectionSingleton] inviaInformazioniAlServerWithURL:[EQNGeneratoreURLServer urlInvioImpostazioniNotifiche] richiesta:impostazioniNotifiche success:^(id result){
|
||||
NSLog(@"Settings saved successfully");
|
||||
} failure:^(NSError *error){
|
||||
NSLog(@"Settings saved failed. Error: %@", error.localizedDescription);
|
||||
}];
|
||||
}
|
||||
|
||||
#pragma mark - Helpers
|
||||
|
||||
- (UIViewController *)getTopControllerFromController:(UIViewController *)viewController
|
||||
@@ -140,6 +151,17 @@ static NSString * const SegueIdentifierLogs = @"ShowLogs";
|
||||
|
||||
#pragma mark - UITabBarControllerDelegate
|
||||
|
||||
- (BOOL)tabBarController:(UITabBarController *)tabBarController shouldSelectViewController:(UIViewController *)viewController
|
||||
{
|
||||
// if user switch from settings page, we need to force a settings save
|
||||
UIViewController *controller = [self getTopControllerFromController:tabBarController.selectedViewController];
|
||||
if ([controller isKindOfClass:[SettingsViewController class]]) {
|
||||
[self saveSettings];
|
||||
}
|
||||
|
||||
return YES;
|
||||
}
|
||||
|
||||
- (void)tabBarController:(UITabBarController *)tabBarController didSelectViewController:(UIViewController *)viewController
|
||||
{
|
||||
UIViewController *controller = [self getTopControllerFromController:viewController];
|
||||
|
||||
+3
-3
@@ -1,8 +1,8 @@
|
||||
//
|
||||
// SettingsViewController.h
|
||||
// SettingsBaseViewController.h
|
||||
// Earthquake Network
|
||||
//
|
||||
// Refactored by Andrea Busi 25/08/2020.
|
||||
// Created by Busi Andrea on 30/08/2020.
|
||||
// Copyright © 2020 Earthquake Network. All rights reserved.
|
||||
//
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface SettingsViewController : UITableViewController
|
||||
@interface SettingsBaseViewController : UITableViewController
|
||||
|
||||
@end
|
||||
|
||||
@@ -0,0 +1,42 @@
|
||||
//
|
||||
// SettingsBaseViewController.m
|
||||
// Earthquake Network
|
||||
//
|
||||
// Created by Busi Andrea on 30/08/2020.
|
||||
// Copyright © 2020 Earthquake Network. All rights reserved.
|
||||
//
|
||||
|
||||
#import "SettingsBaseViewController.h"
|
||||
#import "ServerRequest.h"
|
||||
#import "EQNGeneratoreURLServer.h"
|
||||
|
||||
@interface SettingsBaseViewController ()
|
||||
|
||||
@end
|
||||
|
||||
@implementation SettingsBaseViewController
|
||||
|
||||
#pragma mark - View Lifecycle
|
||||
|
||||
- (void)viewWillDisappear:(BOOL)animated
|
||||
{
|
||||
[super viewWillDisappear:animated];
|
||||
|
||||
// when controller is dismissed, save settings
|
||||
if (self.isMovingFromParentViewController) {
|
||||
[self saveSettings];
|
||||
}
|
||||
}
|
||||
|
||||
#pragma mark - Private
|
||||
|
||||
- (void)saveSettings
|
||||
{
|
||||
[[ServerRequest defaultServerConnectionSingleton] inviaInformazioniAlServerWithURL:[EQNGeneratoreURLServer urlInvioImpostazioniNotifiche] richiesta:impostazioniNotifiche success:^(id result){
|
||||
NSLog(@"Settings saved successfully");
|
||||
} failure:^(NSError *error){
|
||||
NSLog(@"Settings saved failed. Error: %@", error.localizedDescription);
|
||||
}];
|
||||
}
|
||||
|
||||
@end
|
||||
+2
-1
@@ -7,10 +7,11 @@
|
||||
//
|
||||
|
||||
#import <UIKit/UIKit.h>
|
||||
#import "SettingsBaseViewController.h"
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface SettingsRealTimeAlertsViewController : UITableViewController
|
||||
@interface SettingsRealTimeAlertsViewController : SettingsBaseViewController
|
||||
|
||||
@end
|
||||
|
||||
|
||||
@@ -88,6 +88,8 @@ typedef NS_ENUM(NSInteger, RowIdentifier) {
|
||||
|
||||
- (void)setupUI
|
||||
{
|
||||
self.navigationItem.largeTitleDisplayMode = UINavigationItemLargeTitleDisplayModeNever;
|
||||
|
||||
self.tableView.estimatedRowHeight = 200.0;
|
||||
self.tableView.rowHeight = UITableViewAutomaticDimension;
|
||||
[self.tableView registerClass:[SettingSectionHeaderView class] forHeaderFooterViewReuseIdentifier:SettingSectionHeaderView.Identifier];
|
||||
|
||||
+2
-1
@@ -7,10 +7,11 @@
|
||||
//
|
||||
|
||||
#import <UIKit/UIKit.h>
|
||||
#import "SettingsBaseViewController.h"
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface SettingsSeismicNetworkAlertsViewController : UITableViewController
|
||||
@interface SettingsSeismicNetworkAlertsViewController : SettingsBaseViewController
|
||||
|
||||
@end
|
||||
|
||||
|
||||
+2
@@ -78,6 +78,8 @@ typedef NS_ENUM(NSInteger, RowIdentifier) {
|
||||
|
||||
- (void)setupUI
|
||||
{
|
||||
self.navigationItem.largeTitleDisplayMode = UINavigationItemLargeTitleDisplayModeNever;
|
||||
|
||||
self.tableView.estimatedRowHeight = 200.0;
|
||||
self.tableView.rowHeight = UITableViewAutomaticDimension;
|
||||
[self.tableView registerClass:[SettingSectionHeaderView class] forHeaderFooterViewReuseIdentifier:SettingSectionHeaderView.Identifier];
|
||||
|
||||
+2
-1
@@ -7,10 +7,11 @@
|
||||
//
|
||||
|
||||
#import <UIKit/UIKit.h>
|
||||
#import "SettingsBaseViewController.h"
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface SettingsUserReportAlertsViewController : UITableViewController
|
||||
@interface SettingsUserReportAlertsViewController : SettingsBaseViewController
|
||||
|
||||
@end
|
||||
|
||||
|
||||
+2
@@ -39,6 +39,8 @@
|
||||
|
||||
- (void)setupUI
|
||||
{
|
||||
self.navigationItem.largeTitleDisplayMode = UINavigationItemLargeTitleDisplayModeNever;
|
||||
|
||||
self.tableView.estimatedRowHeight = 100.0;
|
||||
self.tableView.rowHeight = UITableViewAutomaticDimension;
|
||||
[self.tableView registerClass:[SettingSectionHeaderView class] forHeaderFooterViewReuseIdentifier:SettingSectionHeaderView.Identifier];
|
||||
|
||||
@@ -1,79 +0,0 @@
|
||||
//
|
||||
// SettingsViewController.m
|
||||
// Earthquake Network
|
||||
//
|
||||
// Refactored by Andrea Busi 25/08/2020.
|
||||
// Copyright © 2020 Earthquake Network. All rights reserved.
|
||||
//
|
||||
|
||||
#import "SettingsViewController.h"
|
||||
#import "ServerRequest.h"
|
||||
#import "EQNGeneratoreURLServer.h"
|
||||
|
||||
@interface SettingsViewController ()
|
||||
@property (nonatomic, strong) NSArray<SettingItem *> *settings;
|
||||
@end
|
||||
|
||||
@implementation SettingsViewController
|
||||
|
||||
static NSString * const SegueIdentifierAllertaSismica = @"ShowAllertaSismica";
|
||||
static NSString * const SegueIdentifierNotificheSegnalazioniUtente = @"ShowNotificheSegnalazioniUtente";
|
||||
static NSString * const SegueIdentifierNotificheRetiSismiche = @"ShowNotificheRetiSismiche";
|
||||
|
||||
#pragma mark - View Lifecycle
|
||||
|
||||
- (void)viewDidLoad
|
||||
{
|
||||
[super viewDidLoad];
|
||||
|
||||
self.title = NSLocalizedString(@"Impostazioni", @"");
|
||||
[self.tableView registerClass:[SettingDetailTableViewCell class] forCellReuseIdentifier:SettingDetailTableViewCell.Identifier];
|
||||
|
||||
self.settings = @[
|
||||
[[SettingItem alloc] initWithType:SettingTypeDetail title:NSLocalizedString(@"Allerta in tempo reale", @"") subtitle:nil icon:@"🚨" segue:SegueIdentifierAllertaSismica],
|
||||
[[SettingItem alloc] initWithType:SettingTypeDetail title:NSLocalizedString(@"Notifiche da reti sismiche", @"") subtitle:nil icon:@"🔔" segue:SegueIdentifierNotificheRetiSismiche],
|
||||
[[SettingItem alloc] initWithType:SettingTypeDetail title:NSLocalizedString(@"Notifiche segnalazioni utente", @"") subtitle:nil icon:@"🔔" segue:SegueIdentifierNotificheSegnalazioniUtente]
|
||||
];
|
||||
}
|
||||
|
||||
#pragma mark - Table view data source
|
||||
|
||||
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
|
||||
{
|
||||
return self.settings.count;
|
||||
}
|
||||
|
||||
|
||||
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
|
||||
{
|
||||
SettingDetailTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:SettingDetailTableViewCell.Identifier forIndexPath:indexPath];
|
||||
SettingItem *setting = self.settings[indexPath.row];
|
||||
cell.textLabel.text = setting.displayTitle;
|
||||
cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
|
||||
return cell;
|
||||
}
|
||||
|
||||
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
|
||||
{
|
||||
SettingItem *setting = self.settings[indexPath.row];
|
||||
if (setting.segue) {
|
||||
[self performSegueWithIdentifier:setting.segue sender:nil];
|
||||
}
|
||||
}
|
||||
|
||||
#pragma mark - Actions
|
||||
|
||||
- (IBAction)closeTapped:(id)sender
|
||||
{
|
||||
[[ServerRequest defaultServerConnectionSingleton] inviaInformazioniAlServerWithURL:[EQNGeneratoreURLServer urlInvioImpostazioniNotifiche] richiesta:impostazioniNotifiche success:^(id result){
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
[self dismissViewControllerAnimated:YES completion:nil];
|
||||
});
|
||||
} failure:^(NSError *error){
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
[self dismissViewControllerAnimated:YES completion:nil];
|
||||
});
|
||||
}];
|
||||
}
|
||||
|
||||
@end
|
||||
@@ -0,0 +1,128 @@
|
||||
//
|
||||
// SettingsViewController.swift
|
||||
// Earthquake Network
|
||||
//
|
||||
// Created by Busi Andrea on 30/08/2020.
|
||||
// Copyright © 2020 Earthquake Network. All rights reserved.
|
||||
//
|
||||
|
||||
import UIKit
|
||||
import SafariServices
|
||||
|
||||
class SettingsViewController: UITableViewController {
|
||||
|
||||
private static let SegueIdentifierAllertaSismica = "ShowAllertaSismica"
|
||||
private static let SegueIdentifierNotificheSegnalazioniUtente = "ShowNotificheSegnalazioniUtente"
|
||||
private static let SegueIdentifierNotificheRetiSismiche = "ShowNotificheRetiSismiche"
|
||||
private static let SegueIdentifierSafari = "ShowSafari"
|
||||
|
||||
private enum InfoItem: Int {
|
||||
case informations
|
||||
case faq
|
||||
case help
|
||||
case author
|
||||
case sponsors
|
||||
case disclaimer
|
||||
case privacy
|
||||
|
||||
var externalUrl: URL? {
|
||||
let baseUrl = EQNWebsiteAddress
|
||||
switch self {
|
||||
case .informations: return URL(string: "\(baseUrl)")
|
||||
case .faq: return URL(string: "\(baseUrl)/f-a-q/")
|
||||
case .help: return URL(string: "\(baseUrl)/help/")
|
||||
case .author: return URL(string: "\(baseUrl)/contact/")
|
||||
case .sponsors: return URL(string: "\(baseUrl)/sponsors/")
|
||||
case .disclaimer: return URL(string: "\(baseUrl)/terms-conditions/")
|
||||
case .privacy: return URL(string: "\(baseUrl)/privacy/")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private var settings: [[SettingItem]] = [
|
||||
[
|
||||
SettingItem(type: .detail, title: NSLocalizedString("Allerta in tempo reale", comment: ""), segue: SegueIdentifierAllertaSismica, emoji: "🚨"),
|
||||
SettingItem(type: .detail, title: NSLocalizedString("Notifiche da reti sismiche", comment: ""), segue: SegueIdentifierNotificheRetiSismiche, emoji: "🔔"),
|
||||
SettingItem(type: .detail, title: NSLocalizedString("Notifiche segnalazioni utente", comment: ""), segue: SegueIdentifierNotificheSegnalazioniUtente, emoji: "🔔")
|
||||
],
|
||||
[
|
||||
SettingItem(type: .detail, title: NSLocalizedString("Informazioni", comment: ""), segue: SegueIdentifierSafari, icon: "menu-icon-info"),
|
||||
SettingItem(type: .detail, title: NSLocalizedString("F.A.Q.", comment: ""), segue: SegueIdentifierSafari, icon: "menu-icon-faq"),
|
||||
SettingItem(type: .detail, title: NSLocalizedString("Help", comment: ""), segue: SegueIdentifierSafari, icon: "menu-icon-help"),
|
||||
SettingItem(type: .detail, title: NSLocalizedString("Autore", comment: ""), segue: SegueIdentifierSafari, icon: "menu-icon-author"),
|
||||
SettingItem(type: .detail, title: NSLocalizedString("Patrocinatori", comment: ""), segue: SegueIdentifierSafari, icon: "menu-icon-sponsors"),
|
||||
SettingItem(type: .detail, title: NSLocalizedString("Disclaimer", comment: ""), segue: SegueIdentifierSafari, icon: "menu-icon-terms"),
|
||||
SettingItem(type: .detail, title: NSLocalizedString("Privacy", comment: ""), segue: SegueIdentifierSafari, icon: "menu-icon-privacy")
|
||||
]
|
||||
]
|
||||
|
||||
// MARK: - View Lifecycle
|
||||
|
||||
override func viewDidLoad() {
|
||||
super.viewDidLoad()
|
||||
|
||||
title = NSLocalizedString("Impostazioni", comment: "")
|
||||
setupUI()
|
||||
}
|
||||
|
||||
// MARK: - Private
|
||||
|
||||
private func setupUI() {
|
||||
tableView.register(SettingDetailTableViewCell.self, forCellReuseIdentifier: SettingDetailTableViewCell.Identifier)
|
||||
tableView.contentInset = UIEdgeInsets(top: 20.0, left: 0.0, bottom: 0.0, right: 0.0)
|
||||
}
|
||||
|
||||
// MARK: - Table view data source
|
||||
|
||||
override func numberOfSections(in tableView: UITableView) -> Int {
|
||||
settings.count
|
||||
}
|
||||
|
||||
override func tableView(_ tableView: UITableView, titleForFooterInSection section: Int) -> String? {
|
||||
if section == 0 {
|
||||
return nil
|
||||
}
|
||||
|
||||
var title = ""
|
||||
if let appVersion = Bundle.main.infoDictionary?["CFBundleShortVersionString"] as? String {
|
||||
let version = NSLocalizedString("Versione", comment: "etichetta versione app")
|
||||
title = "\(version): \(appVersion)"
|
||||
}
|
||||
|
||||
let userId = EQNUser.default().user_ID ?? "n.d."
|
||||
title = "\(title) - User id: \(userId)"
|
||||
|
||||
return title
|
||||
}
|
||||
|
||||
override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
|
||||
let aSection = settings[section]
|
||||
return aSection.count
|
||||
}
|
||||
|
||||
override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
|
||||
let setting = settings[indexPath.section][indexPath.row]
|
||||
let cell = tableView.dequeueReusableCell(withIdentifier: SettingDetailTableViewCell.Identifier, for: indexPath) as! SettingDetailTableViewCell
|
||||
cell.textLabel?.text = setting.displayTitle
|
||||
if let icon = setting.icon {
|
||||
cell.imageView?.tintColor = .darkGray
|
||||
cell.imageView?.image = UIImage(named: icon)
|
||||
}
|
||||
cell.accessoryType = .disclosureIndicator
|
||||
return cell
|
||||
}
|
||||
|
||||
override func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
|
||||
tableView.deselectRow(at: indexPath, animated: true)
|
||||
let setting = settings[indexPath.section][indexPath.row]
|
||||
if let segue = setting.segue {
|
||||
if segue == Self.SegueIdentifierSafari, let item = InfoItem(rawValue: indexPath.row), let url = item.externalUrl {
|
||||
// show Safari with the given URL
|
||||
let controller = SFSafariViewController(url: url)
|
||||
present(controller, animated: true, completion: nil)
|
||||
} else {
|
||||
performSegue(withIdentifier: segue, sender: nil)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -49,5 +49,8 @@ public class EQNAppearanceCommand: EQNCommandProtocol {
|
||||
NSAttributedString.Key.foregroundColor: UIColor.white
|
||||
]
|
||||
}
|
||||
|
||||
let proxyTabBar = UITabBar.appearance()
|
||||
proxyTabBar.tintColor = UIColor(named: "Red")!
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,13 +22,14 @@ import Foundation
|
||||
class SettingItem: NSObject {
|
||||
let title: String
|
||||
let subtitle: String?
|
||||
let icon: String?
|
||||
let segue: String?
|
||||
let icon: String?
|
||||
let emoji: String?
|
||||
let type: SettingType
|
||||
|
||||
var displayTitle: String {
|
||||
if let icon = icon {
|
||||
return "\(icon) \(title)"
|
||||
if let emoji = emoji {
|
||||
return "\(emoji) \(title)"
|
||||
}
|
||||
return title
|
||||
}
|
||||
@@ -36,22 +37,31 @@ class SettingItem: NSObject {
|
||||
// MARK: - Init
|
||||
|
||||
convenience init(type: SettingType, title: String) {
|
||||
self.init(type: type, title: title, subtitle: nil, icon: nil, segue: nil)
|
||||
self.init(type: type, title: title, subtitle: nil, segue: nil, icon: nil, emoji: nil)
|
||||
}
|
||||
|
||||
convenience init(type: SettingType, title: String, subtitle: String) {
|
||||
self.init(type: type, title: title, subtitle: subtitle, icon: nil, segue: nil)
|
||||
self.init(type: type, title: title, subtitle: subtitle, segue: nil, icon: nil, emoji: nil)
|
||||
}
|
||||
|
||||
convenience init(type: SettingType, title: String, segue: String) {
|
||||
self.init(type: type, title: title, subtitle: nil, icon: nil, segue: segue)
|
||||
self.init(type: type, title: title, subtitle: nil, segue: segue, icon: nil, emoji: nil)
|
||||
}
|
||||
|
||||
init(type: SettingType, title: String, subtitle: String? = nil, icon: String? = nil, segue: String? = nil) {
|
||||
convenience init(type: SettingType, title: String, segue: String, icon: String) {
|
||||
self.init(type: type, title: title, subtitle: nil, segue: segue, icon: icon, emoji: nil)
|
||||
}
|
||||
|
||||
convenience init(type: SettingType, title: String, segue: String, emoji: String) {
|
||||
self.init(type: type, title: title, subtitle: nil, segue: segue, icon: nil, emoji: emoji)
|
||||
}
|
||||
|
||||
init(type: SettingType, title: String, subtitle: String? = nil, segue: String? = nil, icon: String? = nil, emoji: String? = nil) {
|
||||
self.type = type
|
||||
self.title = title
|
||||
self.subtitle = subtitle
|
||||
self.icon = icon
|
||||
self.segue = segue
|
||||
self.icon = icon
|
||||
self.emoji = emoji
|
||||
}
|
||||
}
|
||||
|
||||
+23
@@ -0,0 +1,23 @@
|
||||
{
|
||||
"images" : [
|
||||
{
|
||||
"filename" : "tabbar-icon-settings.png",
|
||||
"idiom" : "universal",
|
||||
"scale" : "1x"
|
||||
},
|
||||
{
|
||||
"filename" : "tabbar-icon-settings@2x.png",
|
||||
"idiom" : "universal",
|
||||
"scale" : "2x"
|
||||
},
|
||||
{
|
||||
"filename" : "tabbar-icon-settings@3x.png",
|
||||
"idiom" : "universal",
|
||||
"scale" : "3x"
|
||||
}
|
||||
],
|
||||
"info" : {
|
||||
"author" : "xcode",
|
||||
"version" : 1
|
||||
}
|
||||
}
|
||||
BIN
Binary file not shown.
|
After Width: | Height: | Size: 1.8 KiB |
BIN
Binary file not shown.
|
After Width: | Height: | Size: 2.4 KiB |
BIN
Binary file not shown.
|
After Width: | Height: | Size: 3.0 KiB |
@@ -1,5 +1,5 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="16097.2" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="BYZ-38-t0r">
|
||||
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="16097.2" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="CWo-PE-Dqp">
|
||||
<device id="retina4_0" orientation="portrait" appearance="light"/>
|
||||
<dependencies>
|
||||
<deployment identifier="iOS"/>
|
||||
@@ -2528,8 +2528,8 @@ In più sostieni il progetto di ricerca il quale non riceve finanziamenti estern
|
||||
<segue destination="Qva-UZ-dos" kind="relationship" relationship="viewControllers" id="Gut-Ub-oRh"/>
|
||||
<segue destination="1d8-oR-UOQ" kind="relationship" relationship="viewControllers" id="8F0-ud-Dtb"/>
|
||||
<segue destination="OV8-Cl-IaS" kind="presentation" identifier="ShowInitialLoading" modalPresentationStyle="fullScreen" modalTransitionStyle="coverVertical" id="Cmi-EJ-jD5"/>
|
||||
<segue destination="1Ig-lx-PLm" kind="presentation" identifier="ShowSettings" modalPresentationStyle="fullScreen" id="GcE-Ki-D03"/>
|
||||
<segue destination="noK-2F-IZE" kind="presentation" identifier="ShowLogs" id="nTq-XX-Uts"/>
|
||||
<segue destination="1Ig-lx-PLm" kind="relationship" relationship="viewControllers" id="bBS-RW-R9T"/>
|
||||
</connections>
|
||||
</tabBarController>
|
||||
<placeholder placeholderIdentifier="IBFirstResponder" id="JkD-5l-otE" userLabel="First Responder" customClass="UIResponder" sceneMemberID="firstResponder"/>
|
||||
@@ -2823,7 +2823,7 @@ In più sostieni il progetto di ricerca il quale non riceve finanziamenti estern
|
||||
<!--Settings-->
|
||||
<scene sceneID="nIl-RI-AZv">
|
||||
<objects>
|
||||
<tableViewController id="lfN-fJ-Rhu" customClass="SettingsViewController" sceneMemberID="viewController">
|
||||
<tableViewController id="lfN-fJ-Rhu" customClass="SettingsViewController" customModule="Earthquake_Network" customModuleProvider="target" sceneMemberID="viewController">
|
||||
<tableView key="view" clipsSubviews="YES" contentMode="scaleToFill" alwaysBounceVertical="YES" dataMode="prototypes" style="insetGrouped" separatorStyle="default" rowHeight="-1" estimatedRowHeight="-1" sectionHeaderHeight="18" sectionFooterHeight="18" id="w1e-nB-r5b">
|
||||
<rect key="frame" x="0.0" y="0.0" width="320" height="568"/>
|
||||
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
|
||||
@@ -2833,13 +2833,7 @@ In più sostieni il progetto di ricerca il quale non riceve finanziamenti estern
|
||||
<outlet property="delegate" destination="lfN-fJ-Rhu" id="0TK-rn-wet"/>
|
||||
</connections>
|
||||
</tableView>
|
||||
<navigationItem key="navigationItem" title="Settings" id="4HJ-mw-8dz">
|
||||
<barButtonItem key="rightBarButtonItem" style="done" systemItem="done" id="Evv-sz-Dkd">
|
||||
<connections>
|
||||
<action selector="closeTapped:" destination="lfN-fJ-Rhu" id="g3p-Bo-wXU"/>
|
||||
</connections>
|
||||
</barButtonItem>
|
||||
</navigationItem>
|
||||
<navigationItem key="navigationItem" title="Settings" id="4HJ-mw-8dz"/>
|
||||
<connections>
|
||||
<segue destination="oA9-rq-Kqp" kind="show" identifier="ShowAllertaSismica" id="PKv-wx-VXN"/>
|
||||
<segue destination="jlJ-xb-75r" kind="show" identifier="ShowNotificheRetiSismiche" id="jjk-tO-OBj"/>
|
||||
@@ -2848,7 +2842,7 @@ In più sostieni il progetto di ricerca il quale non riceve finanziamenti estern
|
||||
</tableViewController>
|
||||
<placeholder placeholderIdentifier="IBFirstResponder" id="Lzh-6m-4x5" userLabel="First Responder" sceneMemberID="firstResponder"/>
|
||||
</objects>
|
||||
<point key="canvasLocation" x="-7973" y="-379"/>
|
||||
<point key="canvasLocation" x="-7824" y="-2802"/>
|
||||
</scene>
|
||||
<!--Settings Seismic Networks View Controller-->
|
||||
<scene sceneID="LVn-Sl-UM6">
|
||||
@@ -2867,7 +2861,7 @@ In più sostieni il progetto di ricerca il quale non riceve finanziamenti estern
|
||||
</tableViewController>
|
||||
<placeholder placeholderIdentifier="IBFirstResponder" id="Uvt-gu-Bum" userLabel="First Responder" sceneMemberID="firstResponder"/>
|
||||
</objects>
|
||||
<point key="canvasLocation" x="-5901" y="-360"/>
|
||||
<point key="canvasLocation" x="-5753" y="-2783"/>
|
||||
</scene>
|
||||
<!--Settings Real Time Alerts View Controller-->
|
||||
<scene sceneID="fj3-1O-nSI">
|
||||
@@ -2886,7 +2880,7 @@ In più sostieni il progetto di ricerca il quale non riceve finanziamenti estern
|
||||
</tableViewController>
|
||||
<placeholder placeholderIdentifier="IBFirstResponder" id="z3g-sW-ZwB" userLabel="First Responder" sceneMemberID="firstResponder"/>
|
||||
</objects>
|
||||
<point key="canvasLocation" x="-6853" y="-1093"/>
|
||||
<point key="canvasLocation" x="-6701" y="-3517"/>
|
||||
</scene>
|
||||
<!--Settings User Report Alerts View Controller-->
|
||||
<scene sceneID="70o-xn-uI2">
|
||||
@@ -2905,7 +2899,7 @@ In più sostieni il progetto di ricerca il quale non riceve finanziamenti estern
|
||||
</tableViewController>
|
||||
<placeholder placeholderIdentifier="IBFirstResponder" id="D0G-lo-3RH" userLabel="First Responder" sceneMemberID="firstResponder"/>
|
||||
</objects>
|
||||
<point key="canvasLocation" x="-6853" y="425"/>
|
||||
<point key="canvasLocation" x="-6701" y="-1999"/>
|
||||
</scene>
|
||||
<!--Settings Seismic Network Alerts View Controller-->
|
||||
<scene sceneID="44E-lc-Pfe">
|
||||
@@ -2927,15 +2921,16 @@ In più sostieni il progetto di ricerca il quale non riceve finanziamenti estern
|
||||
</tableViewController>
|
||||
<placeholder placeholderIdentifier="IBFirstResponder" id="Ycw-pT-hjt" userLabel="First Responder" sceneMemberID="firstResponder"/>
|
||||
</objects>
|
||||
<point key="canvasLocation" x="-6853" y="-360"/>
|
||||
<point key="canvasLocation" x="-6701" y="-2783"/>
|
||||
</scene>
|
||||
<!--Navigation Controller-->
|
||||
<!--Settings-->
|
||||
<scene sceneID="bcf-1h-akt">
|
||||
<objects>
|
||||
<navigationController automaticallyAdjustsScrollViewInsets="NO" id="1Ig-lx-PLm" sceneMemberID="viewController">
|
||||
<tabBarItem key="tabBarItem" title="Settings" image="tabbar-icon-settings" id="5VO-yI-kw5"/>
|
||||
<toolbarItems/>
|
||||
<navigationBar key="navigationBar" contentMode="scaleToFill" insetsLayoutMarginsFromSafeArea="NO" id="B9g-HM-VPb">
|
||||
<rect key="frame" x="0.0" y="0.0" width="320" height="44"/>
|
||||
<navigationBar key="navigationBar" contentMode="scaleToFill" insetsLayoutMarginsFromSafeArea="NO" largeTitles="YES" id="B9g-HM-VPb">
|
||||
<rect key="frame" x="0.0" y="0.0" width="320" height="91"/>
|
||||
<autoresizingMask key="autoresizingMask"/>
|
||||
</navigationBar>
|
||||
<nil name="viewControllers"/>
|
||||
@@ -2945,7 +2940,7 @@ In più sostieni il progetto di ricerca il quale non riceve finanziamenti estern
|
||||
</navigationController>
|
||||
<placeholder placeholderIdentifier="IBFirstResponder" id="We7-MM-5Sn" userLabel="First Responder" sceneMemberID="firstResponder"/>
|
||||
</objects>
|
||||
<point key="canvasLocation" x="-8856" y="-379"/>
|
||||
<point key="canvasLocation" x="-8708" y="-2802"/>
|
||||
</scene>
|
||||
<!--Navigation Controller-->
|
||||
<scene sceneID="ugg-0S-WiU">
|
||||
@@ -3214,6 +3209,7 @@ In più sostieni il progetto di ricerca il quale non riceve finanziamenti estern
|
||||
<image name="tabbar-icon-alerts" width="25" height="25"/>
|
||||
<image name="tabbar-icon-networks" width="25" height="25"/>
|
||||
<image name="tabbar-icon-reports" width="25" height="25"/>
|
||||
<image name="tabbar-icon-settings" width="25" height="25"/>
|
||||
<image name="top_100k" width="97.5" height="30"/>
|
||||
<image name="top_10k" width="86" height="26.5"/>
|
||||
<namedColor name="Light blue">
|
||||
|
||||
@@ -543,3 +543,4 @@
|
||||
"aeo-GH-qCD.title" = "Alertas";
|
||||
"oaL-SG-Zpq.title" = "Informes";
|
||||
"eed-sY-0Ua.title" = "Redes Sísmicas";
|
||||
"5VO-yI-kw5.title" = "Ajustes";
|
||||
|
||||
@@ -543,3 +543,4 @@
|
||||
"aeo-GH-qCD.title" = "Allerte";
|
||||
"oaL-SG-Zpq.title" = "Segnalazioni";
|
||||
"eed-sY-0Ua.title" = "Reti Sismiche";
|
||||
"5VO-yI-kw5.title" = "Impostazioni";
|
||||
|
||||
Reference in New Issue
Block a user