From 96189b410f7ff9342f681804917f3d7a96e868ec Mon Sep 17 00:00:00 2001 From: Davide De Rosa Date: Sun, 7 Feb 2021 12:50:39 +0100 Subject: [PATCH] Review product bullets - Show features in platform - Show iOS/macOS in multiplatform Drop dashes in iOS. --- .../Purchase/PurchaseViewController.swift | 22 +++++++++---------- .../Purchase/PurchaseViewController.swift | 22 +++++++++---------- .../Core/Sources/Model/ProductManager.swift | 15 +++++++++++++ 3 files changed, 35 insertions(+), 24 deletions(-) diff --git a/Passepartout/App/iOS/Scenes/Purchase/PurchaseViewController.swift b/Passepartout/App/iOS/Scenes/Purchase/PurchaseViewController.swift index a5c48e38..d9739e74 100644 --- a/Passepartout/App/iOS/Scenes/Purchase/PurchaseViewController.swift +++ b/Passepartout/App/iOS/Scenes/Purchase/PurchaseViewController.swift @@ -66,10 +66,20 @@ class PurchaseViewController: UITableViewController, StrongTableHost { if let skPlatformVersion = pm.product(withIdentifier: .fullVersion_iOS) { self.skPlatformVersion = skPlatformVersion rows.append(.platformVersion) + + let bullets: [String] = ProductManager.shared.featureProducts(excluding: [.fullVersion, .fullVersion_iOS, .fullVersion_macOS]).map { + return $0.localizedTitle + }.sortedCaseInsensitive() + platformVersionExtra = bullets.joined(separator: "\n") } if let skFullVersion = pm.product(withIdentifier: .fullVersion) { self.skFullVersion = skFullVersion rows.append(.fullVersion) + + let bullets: [String] = ProductManager.shared.featureProducts(including: [.fullVersion_iOS, .fullVersion_macOS]).map { + return $0.localizedTitle + }.sortedCaseInsensitive() + fullVersionExtra = bullets.joined(separator: "\n") } if let feature = feature, let skFeature = pm.product(withIdentifier: feature) { self.skFeature = skFeature @@ -77,18 +87,6 @@ class PurchaseViewController: UITableViewController, StrongTableHost { } rows.append(.restore) model.set(rows, forSection: .products) - - let platformBulletsList: [String] = ProductManager.shared.featureProducts(excluding: [.fullVersion, .fullVersion_iOS, .fullVersion_macOS]).map { - return "- \($0.localizedTitle)" - }.sortedCaseInsensitive() - let platformBullets = platformBulletsList.joined(separator: "\n") - platformVersionExtra = "- \(L10n.Core.Purchase.Cells.FullVersion.extraDescription(platformBullets))" - - let fullBulletsList: [String] = ProductManager.shared.featureProducts(excluding: [.fullVersion, .fullVersion_iOS]).map { - return "- \($0.localizedTitle)" - }.sortedCaseInsensitive() - let fullBullets = fullBulletsList.joined(separator: "\n") - fullVersionExtra = "- \(L10n.Core.Purchase.Cells.FullVersion.extraDescription(fullBullets))" } // MARK: UIViewController diff --git a/Passepartout/App/macOS/Scenes/Purchase/PurchaseViewController.swift b/Passepartout/App/macOS/Scenes/Purchase/PurchaseViewController.swift index 65bfb8ff..371e7402 100644 --- a/Passepartout/App/macOS/Scenes/Purchase/PurchaseViewController.swift +++ b/Passepartout/App/macOS/Scenes/Purchase/PurchaseViewController.swift @@ -74,27 +74,25 @@ class PurchaseViewController: NSViewController { if let skPlatformVersion = pm.product(withIdentifier: .fullVersion_macOS) { self.skPlatformVersion = skPlatformVersion rows.append(.platformVersion) + + let bullets: [String] = ProductManager.shared.featureProducts(excluding: [.fullVersion, .fullVersion_iOS, .fullVersion_macOS, .siriShortcuts]).map { + return $0.localizedTitle + }.sortedCaseInsensitive() + platformVersionExtra = bullets.joined(separator: "\n") } if let skFullVersion = pm.product(withIdentifier: .fullVersion) { self.skFullVersion = skFullVersion rows.append(.fullVersion) + + let bullets: [String] = ProductManager.shared.featureProducts(including: [.fullVersion_iOS, .fullVersion_macOS]).map { + return $0.localizedTitle + }.sortedCaseInsensitive() + fullVersionExtra = bullets.joined(separator: "\n") } if let feature = feature, let skFeature = pm.product(withIdentifier: feature) { self.skFeature = skFeature rows.append(.feature) } - - let platformBulletsList: [String] = ProductManager.shared.featureProducts(excluding: [.siriShortcuts, .fullVersion, .fullVersion_iOS, .fullVersion_macOS]).map { - return $0.localizedTitle - }.sortedCaseInsensitive() - let platformBullets = platformBulletsList.joined(separator: "\n") - platformVersionExtra = L10n.Core.Purchase.Cells.FullVersion.extraDescription(platformBullets) - - let fullBulletsList: [String] = ProductManager.shared.featureProducts(excluding: [.fullVersion, .fullVersion_macOS]).map { - return $0.localizedTitle - }.sortedCaseInsensitive() - let fullBullets = fullBulletsList.joined(separator: "\n") - fullVersionExtra = L10n.Core.Purchase.Cells.FullVersion.extraDescription(fullBullets) } // MARK: NSViewController diff --git a/Passepartout/Core/Sources/Model/ProductManager.swift b/Passepartout/Core/Sources/Model/ProductManager.swift index bd1cb517..1693ac49 100644 --- a/Passepartout/Core/Sources/Model/ProductManager.swift +++ b/Passepartout/Core/Sources/Model/ProductManager.swift @@ -126,6 +126,21 @@ public class ProductManager: NSObject { return inApp.product(withIdentifier: identifier) } + public func featureProducts(including: [Product]) -> [SKProduct] { + return inApp.products.filter { + guard let p = Product(rawValue: $0.productIdentifier) else { + return false + } + guard including.contains(p) else { + return false + } + guard p.isFeature else { + return false + } + return true + } + } + public func featureProducts(excluding: [Product]) -> [SKProduct] { return inApp.products.filter { guard let p = Product(rawValue: $0.productIdentifier) else {