From ccf1ef37341ae55bfd8425a825cc9b0ae37bf51d Mon Sep 17 00:00:00 2001 From: Christoph Hagen Date: Mon, 24 Feb 2025 18:46:59 +0100 Subject: [PATCH] Remove initial setup view --- CHDataManagement.xcodeproj/project.pbxproj | 4 - CHDataManagement/Main/InitialSetupView.swift | 84 -------------------- CHDataManagement/Main/MainView.swift | 9 --- 3 files changed, 97 deletions(-) delete mode 100644 CHDataManagement/Main/InitialSetupView.swift diff --git a/CHDataManagement.xcodeproj/project.pbxproj b/CHDataManagement.xcodeproj/project.pbxproj index e463885..3185fa1 100644 --- a/CHDataManagement.xcodeproj/project.pbxproj +++ b/CHDataManagement.xcodeproj/project.pbxproj @@ -49,7 +49,6 @@ E22990462D10B7A7009F8D77 /* SecurityScopeStatus.swift in Sources */ = {isa = PBXBuildFile; fileRef = E22990452D10B7A6009F8D77 /* SecurityScopeStatus.swift */; }; E22990482D10B7B7009F8D77 /* StorageAccessError.swift in Sources */ = {isa = PBXBuildFile; fileRef = E22990472D10B7B7009F8D77 /* StorageAccessError.swift */; }; E229904A2D10BB90009F8D77 /* SecurityScopeBookmark.swift in Sources */ = {isa = PBXBuildFile; fileRef = E22990492D10BB90009F8D77 /* SecurityScopeBookmark.swift */; }; - E229904C2D10BE5D009F8D77 /* InitialSetupView.swift in Sources */ = {isa = PBXBuildFile; fileRef = E229904B2D10BE59009F8D77 /* InitialSetupView.swift */; }; E229904E2D13535C009F8D77 /* SecurityBookmark.swift in Sources */ = {isa = PBXBuildFile; fileRef = E229904D2D135349009F8D77 /* SecurityBookmark.swift */; }; E24252012C50E0A40029FF16 /* HighlightedTextEditor in Frameworks */ = {isa = PBXBuildFile; productRef = E24252002C50E0A40029FF16 /* HighlightedTextEditor */; }; E242520A2C52C9260029FF16 /* ContentLanguage.swift in Sources */ = {isa = PBXBuildFile; fileRef = E24252092C52C9260029FF16 /* ContentLanguage.swift */; }; @@ -325,7 +324,6 @@ E22990452D10B7A6009F8D77 /* SecurityScopeStatus.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SecurityScopeStatus.swift; sourceTree = ""; }; E22990472D10B7B7009F8D77 /* StorageAccessError.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = StorageAccessError.swift; sourceTree = ""; }; E22990492D10BB90009F8D77 /* SecurityScopeBookmark.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SecurityScopeBookmark.swift; sourceTree = ""; }; - E229904B2D10BE59009F8D77 /* InitialSetupView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = InitialSetupView.swift; sourceTree = ""; }; E229904D2D135349009F8D77 /* SecurityBookmark.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SecurityBookmark.swift; sourceTree = ""; }; E24252092C52C9260029FF16 /* ContentLanguage.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ContentLanguage.swift; sourceTree = ""; }; E2521DFB2D501DAE00C56662 /* PostContentGenerator.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PostContentGenerator.swift; sourceTree = ""; }; @@ -721,7 +719,6 @@ children = ( E2521E032D51795B00C56662 /* StorageStatusView.swift */, E2FD1D332D3BA2DE00B48627 /* SelectedContent.swift */, - E229904B2D10BE59009F8D77 /* InitialSetupView.swift */, E29D31422D0488950051B7F4 /* MainContentView.swift */, E2DD04732C276F31003BFF1F /* MainView.swift */, E29D31442D0488CB0051B7F4 /* SelectedContentView.swift */, @@ -1285,7 +1282,6 @@ E20BCCA32D5398AA00B8DBEB /* LocalizedAudioSettingsDetailView.swift in Sources */, E25DA5772D018B9900AEF16D /* File+Mock.swift in Sources */, E25DA5892D01CBD300AEF16D /* Content+Generation.swift in Sources */, - E229904C2D10BE5D009F8D77 /* InitialSetupView.swift in Sources */, E218502B2CF790B30090B18B /* PostContentView.swift in Sources */, E29D317D2D086AB00051B7F4 /* Int+Random.swift in Sources */, E2BF1BC62D6B16FF003089F1 /* HeadlineLink.swift in Sources */, diff --git a/CHDataManagement/Main/InitialSetupView.swift b/CHDataManagement/Main/InitialSetupView.swift deleted file mode 100644 index 645c262..0000000 --- a/CHDataManagement/Main/InitialSetupView.swift +++ /dev/null @@ -1,84 +0,0 @@ -import SwiftUI - -struct InitialSetupView: View { - - @EnvironmentObject - private var content: Content - - @Environment(\.dismiss) - private var dismiss - - @State - private var message: String? - - var body: some View { - VStack { - Text("No Database Loaded") - .font(.title) - .padding() - Text("To start editing the content of a website, create a new database or load an existing one. Open a folder with an existing database, or choose an empty folder to create a new project.") - .multilineTextAlignment(.center) - Button("Select folder", action: selectContentPath) - .padding() - if let message { - Text(message) - .padding(.bottom) - .lineLimit(10) - } - } - .padding() - .frame(maxWidth: 350) - } - - private func selectContentPath() { - let panel = NSOpenPanel() - // Sets up so user can only select a single directory - panel.canChooseFiles = false - panel.canChooseDirectories = true - panel.allowsMultipleSelection = false - panel.showsHiddenFiles = false - panel.title = "Select the database folder" - - let response = panel.runModal() - guard response == .OK else { - set(message: "Failed to select a folder: \(response)") - return - } - guard let url = panel.url else { - set(message: "No folder url found") - return - } - - guard content.storage.save(contentPath: url) else { - set(message: "Failed to set content path") - return - } - - DispatchQueue.global().async { - let loader = ModelLoader(content: content, storage: content.storage) - let result = loader.load() - guard result.errors.isEmpty else { - let message = "Failed to load database" - #warning("Show load errors") - set(message: message) - return - } - - DispatchQueue.main.async { - content.files = result.files - content.posts = result.posts - content.pages = result.pages - content.tags = result.tags - content.settings = result.settings - content.tagOverview = result.tagOverview - dismiss() - } - } - } - - private func set(message: String) { - DispatchQueue.main.async { - self.message = message - } - } -} diff --git a/CHDataManagement/Main/MainView.swift b/CHDataManagement/Main/MainView.swift index b3b4d11..4f8a5e0 100644 --- a/CHDataManagement/Main/MainView.swift +++ b/CHDataManagement/Main/MainView.swift @@ -29,9 +29,6 @@ struct MainView: App { @State private var showAddSheet = false - @State - private var showInitialSetupSheet = false - @State private var showStorageStatusSheet = false @@ -193,12 +190,6 @@ struct MainView: App { .environmentObject(content) .environmentObject(selection) } - .sheet(isPresented: $showInitialSetupSheet) { - InitialSetupView() - .environment(\.language, language) - .environmentObject(content) - .environmentObject(selection) - } .sheet(isPresented: $showStorageStatusSheet) { StorageStatusView(isPresented: $showStorageStatusSheet) .environmentObject(content)