more swift 6 stuff

dialogview updates - remove button
make disconnect button on terminal dismiss the terminal
This commit is contained in:
neon443
2025-06-24 13:25:57 +01:00
parent 1e3a57d788
commit 507c533b46
3 changed files with 8 additions and 7 deletions

View File

@@ -9,7 +9,7 @@ import SwiftUI
struct DialogView: View {
@ObservedObject var handler: SSHHandler
@State var showDialog: Bool = true
@State var showDialog: Bool
@State var icon: String = "network.slash"
@State var headline: String = "Disconnected"
@State var text: String = "Connection to the SSH server has been lost, try reconnecting"
@@ -53,15 +53,12 @@ struct DialogView: View {
.frame(maxWidth: .infinity, maxHeight: .infinity)
}
}
Button("show button") {
withAnimation { showDialog.toggle() }
}
}
}
#Preview {
ZStack {
Color.black
DialogView(handler: SSHHandler(host: Host.debug))
DialogView(handler: SSHHandler(host: Host.debug), showDialog: true)
}
}

View File

@@ -24,8 +24,8 @@ final class SSHTerminalView: TerminalView, Sendable, @preconcurrency TerminalVie
super.init(frame: frame)
terminalDelegate = self
sshQueue.async {
guard let handler = self.handler else { return }
sshQueue.async { [self] in
guard let handler = handler else { return }
while handler.connected {
if let read = handler.readFromChannel() {

View File

@@ -9,6 +9,7 @@ import SwiftUI
struct ShellView: View {
@ObservedObject var handler: SSHHandler
@Environment(\.dismiss) var dismiss
var body: some View {
NavigationStack {
@@ -22,6 +23,9 @@ struct ShellView: View {
ToolbarItem {
Button() {
handler.go()
if !handler.connected {
dismiss()
}
} label: {
Label(
handler.connected ? "Disconnect" : "Connect",