|
@@ -6,6 +6,7 @@
|
|
|
//
|
|
|
|
|
|
import Cocoa
|
|
|
+import StoreKit
|
|
|
|
|
|
typealias KMComparativeViewCollectionItemDoneAction = (_ view: KMComparativeViewCollectionItem, _ data: [String: Any]) -> Void
|
|
|
class KMComparativeViewCollectionItem: NSCollectionViewItem {
|
|
@@ -66,7 +67,8 @@ class KMComparativeViewCollectionItem: NSCollectionViewItem {
|
|
|
self.titleLabel.stringValue = NSLocalizedString(data["title"] as! String, comment: "")
|
|
|
self.subtitleLabel.stringValue = NSLocalizedString(data["subtitle"] as! String, comment: "")
|
|
|
self.doneButton.title = NSLocalizedString(data["buttonTitle"] as! String, comment: "")
|
|
|
- self.describeLabel.stringValue = NSLocalizedString(data["describe"] as? String ?? "", comment: "")
|
|
|
+ let describe = NSLocalizedString(data["describe"] as? String ?? "", comment: "")
|
|
|
+ self.describeLabel.stringValue = describe
|
|
|
|
|
|
if data["type"] as! Int == 1 {
|
|
|
self.describeLabel.isHidden = false
|
|
@@ -76,6 +78,33 @@ class KMComparativeViewCollectionItem: NSCollectionViewItem {
|
|
|
self.doneButton.border(NSColor(hex: "#FF852E"), 0, 20)
|
|
|
self.doneButton.contentTintColor = NSColor(hex: "#FFFFFF")
|
|
|
self.doneButton.font = NSFont.SFProTextSemibold(16)
|
|
|
+
|
|
|
+ if KMLightMemberManager.manager.purchaseState == .trialExpired ||
|
|
|
+ KMLightMemberManager.manager.purchaseState == .subscriptionExpired {
|
|
|
+ self.iconImageView.isHidden = true
|
|
|
+ } else {
|
|
|
+ self.iconImageView.isHidden = false
|
|
|
+ }
|
|
|
+
|
|
|
+ if KMInAppPurchaseManager.manager.availableProducts.count == 0 {
|
|
|
+ KMInAppPurchaseManager.manager.fetchProducts { [unowned self] isSuccess, products, error in
|
|
|
+ let productId: String = data["productId"] as! String
|
|
|
+ for product in KMInAppPurchaseManager.manager.availableProducts {
|
|
|
+ if product.productIdentifier == productId {
|
|
|
+ print("-----------------------------")
|
|
|
+ print(product.priceLocale.currencyCode)
|
|
|
+ print(product.introductoryPrice?.price)
|
|
|
+ print(product.price)
|
|
|
+ print("-----------------------------")
|
|
|
+ let currencyCode: String = product.priceLocale.currencyCode ?? "$"
|
|
|
+ let price: String = product.introductoryPrice?.price.description ?? "39.9"
|
|
|
+ let originPrice: String = product.price.description ?? "79.9"
|
|
|
+ self.subtitleLabel.stringValue = "\(currencyCode) \(price)"
|
|
|
+ self.describeLabel.stringValue = "\(currencyCode) \(originPrice) \(describe)"
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
} else {
|
|
|
self.describeLabel.isHidden = true
|
|
|
self.iconImageView.isHidden = true
|
|
@@ -87,13 +116,6 @@ class KMComparativeViewCollectionItem: NSCollectionViewItem {
|
|
|
}
|
|
|
self.contentCollectionView.reloadData()
|
|
|
}
|
|
|
-
|
|
|
- if KMLightMemberManager.manager.purchaseState == .trialExpired ||
|
|
|
- KMLightMemberManager.manager.purchaseState == .subscriptionExpired {
|
|
|
- self.iconImageView.isHidden = true
|
|
|
- } else {
|
|
|
- self.iconImageView.isHidden = false
|
|
|
- }
|
|
|
}
|
|
|
}
|
|
|
|