diff --git a/Sources/Earthquake Network/Controllers/InApp/SubscriptionsHeaderTableViewCell.swift b/Sources/Earthquake Network/Controllers/InApp/SubscriptionsHeaderTableViewCell.swift
index b36c993..fc363e4 100644
--- a/Sources/Earthquake Network/Controllers/InApp/SubscriptionsHeaderTableViewCell.swift
+++ b/Sources/Earthquake Network/Controllers/InApp/SubscriptionsHeaderTableViewCell.swift
@@ -10,10 +10,37 @@ import UIKit
class SubscriptionsHeaderTableViewCell: EQNBaseTableViewCell {
- @IBOutlet weak var headerTitleLabel: UILabel!
+ var isLoading = false {
+ didSet {
+ updateUI()
+ }
+ }
+
+ var title: String? = nil {
+ didSet {
+ updateUI()
+ }
+ }
+
+ @IBOutlet private weak var headerTitleLabel: UILabel!
+ @IBOutlet private weak var loadingActivityIndicator: UIActivityIndicatorView!
+
+ // MARK: - View Lifecycle
override func awakeFromNib() {
super.awakeFromNib()
// Initialization code
}
+
+ // MARK: - Private
+
+ private func updateUI() {
+ headerTitleLabel.text = title
+
+ if isLoading && title != nil {
+ loadingActivityIndicator.startAnimating()
+ } else {
+ loadingActivityIndicator.stopAnimating()
+ }
+ }
}
diff --git a/Sources/Earthquake Network/Controllers/InApp/SubscriptionsViewController.swift b/Sources/Earthquake Network/Controllers/InApp/SubscriptionsViewController.swift
index b510d87..e2321e4 100644
--- a/Sources/Earthquake Network/Controllers/InApp/SubscriptionsViewController.swift
+++ b/Sources/Earthquake Network/Controllers/InApp/SubscriptionsViewController.swift
@@ -38,6 +38,8 @@ class SubscriptionsViewController: UITableViewController {
private var subscribedProduct: SKProduct?
/// Availability for subscriptions
private var availability: EQNPurchaseAvailability?
+ /// Tells if products are loading
+ private var isLoading = false
// MARK: - View Lifecycle
@@ -117,7 +119,11 @@ class SubscriptionsViewController: UITableViewController {
}
private func loadData() {
+ isLoading = true
+
VersioneProProducts.store.requestProducts{ [weak self] success, products in
+ self?.isLoading = false
+
guard let self = self, let products = products, success == true else { return }
// todo: teniamo il più "alto"
@@ -172,7 +178,8 @@ class SubscriptionsViewController: UITableViewController {
override func tableView(_ tableView: UITableView, viewForHeaderInSection section: Int) -> UIView? {
let tableSection = sections[section]
if let cell = tableView.dequeueReusableCell(withIdentifier: "SectionHeaderCell") as? SubscriptionsHeaderTableViewCell {
- cell.headerTitleLabel.text = tableSection.sectionTitle
+ cell.title = tableSection.sectionTitle
+ cell.isLoading = isLoading
return cell
}
return nil
diff --git a/Sources/Earthquake Network/Storyboards/Base.lproj/Main.storyboard b/Sources/Earthquake Network/Storyboards/Base.lproj/Main.storyboard
index c13c77c..20a3880 100644
--- a/Sources/Earthquake Network/Storyboards/Base.lproj/Main.storyboard
+++ b/Sources/Earthquake Network/Storyboards/Base.lproj/Main.storyboard
@@ -2493,32 +2493,44 @@ In più sostieni il progetto di ricerca il quale non riceve finanziamenti estern
-
+
-
+
-
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
-
-
+
+
+
+
-
+