Skip to content

Commit

Permalink
Removed December 2024 sale promo
Browse files Browse the repository at this point in the history
  • Loading branch information
tobihagemann committed Feb 6, 2025
1 parent 482112a commit 217c4f9
Show file tree
Hide file tree
Showing 10 changed files with 0 additions and 162 deletions.
11 changes: 0 additions & 11 deletions Cryptomator/MainCoordinator.swift
Original file line number Diff line number Diff line change
Expand Up @@ -78,15 +78,6 @@ class MainCoordinator: NSObject, Coordinator, UINavigationControllerDelegate {
rootViewController.showDetailViewController(detailNavigationController, sender: nil)
}

// Temporarily added for December 2024 Sale
func showPurchase() {
let modalNavigationController = BaseNavigationController()
let child = PurchaseCoordinator(navigationController: modalNavigationController)
childCoordinators.append(child)
navigationController.topViewController?.present(modalNavigationController, animated: true)
child.start()
}

// MARK: - UINavigationControllerDelegate

func navigationController(_ navigationController: UINavigationController, didShow viewController: UIViewController, animated: Bool) {
Expand Down Expand Up @@ -124,8 +115,6 @@ extension MainCoordinator: StoreObserverDelegate {
switch transaction {
case .fullVersion, .yearlySubscription:
showFullVersionAlert()
// Temporarily added for December 2024 Sale
NotificationCenter.default.post(name: .purchasedFullVersionNotification, object: nil)
case let .freeTrial(expiresOn):
showTrialAlert(expirationDate: expiresOn)
case .unknown:
Expand Down
2 changes: 0 additions & 2 deletions Cryptomator/Purchase/Cells/PurchaseCell.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import UIKit

struct PurchaseCellViewModel: Hashable {
let productName: String
let productDetail: String?
let price: String
let purchaseDetail: String?
let purchaseButtonViewModel = PurchaseButtonViewModel()
Expand All @@ -37,7 +36,6 @@ class PurchaseCell: IAPCell {

func configure(with viewModel: PurchaseCellViewModel) {
productTitleLabel.text = viewModel.productName
productDetailLabel.text = viewModel.productDetail
accessory.button.setTitle(viewModel.price, for: .normal)
accessory.detailLabel.text = viewModel.purchaseDetail
accessory.configure(with: viewModel.purchaseButtonViewModel)
Expand Down
2 changes: 0 additions & 2 deletions Cryptomator/Purchase/PurchaseCoordinator.swift
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,6 @@ class PurchaseCoordinator: Coordinator {
}
self.unlockedPro()
}
// Temporarily added for December 2024 Sale
NotificationCenter.default.post(name: .purchasedFullVersionNotification, object: nil)
}

func handleRestoreResult(_ result: RestoreTransactionsResult) {
Expand Down
24 changes: 0 additions & 24 deletions Cryptomator/Purchase/PurchaseViewModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -33,23 +33,6 @@ class PurchaseViewModel: BaseIAPViewModel, ProductFetching {
return LocalizedString.getValue("purchase.title")
}

// Temporarily added for December 2024 Sale
override var infoText: NSAttributedString? {
let currentYear = Calendar.current.component(.year, from: Date())
let currentMonth = Calendar.current.component(.month, from: Date())
if currentYear == 2024 && currentMonth == 12 {
return NSAttributedString(
string: "*Note: The discount amount may vary by region.",
attributes: [
.font: UIFont.preferredFont(forTextStyle: .footnote),
.foregroundColor: UIColor.secondaryLabel
]
)
} else {
return nil
}
}

private let cryptomatorSettings: CryptomatorSettings

init(storeManager: IAPStore = StoreManager.shared, iapManager: IAPManager = StoreObserver.shared, cryptomatorSettings: CryptomatorSettings = CryptomatorUserDefaults.shared, minimumDisplayTime: TimeInterval = 1.0) {
Expand All @@ -73,7 +56,6 @@ class PurchaseViewModel: BaseIAPViewModel, ProductFetching {
cells.append(.trialCell(TrialCellViewModel(expirationDate: trialExpirationDate)))
} else {
cells.append(.purchaseCell(PurchaseCellViewModel(productName: LocalizedString.getValue("purchase.product.trial"),
productDetail: nil,
price: LocalizedString.getValue("purchase.product.pricing.free"),
purchaseDetail: LocalizedString.getValue("purchase.product.trial.duration"),
productIdentifier: .thirtyDayTrial)))
Expand All @@ -83,7 +65,6 @@ class PurchaseViewModel: BaseIAPViewModel, ProductFetching {
private func addSubscriptionItem() {
if let product = products[.yearlySubscription], let localizedPrice = product.localizedPrice {
let viewModel = PurchaseCellViewModel(productName: LocalizedString.getValue("purchase.product.yearlySubscription"),
productDetail: nil,
price: localizedPrice,
purchaseDetail: LocalizedString.getValue("purchase.product.yearlySubscription.duration"),
productIdentifier: .yearlySubscription)
Expand All @@ -93,12 +74,7 @@ class PurchaseViewModel: BaseIAPViewModel, ProductFetching {

private func addLifetimeLicenseItem() {
if let product = products[.fullVersion], let localizedPrice = product.localizedPrice {
// Temporarily added for December 2024 Sale
let currentYear = Calendar.current.component(.year, from: Date())
let currentMonth = Calendar.current.component(.month, from: Date())
let productDetail = currentYear == 2024 && currentMonth == 12 ? "🎁 33%* off in December" : nil
let viewModel = PurchaseCellViewModel(productName: LocalizedString.getValue("purchase.product.lifetimeLicense"),
productDetail: productDetail,
price: localizedPrice,
purchaseDetail: LocalizedString.getValue("purchase.product.lifetimeLicense.duration"),
productIdentifier: .fullVersion)
Expand Down
2 changes: 0 additions & 2 deletions Cryptomator/Purchase/UpgradeViewModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ class UpgradeViewModel: BaseIAPViewModel, ProductFetching {
func addFreeUpgradeItem() {
guard products[.freeUpgrade] != nil else { return }
let viewModel = PurchaseCellViewModel(productName: LocalizedString.getValue("purchase.product.freeUpgrade"),
productDetail: nil,
price: LocalizedString.getValue("purchase.product.pricing.free"),
purchaseDetail: nil,
productIdentifier: .freeUpgrade)
Expand All @@ -44,7 +43,6 @@ class UpgradeViewModel: BaseIAPViewModel, ProductFetching {
func addPaidUpgradeItem() {
if let product = products[.paidUpgrade], let localizedPrice = product.localizedPrice {
let viewModel = PurchaseCellViewModel(productName: LocalizedString.getValue("purchase.product.donateAndUpgrade"),
productDetail: nil,
price: localizedPrice,
purchaseDetail: LocalizedString.getValue("purchase.product.lifetimeLicense.duration"),
productIdentifier: .paidUpgrade)
Expand Down
103 changes: 0 additions & 103 deletions Cryptomator/VaultList/VaultListViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,6 @@ class VaultListViewController: ListViewController<VaultCellViewModel> {
private let viewModel: VaultListViewModelProtocol
private var willEnterForegroundObserver: NSObjectProtocol?
@Dependency(\.fullVersionChecker) private var fullVersionChecker
@Dependency(\.cryptomatorSettings) private var cryptomatorSettings

#if !ALWAYS_PREMIUM
private var bannerView: UIView?
private var fullVersionPurchasedObserver: NSObjectProtocol?
#endif

init(with viewModel: VaultListViewModelProtocol) {
self.viewModel = viewModel
Expand Down Expand Up @@ -55,13 +49,6 @@ class VaultListViewController: ListViewController<VaultCellViewModel> {
DDLogError("Refresh vault lock states failed with error: \(error)")
}
}

#if !ALWAYS_PREMIUM
fullVersionPurchasedObserver = NotificationCenter.default.addObserver(forName: .purchasedFullVersionNotification, object: nil, queue: .main) { [weak self] _ in
self?.dismissBanner()
}
checkAndShowBanner()
#endif
}

override func viewWillAppear(_ animated: Bool) {
Expand Down Expand Up @@ -121,94 +108,4 @@ class VaultListViewController: ListViewController<VaultCellViewModel> {
coordinator?.showVaultDetail(for: vaultCellViewModel.vault)
}
}

// MARK: - Discount Banner

#if !ALWAYS_PREMIUM
private func checkAndShowBanner() {
let currentYear = Calendar.current.component(.year, from: Date())
let currentMonth = Calendar.current.component(.month, from: Date())
if currentYear == 2024, currentMonth == 12, !(cryptomatorSettings.fullVersionUnlocked || cryptomatorSettings.hasRunningSubscription), !cryptomatorSettings.december2024BannerDismissed {
showBanner()
}
}

private func showBanner() {
let banner = UIView()
banner.backgroundColor = UIColor.cryptomatorPrimary
banner.translatesAutoresizingMaskIntoConstraints = false
banner.layer.cornerRadius = 12
banner.layer.masksToBounds = true

let emojiLabel = UILabel()
emojiLabel.text = "🎁"
emojiLabel.translatesAutoresizingMaskIntoConstraints = false
emojiLabel.setContentHuggingPriority(.required, for: .horizontal)
emojiLabel.setContentCompressionResistancePriority(.required, for: .horizontal)

let textLabel = UILabel()
textLabel.text = "Lifetime License is 33%* off in December!"
textLabel.textColor = .white
textLabel.font = UIFont.preferredFont(forTextStyle: .footnote)
textLabel.adjustsFontSizeToFitWidth = true
textLabel.minimumScaleFactor = 0.5
textLabel.numberOfLines = 2
textLabel.translatesAutoresizingMaskIntoConstraints = false

let dismissButton = UIButton(type: .close)
dismissButton.addTarget(self, action: #selector(dismissBanner), for: .touchUpInside)
dismissButton.translatesAutoresizingMaskIntoConstraints = false
dismissButton.setContentHuggingPriority(.required, for: .horizontal)
dismissButton.setContentCompressionResistancePriority(.required, for: .horizontal)

banner.addSubview(emojiLabel)
banner.addSubview(textLabel)
banner.addSubview(dismissButton)

NSLayoutConstraint.activate([
emojiLabel.leadingAnchor.constraint(equalTo: banner.leadingAnchor, constant: 16),
emojiLabel.centerYAnchor.constraint(equalTo: banner.centerYAnchor),

textLabel.leadingAnchor.constraint(equalTo: emojiLabel.trailingAnchor, constant: 8),
textLabel.centerYAnchor.constraint(equalTo: banner.centerYAnchor),

dismissButton.leadingAnchor.constraint(equalTo: textLabel.trailingAnchor, constant: 8),
dismissButton.trailingAnchor.constraint(equalTo: banner.trailingAnchor, constant: -16),
dismissButton.centerYAnchor.constraint(equalTo: banner.centerYAnchor)
])

let tapGestureRecognizer = UITapGestureRecognizer(target: self, action: #selector(bannerTapped))
banner.addGestureRecognizer(tapGestureRecognizer)

view.addSubview(banner)

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, constant: -16),
banner.centerXAnchor.constraint(equalTo: view.centerXAnchor),
banner.heightAnchor.constraint(equalToConstant: 50)
])

bannerView = banner
}

@objc private func dismissBanner() {
UIView.animate(withDuration: 0.3, animations: {
self.bannerView?.alpha = 0
}, completion: { _ in
self.bannerView?.removeFromSuperview()
self.bannerView = nil
})
CryptomatorUserDefaults.shared.december2024BannerDismissed = true
}

@objc private func bannerTapped() {
coordinator?.showPurchase()
}
#endif
}

extension Notification.Name {
static let purchasedFullVersionNotification = Notification.Name("PurchasedFullVersionNotification")
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,6 @@ public protocol CryptomatorSettings {
var trialExpirationDate: Date? { get set }
var fullVersionUnlocked: Bool { get set }
var hasRunningSubscription: Bool { get set }
#if !ALWAYS_PREMIUM
var december2024BannerDismissed: Bool { get set }
#endif
}

private enum CryptomatorSettingsKey: DependencyKey {
Expand Down Expand Up @@ -111,11 +108,4 @@ extension CryptomatorUserDefaults: CryptomatorSettings {
get { read() ?? false }
set { write(value: newValue) }
}

#if !ALWAYS_PREMIUM
public var december2024BannerDismissed: Bool {
get { read() ?? false }
set { write(value: newValue) }
}
#endif
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,5 @@ class CryptomatorSettingsMock: CryptomatorSettings {
var debugModeEnabled: Bool = false
var fullVersionUnlocked: Bool = false
var hasRunningSubscription: Bool = false
#if !ALWAYS_PREMIUM
var december2024BannerDismissed: Bool = false
#endif
}
#endif
3 changes: 0 additions & 3 deletions CryptomatorTests/Purchase/PurchaseViewModelTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -153,23 +153,20 @@ class PurchaseViewModelTests: IAPViewModelTestCase {

private var purchaseTrialCell: Item {
return .purchaseCell(.init(productName: LocalizedString.getValue("purchase.product.trial"),
productDetail: nil,
price: LocalizedString.getValue("purchase.product.pricing.free"),
purchaseDetail: LocalizedString.getValue("purchase.product.trial.duration"),
productIdentifier: .thirtyDayTrial))
}

private var yearlySubscriptionCell: Item {
return .purchaseCell(.init(productName: LocalizedString.getValue("purchase.product.yearlySubscription"),
productDetail: nil,
price: "$5.99",
purchaseDetail: LocalizedString.getValue("purchase.product.yearlySubscription.duration"),
productIdentifier: .yearlySubscription))
}

private var lifetimeLicenseCell: Item {
return .purchaseCell(.init(productName: LocalizedString.getValue("purchase.product.lifetimeLicense"),
productDetail: nil,
price: "$11.99",
purchaseDetail: LocalizedString.getValue("purchase.product.lifetimeLicense.duration"),
productIdentifier: .fullVersion))
Expand Down
2 changes: 0 additions & 2 deletions CryptomatorTests/Purchase/UpgradeViewModelTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -77,15 +77,13 @@ class UpgradeViewModelTests: IAPViewModelTestCase {

private var freeUpgradeCell: Item {
return .purchaseCell(.init(productName: LocalizedString.getValue("purchase.product.freeUpgrade"),
productDetail: nil,
price: LocalizedString.getValue("purchase.product.pricing.free"),
purchaseDetail: nil,
productIdentifier: .freeUpgrade))
}

private var paidUpgradeCell: Item {
return .purchaseCell(.init(productName: LocalizedString.getValue("purchase.product.donateAndUpgrade"),
productDetail: nil,
price: "$1.99",
purchaseDetail: LocalizedString.getValue("purchase.product.lifetimeLicense.duration"),
productIdentifier: .paidUpgrade))
Expand Down

0 comments on commit 217c4f9

Please sign in to comment.