From e3e41087239f502ea6b3f46d3c17b70b3fac9b31 Mon Sep 17 00:00:00 2001 From: neon443 <69979447+neon443@users.noreply.github.com> Date: Wed, 9 Jul 2025 13:54:34 +0100 Subject: [PATCH] updated updatetheme to add the theme if not present added a new theme button with a avigation destination --- ShhShell/Host/HostsManager.swift | 6 +++++- ShhShell/Views/Themes/ThemeManagerView.swift | 14 ++++++++++++++ 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/ShhShell/Host/HostsManager.swift b/ShhShell/Host/HostsManager.swift index 6a8cbf6..8d53aaa 100644 --- a/ShhShell/Host/HostsManager.swift +++ b/ShhShell/Host/HostsManager.swift @@ -129,7 +129,11 @@ class HostsManager: ObservableObject, @unchecked Sendable { } func updateTheme(_ theme: Theme) { - guard let index = themes.firstIndex(where: { $0.id == theme.id }) else { return } + guard let index = themes.firstIndex(where: { $0.id == theme.id }) else { + themes.append(theme) + saveThemes() + return + } themes[index] = theme if selectedTheme.id == theme.id { selectedTheme = theme diff --git a/ShhShell/Views/Themes/ThemeManagerView.swift b/ShhShell/Views/Themes/ThemeManagerView.swift index 139479d..5d63a26 100644 --- a/ShhShell/Views/Themes/ThemeManagerView.swift +++ b/ShhShell/Views/Themes/ThemeManagerView.swift @@ -14,6 +14,9 @@ struct ThemeManagerView: View { @State var importURL: String = "" @State var toImportName: String = "" + @State private var newTheme: Theme = Theme.defaultTheme + @State private var showNewThemeEditor: Bool = false + var minColWidth: CGFloat {150} var spacing: CGFloat {8} var grid: GridItem { @@ -121,6 +124,17 @@ struct ThemeManagerView: View { } } + ToolbarItem() { + Button() { + newTheme = Theme.defaultTheme + showNewThemeEditor = true + } label: { + Label("New", systemImage: "plus") + } + } + } + .navigationDestination(isPresented: $showNewThemeEditor) { + ThemeEditorView(hostsManager: hostsManager, theme: $newTheme) } } }