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 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) { func renameTheme(_ theme: Theme?, to newName: String) {
guard let theme else { return } guard let theme else { return }
guard theme.name != newName else { return } guard theme.name != newName else { return }

View File

@@ -21,10 +21,6 @@ struct ShellView: View {
hostsManager.selectedTheme.background.suiColor hostsManager.selectedTheme.background.suiColor
.ignoresSafeArea(.all) .ignoresSafeArea(.all)
TerminalController(handler: handler, hostsManager: hostsManager) 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 { Group {
Color.gray.opacity(0.2) Color.gray.opacity(0.2)

View File

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

View File

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