Skip to content

Commit

Permalink
Renamed notification, hardcoded sale texts to English, added asterisk…
Browse files Browse the repository at this point in the history
… to discount amount, fixed tests
  • Loading branch information
tobihagemann committed Nov 30, 2024
1 parent ff49b0f commit c9d32d6
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 14 deletions.
2 changes: 1 addition & 1 deletion Cryptomator/MainCoordinator.swift
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ extension MainCoordinator: StoreObserverDelegate {
case .fullVersion, .yearlySubscription:
showFullVersionAlert()
// Temporarily added for December 2024 Sale
NotificationCenter.default.post(name: .dismissBannerNotification, object: nil)
NotificationCenter.default.post(name: .purchasedFullVersionNotification, object: nil)
case let .freeTrial(expiresOn):
showTrialAlert(expirationDate: expiresOn)
case .unknown:
Expand Down
2 changes: 1 addition & 1 deletion Cryptomator/Purchase/PurchaseCoordinator.swift
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ class PurchaseCoordinator: Coordinator {
self.unlockedPro()
}
// Temporarily added for December 2024 Sale
NotificationCenter.default.post(name: .dismissBannerNotification, object: nil)
NotificationCenter.default.post(name: .purchasedFullVersionNotification, object: nil)
}

func handleRestoreResult(_ result: RestoreTransactionsResult) {
Expand Down
13 changes: 8 additions & 5 deletions Cryptomator/Purchase/PurchaseViewModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,13 @@ class PurchaseViewModel: BaseIAPViewModel, ProductFetching {
let currentMonth = Calendar.current.component(.month, from: Date())
// TODO: Change `currentMonth == 11` to `12`
if currentYear == 2024 && currentMonth == 11 {
return .textWithLeadingSystemImage("info.circle.fill",
text: LocalizedString.getValue("purchase.discount"),
font: .preferredFont(forTextStyle: .body),
color: .secondaryLabel)
return NSAttributedString(
string: "*Note: The discount amount may vary by region.",
attributes: [
.font: UIFont.preferredFont(forTextStyle: .footnote),
.foregroundColor: UIColor.secondaryLabel
]
)
} else {
return nil
}
Expand Down Expand Up @@ -92,7 +95,7 @@ class PurchaseViewModel: BaseIAPViewModel, ProductFetching {
private func addLifetimeLicenseItem() {
if let product = products[.fullVersion], let localizedPrice = product.localizedPrice {
let viewModel = PurchaseCellViewModel(productName: LocalizedString.getValue("purchase.product.lifetimeLicense"),
productDetail: LocalizedString.getValue("purchase.product.lifetimeLicense.detail"),
productDetail: "🎁 33%* off in December",
price: localizedPrice,
purchaseDetail: LocalizedString.getValue("purchase.product.lifetimeLicense.duration"),
productIdentifier: .fullVersion)
Expand Down
8 changes: 4 additions & 4 deletions Cryptomator/VaultList/VaultListViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ class VaultListViewController: ListViewController<VaultCellViewModel> {
}

#if !ALWAYS_PREMIUM
fullVersionPurchasedObserver = NotificationCenter.default.addObserver(forName: .dismissBannerNotification, object: nil, queue: .main) { [weak self] _ in
fullVersionPurchasedObserver = NotificationCenter.default.addObserver(forName: .purchasedFullVersionNotification, object: nil, queue: .main) { [weak self] _ in
self?.dismissBanner()
}
checkAndShowBanner()
Expand Down Expand Up @@ -148,7 +148,7 @@ class VaultListViewController: ListViewController<VaultCellViewModel> {
emojiLabel.setContentCompressionResistancePriority(.required, for: .horizontal)

let textLabel = UILabel()
textLabel.text = LocalizedString.getValue("purchase.discount")
textLabel.text = "Lifetime License is 33%* off in December!"
textLabel.textColor = .white
textLabel.font = UIFont.preferredFont(forTextStyle: .body)
textLabel.adjustsFontSizeToFitWidth = true
Expand Down Expand Up @@ -185,7 +185,7 @@ class VaultListViewController: ListViewController<VaultCellViewModel> {
NSLayoutConstraint.activate([
banner.leadingAnchor.constraint(equalTo: view.leadingAnchor, constant: 16),
banner.trailingAnchor.constraint(equalTo: view.trailingAnchor, constant: -16),
banner.bottomAnchor.constraint(equalTo: view.safeAreaLayoutGuide.bottomAnchor),
banner.bottomAnchor.constraint(equalTo: view.safeAreaLayoutGuide.bottomAnchor, constant: -16),
banner.centerXAnchor.constraint(equalTo: view.centerXAnchor),
banner.heightAnchor.constraint(equalToConstant: 60)
])
Expand All @@ -210,5 +210,5 @@ class VaultListViewController: ListViewController<VaultCellViewModel> {
}

extension Notification.Name {
static let dismissBannerNotification = Notification.Name("DismissBannerNotification")
static let purchasedFullVersionNotification = Notification.Name("PurchasedFullVersionNotification")
}
2 changes: 1 addition & 1 deletion CryptomatorTests/Purchase/PurchaseViewModelTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ class PurchaseViewModelTests: IAPViewModelTestCase {

private var lifetimeLicenseCell: Item {
return .purchaseCell(.init(productName: LocalizedString.getValue("purchase.product.lifetimeLicense"),
productDetail: nil,
productDetail: "🎁 33%* off in December",
price: "$11.99",
purchaseDetail: LocalizedString.getValue("purchase.product.lifetimeLicense.duration"),
productIdentifier: .fullVersion))
Expand Down
2 changes: 0 additions & 2 deletions SharedResources/en.lproj/Localizable.strings
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,6 @@
"onboarding.button.continue" = "Continue";

"purchase.beginFreeTrial.alert.title" = "Trial Unlocked";
"purchase.discount" = "Lifetime License is 33% off in December!";
"purchase.expiredTrial" = "Your trial has expired.";
"purchase.footer.privacyPolicy" = "Privacy Policy";
"purchase.footer.termsOfUse" = "Terms of Use";
Expand All @@ -172,7 +171,6 @@
"purchase.product.donateAndUpgrade" = "Donate & Upgrade";
"purchase.product.freeUpgrade" = "Free Upgrade";
"purchase.product.lifetimeLicense" = "Lifetime License";
"purchase.product.lifetimeLicense.detail" = "🎁 33% off in December";
"purchase.product.lifetimeLicense.duration" = "one-time";
"purchase.product.pricing.free" = "Free";
"purchase.product.trial" = "30-Day Trial";
Expand Down

0 comments on commit c9d32d6

Please sign in to comment.