more swift 6 stuff

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

No files matched your search

+2 -5
View File
@@ -9,7 +9,7 @@ import SwiftUI
struct DialogView: View { struct DialogView: View {
@ObservedObject var handler: SSHHandler @ObservedObject var handler: SSHHandler
@State var showDialog: Bool = true @State var showDialog: Bool
@State var icon: String = "network.slash" @State var icon: String = "network.slash"
@State var headline: String = "Disconnected" @State var headline: String = "Disconnected"
@State var text: String = "Connection to the SSH server has been lost, try reconnecting" @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) .frame(maxWidth: .infinity, maxHeight: .infinity)
} }
} }
Button("show button") {
withAnimation { showDialog.toggle() }
}
} }
} }
#Preview { #Preview {
ZStack { ZStack {
Color.black Color.black
DialogView(handler: SSHHandler(host: Host.debug)) DialogView(handler: SSHHandler(host: Host.debug), showDialog: true)
} }
} }
@@ -24,8 +24,8 @@ final class SSHTerminalView: TerminalView, Sendable, @preconcurrency TerminalVie
super.init(frame: frame) super.init(frame: frame)
terminalDelegate = self terminalDelegate = self
sshQueue.async { sshQueue.async { [self] in
guard let handler = self.handler else { return } guard let handler = handler else { return }
while handler.connected { while handler.connected {
if let read = handler.readFromChannel() { if let read = handler.readFromChannel() {
+4
View File
@@ -9,6 +9,7 @@ import SwiftUI
struct ShellView: View { struct ShellView: View {
@ObservedObject var handler: SSHHandler @ObservedObject var handler: SSHHandler
@Environment(\.dismiss) var dismiss
var body: some View { var body: some View {
NavigationStack { NavigationStack {
@@ -22,6 +23,9 @@ struct ShellView: View {
ToolbarItem { ToolbarItem {
Button() { Button() {
handler.go() handler.go()
if !handler.connected {
dismiss()
}
} label: { } label: {
Label( Label(
handler.connected ? "Disconnect" : "Connect", handler.connected ? "Disconnect" : "Connect",
Reference in new issue
Block a user
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.