diff --git a/Config.xcconfig b/Config.xcconfig index adc46c2..a93e965 100644 --- a/Config.xcconfig +++ b/Config.xcconfig @@ -5,8 +5,8 @@ // Created by neon443 on 06/06/2025. // -VERSION = 1.2 -BUILD = 25 +VERSION = 1.3.1 +BUILD = 50 // Configuration settings file format documentation can be found at: // https://developer.apple.com/documentation/xcode/adding-a-build-configuration-file-to-your-project diff --git a/ShhShell/SSH/SSHHandler.swift b/ShhShell/SSH/SSHHandler.swift index 627d3ab..95bc6af 100644 --- a/ShhShell/SSH/SSHHandler.swift +++ b/ShhShell/SSH/SSHHandler.swift @@ -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() { Task { @MainActor in withAnimation { self.bell = true } diff --git a/ShhShell/Views/Sessions/SessionView.swift b/ShhShell/Views/Sessions/SessionView.swift index 0c1ce06..1afe39c 100644 --- a/ShhShell/Views/Sessions/SessionView.swift +++ b/ShhShell/Views/Sessions/SessionView.swift @@ -18,18 +18,19 @@ struct SessionView: View { container.sessions[key]?.handler.host ?? Host.blank } - var body: some View { - HStack { - Image(systemName: "apple.terminal") - .resizable().scaledToFit() - .frame(width: 40, height: 40) - .foregroundStyle(.terminalGreen) - SymbolPreview(symbol: host.symbol, label: host.label) - .frame(width: 40, height: 40) - Text(hostsManager.makeLabel(forHost: host)) - } - .onTapGesture { + var body: some View { + Button() { shellPresented.toggle() + } label: { + HStack { + Image(systemName: "apple.terminal") + .resizable().scaledToFit() + .frame(width: 40, height: 40) + .foregroundStyle(.terminalGreen) + SymbolPreview(symbol: host.symbol, label: host.label) + .frame(width: 40, height: 40) + Text(hostsManager.makeLabel(forHost: host)) + } } .fullScreenCover(isPresented: $shellPresented) { ShellView( @@ -37,7 +38,7 @@ struct SessionView: View { hostsManager: hostsManager ) } - } + } } #Preview { diff --git a/ShhShell/Views/Terminal/SSHTerminalDelegate.swift b/ShhShell/Views/Terminal/SSHTerminalDelegate.swift index 406920f..6e19f5c 100644 --- a/ShhShell/Views/Terminal/SSHTerminalDelegate.swift +++ b/ShhShell/Views/Terminal/SSHTerminalDelegate.swift @@ -22,7 +22,7 @@ final class SSHTerminalDelegate: TerminalView, Sendable, @preconcurrency Termina print(getTerminal().backgroundColor) print(getTerminal().foregroundColor) - applyTheme(hostsManager.selectedTheme) + applySelectedTheme() DispatchQueue.main.async { 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) { getTerminal().installPalette(colors: theme.ansi) getTerminal().foregroundColor = theme.foreground diff --git a/ShhShell/Views/Terminal/ShellView.swift b/ShhShell/Views/Terminal/ShellView.swift index 2cd22d3..e92ff40 100644 --- a/ShhShell/Views/Terminal/ShellView.swift +++ b/ShhShell/Views/Terminal/ShellView.swift @@ -38,6 +38,14 @@ struct ShellView: View { DialogView(handler: handler, showDialog: !handler.connected) } } + .onChange(of: handler.connected) { _ in + if !handler.connected { dismiss() } + } + .onAppear { + handler.applySelectedTheme() + } + .navigationTitle(handler.title) + .navigationBarTitleDisplayMode(.inline) .toolbar { ToolbarItem { Button() { @@ -56,11 +64,6 @@ struct ShellView: View { } } } - .onChange(of: handler.connected) { _ in - if !handler.connected { dismiss() } - } - .navigationTitle(handler.title) - .navigationBarTitleDisplayMode(.inline) } } } diff --git a/ShhShell/Views/Terminal/TerminalController.swift b/ShhShell/Views/Terminal/TerminalController.swift index c762c34..f65f5ad 100644 --- a/ShhShell/Views/Terminal/TerminalController.swift +++ b/ShhShell/Views/Terminal/TerminalController.swift @@ -32,10 +32,12 @@ struct TerminalController: UIViewRepresentable { tv.autoresizingMask = [.flexibleWidth, .flexibleHeight] if let sessionID = handler.sessionID { - container.sessions[sessionID] = TerminalContainer( - handler: handler, - terminalView: tv - ) + Task { @MainActor in + container.sessions[sessionID] = TerminalContainer( + handler: handler, + terminalView: tv + ) + } } return tv