mirror of
https://github.com/neon443/ShhShell.git
synced 2026-03-11 13:26:16 +00:00
TABS!!!!
added shelltabview it basically puts tabs at the top, and when tapped the id is updated and so is the shellView var to have a new handler (corresponding to that session) remove @State var shellView from connectionview &other stuff
This commit is contained in:
@@ -12,7 +12,7 @@ struct ConnectionView: View {
|
||||
@ObservedObject var hostsManager: HostsManager
|
||||
@ObservedObject var keyManager: KeyManager
|
||||
|
||||
@State private var shellView: ShellView? = nil
|
||||
// @State private var shellView: ShellTabView? = nil
|
||||
|
||||
@State var pubkeyStr: String = ""
|
||||
@State var privkeyStr: String = ""
|
||||
@@ -120,11 +120,6 @@ struct ConnectionView: View {
|
||||
.onDisappear {
|
||||
hostsManager.updateHost(handler.host)
|
||||
}
|
||||
.onAppear {
|
||||
if shellView == nil {
|
||||
shellView = ShellView(handler: handler, hostsManager: hostsManager)
|
||||
}
|
||||
}
|
||||
.onAppear {
|
||||
hostsManager.addHostIfNeeded(handler.host)
|
||||
}
|
||||
@@ -156,12 +151,13 @@ struct ConnectionView: View {
|
||||
}
|
||||
}
|
||||
.fullScreenCover(isPresented: $showTerminal) {
|
||||
if let shellView {
|
||||
shellView
|
||||
} else {
|
||||
Text("no shellview")
|
||||
}
|
||||
ShellTabView(handler: handler, hostsManager: hostsManager)
|
||||
}
|
||||
// .onAppear {
|
||||
// if shellView == nil {
|
||||
// shellView = ShellTabView(handler: handler, hostsManager: hostsManager)
|
||||
// }
|
||||
// }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
60
ShhShell/Views/Terminal/ShellTabView.swift
Normal file
60
ShhShell/Views/Terminal/ShellTabView.swift
Normal file
@@ -0,0 +1,60 @@
|
||||
//
|
||||
// ShellTabView.swift
|
||||
// ShhShell
|
||||
//
|
||||
// Created by neon443 on 03/07/2025.
|
||||
//
|
||||
|
||||
import SwiftUI
|
||||
|
||||
struct ShellTabView: View {
|
||||
@ObservedObject var handler: SSHHandler
|
||||
@ObservedObject var hostsManager: HostsManager
|
||||
|
||||
@ObservedObject var container = TerminalViewContainer.shared
|
||||
@State var selectedID: UUID?
|
||||
|
||||
@State var shellView: ShellView? = nil
|
||||
|
||||
var body: some View {
|
||||
GeometryReader { geo in
|
||||
VStack {
|
||||
let oneTabWidth = max(60, geo.size.width/CGFloat(container.sessionIDs.count))
|
||||
ScrollView(.horizontal, showsIndicators: false) {
|
||||
HStack(spacing: 0) {
|
||||
ForEach(container.sessionIDs, id: \.self) { id in
|
||||
Text(container.sessions[id]!.handler.host.description)
|
||||
.frame(width: oneTabWidth)
|
||||
.background(.blue)
|
||||
.onTapGesture {
|
||||
selectedID = id
|
||||
if let session = container.sessions[selectedID!] {
|
||||
shellView = ShellView(handler: session.handler, hostsManager: hostsManager)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
.onAppear {
|
||||
if shellView == nil {
|
||||
shellView = ShellView(handler: handler, hostsManager: hostsManager)
|
||||
}
|
||||
}
|
||||
.frame(height: 30)
|
||||
if let shellView {
|
||||
shellView
|
||||
.id(selectedID)
|
||||
} else {
|
||||
Text("no shellview")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#Preview {
|
||||
ShellTabView(
|
||||
handler: SSHHandler(host: Host.blank, keyManager: nil),
|
||||
hostsManager: HostsManager()
|
||||
)
|
||||
}
|
||||
Reference in New Issue
Block a user