mirror of
https://github.com/neon443/ShhShell.git
synced 2026-03-11 05:19:13 +00:00
added a duplicate theme button
added dividers to sort theme context menu items
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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: {
|
||||
|
||||
Reference in New Issue
Block a user