diff --git a/Sources/Earthquake Network/Controllers/Alerts/AllerteViewController.m b/Sources/Earthquake Network/Controllers/Alerts/AllerteViewController.m
index fab64fe..8362b2b 100644
--- a/Sources/Earthquake Network/Controllers/Alerts/AllerteViewController.m
+++ b/Sources/Earthquake Network/Controllers/Alerts/AllerteViewController.m
@@ -105,6 +105,7 @@ typedef NS_ENUM(NSInteger, AllerteTableRow) {
self.tableView.estimatedRowHeight = 200.0;
self.tableView.rowHeight = UITableViewAutomaticDimension;
[self.tableView registerClass:[AlertsSmartphoneNetworkTableViewCell class] forCellReuseIdentifier:@"SmartphoneNetworkCell"];
+ [self.tableView registerClass:[AlertsPriorityServiceTableViewCell class] forCellReuseIdentifier:@"PriorityCell"];
if (EQNBackgroundPositionDebugHelper.shared.isEnabled) {
self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemBookmarks target:self action:@selector(backgroundPositionDebugTapped:)];
@@ -330,7 +331,7 @@ typedef NS_ENUM(NSInteger, AllerteTableRow) {
} else if (tableRow == AllerteTableRowServizioPriorita) {
AlertsPriorityServiceTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"PriorityCell" forIndexPath:indexPath];
- cell.smartphoneNetwork = [EQNManager defaultManager].rete_smartphone;
+ [cell updateWith:[EQNManager defaultManager].rete_smartphone];
return cell;
} else if (tableRow == AllerteTableRowDatiPosizione) {
diff --git a/Sources/Earthquake Network/Controllers/Alerts/Cells/AlertsPriorityServiceTableViewCell.swift b/Sources/Earthquake Network/Controllers/Alerts/Cells/AlertsPriorityServiceTableViewCell.swift
index a9740c8..e4731a5 100644
--- a/Sources/Earthquake Network/Controllers/Alerts/Cells/AlertsPriorityServiceTableViewCell.swift
+++ b/Sources/Earthquake Network/Controllers/Alerts/Cells/AlertsPriorityServiceTableViewCell.swift
@@ -8,37 +8,61 @@
import UIKit
-class AlertsPriorityServiceTableViewCell: EQNBaseTableViewCell {
-
- @objc var smartphoneNetwork: EQNReteSmartphone? {
- didSet {
- updateUI()
- }
- }
+@objc
+class AlertsPriorityServiceTableViewCell: EQNBaseContainerTableViewCell {
+ override var headerText: String { NSLocalizedString("inapp_list", comment: "") }
+
+ // MARK: - UI
+
+ private lazy var descriptionLabel: UILabel = {
+ let label = UILabel()
+ label.translatesAutoresizingMaskIntoConstraints = false
+ label.numberOfLines = 0
+ label.textColor = AppTheme.Colors.darkGray
+ label.font = .preferredFont(forTextStyle: .body)
+ return label
+ }()
+
+ private lazy var lastSubscriptionLabel: UILabel = {
+ let label = UILabel()
+ label.translatesAutoresizingMaskIntoConstraints = false
+ label.numberOfLines = 0
+ label.textColor = AppTheme.Colors.red
+ label.font = .preferredFont(forTextStyle: .body)
+ return label
+ }()
+
// MARK: - Internal
- @IBOutlet private weak var headerLabel: UILabel!
- @IBOutlet private weak var descriptionLabel: UILabel!
- @IBOutlet private weak var lastSubscriptionLabel: UILabel!
-
- // MARK: - View Lifecycle
-
- override func awakeFromNib() {
- super.awakeFromNib()
+ override func setupUI() {
+ super.setupUI()
- localizeUI()
+ containerView.addSubview(descriptionLabel)
+ containerView.addSubview(lastSubscriptionLabel)
+
+ descriptionLabel.topAnchor.constraint(equalTo: topView.bottomAnchor, constant: Self.DefaultVerticalSpacing).isActive = true
+ descriptionLabel.leadingAnchor.constraint(equalTo: containerView.leadingAnchor, constant: Self.DefaultPadding).isActive = true
+ descriptionLabel.trailingAnchor.constraint(equalTo: containerView.trailingAnchor, constant: -Self.DefaultPadding).isActive = true
+
+ lastSubscriptionLabel.topAnchor.constraint(equalTo: descriptionLabel.bottomAnchor, constant: Self.DefaultVerticalSpacing/2.0).isActive = true
+ lastSubscriptionLabel.leadingAnchor.constraint(equalTo: descriptionLabel.leadingAnchor).isActive = true
+ lastSubscriptionLabel.trailingAnchor.constraint(equalTo: descriptionLabel.trailingAnchor).isActive = true
+ lastSubscriptionLabel.bottomAnchor.constraint(equalTo: containerView.bottomAnchor, constant: -Self.DefaultPadding).isActive = true
}
- // MARK: - Private
-
- private func localizeUI() {
- headerLabel.text = NSLocalizedString("inapp_list", comment: "")
+ override func updateUI() {
+ super.updateUI()
+
+ containerView.backgroundColor = AppTheme.Colors.cardBackgroundRed
descriptionLabel.text = NSLocalizedString("inapp_adv", comment: "")
}
- private func updateUI() {
- guard let smartphoneNetwork = smartphoneNetwork else { return }
+ // MARK: - Public
+
+ @objc
+ func update(with smartphoneNetwork: EQNReteSmartphone?) {
+ guard let smartphoneNetwork else { return }
lastSubscriptionLabel.text = subscriptionText(for: smartphoneNetwork.lastSubscriptionDiff)
}
diff --git a/Sources/Earthquake Network/Storyboards/Base.lproj/Main.storyboard b/Sources/Earthquake Network/Storyboards/Base.lproj/Main.storyboard
index 7410e6e..f60803d 100644
--- a/Sources/Earthquake Network/Storyboards/Base.lproj/Main.storyboard
+++ b/Sources/Earthquake Network/Storyboards/Base.lproj/Main.storyboard
@@ -1846,91 +1846,8 @@ Sisma rilevato da 10 smartphone
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
@@ -2097,7 +2014,6 @@ Sisma rilevato da 10 smartphone
-
@@ -2157,9 +2073,6 @@ Sisma rilevato da 10 smartphone
-
-
-
diff --git a/Sources/Earthquake Network/UI/AppTheme.swift b/Sources/Earthquake Network/UI/AppTheme.swift
index 597fa98..f163e19 100644
--- a/Sources/Earthquake Network/UI/AppTheme.swift
+++ b/Sources/Earthquake Network/UI/AppTheme.swift
@@ -19,6 +19,8 @@ class AppTheme: NSObject {
static let gray = UIColor(named: "Gray")!
static let darkGray = UIColor(named: "Gray (dark)")!
static let lightGray = UIColor(named: "Gray (light)")!
+
+ static let cardBackgroundRed = UIColor(named: "Red (card background)")!
}
static let shared = AppTheme()
diff --git a/Sources/Earthquake Network/UI/EQNBaseContainerTableViewCell.swift b/Sources/Earthquake Network/UI/EQNBaseContainerTableViewCell.swift
index 8283d08..233e109 100644
--- a/Sources/Earthquake Network/UI/EQNBaseContainerTableViewCell.swift
+++ b/Sources/Earthquake Network/UI/EQNBaseContainerTableViewCell.swift
@@ -37,9 +37,15 @@ class EQNBaseContainerTableViewCell: UITableViewCell {
label.textColor = .white
return label
}()
+
+ private lazy var emptyTopView: UIView = {
+ let view = UIView(frame: .zero)
+ view.backgroundColor = .clear
+ return view
+ }()
var topView: UIView {
- isHeaderVisible ? headerLabel : containerView
+ isHeaderVisible ? headerLabel : emptyTopView
}
var isHeaderVisible: Bool { true }
@@ -77,6 +83,12 @@ class EQNBaseContainerTableViewCell: UITableViewCell {
headerLabel.topAnchor.constraint(equalTo: containerView.topAnchor).isActive = true
headerLabel.leadingAnchor.constraint(equalTo: containerView.leadingAnchor).isActive = true
headerLabel.heightAnchor.constraint(equalToConstant: 26.0).isActive = true
+ } else {
+ containerView.addSubview(emptyTopView)
+ emptyTopView.topAnchor.constraint(equalTo: containerView.topAnchor).isActive = true
+ emptyTopView.leadingAnchor.constraint(equalTo: containerView.leadingAnchor).isActive = true
+ emptyTopView.trailingAnchor.constraint(equalTo: containerView.trailingAnchor).isActive = true
+ emptyTopView.heightAnchor.constraint(equalToConstant: 0.0).isActive = true
}
}