Improve storage, paths
This commit is contained in:
8
CHDataManagement/Main/InitialSetupView.swift
Normal file
8
CHDataManagement/Main/InitialSetupView.swift
Normal 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@*/
|
||||
}
|
||||
}
|
@ -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 {
|
||||
|
Reference in New Issue
Block a user