mirror of
https://github.com/neon443/ShhShell.git
synced 2026-03-11 13:26:16 +00:00
updated updatetheme to add the theme if not present
added a new theme button with a avigation destination
This commit is contained in:
@@ -129,7 +129,11 @@ class HostsManager: ObservableObject, @unchecked Sendable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
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 {
|
||||||
|
themes.append(theme)
|
||||||
|
saveThemes()
|
||||||
|
return
|
||||||
|
}
|
||||||
themes[index] = theme
|
themes[index] = theme
|
||||||
if selectedTheme.id == theme.id {
|
if selectedTheme.id == theme.id {
|
||||||
selectedTheme = theme
|
selectedTheme = theme
|
||||||
|
|||||||
@@ -14,6 +14,9 @@ struct ThemeManagerView: View {
|
|||||||
@State var importURL: String = ""
|
@State var importURL: String = ""
|
||||||
@State var toImportName: String = ""
|
@State var toImportName: String = ""
|
||||||
|
|
||||||
|
@State private var newTheme: Theme = Theme.defaultTheme
|
||||||
|
@State private var showNewThemeEditor: Bool = false
|
||||||
|
|
||||||
var minColWidth: CGFloat {150}
|
var minColWidth: CGFloat {150}
|
||||||
var spacing: CGFloat {8}
|
var spacing: CGFloat {8}
|
||||||
var grid: GridItem {
|
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