Move settings + generation to sheets

This commit is contained in:
Christoph Hagen
2025-02-05 15:40:09 +01:00
parent 5abe6e1a9f
commit 156bbf77d1
32 changed files with 402 additions and 852 deletions

View File

@ -52,6 +52,12 @@ struct MainView: App {
@State
private var showStorageErrorSheet = false
@State
private var showSettingsSheet = false
@State
private var showGenerationSheet = false
@ViewBuilder
var sidebar: some View {
switch selection.tab {
@ -59,7 +65,6 @@ struct MainView: App {
case .pages: PageListView()
case .tags: TagListView()
case .files: FileListView(selectedFile: $selection.file)
case .generation: SettingsListView()
}
}
@ -74,8 +79,6 @@ struct MainView: App {
SelectedContentView<TagContentView>(selected: $selection.tag)
case .files:
SelectedContentView<FileContentView>(selected: $selection.file)
case .generation:
GenerationContentView(selected: $selection.section)
}
}
@ -90,8 +93,6 @@ struct MainView: App {
SelectedDetailView<TagDetailView>(selected: $selection.tag)
case .files:
SelectedDetailView<FileDetailView>(selected: $selection.file)
case .generation:
GenerationDetailView(section: selection.section)
}
}
@ -106,8 +107,6 @@ struct MainView: App {
AddTagView(selected: $selection.tag)
case .files:
AddFileView(selectedFile: $selection.file)
case .generation:
Text("Not implemented")
}
}
@ -115,42 +114,61 @@ struct MainView: App {
WindowGroup {
NavigationSplitView {
sidebar
.toolbar {
ToolbarItem(placement: .navigation) {
Picker("", selection: $selection.tab) {
Text("Posts").tag(MainViewTab.posts)
Text("Pages").tag(MainViewTab.pages)
Text("Tags").tag(MainViewTab.tags)
Text("Files").tag(MainViewTab.files)
Text("Generation").tag(MainViewTab.generation)
}.pickerStyle(.segmented)
}
}
.navigationSplitViewColumnWidth(min: sidebarWidth, ideal: sidebarWidth, max: sidebarWidth)
.toolbar {
ToolbarItem(placement: .primaryAction) {
ToolbarItem(placement: .automatic) {
Button(action: { showAddSheet = true }) {
Label("Add", systemSymbol: .plus)
}
.disabled(!selection.tab.canAddItems)
}
}
} content: {
viewContent
.toolbar {
ToolbarItem(placement: .navigation) {
HStack {
Picker("", selection: $selection.tab) {
Text("Posts").tag(MainViewTab.posts)
Text("Pages").tag(MainViewTab.pages)
Text("Tags").tag(MainViewTab.tags)
Text("Files").tag(MainViewTab.files)
}.pickerStyle(.segmented)
}.frame(minWidth: 400)
}
}
} detail: {
detail
.navigationSplitViewColumnWidth(min: detailWidth, ideal: detailWidth, max: detailWidth)
}
.toolbar {
ToolbarItem(placement: .primaryAction) {
ToolbarItem {
Picker("", selection: $language) {
Text("English")
.tag(ContentLanguage.english)
Text("German")
.tag(ContentLanguage.german)
}.pickerStyle(.segmented)
}
.pickerStyle(.segmented)
.frame(minWidth: 200)
}
ToolbarItem(placement: .primaryAction) {
ToolbarItem {
Button(action: { showSettingsSheet = true }) {
Image(systemSymbol: .gearshape)
}
}
ToolbarItem {
Button(action: { showGenerationSheet = true }) {
if content.isGeneratingWebsite {
ProgressView()
.scaleEffect(0.6)
.frame(width: 20, height: 20, alignment: .center)
} else {
Image(systemSymbol: .globe)
.frame(width: 20, height: 20, alignment: .center)
}
}
}
ToolbarItem {
Button(action: saveButtonPressed) {
Image(systemSymbol: content.saveState.symbol)
.foregroundStyle(content.saveState.color)
@ -178,6 +196,15 @@ struct MainView: App {
StorageErrorView(isPresented: $showStorageErrorSheet)
.environmentObject(content)
}
.sheet(isPresented: $showSettingsSheet) {
SettingsSheet(language: $language)
.environmentObject(content)
.presentedWindowStyle(.titleBar)
}
.sheet(isPresented: $showGenerationSheet) {
GenerationContentView()
.environmentObject(content)
}
}
}
@ -224,8 +251,6 @@ struct MainView: App {
private func showInitialSheet() {
DispatchQueue.main.async {
selection.section = .folders
selection.tab = .generation
showInitialSetupSheet = true
}
}