themeeditor can now save

add an updatetheme
remove the frame on the terminalcontroller, it made incorrect sizes
This commit is contained in:
neon443
2025-07-08 12:57:23 +01:00
parent c9c78adf7c
commit bcdece3bee
4 changed files with 18 additions and 7 deletions

View File

@@ -114,6 +114,11 @@ class HostsManager: ObservableObject, @unchecked Sendable {
return themeInQuestion == self.selectedTheme
}
func updateTheme(_ theme: Theme) {
guard let index = themes.firstIndex(where: { $0.id == theme.id }) else { return }
themes[index] = theme
}
func renameTheme(_ theme: Theme?, to newName: String) {
guard let theme else { return }
guard theme.name != newName else { return }

View File

@@ -21,10 +21,6 @@ struct ShellView: View {
hostsManager.selectedTheme.background.suiColor
.ignoresSafeArea(.all)
TerminalController(handler: handler, hostsManager: hostsManager)
.frame(
width: container.sessions[handler.sessionID ?? UUID()]?.terminalView.getOptimalFrameSize().width,
height: container.sessions[handler.sessionID ?? UUID()]?.terminalView.getOptimalFrameSize().width
)
Group {
Color.gray.opacity(0.2)

View File

@@ -9,10 +9,13 @@ import SwiftUI
import SwiftTerm
struct ThemeEditorView: View {
@ObservedObject var hostsManager: HostsManager
// @State var theme: Theme
@State var themeCodable: ThemeCodable
init(theme: Theme) {
init(hostsManager: HostsManager, theme: Theme) {
self.hostsManager = hostsManager
// self.theme = theme
self.themeCodable = theme.themeCodable
}
@@ -42,6 +45,13 @@ struct ThemeEditorView: View {
.fill(themeCodable.selectedText.stColor.suiColor)
}
.frame(width: 100)
.toolbar {
Button() {
} label: {
Label("Donw", systemImage: "checkmark")
}
}
ForEach(0...1, id: \.self) { row in
HStack {
@@ -57,5 +67,5 @@ struct ThemeEditorView: View {
}
#Preview {
ThemeEditorView(theme: Theme.defaultTheme)
ThemeEditorView(hostsManager: HostsManager(), theme: Theme.defaultTheme)
}

View File

@@ -79,7 +79,7 @@ struct ThemePreview: View {
.contextMenu {
if canModify {
NavigationLink {
ThemeEditorView(theme: theme)
ThemeEditorView(hostsManager: hostsManager, theme: theme)
} label: {
Label("Edit", systemImage: "pencil")
}