mirror of
https://github.com/neon443/ShhShell.git
synced 2026-03-11 13:26:16 +00:00
improved functionality, if disconnected, it switches to the last tab open or if no more, it dismisses remove dialogview
68 lines
1.4 KiB
Swift
68 lines
1.4 KiB
Swift
//
|
|
// ShellView.swift
|
|
// ShhShell
|
|
//
|
|
// Created by neon443 on 22/06/2025.
|
|
//
|
|
|
|
import SwiftUI
|
|
|
|
struct ShellView: View {
|
|
@ObservedObject var handler: SSHHandler
|
|
@ObservedObject var hostsManager: HostsManager
|
|
|
|
@ObservedObject var container = TerminalViewContainer.shared
|
|
|
|
@Environment(\.dismiss) var dismiss
|
|
|
|
var body: some View {
|
|
NavigationStack {
|
|
ZStack {
|
|
TerminalController(handler: handler, hostsManager: hostsManager)
|
|
.onAppear {
|
|
if let sessionID = handler.sessionID {
|
|
container.sessions[sessionID]?.terminalView.restoreScrollback()
|
|
}
|
|
}
|
|
|
|
Group {
|
|
Color.gray.opacity(0.2)
|
|
.transition(.opacity)
|
|
Image(systemName: "bell.fill")
|
|
.font(.largeTitle)
|
|
.shadow(color: .black, radius: 5)
|
|
}
|
|
.opacity(handler.bell ? 1 : 0)
|
|
}
|
|
.onAppear {
|
|
handler.applySelectedTheme()
|
|
}
|
|
.navigationTitle(handler.title)
|
|
.navigationBarTitleDisplayMode(.inline)
|
|
.toolbar {
|
|
ToolbarItem(placement: .cancellationAction) {
|
|
Button() {
|
|
handler.disconnect()
|
|
} label: {
|
|
Label("Disconnect", systemImage: "xmark.app.fill")
|
|
}
|
|
}
|
|
ToolbarItem(placement: .cancellationAction) {
|
|
Button() {
|
|
dismiss()
|
|
} label: {
|
|
Label("Close", systemImage: "arrow.down.right.and.arrow.up.left")
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
#Preview {
|
|
ShellView(
|
|
handler: SSHHandler(host: Host.debug, keyManager: nil),
|
|
hostsManager: HostsManager()
|
|
)
|
|
}
|