added a duplicate theme button

added dividers to sort theme context menu items
This commit is contained in:
neon443
2025-07-09 13:47:58 +01:00
parent 10310be80e
commit 53888bc600
2 changed files with 22 additions and 0 deletions

View File

@@ -117,6 +117,17 @@ class HostsManager: ObservableObject, @unchecked Sendable {
return themeInQuestion == self.selectedTheme 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) { 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 { return }
themes[index] = theme themes[index] = theme

View File

@@ -90,6 +90,17 @@ struct ThemeButton: View {
} label: { } label: {
Label("Rename", systemImage: "text.cursor") Label("Rename", systemImage: "text.cursor")
} }
Divider()
}
Button() {
hostsManager.duplicateTheme(theme)
} label: {
Label("Duplicate", systemImage: "square.filled.on.square")
}
if canModify {
Divider()
Button(role: .destructive) { Button(role: .destructive) {
hostsManager.deleteTheme(theme) hostsManager.deleteTheme(theme)
} label: { } label: {