mirror of
https://github.com/neon443/ShhShell.git
synced 2026-03-11 05:19:13 +00:00
more swift 6 stuff
dialogview updates - remove button make disconnect button on terminal dismiss the terminal
This commit is contained in:
@@ -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)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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() {
|
||||
|
||||
@@ -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",
|
||||
|
||||
Reference in New Issue
Block a user