refactor: New style for "Notifiche sismi" settings page

This commit is contained in:
Andrea Busi
2020-08-25 20:10:06 +02:00
parent 9344eae39a
commit 87becee4fb
6 changed files with 186 additions and 400 deletions
@@ -130,6 +130,7 @@
DCD3E3C024D15576007C78D4 /* PurchaseProVersionViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = DCD3E3BF24D15576007C78D4 /* PurchaseProVersionViewController.swift */; };
DCDE0BD924E58CCE00209778 /* EQNMainTabBarController.m in Sources */ = {isa = PBXBuildFile; fileRef = DCDE0BD824E58CCE00209778 /* EQNMainTabBarController.m */; };
DCEFF21324F5821E009D3FE1 /* SettingDetailTableViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = DCEFF21224F5821E009D3FE1 /* SettingDetailTableViewCell.swift */; };
DCEFF21724F58569009D3FE1 /* SettingSectionHeaderView.swift in Sources */ = {isa = PBXBuildFile; fileRef = DCEFF21624F58569009D3FE1 /* SettingSectionHeaderView.swift */; };
DCEFF21A24F587E3009D3FE1 /* SettingItem.swift in Sources */ = {isa = PBXBuildFile; fileRef = DCEFF21924F587E3009D3FE1 /* SettingItem.swift */; };
DCF10DC624D2B8C7009F34C3 /* EQNPurchaseUtility.swift in Sources */ = {isa = PBXBuildFile; fileRef = DCF10DC524D2B8C7009F34C3 /* EQNPurchaseUtility.swift */; };
DCF10DCD24D2C935009F34C3 /* EQNPurchaseAvailability.swift in Sources */ = {isa = PBXBuildFile; fileRef = DCF10DCC24D2C935009F34C3 /* EQNPurchaseAvailability.swift */; };
@@ -356,6 +357,7 @@
DCDE0BD724E58CCE00209778 /* EQNMainTabBarController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = EQNMainTabBarController.h; sourceTree = "<group>"; };
DCDE0BD824E58CCE00209778 /* EQNMainTabBarController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = EQNMainTabBarController.m; sourceTree = "<group>"; };
DCEFF21224F5821E009D3FE1 /* SettingDetailTableViewCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SettingDetailTableViewCell.swift; sourceTree = "<group>"; };
DCEFF21624F58569009D3FE1 /* SettingSectionHeaderView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SettingSectionHeaderView.swift; sourceTree = "<group>"; };
DCEFF21924F587E3009D3FE1 /* SettingItem.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SettingItem.swift; sourceTree = "<group>"; };
DCF10DC524D2B8C7009F34C3 /* EQNPurchaseUtility.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = EQNPurchaseUtility.swift; sourceTree = "<group>"; };
DCF10DCC24D2C935009F34C3 /* EQNPurchaseAvailability.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = EQNPurchaseAvailability.swift; sourceTree = "<group>"; };
@@ -542,8 +544,6 @@
8CCE164521E69A9300173CD9 /* impostazioniNotifiche */ = {
isa = PBXGroup;
children = (
8C149FA121E54E85002C44FD /* NotificheSismiTableViewController.h */,
8C149FA221E54E85002C44FD /* NotificheSismiTableViewController.m */,
8CCE164621E69AEC00173CD9 /* TempoRealeTableViewController.h */,
8CCE164721E69AEC00173CD9 /* TempoRealeTableViewController.m */,
8CCE165321EA378800173CD9 /* SegnalazioniUtentiTableViewController.h */,
@@ -809,9 +809,16 @@
DCEFF21124F581F9009D3FE1 /* Cells */,
8C7E945821E548A600B0B770 /* SettingsViewController.h */,
8C7E945921E548A600B0B770 /* SettingsViewController.m */,
8C149FA121E54E85002C44FD /* NotificheSismiTableViewController.h */,
8C149FA221E54E85002C44FD /* NotificheSismiTableViewController.m */,
);
path = Settings;
sourceTree = "<group>";
};
DCEFF21124F581F9009D3FE1 /* Cells */ = {
isa = PBXGroup;
children = (
DCEFF21624F58569009D3FE1 /* SettingSectionHeaderView.swift */,
DCEFF21224F5821E009D3FE1 /* SettingDetailTableViewCell.swift */,
);
path = Cells;
@@ -1148,6 +1155,7 @@
8CD08631218ADFCA0000CB5E /* Cell_Reti_sismicheTableViewCell.m in Sources */,
DCF10DC624D2B8C7009F34C3 /* EQNPurchaseUtility.swift in Sources */,
8C2B251121938BFD00E0E25E /* SegnalazioniUtenteDettagliMappa.m in Sources */,
DCEFF21724F58569009D3FE1 /* SettingSectionHeaderView.swift in Sources */,
8C14113121ED3E5B00A59729 /* AllertaSismiTableViewController.m in Sources */,
8CCE164B21E7BAB200173CD9 /* EQNNotificheTempoReale.m in Sources */,
DCBB267A24D1E7F500F04559 /* SubscriptionsHeaderTableViewCell.swift in Sources */,
@@ -0,0 +1,50 @@
//
// SettingSectionHeaderView.swift
// Earthquake Network
//
// Created by Busi Andrea on 25/08/2020.
// Copyright © 2020 Earthquake Network. All rights reserved.
//
import UIKit
class SettingSectionHeaderView: UITableViewHeaderFooterView {
@objc static let Identifier = "SectionHeaderView"
@objc static let Height = 50.0
// MARK: - Properties
@objc lazy var titleLabel: UILabel = {
let titleLabel = UILabel()
titleLabel.font = UIFont.preferredFont(forTextStyle: .headline)
titleLabel.textColor = UIColor(named: "Light blue")
return titleLabel
}()
// MARK: - Init
override init(reuseIdentifier: String?) {
super.init(reuseIdentifier: reuseIdentifier)
setupUI()
}
required init?(coder: NSCoder) {
super.init(coder: coder)
setupUI()
}
// MARK: - Private
private func setupUI() {
contentView.addSubview(titleLabel)
titleLabel.translatesAutoresizingMaskIntoConstraints = false
titleLabel.centerYAnchor.constraint(equalTo: contentView.centerYAnchor).isActive = true
titleLabel.trailingAnchor.constraint(equalTo: contentView.trailingAnchor).isActive = true
titleLabel.leadingAnchor.constraint(equalTo: contentView.leadingAnchor).isActive = true
}
}
@@ -2,8 +2,8 @@
// NotificheSismiTableViewController.h
// Earthquake Network
//
// Created by Luca Beretta on 08/01/2019.
// Copyright © 2019 Luca Beretta. All rights reserved.
// Refactored by Andrea Busi 25/08/2020.
// Copyright © 2020 Earthquake Network. All rights reserved.
//
#import <UIKit/UIKit.h>
@@ -11,7 +11,6 @@
NS_ASSUME_NONNULL_BEGIN
@interface NotificheSismiTableViewController : UITableViewController
@property (nonatomic, strong) NSArray *lista;
@end
@@ -0,0 +1,122 @@
//
// NotificheSismiTableViewController.m
// Earthquake Network
//
// Refactored by Andrea Busi 25/08/2020.
// Copyright © 2020 Earthquake Network. All rights reserved.
//
#import "NotificheSismiTableViewController.h"
#import "TBDInputViewControllerData.h"
#import "EQNImpostazioniNotifiche.h"
#import "EQNUtility.h"
#import "EQNNotificheTempoReale.h"
#import "EQNNotificheSegnalazioniUtente.h"
@interface NotificheSismiTableViewController () <InputViewControllerDataDelegate, UITextFieldDelegate>
@property (nonatomic, strong) NSArray<SettingItem *> *settings;
@property (nonatomic, assign) BOOL abilitaIntervallo;
@property (nonatomic, strong) TBDInputViewControllerData *pikerViewController;
@property (nonatomic, strong) NSString *oraInizio;
@property (nonatomic, strong) NSString *oraFine;
@property (nonatomic, strong) UITextField *textFildInizio;
@property (nonatomic, strong) UITextField *textFildfine;
@property (nonatomic, strong) UITextField *textFild;
@property (nonatomic, strong) NSDateFormatter *dateFormatter;
@end
@implementation NotificheSismiTableViewController
static NSString * const SegueIdentifierSegnalazioniUtente = @"segnalazioneUtenti";
static NSString * const SegueIdentifierRetiSismiche = @"retiSismiche";
#pragma mark - View Lifecycle
- (void)viewDidLoad
{
[super viewDidLoad];
self.settings = @[
[[SettingItem alloc] initWithTitle:NSLocalizedString(@"Notifiche segnalazioni utente", @"voce menu") icon:nil segue:SegueIdentifierSegnalazioniUtente],
[[SettingItem alloc] initWithTitle:NSLocalizedString(@"Notifiche da reti sismiche", @"voce menu") icon:nil segue:SegueIdentifierRetiSismiche]
];
[self.tableView registerClass:[SettingDetailTableViewCell class] forCellReuseIdentifier:SettingDetailTableViewCell.Identifier];
[self.tableView registerClass:[SettingSectionHeaderView class] forHeaderFooterViewReuseIdentifier:SettingSectionHeaderView.Identifier];
self.pikerViewController = [[TBDInputViewControllerData alloc] initWithNibName:@"TBDInputViewControllerData" bundle:nil];
self.pikerViewController.delegate = self;
self.dateFormatter = [[NSDateFormatter alloc] init];
[self.dateFormatter setDateFormat:@"HH:mm"];
[self updateUI];
}
#pragma mark - Private
- (void)updateUI
{
self.abilitaIntervallo = [EQNImpostazioniNotifiche center].attivaIntervalloNotifica;
if ([EQNImpostazioniNotifiche center].oraioInizio)
self.oraInizio = [self.dateFormatter stringFromDate:[EQNImpostazioniNotifiche center].oraioInizio];
else
self.oraInizio = @"8:00";
if ([EQNImpostazioniNotifiche center].orarioFine)
self.oraFine = [self.dateFormatter stringFromDate:[EQNImpostazioniNotifiche center].orarioFine];
else
self.oraFine = @"22:00";
}
#pragma mark - Table view data source
- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
{
SettingSectionHeaderView *headerView = [tableView dequeueReusableHeaderFooterViewWithIdentifier:SettingSectionHeaderView.Identifier];
headerView.titleLabel.text = NSLocalizedString(@"Notifiche sismi", @"titolo impostazioni notifiche");
return headerView;
}
- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
{
return SettingSectionHeaderView.Height;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
return self.settings.count;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
SettingDetailTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:SettingDetailTableViewCell.Identifier];
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];
[self performSegueWithIdentifier:setting.segue sender:nil];
}
# pragma mark pikerViewdata data
- (void)dataSelezionata:(NSDate *)data withTextFild:(UITextField *)textFild
{
self.textFild.text = [self.dateFormatter stringFromDate:data];
if (self.textFild == self.textFildInizio)
[EQNImpostazioniNotifiche center].oraioInizio = data;
else
[EQNImpostazioniNotifiche center].orarioFine = data;
[[EQNImpostazioniNotifiche center] saveUserInfo];
[self updateUI];
[self.tableView endEditing:YES];
}
@end
@@ -3711,168 +3711,10 @@ In più sostieni il progetto di ricerca il quale non riceve finanziamenti estern
<scene sceneID="SuQ-Fi-PSx">
<objects>
<tableViewController id="e2e-CQ-gxv" customClass="NotificheSismiTableViewController" sceneMemberID="viewController">
<tableView key="view" clipsSubviews="YES" contentMode="scaleToFill" alwaysBounceVertical="YES" dataMode="prototypes" style="plain" separatorStyle="default" rowHeight="-1" estimatedRowHeight="-1" sectionHeaderHeight="28" sectionFooterHeight="28" id="7fF-Jd-rIu">
<tableView key="view" clipsSubviews="YES" contentMode="scaleToFill" alwaysBounceVertical="YES" dataMode="prototypes" style="insetGrouped" separatorStyle="default" rowHeight="-1" estimatedRowHeight="-1" sectionHeaderHeight="18" sectionFooterHeight="18" id="7fF-Jd-rIu">
<rect key="frame" x="0.0" y="0.0" width="320" height="568"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<prototypes>
<tableViewCell clipsSubviews="YES" contentMode="scaleToFill" preservesSuperviewLayoutMargins="YES" selectionStyle="default" indentationWidth="10" reuseIdentifier="vociDettagli" rowHeight="90" id="ngG-Cg-94P">
<rect key="frame" x="0.0" y="28" width="320" height="90"/>
<autoresizingMask key="autoresizingMask"/>
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" preservesSuperviewLayoutMargins="YES" insetsLayoutMarginsFromSafeArea="NO" tableViewCell="ngG-Cg-94P" id="gBe-1s-4J0">
<rect key="frame" x="0.0" y="0.0" width="320" height="90"/>
<autoresizingMask key="autoresizingMask"/>
<subviews>
<label opaque="NO" userInteractionEnabled="NO" tag="1" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Label" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="Kv4-iM-8Td">
<rect key="frame" x="16" y="11" width="288" height="39"/>
<constraints>
<constraint firstAttribute="height" constant="39" id="ZMs-Tv-Ktj"/>
</constraints>
<fontDescription key="fontDescription" type="system" pointSize="17"/>
<nil key="textColor"/>
<nil key="highlightedColor"/>
</label>
<textField opaque="NO" tag="2" contentMode="scaleToFill" contentHorizontalAlignment="left" contentVerticalAlignment="center" textAlignment="natural" minimumFontSize="17" translatesAutoresizingMaskIntoConstraints="NO" id="ko8-kC-GUX">
<rect key="frame" x="16" y="52" width="288" height="30"/>
<constraints>
<constraint firstAttribute="height" constant="30" id="ULR-fp-Tmu"/>
</constraints>
<color key="textColor" red="0.0" green="0.56284224989999998" blue="0.31881666180000001" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<fontDescription key="fontDescription" type="system" pointSize="14"/>
<textInputTraits key="textInputTraits"/>
</textField>
</subviews>
<constraints>
<constraint firstAttribute="trailing" secondItem="ko8-kC-GUX" secondAttribute="trailing" constant="16" id="CEz-8w-0mn"/>
<constraint firstItem="Kv4-iM-8Td" firstAttribute="top" secondItem="gBe-1s-4J0" secondAttribute="topMargin" id="F8n-7x-ex3"/>
<constraint firstItem="Kv4-iM-8Td" firstAttribute="leading" secondItem="gBe-1s-4J0" secondAttribute="leadingMargin" id="RQe-IB-kJX"/>
<constraint firstItem="ko8-kC-GUX" firstAttribute="leading" secondItem="gBe-1s-4J0" secondAttribute="leading" constant="16" id="Rvs-sx-Gao"/>
<constraint firstAttribute="trailingMargin" secondItem="Kv4-iM-8Td" secondAttribute="trailing" id="afo-H6-kOC"/>
<constraint firstItem="ko8-kC-GUX" firstAttribute="top" secondItem="Kv4-iM-8Td" secondAttribute="bottom" constant="2" id="zhU-ov-CmK"/>
</constraints>
</tableViewCellContentView>
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
</tableViewCell>
<tableViewCell clipsSubviews="YES" contentMode="scaleToFill" preservesSuperviewLayoutMargins="YES" selectionStyle="none" accessoryType="checkmark" indentationWidth="10" reuseIdentifier="cellaSelezioneOrario" rowHeight="90" id="dZu-f9-a0q">
<rect key="frame" x="0.0" y="118" width="320" height="90"/>
<autoresizingMask key="autoresizingMask"/>
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" preservesSuperviewLayoutMargins="YES" insetsLayoutMarginsFromSafeArea="NO" tableViewCell="dZu-f9-a0q" id="nod-EU-weI">
<rect key="frame" x="0.0" y="0.0" width="280" height="90"/>
<autoresizingMask key="autoresizingMask"/>
<subviews>
<label opaque="NO" userInteractionEnabled="NO" tag="1" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Label" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="VNx-fE-Rhs">
<rect key="frame" x="16" y="11" width="256" height="39"/>
<constraints>
<constraint firstAttribute="height" constant="39" id="YBA-3V-neF"/>
</constraints>
<fontDescription key="fontDescription" type="system" pointSize="17"/>
<nil key="textColor"/>
<nil key="highlightedColor"/>
</label>
<label opaque="NO" userInteractionEnabled="NO" tag="2" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Label" textAlignment="natural" lineBreakMode="tailTruncation" numberOfLines="0" baselineAdjustment="alignBaselines" minimumFontSize="8" translatesAutoresizingMaskIntoConstraints="NO" id="P51-pk-ur9">
<rect key="frame" x="16" y="52" width="256" height="26"/>
<constraints>
<constraint firstAttribute="height" constant="26" id="ZqK-Wq-dSz"/>
</constraints>
<fontDescription key="fontDescription" type="system" pointSize="16"/>
<color key="textColor" white="0.33333333333333331" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<nil key="highlightedColor"/>
</label>
</subviews>
<constraints>
<constraint firstItem="P51-pk-ur9" firstAttribute="leading" secondItem="nod-EU-weI" secondAttribute="leadingMargin" id="Snh-e1-sZV"/>
<constraint firstItem="P51-pk-ur9" firstAttribute="trailing" secondItem="nod-EU-weI" secondAttribute="trailingMargin" id="d3t-fm-Duf"/>
<constraint firstItem="P51-pk-ur9" firstAttribute="top" secondItem="VNx-fE-Rhs" secondAttribute="bottom" constant="2" id="dS3-i9-gFk"/>
<constraint firstItem="VNx-fE-Rhs" firstAttribute="leading" secondItem="nod-EU-weI" secondAttribute="leadingMargin" id="fwZ-Vu-SNQ"/>
<constraint firstItem="VNx-fE-Rhs" firstAttribute="top" secondItem="nod-EU-weI" secondAttribute="topMargin" id="sF8-0s-fPQ"/>
<constraint firstItem="VNx-fE-Rhs" firstAttribute="trailing" secondItem="nod-EU-weI" secondAttribute="trailingMargin" id="tSa-Lg-vuK"/>
</constraints>
</tableViewCellContentView>
</tableViewCell>
<tableViewCell clipsSubviews="YES" contentMode="scaleToFill" preservesSuperviewLayoutMargins="YES" selectionStyle="none" indentationWidth="10" reuseIdentifier="cellaOrario" rowHeight="90" id="6Cp-4i-ZGg">
<rect key="frame" x="0.0" y="208" width="320" height="90"/>
<autoresizingMask key="autoresizingMask"/>
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" preservesSuperviewLayoutMargins="YES" insetsLayoutMarginsFromSafeArea="NO" tableViewCell="6Cp-4i-ZGg" id="36I-Jj-d06">
<rect key="frame" x="0.0" y="0.0" width="320" height="90"/>
<autoresizingMask key="autoresizingMask"/>
<subviews>
<label opaque="NO" userInteractionEnabled="NO" tag="1" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Label" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="q3f-N3-If9">
<rect key="frame" x="16" y="11" width="288" height="39"/>
<constraints>
<constraint firstAttribute="height" constant="39" id="qtV-9X-Rep"/>
</constraints>
<fontDescription key="fontDescription" type="system" pointSize="17"/>
<color key="textColor" white="0.33333333333333331" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<nil key="highlightedColor"/>
</label>
<textField opaque="NO" tag="2" contentMode="scaleToFill" contentHorizontalAlignment="left" contentVerticalAlignment="center" textAlignment="natural" minimumFontSize="17" translatesAutoresizingMaskIntoConstraints="NO" id="QqB-Ag-0rH">
<rect key="frame" x="16" y="52" width="288" height="30"/>
<constraints>
<constraint firstAttribute="height" constant="30" id="WSa-jr-Glc"/>
</constraints>
<color key="textColor" red="0.0" green="0.56284224989999998" blue="0.31881666180000001" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<fontDescription key="fontDescription" type="system" pointSize="14"/>
<textInputTraits key="textInputTraits"/>
</textField>
</subviews>
<constraints>
<constraint firstItem="QqB-Ag-0rH" firstAttribute="leading" secondItem="36I-Jj-d06" secondAttribute="leading" constant="16" id="2vo-ii-bgF"/>
<constraint firstAttribute="trailing" secondItem="QqB-Ag-0rH" secondAttribute="trailing" constant="16" id="JJP-f6-dLz"/>
<constraint firstItem="q3f-N3-If9" firstAttribute="top" secondItem="36I-Jj-d06" secondAttribute="topMargin" id="WS7-gc-XeN"/>
<constraint firstItem="q3f-N3-If9" firstAttribute="trailing" secondItem="36I-Jj-d06" secondAttribute="trailingMargin" id="joP-eM-Aa9"/>
<constraint firstItem="q3f-N3-If9" firstAttribute="leading" secondItem="36I-Jj-d06" secondAttribute="leadingMargin" id="oVU-rE-cFW"/>
<constraint firstItem="QqB-Ag-0rH" firstAttribute="top" secondItem="q3f-N3-If9" secondAttribute="bottom" constant="2" id="zWr-Wq-u40"/>
</constraints>
</tableViewCellContentView>
</tableViewCell>
<tableViewCell clipsSubviews="YES" contentMode="scaleToFill" preservesSuperviewLayoutMargins="YES" selectionStyle="default" indentationWidth="10" reuseIdentifier="cellSection" id="UQV-Xm-UzM">
<rect key="frame" x="0.0" y="298" width="320" height="43.5"/>
<autoresizingMask key="autoresizingMask"/>
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" preservesSuperviewLayoutMargins="YES" insetsLayoutMarginsFromSafeArea="NO" tableViewCell="UQV-Xm-UzM" id="G5d-lI-pa8">
<rect key="frame" x="0.0" y="0.0" width="320" height="43.5"/>
<autoresizingMask key="autoresizingMask"/>
<subviews>
<label opaque="NO" userInteractionEnabled="NO" tag="1" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Label" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="Hcz-F8-6wV">
<rect key="frame" x="16" y="5.5" width="288" height="33"/>
<constraints>
<constraint firstAttribute="height" constant="33" id="PQ9-9g-RUI"/>
</constraints>
<fontDescription key="fontDescription" type="boldSystem" pointSize="14"/>
<color key="textColor" red="0.50766238939999997" green="0.75272958739999996" blue="0.98132258650000004" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<nil key="highlightedColor"/>
</label>
</subviews>
<color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<constraints>
<constraint firstAttribute="trailing" secondItem="Hcz-F8-6wV" secondAttribute="trailing" constant="16" id="epC-UU-NGo"/>
<constraint firstItem="Hcz-F8-6wV" firstAttribute="leading" secondItem="G5d-lI-pa8" secondAttribute="leading" constant="16" id="tbv-6Q-Tw4"/>
<constraint firstItem="Hcz-F8-6wV" firstAttribute="centerY" secondItem="G5d-lI-pa8" secondAttribute="centerY" id="wUY-fJ-qcc"/>
</constraints>
</tableViewCellContentView>
</tableViewCell>
<tableViewCell clipsSubviews="YES" contentMode="scaleToFill" preservesSuperviewLayoutMargins="YES" selectionStyle="default" indentationWidth="10" reuseIdentifier="impostazioniNotifiche" rowHeight="88" id="NnD-np-3Mv">
<rect key="frame" x="0.0" y="341.5" width="320" height="88"/>
<autoresizingMask key="autoresizingMask"/>
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" preservesSuperviewLayoutMargins="YES" insetsLayoutMarginsFromSafeArea="NO" tableViewCell="NnD-np-3Mv" id="yom-Ab-ogZ">
<rect key="frame" x="0.0" y="0.0" width="320" height="88"/>
<autoresizingMask key="autoresizingMask"/>
<subviews>
<label opaque="NO" userInteractionEnabled="NO" tag="1" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Label" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="w8w-9g-aeX">
<rect key="frame" x="16" y="11" width="288" height="66"/>
<fontDescription key="fontDescription" type="system" pointSize="17"/>
<color key="textColor" cocoaTouchSystemColor="darkTextColor"/>
<nil key="highlightedColor"/>
</label>
</subviews>
<constraints>
<constraint firstItem="w8w-9g-aeX" firstAttribute="bottom" secondItem="yom-Ab-ogZ" secondAttribute="bottomMargin" id="Uik-Bs-4fa"/>
<constraint firstItem="w8w-9g-aeX" firstAttribute="leading" secondItem="yom-Ab-ogZ" secondAttribute="leadingMargin" id="wXo-6B-brV"/>
<constraint firstItem="w8w-9g-aeX" firstAttribute="trailing" secondItem="yom-Ab-ogZ" secondAttribute="trailingMargin" id="wdN-Gl-vVE"/>
<constraint firstItem="w8w-9g-aeX" firstAttribute="top" secondItem="yom-Ab-ogZ" secondAttribute="topMargin" id="wzw-A1-Ydc"/>
</constraints>
</tableViewCellContentView>
</tableViewCell>
</prototypes>
<color key="backgroundColor" cocoaTouchSystemColor="groupTableViewBackgroundColor"/>
<connections>
<outlet property="dataSource" destination="e2e-CQ-gxv" id="zwI-9C-iNf"/>
<outlet property="delegate" destination="e2e-CQ-gxv" id="2x9-42-9Dc"/>
@@ -1,235 +0,0 @@
//
// NotificheSismiTableViewController.m
// Earthquake Network
//
// Created by Luca Beretta on 08/01/2019.
// Copyright © 2019 Luca Beretta. All rights reserved.
//
#import "NotificheSismiTableViewController.h"
#import "TBDInputViewControllerData.h"
#import "EQNImpostazioniNotifiche.h"
#import "EQNUtility.h"
#import "EQNNotificheTempoReale.h"
#import "EQNNotificheSegnalazioniUtente.h"
@interface NotificheSismiTableViewController () <InputViewControllerDataDelegate, UITextFieldDelegate>
@property (nonatomic, assign) BOOL abilitaIntervallo;
@property (nonatomic, strong) TBDInputViewControllerData *pikerViewController;
@property (nonatomic, strong) NSString *oraInizio;
@property (nonatomic, strong) NSString *oraFine;
@property (nonatomic, strong) UITextField *textFildInizio;
@property (nonatomic, strong) UITextField *textFildfine;
@property (nonatomic, strong) UITextField *textFild;
@property (nonatomic, strong) NSDateFormatter *dateFormatter;
@property (nonatomic, strong) UIColor *textColor;
@end
@implementation NotificheSismiTableViewController
- (void)viewDidLoad {
[super viewDidLoad];
self.lista = @[/*NSLocalizedString(@"Notifiche sismi rilevati in tempo reale", @"voce menu"),*/ NSLocalizedString(@"Notifiche segnalazioni utente", @"voce menu"), NSLocalizedString(@"Notifiche da reti sismiche", @"voce menu")/*, NSLocalizedString(@"Intervallo notifiche", @"voce menu"), NSLocalizedString(@"Ora inizio", @"voce menu"), NSLocalizedString(@"Ora fine", @"voce menu")*/];
self.pikerViewController = [[TBDInputViewControllerData alloc] initWithNibName:@"TBDInputViewControllerData" bundle:nil];
self.pikerViewController.delegate = self;
self.dateFormatter = [[NSDateFormatter alloc] init];
[self.dateFormatter setDateFormat:@"HH:mm"];
self.textColor = [UIColor colorWithRed:0 green:0.5647 blue:0.317 alpha:1];
[self setUpView];
}
-(void)setUpView{
self.abilitaIntervallo = [EQNImpostazioniNotifiche center].attivaIntervalloNotifica;
if ([EQNImpostazioniNotifiche center].oraioInizio)
self.oraInizio = [self.dateFormatter stringFromDate:[EQNImpostazioniNotifiche center].oraioInizio];
else
self.oraInizio = @"8:00";
if ([EQNImpostazioniNotifiche center].orarioFine)
self.oraFine = [self.dateFormatter stringFromDate:[EQNImpostazioniNotifiche center].orarioFine];
else
self.oraFine = @"22:00";
}
#pragma mark - Table view data source
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
return 1;
}
- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section{
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"cellSection"];
UILabel *titolo = (UILabel *)[cell viewWithTag:1];
titolo.text = NSLocalizedString(@"Notifiche sismi", @"titolo impostazioni notifiche");
return cell;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
return self.lista.count;
}
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
switch (indexPath.row) {
case 0:
return 60;
break;
case 1:
return 60;
break;
/* case 2:
return 60;
break;*/
default:
break;
}
return 90;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
switch (indexPath.row) {
case 2:{
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"cellaSelezioneOrario"];
UILabel *titolo = (UILabel *)[cell viewWithTag:1];
titolo.text = self.lista[indexPath.row];
UILabel *stato = (UILabel *)[cell viewWithTag:2];
stato.text = NSLocalizedString(@"Ricevi le notifiche solo in un intervallo del giorno", @"voce menu");
if (self.abilitaIntervallo){
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;
}
break;
case 3:{
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"cellaOrario"];
UILabel *titolo = (UILabel *)[cell viewWithTag:1];
titolo.text = self.lista[indexPath.row];
self.textFildInizio = (UITextField *)[cell viewWithTag:2];
self.textFildInizio.delegate = self;
self.textFildInizio.inputView = self.pikerViewController.view;
self.textFildInizio.text = self.oraInizio;
self.textFildInizio.enabled = self.abilitaIntervallo;
if (self.abilitaIntervallo) {
titolo.textColor = [UIColor blackColor];
self.textFildInizio.textColor = self.textColor;
}
else{
titolo.textColor = [UIColor grayColor];
self.textFildInizio.textColor = [UIColor grayColor];
}
return cell;
}
break;
case 4:{
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"cellaOrario"];
UILabel *titolo = (UILabel *)[cell viewWithTag:1];
titolo.text = self.lista[indexPath.row];
self.textFildfine = (UITextField *)[cell viewWithTag:2];
self.textFildfine.delegate = self;
self.textFildfine.inputView = self.pikerViewController.view;
self.textFildfine.text = self.oraFine;
self.textFildfine.enabled = self.abilitaIntervallo;
if (self.abilitaIntervallo) {
titolo.textColor = [UIColor blackColor];
self.textFildfine.textColor = self.textColor;
}
else{
titolo.textColor = [UIColor grayColor];
self.textFildfine.textColor = [UIColor grayColor];
}
return cell;
}
break;
default:{
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"impostazioniNotifiche"];
UILabel *titolo = (UILabel *)[cell viewWithTag:1];
titolo.text = self.lista[indexPath.row];
return cell;
}
break;
}
}
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
switch (indexPath.row) {
/* case 0:{
[self performSegueWithIdentifier:@"sismiTempoReale" sender:nil];
}break;*/
case 0:
[self performSegueWithIdentifier:@"segnalazioneUtenti" sender:nil];
break;
case 1:
[self performSegueWithIdentifier:@"retiSismiche" sender:nil];
break;
case 2:{
self.abilitaIntervallo = !self.abilitaIntervallo;
[EQNImpostazioniNotifiche center].attivaIntervalloNotifica = self.abilitaIntervallo;
[[EQNImpostazioniNotifiche center] saveUserInfo];
[self.tableView reloadData];
}break;
default:
break;
}
}
# pragma textFild delegate
- (BOOL)textFieldShouldBeginEditing:(UITextField *)textField{
self.textFild = textField;
return YES;
}
# pragma mark pikerViewdata data
-(void)dataSelezionata:(NSDate *)data withTextFild:(UITextField *)textFild{
self.textFild.text = [self.dateFormatter stringFromDate:data];
if (self.textFild == self.textFildInizio)
[EQNImpostazioniNotifiche center].oraioInizio = data;
else
[EQNImpostazioniNotifiche center].orarioFine = data;
[[EQNImpostazioniNotifiche center] saveUserInfo];
[self setUpView];
[self.tableView endEditing:YES];
}
-(void)esci{
[self.tableView endEditing:YES];
}
@end