updated updatetheme to add the theme if not present

added a new theme button with a avigation destination
This commit is contained in:
neon443 committed 2025-07-09 13:54:34 +01:00
1 parent 53888bc600
commit e3e4108723
2 files changed
+19 -1

No files matched your search

+5 -1
View File
@@ -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
@@ -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)
}
}
}
Reference in new issue
Block a user
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.