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:
@@ -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 = "<group>"; };
|
||||
A9FD375E2E14648E005319A8 /* KeyImporterView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = KeyImporterView.swift; sourceTree = "<group>"; };
|
||||
A9FD37642E169937005319A8 /* AuthType.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AuthType.swift; sourceTree = "<group>"; };
|
||||
A9FD37682E16A6BF005319A8 /* ShellTabView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ShellTabView.swift; sourceTree = "<group>"; };
|
||||
/* 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 = "<group>";
|
||||
@@ -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 */,
|
||||
|
||||
@@ -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