Reset data after folder change
This commit is contained in:
@ -1,4 +1,5 @@
|
||||
import SwiftUI
|
||||
import SFSafeSymbols
|
||||
|
||||
struct FolderOnDiskPropertyView: View {
|
||||
|
||||
@ -7,21 +8,31 @@ struct FolderOnDiskPropertyView: View {
|
||||
@Binding
|
||||
var folder: URL?
|
||||
|
||||
@Binding
|
||||
var isStale: Bool
|
||||
|
||||
let footer: LocalizedStringKey
|
||||
|
||||
let update: (URL) -> Void
|
||||
|
||||
init(title: LocalizedStringKey, folder: Binding<URL?>, footer: LocalizedStringKey, update: @escaping (URL) -> Void) {
|
||||
init(title: LocalizedStringKey, folder: Binding<URL?>, isStale: Binding<Bool>, footer: LocalizedStringKey, update: @escaping (URL) -> Void) {
|
||||
self.title = title
|
||||
self._folder = folder
|
||||
self._isStale = isStale
|
||||
self.footer = footer
|
||||
self.update = update
|
||||
}
|
||||
|
||||
var body: some View {
|
||||
GenericPropertyView(title: title, footer: footer) {
|
||||
VStack(alignment: .leading) {
|
||||
|
||||
HStack(alignment: .firstTextBaseline) {
|
||||
Text(folder?.path() ?? "No folder selected")
|
||||
Text(title)
|
||||
.font(.headline)
|
||||
if isStale {
|
||||
Image(systemSymbol: .exclamationmarkTriangle)
|
||||
.foregroundStyle(.yellow)
|
||||
}
|
||||
Spacer()
|
||||
Button("Select") {
|
||||
guard let url = openFolderSelectionPanel() else {
|
||||
@ -32,6 +43,11 @@ struct FolderOnDiskPropertyView: View {
|
||||
}
|
||||
}
|
||||
}
|
||||
Text(folder?.path() ?? "No folder selected")
|
||||
.padding(.bottom, 5)
|
||||
Text(footer)
|
||||
.foregroundStyle(.secondary)
|
||||
.padding(.bottom)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -18,16 +18,15 @@ struct PathSettingsView: View {
|
||||
FolderOnDiskPropertyView(
|
||||
title: "Content Folder",
|
||||
folder: $content.storage.contentPath,
|
||||
isStale: $content.storage.contentPathUrlIsStale,
|
||||
footer: "The folder where the raw content of the website is stored") { url in
|
||||
guard content.storage.save(contentPath: url) else {
|
||||
return
|
||||
}
|
||||
#warning("Reload database")
|
||||
content.update(contentPath: url)
|
||||
}
|
||||
|
||||
FolderOnDiskPropertyView(
|
||||
title: "Output Folder",
|
||||
folder: $content.storage.outputPath,
|
||||
isStale: $content.storage.outputPathUrlIsStale,
|
||||
footer: "The folder where the generated website is stored") { url in
|
||||
content.storage.save(outputPath: url)
|
||||
}
|
||||
|
Reference in New Issue
Block a user