Improve storage, paths

This commit is contained in:
Christoph Hagen
2024-12-16 21:01:38 +01:00
parent b22b76fd32
commit 849585acc7
19 changed files with 393 additions and 268 deletions

View File

@ -0,0 +1,8 @@
import SwiftUI
struct InitialSetupView: View {
var body: some View {
/*@START_MENU_TOKEN@*//*@PLACEHOLDER=Hello, world!@*/Text("Hello, world!")/*@END_MENU_TOKEN@*/
}
}

View File

@ -55,6 +55,9 @@ struct MainView: App {
@State
private var showAddSheet = false
@State
private var showInitialSetupSheet = false
@ViewBuilder
var sidebar: some View {
switch selectedTab {
@ -159,8 +162,18 @@ struct MainView: App {
}.pickerStyle(.segmented)
}
ToolbarItem(placement: .primaryAction) {
Button(action: save) {
Text("Save")
if content.storageIsInitialized {
Button(action: save) {
Text("Save")
}
} else {
Button {
selectedSection = .folders
selectedTab = .generation
} label: {
Text("Setup")
}
.foregroundColor(.red)
}
}
}
@ -176,11 +189,15 @@ struct MainView: App {
.environment(\.language, language)
.environmentObject(content)
}
.sheet(isPresented: $showInitialSetupSheet) {
InitialSetupView()
.environment(\.language, language)
.environmentObject(content)
}
}
}
private func save() {
// Save all changed files
do {
try content.saveToDisk()
} catch {
@ -189,6 +206,12 @@ struct MainView: App {
}
private func loadContent() {
guard content.storageIsInitialized else {
DispatchQueue.main.async {
self.showInitialSetupSheet = true
}
return
}
do {
try content.loadFromDisk()
} catch {