Skip to content

Commit 6ecbdad

Browse files
committed
Refactor settings to use unlockFullVersion terminology
1 parent a24cc04 commit 6ecbdad

File tree

4 files changed

+16
-20
lines changed

4 files changed

+16
-20
lines changed

Cryptomator/Purchase/Cells/TrialCell.swift

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,8 +76,7 @@ struct TrialCellViewModel: Hashable {
7676
var expirationText: String {
7777
let formatter = DateFormatter()
7878
formatter.dateStyle = .short
79-
let formattedExpirationDate = formatter.string(for: expirationDate) ?? "Invalid Date"
80-
return String(format: LocalizedString.getValue("purchase.product.trial.expirationDate"), formattedExpirationDate)
79+
return String(format: LocalizedString.getValue("purchase.product.trial.expirationDate"), formatter.string(from: expirationDate))
8180
}
8281

8382
let expirationDate: Date

Cryptomator/Purchase/PurchaseAlert.swift

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,7 @@ enum PurchaseAlert {
1818
static func showForTrial(title: String, expirationDate: Date, on presentingViewController: UIViewController) -> Promise<Void> {
1919
let formatter = DateFormatter()
2020
formatter.dateStyle = .short
21-
let formattedExpireDate = formatter.string(for: expirationDate) ?? "Invalid Date"
22-
let message = String(format: LocalizedString.getValue("purchase.restorePurchase.validTrialFound.alert.message"), formattedExpireDate)
21+
let message = String(format: LocalizedString.getValue("purchase.restorePurchase.validTrialFound.alert.message"), formatter.string(from: expirationDate))
2322
return showAlert(title: title, message: message, on: presentingViewController)
2423
}
2524

Cryptomator/Settings/SettingsViewModel.swift

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ enum SettingsButtonAction: String {
2828
}
2929

3030
enum SettingsSection: Int {
31-
case purchaseStatusSection = 0
31+
case unlockFullVersionSection = 0
3232
case cloudServiceSection
3333
case cacheSection
3434
case aboutSection
@@ -46,22 +46,22 @@ class SettingsViewModel: TableViewModel<SettingsSection> {
4646
}
4747

4848
override func getFooterTitle(for section: Int) -> String? {
49-
guard sections[section].id == .aboutSection, hasFullAccess else { return nil }
50-
return LocalizedString.getValue("settings.fullVersion.footer")
49+
guard sections[section].id == .aboutSection, hasFullVersion else { return nil }
50+
return LocalizedString.getValue("settings.aboutCryptomator.hasFullVersion.footer")
5151
}
5252

5353
var showDebugModeWarning: AnyPublisher<Void, Never> {
5454
return showDebugModeWarningPublisher.eraseToAnyPublisher()
5555
}
5656

57-
private var hasFullAccess: Bool {
57+
private var hasFullVersion: Bool {
5858
cryptomatorSettings.hasRunningSubscription || cryptomatorSettings.fullVersionUnlocked
5959
}
6060

6161
private var _sections: [Section<SettingsSection>] {
6262
var sections: [Section<SettingsSection>] = []
63-
if !hasFullAccess {
64-
sections.append(Section(id: .purchaseStatusSection, elements: [purchaseStatusCellViewModel]))
63+
if !hasFullVersion {
64+
sections.append(Section(id: .unlockFullVersionSection, elements: [unlockFullVersionCellViewModel]))
6565
}
6666
sections.append(contentsOf: [
6767
Section(id: .cloudServiceSection, elements: [
@@ -95,23 +95,21 @@ class SettingsViewModel: TableViewModel<SettingsSection> {
9595
return elements
9696
}
9797

98-
private var purchaseStatusCellViewModel: ButtonCellViewModel<SettingsButtonAction> {
98+
private var unlockFullVersionCellViewModel: ButtonCellViewModel<SettingsButtonAction> {
9999
let detailTitle: String
100100
if let trialExpirationDate = cryptomatorSettings.trialExpirationDate, trialExpirationDate > Date() {
101-
let dateFormatter = DateFormatter()
102-
dateFormatter.dateStyle = .medium
103-
dateFormatter.timeStyle = .none
104-
detailTitle = String(format: LocalizedString.getValue("settings.trial.expirationDate"), dateFormatter.string(from: trialExpirationDate))
101+
let formatter = DateFormatter()
102+
formatter.dateStyle = .short
103+
detailTitle = String(format: LocalizedString.getValue("settings.unlockFullVersion.trialExpirationDate"), formatter.string(from: trialExpirationDate))
105104
} else {
106-
detailTitle = LocalizedString.getValue("settings.freeTier.subtitle")
105+
detailTitle = LocalizedString.getValue("settings.unlockFullVersion.detail")
107106
}
108107
let image = UIImage(systemName: "checkmark.seal.fill", withConfiguration: UIImage.SymbolConfiguration(pointSize: 22))
109108
return ButtonCellViewModel.createDisclosureButton(action: .showUnlockFullVersion, title: LocalizedString.getValue("settings.unlockFullVersion"), detailTitle: detailTitle, image: image, cellStyle: .subtitle)
110109
}
111110

112111
private let cacheSizeCellViewModel = LoadingWithLabelCellViewModel(title: LocalizedString.getValue("settings.cacheSize"))
113112
private let clearCacheButtonCellViewModel = ButtonCellViewModel<SettingsButtonAction>(action: .clearCache, title: LocalizedString.getValue("settings.clearCache"), isEnabled: false)
114-
115113
private var cryptomatorSettings: CryptomatorSettings
116114

117115
private lazy var debugModeViewModel: SwitchCellViewModel = {

SharedResources/en.lproj/Localizable.strings

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -202,6 +202,7 @@
202202
"settings.title" = "Settings";
203203
"settings.aboutCryptomator" = "About Cryptomator";
204204
"settings.aboutCryptomator.title" = "Version %@ (%@)";
205+
"settings.aboutCryptomator.hasFullVersion.footer" = "You have unlocked the full version and gained write access to your vaults.";
205206
"settings.cacheSize" = "Cache Size";
206207
"settings.clearCache" = "Clear Cache";
207208
"settings.cloudServices" = "Cloud Services";
@@ -213,9 +214,8 @@
213214
"settings.sendLogFile" = "Send Log File";
214215
"settings.shortcutsGuide" = "Shortcuts Guide";
215216
"settings.unlockFullVersion" = "Unlock Full Version";
216-
"settings.fullVersion.footer" = "You have unlocked the full version and gained write access to your vaults.";
217-
"settings.trial.expirationDate" = "Trial Expiration Date: %@";
218-
"settings.freeTier.subtitle" = "Gain write access to your vaults.";
217+
"settings.unlockFullVersion.detail" = "Gain write access to your vaults.";
218+
"settings.unlockFullVersion.trialExpirationDate" = "Trial Expiration Date: %@";
219219

220220
"sharePoint.enterURL.title" = "Enter SharePoint URL";
221221
"sharePoint.enterURL.placeholder" = "SharePoint Site URL";

0 commit comments

Comments
 (0)