From 53888bc60003c8793d5ae63ae09aae7f01ce4c25 Mon Sep 17 00:00:00 2001 From: neon443 <69979447+neon443@users.noreply.github.com> Date: Wed, 9 Jul 2025 13:47:58 +0100 Subject: [PATCH] added a duplicate theme button added dividers to sort theme context menu items --- ShhShell/Host/HostsManager.swift | 11 +++++++++++ ShhShell/Views/Themes/ThemeButton.swift | 11 +++++++++++ 2 files changed, 22 insertions(+) diff --git a/ShhShell/Host/HostsManager.swift b/ShhShell/Host/HostsManager.swift index 19d3820..6a8cbf6 100644 --- a/ShhShell/Host/HostsManager.swift +++ b/ShhShell/Host/HostsManager.swift @@ -117,6 +117,17 @@ class HostsManager: ObservableObject, @unchecked Sendable { return themeInQuestion == self.selectedTheme } + func duplicateTheme(_ theme: Theme) { + var newTheme = theme + newTheme.id = UUID().uuidString + if let index = themes.firstIndex(where: { $0.id == theme.id }) { + themes.insert(newTheme, at: index) + } else { + themes.append(newTheme) + } + saveThemes() + } + func updateTheme(_ theme: Theme) { guard let index = themes.firstIndex(where: { $0.id == theme.id }) else { return } themes[index] = theme diff --git a/ShhShell/Views/Themes/ThemeButton.swift b/ShhShell/Views/Themes/ThemeButton.swift index bbe17b6..760f6ef 100644 --- a/ShhShell/Views/Themes/ThemeButton.swift +++ b/ShhShell/Views/Themes/ThemeButton.swift @@ -90,6 +90,17 @@ struct ThemeButton: View { } label: { Label("Rename", systemImage: "text.cursor") } + Divider() + } + + Button() { + hostsManager.duplicateTheme(theme) + } label: { + Label("Duplicate", systemImage: "square.filled.on.square") + } + + if canModify { + Divider() Button(role: .destructive) { hostsManager.deleteTheme(theme) } label: {