mirror of
https://github.com/neon443/ShhShell.git
synced 2026-03-11 05:19:13 +00:00
improved tab ui - now orange if selected, gray if not
improved functionality, if disconnected, it switches to the last tab open or if no more, it dismisses remove dialogview
This commit is contained in:
@@ -55,7 +55,6 @@
|
||||
A98554612E058433009051BD /* HostsManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = A98554602E058433009051BD /* HostsManager.swift */; };
|
||||
A98554632E0587DF009051BD /* HostsView.swift in Sources */ = {isa = PBXBuildFile; fileRef = A98554622E0587DF009051BD /* HostsView.swift */; };
|
||||
A9A587202E0BF220006B31E6 /* SwiftTerm in Frameworks */ = {isa = PBXBuildFile; productRef = A9A5871F2E0BF220006B31E6 /* SwiftTerm */; };
|
||||
A9B15A9A2E0ABA0400F66E02 /* DialogView.swift in Sources */ = {isa = PBXBuildFile; fileRef = A9B15A992E0ABA0400F66E02 /* DialogView.swift */; };
|
||||
A9C4140C2E096DB7005E3047 /* SSHError.swift in Sources */ = {isa = PBXBuildFile; fileRef = A9C4140B2E096DB7005E3047 /* SSHError.swift */; };
|
||||
A9C897EF2DF1A9A400EF9A5F /* SSHHandler.swift in Sources */ = {isa = PBXBuildFile; fileRef = A9C897EE2DF1A9A400EF9A5F /* SSHHandler.swift */; };
|
||||
A9D819292E0E904200442D38 /* Theme.swift in Sources */ = {isa = PBXBuildFile; fileRef = A9D819282E0E904200442D38 /* Theme.swift */; };
|
||||
@@ -159,7 +158,6 @@
|
||||
A985545C2E055D4D009051BD /* ConnectionView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ConnectionView.swift; sourceTree = "<group>"; };
|
||||
A98554602E058433009051BD /* HostsManager.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HostsManager.swift; sourceTree = "<group>"; };
|
||||
A98554622E0587DF009051BD /* HostsView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HostsView.swift; sourceTree = "<group>"; };
|
||||
A9B15A992E0ABA0400F66E02 /* DialogView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DialogView.swift; sourceTree = "<group>"; };
|
||||
A9C4140B2E096DB7005E3047 /* SSHError.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SSHError.swift; sourceTree = "<group>"; };
|
||||
A9C897EE2DF1A9A400EF9A5F /* SSHHandler.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SSHHandler.swift; sourceTree = "<group>"; };
|
||||
A9D819282E0E904200442D38 /* Theme.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Theme.swift; sourceTree = "<group>"; };
|
||||
@@ -353,7 +351,6 @@
|
||||
children = (
|
||||
A96C6B012E0C49E800F377FE /* CenteredLabel.swift */,
|
||||
A93143C52DF61FE300FCD5DB /* ViewModifiers.swift */,
|
||||
A9B15A992E0ABA0400F66E02 /* DialogView.swift */,
|
||||
A96C90A02E12B87900724253 /* TextBox.swift */,
|
||||
A9DA97722E0D40C100142DDC /* HostSymbolPreview.swift */,
|
||||
);
|
||||
@@ -614,7 +611,6 @@
|
||||
A96BE6A42E113D9400C0FEE9 /* ThemeCodable.swift in Sources */,
|
||||
A9FD375F2E14648E005319A8 /* KeyImporterView.swift in Sources */,
|
||||
A93143C02DF61B3200FCD5DB /* Host.swift in Sources */,
|
||||
A9B15A9A2E0ABA0400F66E02 /* DialogView.swift in Sources */,
|
||||
A92538C92DEE0742007E0A18 /* ShhShellApp.swift in Sources */,
|
||||
A96BE6AD2E11825800C0FEE9 /* SessionView.swift in Sources */,
|
||||
A96C6B002E0C45FE00F377FE /* KeyDetailView.swift in Sources */,
|
||||
|
||||
@@ -1,64 +0,0 @@
|
||||
//
|
||||
// DialogView.swift
|
||||
// ShhShell
|
||||
//
|
||||
// Created by neon443 on 24/06/2025.
|
||||
//
|
||||
|
||||
import SwiftUI
|
||||
|
||||
struct DialogView: View {
|
||||
@ObservedObject var handler: SSHHandler
|
||||
@State var showDialog: Bool
|
||||
@State var icon: String = "network.slash"
|
||||
@State var headline: String = "Disconnected"
|
||||
@State var text: String = "Connection to the SSH server has been lost, try reconnecting"
|
||||
|
||||
var body: some View {
|
||||
GeometryReader { geo in
|
||||
let width = geo.size.width*0.75
|
||||
let height = geo.size.height*0.15
|
||||
if showDialog {
|
||||
ZStack(alignment: .center) {
|
||||
Color.black
|
||||
.clipShape(RoundedRectangle(cornerRadius: 15))
|
||||
.frame(maxWidth: width, maxHeight: height)
|
||||
.shadow(color: .white, radius: 2)
|
||||
HStack(alignment: .top) {
|
||||
Image(systemName: icon)
|
||||
.resizable().scaledToFit()
|
||||
.frame(width: width*0.2)
|
||||
.foregroundStyle(.terminalGreen)
|
||||
.symbolRenderingMode(.hierarchical)
|
||||
VStack(alignment: .leading) {
|
||||
Text(headline)
|
||||
.foregroundStyle(.terminalGreen)
|
||||
.font(.title2)
|
||||
.bold()
|
||||
Text(text)
|
||||
.foregroundStyle(.terminalGreen)
|
||||
.font(.footnote)
|
||||
}
|
||||
.frame(width: width*0.7)
|
||||
}
|
||||
.frame(maxWidth: width, maxHeight: height)
|
||||
}
|
||||
.transition(
|
||||
.asymmetric(
|
||||
insertion: .move(edge: .bottom),
|
||||
removal: .move(edge: .bottom)
|
||||
)
|
||||
.combined(with: .opacity)
|
||||
)
|
||||
.frame(maxWidth: .infinity, maxHeight: .infinity)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#Preview {
|
||||
ZStack {
|
||||
Color.black
|
||||
DialogView(handler: SSHHandler(host: Host.debug, keyManager: nil), showDialog: true)
|
||||
}
|
||||
}
|
||||
@@ -14,7 +14,7 @@ struct ShellTabView: View {
|
||||
@ObservedObject var container = TerminalViewContainer.shared
|
||||
@State var selectedID: UUID?
|
||||
|
||||
@State var shellView: ShellView? = nil
|
||||
@Environment(\.dismiss) var dismiss
|
||||
|
||||
var body: some View {
|
||||
GeometryReader { geo in
|
||||
@@ -23,29 +23,46 @@ struct ShellTabView: View {
|
||||
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)
|
||||
}
|
||||
}
|
||||
ZStack {
|
||||
Rectangle()
|
||||
.fill(selectedID == id ? .orange : .gray)
|
||||
.opacity(0.5)
|
||||
Text(container.sessions[id]!.handler.host.description)
|
||||
.frame(width: oneTabWidth)
|
||||
}
|
||||
.ignoresSafeArea(.all)
|
||||
.onTapGesture {
|
||||
withAnimation { selectedID = id }
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
.frame(height: 30)
|
||||
.onAppear {
|
||||
if shellView == nil {
|
||||
shellView = ShellView(handler: handler, hostsManager: hostsManager)
|
||||
if selectedID == nil {
|
||||
selectedID = handler.sessionID
|
||||
}
|
||||
}
|
||||
.frame(height: 30)
|
||||
if let shellView {
|
||||
shellView
|
||||
.id(selectedID)
|
||||
|
||||
if let selectedID,
|
||||
let session = container.sessions[selectedID] {
|
||||
ShellView(
|
||||
handler: session.handler,
|
||||
hostsManager: hostsManager
|
||||
)
|
||||
.onDisappear {
|
||||
if !checkShell(session.handler.state) {
|
||||
if let lastSession = container.sessionIDs.last {
|
||||
withAnimation { self.selectedID = lastSession }
|
||||
} else {
|
||||
dismiss()
|
||||
}
|
||||
}
|
||||
}
|
||||
.id(selectedID)
|
||||
.transition(.opacity)
|
||||
} else {
|
||||
Text("no shellview")
|
||||
ShellView(handler: handler, hostsManager: hostsManager)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -33,13 +33,6 @@ struct ShellView: View {
|
||||
.shadow(color: .black, radius: 5)
|
||||
}
|
||||
.opacity(handler.bell ? 1 : 0)
|
||||
|
||||
if !handler.connected {
|
||||
DialogView(handler: handler, showDialog: !handler.connected)
|
||||
}
|
||||
}
|
||||
.onChange(of: handler.connected) { _ in
|
||||
if !handler.connected { dismiss() }
|
||||
}
|
||||
.onAppear {
|
||||
handler.applySelectedTheme()
|
||||
@@ -50,7 +43,6 @@ struct ShellView: View {
|
||||
ToolbarItem(placement: .cancellationAction) {
|
||||
Button() {
|
||||
handler.disconnect()
|
||||
if !handler.connected { dismiss() }
|
||||
} label: {
|
||||
Label("Disconnect", systemImage: "xmark.app.fill")
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user