mirror of
https://github.com/neon443/ShhShell.git
synced 2026-03-11 21:36:17 +00:00
new icon
UI update: has an x if failed testexec, withanimation cleanup new hostkey variable getHostKey returns Data
This commit is contained in:
@@ -10,19 +10,28 @@ import SwiftUI
|
||||
struct ContentView: View {
|
||||
@ObservedObject var handler: SSHHandler
|
||||
@State var connected: Bool = false
|
||||
@State var testSucceded: Bool = false
|
||||
@State var testSucceded: Bool?
|
||||
|
||||
var body: some View {
|
||||
VStack {
|
||||
Text(connected ? "connected" : "not connected")
|
||||
.foregroundStyle(connected ? .green : .red)
|
||||
|
||||
Text(handler.authorized ? "authorized" : "unauthorized")
|
||||
.foregroundStyle(handler.authorized ? .green : .red)
|
||||
if testSucceded {
|
||||
Image(systemName: "checkmark.circle")
|
||||
|
||||
if let testSucceded = testSucceded {
|
||||
Image(systemName: testSucceded ? "checkmark.circle" : "xmark.circle")
|
||||
.foregroundStyle(testSucceded ? .green : .red)
|
||||
}
|
||||
|
||||
if handler.hostkey != nil {
|
||||
Text("Hostkey: \(handler.hostkey!.base64EncodedString())")
|
||||
}
|
||||
|
||||
TextField("address", text: $handler.address)
|
||||
.textFieldStyle(.roundedBorder)
|
||||
|
||||
TextField(
|
||||
"port",
|
||||
text: Binding(
|
||||
@@ -31,8 +40,10 @@ struct ContentView: View {
|
||||
)
|
||||
.keyboardType(.numberPad)
|
||||
.textFieldStyle(.roundedBorder)
|
||||
|
||||
TextField("username", text: $handler.username)
|
||||
.textFieldStyle(.roundedBorder)
|
||||
|
||||
TextField("password", text: $handler.password)
|
||||
.textFieldStyle(.roundedBorder)
|
||||
|
||||
@@ -42,20 +53,28 @@ struct ContentView: View {
|
||||
}
|
||||
handler.authWithPw()
|
||||
}
|
||||
.disabled(connected)
|
||||
|
||||
Button("disconnect") {
|
||||
handler.disconnect()
|
||||
withAnimation { testSucceded = false }
|
||||
withAnimation { connected = false}
|
||||
withAnimation { connected = false }
|
||||
withAnimation { testSucceded = nil }
|
||||
}
|
||||
.disabled(!connected)
|
||||
|
||||
Button("run a test command") {
|
||||
withAnimation {
|
||||
if handler.testExec() {
|
||||
testSucceded = true
|
||||
} else {
|
||||
testSucceded = false
|
||||
}
|
||||
if handler.testExec() {
|
||||
withAnimation { testSucceded = true }
|
||||
} else {
|
||||
withAnimation { testSucceded = false }
|
||||
}
|
||||
}
|
||||
.disabled(!(connected && handler.authorized))
|
||||
|
||||
Button("request a shell") {
|
||||
handler.openShell()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user