mirror of
https://github.com/neon443/ShhShell.git
synced 2026-03-11 05:19:13 +00:00
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:
@@ -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
|
||||
|
||||
@@ -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 }
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user