@@ -28,7 +28,8 @@ enum SettingsButtonAction: String {
2828}
2929
3030enum SettingsSection : Int {
31- case cloudServiceSection = 0
31+ case unlockFullVersionSection = 0
32+ case cloudServiceSection
3233 case cacheSection
3334 case aboutSection
3435 case debugSection
@@ -44,12 +45,25 @@ class SettingsViewModel: TableViewModel<SettingsSection> {
4445 return _sections
4546 }
4647
48+ override func getFooterTitle( for section: Int ) -> String ? {
49+ guard sections [ section] . id == . aboutSection, hasFullVersion else { return nil }
50+ return LocalizedString . getValue ( " settings.aboutCryptomator.hasFullVersion.footer " )
51+ }
52+
4753 var showDebugModeWarning : AnyPublisher < Void , Never > {
4854 return showDebugModeWarningPublisher. eraseToAnyPublisher ( )
4955 }
5056
57+ private var hasFullVersion : Bool {
58+ cryptomatorSettings. hasRunningSubscription || cryptomatorSettings. fullVersionUnlocked
59+ }
60+
5161 private var _sections : [ Section < SettingsSection > ] {
52- return [
62+ var sections : [ Section < SettingsSection > ] = [ ]
63+ if !hasFullVersion {
64+ sections. append ( Section ( id: . unlockFullVersionSection, elements: [ unlockFullVersionCellViewModel] ) )
65+ }
66+ sections. append ( contentsOf: [
5367 Section ( id: . cloudServiceSection, elements: [
5468 ButtonCellViewModel . createDisclosureButton ( action: SettingsButtonAction . showCloudServices, title: LocalizedString . getValue ( " settings.cloudServices " ) )
5569 ] ) ,
@@ -67,24 +81,37 @@ class SettingsViewModel: TableViewModel<SettingsSection> {
6781 ButtonCellViewModel ( action: SettingsButtonAction . showContact, title: LocalizedString . getValue ( " settings.contact " ) ) ,
6882 ButtonCellViewModel ( action: SettingsButtonAction . showRateApp, title: LocalizedString . getValue ( " settings.rateApp " ) )
6983 ] )
70- ]
84+ ] )
85+ return sections
7186 }
7287
7388 private var aboutSectionElements : [ TableViewCellViewModel ] {
74- var elements = [ ButtonCellViewModel . createDisclosureButton ( action: SettingsButtonAction . showAbout, title: LocalizedString . getValue ( " settings.aboutCryptomator " ) ) ]
89+ var elements : [ TableViewCellViewModel ] = [
90+ ButtonCellViewModel . createDisclosureButton ( action: SettingsButtonAction . showAbout, title: LocalizedString . getValue ( " settings.aboutCryptomator " ) )
91+ ]
7592 if cryptomatorSettings. hasRunningSubscription {
76- elements. append ( . init( action: . showManageSubscriptions, title: LocalizedString . getValue ( " settings.manageSubscriptions " ) ) )
77- elements. append ( . init( action: . restorePurchase, title: LocalizedString . getValue ( " purchase.restorePurchase.button " ) ) )
78- } else if !cryptomatorSettings. fullVersionUnlocked {
79- elements. append ( ButtonCellViewModel . createDisclosureButton ( action: SettingsButtonAction . showUnlockFullVersion, title: LocalizedString . getValue ( " settings.unlockFullVersion " ) ) )
93+ elements. append ( ButtonCellViewModel . createDisclosureButton ( action: SettingsButtonAction . showManageSubscriptions, title: LocalizedString . getValue ( " settings.manageSubscriptions " ) ) )
8094 }
8195 return elements
8296 }
8397
98+ private var unlockFullVersionCellViewModel : ButtonCellViewModel < SettingsButtonAction > {
99+ let detailTitle : String
100+ if let trialExpirationDate = cryptomatorSettings. trialExpirationDate, trialExpirationDate > Date ( ) {
101+ let formatter = DateFormatter ( )
102+ formatter. dateStyle = . short
103+ detailTitle = String ( format: LocalizedString . getValue ( " settings.unlockFullVersion.trialExpirationDate " ) , formatter. string ( from: trialExpirationDate) )
104+ } else {
105+ detailTitle = LocalizedString . getValue ( " settings.unlockFullVersion.detail " )
106+ }
107+ let image = UIImage ( systemName: " checkmark.seal.fill " , withConfiguration: UIImage . SymbolConfiguration ( pointSize: 22 ) )
108+ return ButtonCellViewModel . createDisclosureButton ( action: . showUnlockFullVersion, title: LocalizedString . getValue ( " settings.unlockFullVersion " ) , detailTitle: detailTitle, image: image, cellStyle: . subtitle)
109+ }
110+
84111 private let cacheSizeCellViewModel = LoadingWithLabelCellViewModel ( title: LocalizedString . getValue ( " settings.cacheSize " ) )
85112 private let clearCacheButtonCellViewModel = ButtonCellViewModel < SettingsButtonAction > ( action: . clearCache, title: LocalizedString . getValue ( " settings.clearCache " ) , isEnabled: false )
86-
87113 private var cryptomatorSettings : CryptomatorSettings
114+
88115 private lazy var debugModeViewModel : SwitchCellViewModel = {
89116 let viewModel = SwitchCellViewModel ( title: LocalizedString . getValue ( " settings.debugMode " ) , isOn: cryptomatorSettings. debugModeEnabled)
90117 bindDebugModeViewModel ( viewModel)
0 commit comments