Files
ShhShell/ShhShell/Views/Sessions/SessionView.swift
neon443 8e69dfc165 terminalViewContainer is now an observable object
made the session list view more pretty
terminalviewcontaner has a static shared property which is an instance of itself
then it has sessions inside with a dict of uuid:terminalcontainer inside
hostsview is in the section "hosts"
2025-06-29 16:25:49 +01:00

49 lines
1018 B
Swift

//
// SessionView.swift
// ShhShell
//
// Created by neon443 on 29/06/2025.
//
import SwiftUI
struct SessionView: View {
@ObservedObject var hostsManager: HostsManager
@ObservedObject var container = TerminalViewContainer.shared
@State var key: UUID
@State var shellPresented: Bool = false
var host: Host {
container.sessions[key]?.handler.host ?? Host.blank
}
var body: some View {
HStack {
Image(systemName: "apple.terminal")
.resizable().scaledToFit()
.frame(width: 40, height: 40)
.foregroundStyle(.terminalGreen)
SymbolPreview(symbol: host.symbol, label: host.label)
.frame(width: 40, height: 40)
Text(hostsManager.makeLabel(forHost: host))
}
.onTapGesture {
shellPresented.toggle()
}
.fullScreenCover(isPresented: $shellPresented) {
ShellView(
handler: container.sessions[key]?.handler ?? SSHHandler(host: Host.blank),
hostsManager: hostsManager
)
}
}
}
#Preview {
SessionView(
hostsManager: HostsManager(),
key: UUID()
)
}