mirror of
https://github.com/neon443/ShhShell.git
synced 2026-03-11 13:26:16 +00:00
themeeditor can now save
add an updatetheme remove the frame on the terminalcontroller, it made incorrect sizes
This commit is contained in:
@@ -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 }
|
||||||
|
|||||||
@@ -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)
|
||||||
|
|||||||
@@ -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)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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")
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user