mirror of
https://github.com/neon443/ShhShell.git
synced 2026-03-11 13:26:16 +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 {
|
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() {
|
||||||
|
|||||||
@@ -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