diff --git a/Passepartout-iOS/Base.lproj/Organizer.storyboard b/Passepartout-iOS/Base.lproj/Organizer.storyboard
index 02679026..b326da5c 100644
--- a/Passepartout-iOS/Base.lproj/Organizer.storyboard
+++ b/Passepartout-iOS/Base.lproj/Organizer.storyboard
@@ -279,6 +279,23 @@
+
+
+
+
+
+
+
+
+
+
+
diff --git a/Passepartout-iOS/Scenes/Organizer/DonationViewController.swift b/Passepartout-iOS/Scenes/Organizer/DonationViewController.swift
index e6afd14f..40b15c6d 100644
--- a/Passepartout-iOS/Scenes/Organizer/DonationViewController.swift
+++ b/Passepartout-iOS/Scenes/Organizer/DonationViewController.swift
@@ -32,6 +32,8 @@ class DonationViewController: UITableViewController, TableModelHost {
private var productsByIdentifier: [String: SKProduct] = [:]
+ private var isLoading = true
+
private func setProducts(_ products: [SKProduct]) {
for p in products {
productsByIdentifier[p.productIdentifier] = p
@@ -43,11 +45,20 @@ class DonationViewController: UITableViewController, TableModelHost {
// MARK: TableModel
var model: TableModel = TableModel()
-
+
func reloadModel() {
donationList = []
model.clear()
+ model.add(.oneTime)
+ model.setHeader(L10n.Donation.Sections.OneTime.header, for: .oneTime)
+ model.setFooter(L10n.Donation.Sections.OneTime.footer, for: .oneTime)
+
+ guard !isLoading else {
+ model.set([.loading], in: .oneTime)
+ return
+ }
+
let completeList: [InApp.Donation] = [.tiny, .small, .medium, .big, .huge, .maxi]
for row in completeList {
guard let _ = productsByIdentifier[row.rawValue] else {
@@ -55,9 +66,6 @@ class DonationViewController: UITableViewController, TableModelHost {
}
donationList.append(row)
}
- model.add(.oneTime)
- model.setHeader(L10n.Donation.Sections.OneTime.header, for: .oneTime)
- model.setFooter(L10n.Donation.Sections.OneTime.footer, for: .oneTime)
model.set(.donation, count: donationList.count, in: .oneTime)
}
@@ -67,16 +75,16 @@ class DonationViewController: UITableViewController, TableModelHost {
super.viewDidLoad()
title = L10n.Donation.title
+ reloadModel()
let inApp = InAppHelper.shared
if inApp.products.isEmpty {
- let hud = HUD()
- hud.show()
inApp.requestProducts {
- hud.hide()
+ self.isLoading = false
self.setProducts($0)
}
} else {
+ isLoading = false
setProducts(inApp.products)
}
}
@@ -105,6 +113,11 @@ class DonationViewController: UITableViewController, TableModelHost {
override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
switch model.row(at: indexPath) {
+ case .loading:
+ let cell = Cells.activity.dequeue(from: tableView, for: indexPath)
+ cell.textLabel?.text = L10n.Donation.Cells.Loading.caption
+ return cell
+
case .donation:
let productId = productIdentifier(at: indexPath)
guard let product = productsByIdentifier[productId] else {
@@ -129,6 +142,9 @@ class DonationViewController: UITableViewController, TableModelHost {
InAppHelper.shared.purchase(product: product) {
self.handlePurchase(result: $0, error: $1)
}
+
+ default:
+ break
}
}
@@ -151,12 +167,12 @@ class DonationViewController: UITableViewController, TableModelHost {
extension DonationViewController {
enum SectionType {
- case inProgress
-
case oneTime
}
enum RowType {
+ case loading
+
case donation
}
diff --git a/Passepartout/Resources/en.lproj/Localizable.strings b/Passepartout/Resources/en.lproj/Localizable.strings
index c0a35f3a..37362ca5 100644
--- a/Passepartout/Resources/en.lproj/Localizable.strings
+++ b/Passepartout/Resources/en.lproj/Localizable.strings
@@ -251,6 +251,7 @@
"donation.sections.one_time.header" = "One time";
"donation.sections.one_time.footer" = "If you want to display gratitude for my free work, here are a couple amounts you can donate instantly.\n\nYou will only be charged once per donation, and you can donate multiple times.";
//"donation.sections.recurring.header" = "Recurring";
+"donation.cells.loading.caption" = "Loading donations";
"donation.alerts.purchase.success.title" = "Thank you";
"donation.alerts.purchase.success.message" = "This means a lot to me and I really hope you keep using and promoting this app.";
"donation.alerts.purchase.failure.message" = "Unable to perform the donation. %@";
diff --git a/Passepartout/Sources/SwiftGen+Strings.swift b/Passepartout/Sources/SwiftGen+Strings.swift
index 334c11bb..7f93a9de 100644
--- a/Passepartout/Sources/SwiftGen+Strings.swift
+++ b/Passepartout/Sources/SwiftGen+Strings.swift
@@ -314,6 +314,12 @@ public enum L10n {
}
}
}
+ public enum Cells {
+ public enum Loading {
+ /// Loading donations
+ public static let caption = L10n.tr("Localizable", "donation.cells.loading.caption")
+ }
+ }
public enum Sections {
public enum OneTime {
/// If you want to display gratitude for my free work, here are a couple amounts you can donate instantly.\n\nYou will only be charged once per donation, and you can donate multiple times.