@@ -21,15 +21,9 @@ class VaultListViewController: ListViewController<VaultCellViewModel> {
2121 @Dependency ( \. fullVersionChecker) private var fullVersionChecker
2222 @Dependency ( \. cryptomatorSettings) private var cryptomatorSettings
2323
24+ #if !ALWAYS_PREMIUM
2425 private var bannerView : UIView ?
25- private var bannerDismissed : Bool {
26- get {
27- return CryptomatorUserDefaults . shared. bannerDismissed
28- }
29- set {
30- CryptomatorUserDefaults . shared. bannerDismissed = newValue
31- }
32- }
26+ #endif
3327
3428 init ( with viewModel: VaultListViewModelProtocol ) {
3529 self . viewModel = viewModel
@@ -61,7 +55,9 @@ class VaultListViewController: ListViewController<VaultCellViewModel> {
6155 }
6256 }
6357
58+ #if !ALWAYS_PREMIUM
6459 checkAndShowBanner ( )
60+ #endif
6561 }
6662
6763 override func viewWillAppear( _ animated: Bool ) {
@@ -124,14 +120,12 @@ class VaultListViewController: ListViewController<VaultCellViewModel> {
124120
125121 // MARK: - Discount Banner
126122
123+ #if !ALWAYS_PREMIUM
127124 private func checkAndShowBanner( ) {
128- let calendar = Calendar . current
129- let isTargetMonth = calendar. component ( . year, from: Date ( ) ) == 2024 &&
130- calendar. component ( . month, from: Date ( ) ) == 11
131-
132- if isTargetMonth &&
133- !( cryptomatorSettings. fullVersionUnlocked || cryptomatorSettings. hasRunningSubscription) &&
134- !bannerDismissed {
125+ let currentYear = Calendar . current. component ( . year, from: Date ( ) )
126+ let currentMonth = Calendar . current. component ( . month, from: Date ( ) )
127+ // TODO: Change `currentMonth == 11` to `12`
128+ if currentYear == 2024 && currentMonth == 11 && !( cryptomatorSettings. fullVersionUnlocked || cryptomatorSettings. hasRunningSubscription) && !cryptomatorSettings. december2024BannerDismissed {
135129 showBanner ( )
136130 }
137131 }
@@ -146,19 +140,23 @@ class VaultListViewController: ListViewController<VaultCellViewModel> {
146140 let emojiLabel = UILabel ( )
147141 emojiLabel. text = " 🎁 "
148142 emojiLabel. translatesAutoresizingMaskIntoConstraints = false
143+ emojiLabel. setContentHuggingPriority ( . required, for: . horizontal)
144+ emojiLabel. setContentCompressionResistancePriority ( . required, for: . horizontal)
145+
149146
150147 let textLabel = UILabel ( )
151148 textLabel. text = LocalizedString . getValue ( " purchase.discount " )
152149 textLabel. textColor = . white
153- textLabel. font = UIFont . boldSystemFont ( ofSize: 14 )
150+ textLabel. font = UIFont . preferredFont ( forTextStyle: . body)
151+ textLabel. adjustsFontSizeToFitWidth = true
152+ textLabel. minimumScaleFactor = 0.5
154153 textLabel. translatesAutoresizingMaskIntoConstraints = false
155154
156- let dismissButton = UIButton ( type: . system)
157- dismissButton. setTitle ( " X " , for: . normal)
158- dismissButton. setTitleColor ( . white, for: . normal)
159- dismissButton. titleLabel? . font = UIFont . boldSystemFont ( ofSize: 12 )
155+ let dismissButton = UIButton ( type: . close)
160156 dismissButton. addTarget ( self , action: #selector( dismissBanner) , for: . touchUpInside)
161157 dismissButton. translatesAutoresizingMaskIntoConstraints = false
158+ dismissButton. setContentHuggingPriority ( . required, for: . horizontal)
159+ dismissButton. setContentCompressionResistancePriority ( . required, for: . horizontal)
162160
163161 banner. addSubview ( emojiLabel)
164162 banner. addSubview ( textLabel)
@@ -193,34 +191,17 @@ class VaultListViewController: ListViewController<VaultCellViewModel> {
193191 }
194192
195193 @objc private func dismissBanner( ) {
196- bannerView? . removeFromSuperview ( )
197- bannerDismissed = true
194+ UIView . animate ( withDuration: 0.3 , animations: {
195+ self . bannerView? . alpha = 0
196+ } , completion: { _ in
197+ self . bannerView? . removeFromSuperview ( )
198+ self . bannerView = nil
199+ } )
200+ CryptomatorUserDefaults . shared. december2024BannerDismissed = true
198201 }
199202
200203 @objc private func bannerTapped( ) {
201- let purchaseViewModel = PurchaseViewModel ( )
202- let purchaseViewController = PurchaseViewController ( viewModel: purchaseViewModel)
203- purchaseViewController. modalPresentationStyle = . pageSheet
204-
205- let navigationController = UINavigationController ( rootViewController: purchaseViewController)
206- navigationController. modalPresentationStyle = . pageSheet
207-
208- let appearance = UINavigationBarAppearance ( )
209- appearance. configureWithOpaqueBackground ( )
210- appearance. backgroundColor = UIColor . cryptomatorPrimary
211- appearance. titleTextAttributes = [ . foregroundColor: UIColor . white]
212-
213- navigationController. navigationBar. standardAppearance = appearance
214- navigationController. navigationBar. scrollEdgeAppearance = appearance
215- navigationController. navigationBar. tintColor = . white
216-
217- let closeButton = UIBarButtonItem ( barButtonSystemItem: . done, target: self , action: #selector( dismissIAPView) )
218- purchaseViewController. navigationItem. rightBarButtonItem = closeButton
219-
220- present ( navigationController, animated: true , completion: nil )
221- }
222-
223- @objc private func dismissIAPView( ) {
224- dismiss ( animated: true , completion: nil )
204+ coordinator? . showPurchase ( )
225205 }
206+ #endif
226207}
0 commit comments