diff --git a/ShhShell.xcodeproj/project.pbxproj b/ShhShell.xcodeproj/project.pbxproj index 843701b..18bea3a 100644 --- a/ShhShell.xcodeproj/project.pbxproj +++ b/ShhShell.xcodeproj/project.pbxproj @@ -71,6 +71,7 @@ A9FD375D2E143D7E005319A8 /* KeyStoreError.swift in Sources */ = {isa = PBXBuildFile; fileRef = A9FD375C2E143D7E005319A8 /* KeyStoreError.swift */; }; A9FD375F2E14648E005319A8 /* KeyImporterView.swift in Sources */ = {isa = PBXBuildFile; fileRef = A9FD375E2E14648E005319A8 /* KeyImporterView.swift */; }; A9FD37652E169937005319A8 /* AuthType.swift in Sources */ = {isa = PBXBuildFile; fileRef = A9FD37642E169937005319A8 /* AuthType.swift */; }; + A9FD37692E16A6BF005319A8 /* ShellTabView.swift in Sources */ = {isa = PBXBuildFile; fileRef = A9FD37682E16A6BF005319A8 /* ShellTabView.swift */; }; /* End PBXBuildFile section */ /* Begin PBXContainerItemProxy section */ @@ -174,6 +175,7 @@ A9FD375C2E143D7E005319A8 /* KeyStoreError.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = KeyStoreError.swift; sourceTree = ""; }; A9FD375E2E14648E005319A8 /* KeyImporterView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = KeyImporterView.swift; sourceTree = ""; }; A9FD37642E169937005319A8 /* AuthType.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AuthType.swift; sourceTree = ""; }; + A9FD37682E16A6BF005319A8 /* ShellTabView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ShellTabView.swift; sourceTree = ""; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ @@ -213,6 +215,7 @@ A923172E2E08851200ECE1E6 /* ShellView.swift */, A923172C2E07138000ECE1E6 /* SSHTerminalDelegate.swift */, A96BE6A92E116EC000C0FEE9 /* TerminalViewContainer.swift */, + A9FD37682E16A6BF005319A8 /* ShellTabView.swift */, ); path = Terminal; sourceTree = ""; @@ -604,6 +607,7 @@ A93143C62DF61FE300FCD5DB /* ViewModifiers.swift in Sources */, A98554632E0587DF009051BD /* HostsView.swift in Sources */, A96C6A8A2E0C0B1100F377FE /* SSHState.swift in Sources */, + A9FD37692E16A6BF005319A8 /* ShellTabView.swift in Sources */, A9DA97732E0D40C100142DDC /* HostSymbolPreview.swift in Sources */, A96BE6A62E113DB000C0FEE9 /* ColorCodable.swift in Sources */, A92538C82DEE0742007E0A18 /* ContentView.swift in Sources */, diff --git a/ShhShell/Views/Hosts/ConnectionView.swift b/ShhShell/Views/Hosts/ConnectionView.swift index a3e1051..7db2d9b 100644 --- a/ShhShell/Views/Hosts/ConnectionView.swift +++ b/ShhShell/Views/Hosts/ConnectionView.swift @@ -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) +// } +// } } } } diff --git a/ShhShell/Views/Terminal/ShellTabView.swift b/ShhShell/Views/Terminal/ShellTabView.swift new file mode 100644 index 0000000..ca4ef65 --- /dev/null +++ b/ShhShell/Views/Terminal/ShellTabView.swift @@ -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() + ) +}