MainViewModel documentation and image caching improvements
This commit is contained in:
@@ -9,13 +9,14 @@ import Foundation
|
||||
import SwiftUI
|
||||
|
||||
struct SettingsView: View {
|
||||
@StateObject var userSettings = UserSettings()
|
||||
@ObservedObject var userSettings: UserSettings
|
||||
|
||||
var body: some View {
|
||||
ScrollView(showsIndicators: false) {
|
||||
LazyVStack {
|
||||
SettingsSection(headline: "Language", description: "Language settings coming soon.")
|
||||
SettingsSection(headline: "Accent Color", description: "The accent color setting will be released in a future update.")
|
||||
List {
|
||||
SettingsSection(title: "Language", description: "Language settings coming soon.")
|
||||
SettingsSection(title: "Accent Color", description: "The accent color setting will be released in a future update.")
|
||||
SettingsSection(title: "Log out", description: "Log out of your Nextcloud account in this app. Your recipes will be removed from local storage.")
|
||||
{
|
||||
Button("Log out") {
|
||||
print("Log out.")
|
||||
userSettings.serverAddress = ""
|
||||
@@ -26,7 +27,10 @@ struct SettingsView: View {
|
||||
.buttonStyle(.borderedProminent)
|
||||
.accentColor(.red)
|
||||
.padding()
|
||||
|
||||
}
|
||||
|
||||
SettingsSection(title: "Clear local data", description: "Your recipes will be removed from local storage.")
|
||||
{
|
||||
Button("Clear Cache") {
|
||||
print("Clear cache.")
|
||||
|
||||
@@ -35,21 +39,40 @@ struct SettingsView: View {
|
||||
.accentColor(.red)
|
||||
.padding()
|
||||
}
|
||||
|
||||
}.navigationTitle("Settings")
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
struct SettingsSection: View {
|
||||
@State var headline: String
|
||||
@State var description: String
|
||||
struct SettingsSection<Content: View>: View {
|
||||
let title: String
|
||||
let description: String
|
||||
@ViewBuilder let content: () -> Content
|
||||
|
||||
init(title: String, description: String, content: @escaping () -> Content) {
|
||||
self.title = title
|
||||
self.description = description
|
||||
self.content = content
|
||||
}
|
||||
|
||||
init(title: String, description: String) where Content == EmptyView {
|
||||
self.title = title
|
||||
self.description = description
|
||||
self.content = { EmptyView() }
|
||||
}
|
||||
|
||||
var body: some View {
|
||||
VStack(alignment: .leading) {
|
||||
Text(headline)
|
||||
.font(.headline)
|
||||
Text(description)
|
||||
|
||||
Divider()
|
||||
}.padding()
|
||||
HStack {
|
||||
VStack(alignment: .leading) {
|
||||
Text(title)
|
||||
.font(.headline)
|
||||
Text(description)
|
||||
.font(.caption)
|
||||
}.padding()
|
||||
Spacer()
|
||||
content()
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user