@@ -28,7 +28,8 @@ enum SettingsButtonAction: String {
2828}
2929
3030enum SettingsSection : Int {
31- case cloudServiceSection = 0
31+ case purchaseStatusSection = 0
32+ case cloudServiceSection
3233 case cacheSection
3334 case aboutSection
3435 case debugSection
@@ -49,7 +50,11 @@ class SettingsViewModel: TableViewModel<SettingsSection> {
4950 }
5051
5152 private var _sections : [ Section < SettingsSection > ] {
52- return [
53+ var sections : [ Section < SettingsSection > ] = [ ]
54+ if !hasFullAccess {
55+ sections. append ( Section ( id: . purchaseStatusSection, elements: [ purchaseStatusCellViewModel] ) )
56+ }
57+ sections. append ( contentsOf: [
5358 Section ( id: . cloudServiceSection, elements: [
5459 ButtonCellViewModel . createDisclosureButton ( action: SettingsButtonAction . showCloudServices, title: LocalizedString . getValue ( " settings.cloudServices " ) )
5560 ] ) ,
@@ -67,23 +72,25 @@ class SettingsViewModel: TableViewModel<SettingsSection> {
6772 ButtonCellViewModel ( action: SettingsButtonAction . showContact, title: LocalizedString . getValue ( " settings.contact " ) ) ,
6873 ButtonCellViewModel ( action: SettingsButtonAction . showRateApp, title: LocalizedString . getValue ( " settings.rateApp " ) )
6974 ] )
70- ]
75+ ] )
76+ return sections
7177 }
7278
73- private var aboutSectionElements : [ TableViewCellViewModel ] {
74- var elements : [ TableViewCellViewModel ] = [ ButtonCellViewModel . createDisclosureButton ( action: SettingsButtonAction . showAbout, title: LocalizedString . getValue ( " settings.aboutCryptomator " ) ) ]
79+ override func getFooterTitle( for section: Int ) -> String ? {
80+ guard sections [ section] . id == . aboutSection, hasFullAccess else { return nil }
81+ return LocalizedString . getValue ( " settings.fullVersion.footer " )
82+ }
7583
84+ private var hasFullAccess : Bool {
85+ cryptomatorSettings. hasRunningSubscription || cryptomatorSettings. fullVersionUnlocked
86+ }
87+
88+ private var aboutSectionElements : [ TableViewCellViewModel ] {
89+ var elements : [ TableViewCellViewModel ] = [
90+ ButtonCellViewModel . createDisclosureButton ( action: SettingsButtonAction . showAbout, title: LocalizedString . getValue ( " settings.aboutCryptomator " ) )
91+ ]
7692 if cryptomatorSettings. hasRunningSubscription {
77- elements. append ( ButtonCellViewModel < SettingsButtonAction > ( action: . showManageSubscriptions, title: LocalizedString . getValue ( " settings.manageSubscriptions " ) ) )
78- } else if cryptomatorSettings. fullVersionUnlocked {
79- let statusCell = BindableTableViewCellViewModel (
80- title: LocalizedString . getValue ( " settings.fullVersionStatus " ) ,
81- selectionStyle: . none,
82- accessoryType: . checkmark
83- )
84- elements. append ( statusCell)
85- } else {
86- 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 " ) ) )
8794 }
8895 return elements
8996 }
@@ -92,6 +99,24 @@ class SettingsViewModel: TableViewModel<SettingsSection> {
9299 private let clearCacheButtonCellViewModel = ButtonCellViewModel < SettingsButtonAction > ( action: . clearCache, title: LocalizedString . getValue ( " settings.clearCache " ) , isEnabled: false )
93100
94101 private var cryptomatorSettings : CryptomatorSettings
102+
103+ private var purchaseStatusCellViewModel : PurchaseStatusCellViewModel {
104+ let subtitle : String
105+ if let trialExpirationDate = cryptomatorSettings. trialExpirationDate, trialExpirationDate > Date ( ) {
106+ let dateFormatter = DateFormatter ( )
107+ dateFormatter. dateStyle = . medium
108+ dateFormatter. timeStyle = . none
109+ subtitle = String ( format: LocalizedString . getValue ( " settings.trial.expirationDate " ) , dateFormatter. string ( from: trialExpirationDate) )
110+ } else {
111+ subtitle = LocalizedString . getValue ( " settings.freeTier.subtitle " )
112+ }
113+ return PurchaseStatusCellViewModel (
114+ iconName: " checkmark.seal.fill " ,
115+ title: LocalizedString . getValue ( " settings.unlockFullVersion " ) ,
116+ subtitle: subtitle
117+ )
118+ }
119+
95120 private lazy var debugModeViewModel : SwitchCellViewModel = {
96121 let viewModel = SwitchCellViewModel ( title: LocalizedString . getValue ( " settings.debugMode " ) , isOn: cryptomatorSettings. debugModeEnabled)
97122 bindDebugModeViewModel ( viewModel)
0 commit comments