Feed cache

This commit is contained in:
Arkadiusz Fal
2022-12-10 03:01:59 +01:00
parent eae04c9382
commit 971beddc8d
24 changed files with 484 additions and 237 deletions

View File

@@ -11,9 +11,9 @@ struct AdvancedSettings: View {
@State private var countries = [String]()
@State private var filesToShare = [MPVClient.logFile]
@State private var presentingInstanceForm = false
@State private var presentingShareSheet = false
@State private var savedFormInstanceID: Instance.ID?
private var settings = SettingsModel.shared
var body: some View {
VStack(alignment: .leading) {
@@ -36,9 +36,6 @@ struct AdvancedSettings: View {
.onChange(of: countryOfPublicInstances) { newCountry in
InstancesManifest.shared.setPublicAccount(newCountry, asCurrent: AccountsModel.shared.current?.isPublic ?? true)
}
.sheet(isPresented: $presentingInstanceForm) {
InstanceForm(savedInstanceID: $savedFormInstanceID)
}
#if os(tvOS)
.frame(maxWidth: 1000)
#endif
@@ -87,6 +84,11 @@ struct AdvancedSettings: View {
logButton
}
}
Section(header: SettingsHeader(text: "Cache")) {
clearCacheButton
cacheSize
}
}
@ViewBuilder var mpvFooter: some View {
@@ -128,13 +130,27 @@ struct AdvancedSettings: View {
}
#endif
private var addInstanceButton: some View {
private var clearCacheButton: some View {
Button {
presentingInstanceForm = true
settings.presentAlert(
Alert(
title: Text(
"Are you sure you want to clear cache?"
),
primaryButton: .destructive(Text("Clear"), action: CacheModel.shared.clear),
secondaryButton: .cancel()
)
)
} label: {
Label("Add Location...", systemImage: "plus")
Text("Clear all")
.foregroundColor(.red)
}
}
var cacheSize: some View {
Text(String(format: "Total size: %@", CacheModel.shared.totalSizeFormatted))
.foregroundColor(.secondary)
}
}
struct AdvancedSettings_Previews: PreviewProvider {

View File

@@ -164,7 +164,9 @@ struct HistorySettings: View {
struct HistorySettings_Previews: PreviewProvider {
static var previews: some View {
HistorySettings()
.injectFixtureEnvironmentObjects()
VStack(alignment: .leading) {
HistorySettings()
}
.frame(minHeight: 500)
}
}

View File

@@ -231,7 +231,7 @@ struct SettingsView: View {
case .locations:
return 600
case .advanced:
return 250
return 350
case .help:
return 650
}