applying themes on the fly!! (to sessions already active)

added applySelectedTheme to sshhandler which will run applyselectedtheme on the terminalview if it exists
added applyselectedtheme to apply the chosen theme in hostsmanager
applying of the chosen theme on appear of any shell view
made the tap target for sessions actually the whole list item
fix undefined behaivour from modifying published values from background threads
This commit is contained in:
neon443
2025-06-29 16:39:03 +01:00
parent 8e69dfc165
commit 80ddde3a62
6 changed files with 43 additions and 24 deletions

View File

@@ -5,8 +5,8 @@
// Created by neon443 on 06/06/2025. // Created by neon443 on 06/06/2025.
// //
VERSION = 1.2 VERSION = 1.3.1
BUILD = 25 BUILD = 50
// Configuration settings file format documentation can be found at: // Configuration settings file format documentation can be found at:
// https://developer.apple.com/documentation/xcode/adding-a-build-configuration-file-to-your-project // https://developer.apple.com/documentation/xcode/adding-a-build-configuration-file-to-your-project

View File

@@ -168,6 +168,14 @@ class SSHHandler: @unchecked Sendable, ObservableObject {
} }
func applySelectedTheme() {
Task { @MainActor in
guard let sessionID else { return }
guard let session = container.sessions[sessionID] else { return }
session.terminalView.applySelectedTheme()
}
}
func ring() { func ring() {
Task { @MainActor in Task { @MainActor in
withAnimation { self.bell = true } withAnimation { self.bell = true }

View File

@@ -19,6 +19,9 @@ struct SessionView: View {
} }
var body: some View { var body: some View {
Button() {
shellPresented.toggle()
} label: {
HStack { HStack {
Image(systemName: "apple.terminal") Image(systemName: "apple.terminal")
.resizable().scaledToFit() .resizable().scaledToFit()
@@ -28,8 +31,6 @@ struct SessionView: View {
.frame(width: 40, height: 40) .frame(width: 40, height: 40)
Text(hostsManager.makeLabel(forHost: host)) Text(hostsManager.makeLabel(forHost: host))
} }
.onTapGesture {
shellPresented.toggle()
} }
.fullScreenCover(isPresented: $shellPresented) { .fullScreenCover(isPresented: $shellPresented) {
ShellView( ShellView(

View File

@@ -22,7 +22,7 @@ final class SSHTerminalDelegate: TerminalView, Sendable, @preconcurrency Termina
print(getTerminal().backgroundColor) print(getTerminal().backgroundColor)
print(getTerminal().foregroundColor) print(getTerminal().foregroundColor)
applyTheme(hostsManager.selectedTheme) applySelectedTheme()
DispatchQueue.main.async { DispatchQueue.main.async {
Task { Task {
@@ -55,6 +55,11 @@ final class SSHTerminalDelegate: TerminalView, Sendable, @preconcurrency Termina
} }
} }
func applySelectedTheme() {
guard let hostsManager else { return }
applyTheme(hostsManager.selectedTheme)
}
func applyTheme(_ theme: Theme) { func applyTheme(_ theme: Theme) {
getTerminal().installPalette(colors: theme.ansi) getTerminal().installPalette(colors: theme.ansi)
getTerminal().foregroundColor = theme.foreground getTerminal().foregroundColor = theme.foreground

View File

@@ -38,6 +38,14 @@ struct ShellView: View {
DialogView(handler: handler, showDialog: !handler.connected) DialogView(handler: handler, showDialog: !handler.connected)
} }
} }
.onChange(of: handler.connected) { _ in
if !handler.connected { dismiss() }
}
.onAppear {
handler.applySelectedTheme()
}
.navigationTitle(handler.title)
.navigationBarTitleDisplayMode(.inline)
.toolbar { .toolbar {
ToolbarItem { ToolbarItem {
Button() { Button() {
@@ -56,11 +64,6 @@ struct ShellView: View {
} }
} }
} }
.onChange(of: handler.connected) { _ in
if !handler.connected { dismiss() }
}
.navigationTitle(handler.title)
.navigationBarTitleDisplayMode(.inline)
} }
} }
} }

View File

@@ -32,11 +32,13 @@ struct TerminalController: UIViewRepresentable {
tv.autoresizingMask = [.flexibleWidth, .flexibleHeight] tv.autoresizingMask = [.flexibleWidth, .flexibleHeight]
if let sessionID = handler.sessionID { if let sessionID = handler.sessionID {
Task { @MainActor in
container.sessions[sessionID] = TerminalContainer( container.sessions[sessionID] = TerminalContainer(
handler: handler, handler: handler,
terminalView: tv terminalView: tv
) )
} }
}
return tv return tv
} }