Combine initial and storage view
This commit is contained in:
@ -33,7 +33,7 @@ struct MainView: App {
|
||||
private var showInitialSetupSheet = false
|
||||
|
||||
@State
|
||||
private var showStorageErrorSheet = false
|
||||
private var showStorageStatusSheet = false
|
||||
|
||||
@State
|
||||
private var showSettingsSheet = false
|
||||
@ -176,7 +176,7 @@ struct MainView: App {
|
||||
}
|
||||
}
|
||||
ToolbarItem {
|
||||
Button(action: saveButtonPressed) {
|
||||
Button(action: { showStorageStatusSheet = true }) {
|
||||
Image(systemSymbol: content.saveState.symbol)
|
||||
.foregroundStyle(content.saveState.color)
|
||||
}
|
||||
@ -199,8 +199,8 @@ struct MainView: App {
|
||||
.environmentObject(content)
|
||||
.environmentObject(selection)
|
||||
}
|
||||
.sheet(isPresented: $showStorageErrorSheet) {
|
||||
StorageErrorView(isPresented: $showStorageErrorSheet)
|
||||
.sheet(isPresented: $showStorageStatusSheet) {
|
||||
StorageStatusView(isPresented: $showStorageStatusSheet)
|
||||
.environmentObject(content)
|
||||
}
|
||||
.sheet(isPresented: $showSettingsSheet) {
|
||||
@ -230,28 +230,15 @@ struct MainView: App {
|
||||
}
|
||||
}
|
||||
|
||||
private func saveButtonPressed() {
|
||||
switch content.saveState {
|
||||
case .storageNotInitialized:
|
||||
showInitialSheet()
|
||||
case .isSaved, .needsSave:
|
||||
content.saveUnconditionally()
|
||||
case .isSaving:
|
||||
break
|
||||
case .failedToSave, .savingPausedDueToLoadErrors:
|
||||
showStorageErrorSheet = true
|
||||
}
|
||||
}
|
||||
|
||||
private func loadContent() {
|
||||
guard content.storage.contentScope != nil else {
|
||||
showInitialSheet()
|
||||
showStorageStatusSheet = true
|
||||
return
|
||||
}
|
||||
content.loadFromDisk {
|
||||
prepareAfterLoad()
|
||||
if !content.storageErrors.isEmpty {
|
||||
self.showStorageErrorSheet = true
|
||||
self.showStorageStatusSheet = true
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -270,11 +257,5 @@ struct MainView: App {
|
||||
selection.file = content.files.first
|
||||
}
|
||||
}
|
||||
|
||||
private func showInitialSheet() {
|
||||
DispatchQueue.main.async {
|
||||
showInitialSetupSheet = true
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user